Kaydet (Commit) 460f39e6 authored tarafından Chris Sherlock's avatar Chris Sherlock Kaydeden (comit) Tomaž Vajngerl

tdf#116213 OS X and OpenGL bitmap scaline sizes are not 32-bit aligned

Change-Id: I92b43ae2f034bf63cc3f212ec8728c5c6b5e8934
Reviewed-on: https://gerrit.libreoffice.org/51222Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 09d84288
......@@ -81,18 +81,13 @@ inline bool isValidBitCount( sal_uInt16 nBitCount )
sal_uInt16 lclBytesPerRow(sal_uInt16 nBits, int nWidth)
{
switch(nBits)
{
case 1: return (nWidth + 7) >> 3;
case 4: return (nWidth + 1) >> 1;
case 8: return nWidth;
case 16: return nWidth * 2;
case 24: return nWidth * 3;
case 32: return nWidth * 4;
default:
OSL_FAIL("vcl::OpenGLSalBitmap::AllocateUserData(), illegal bitcount!");
}
return 0;
assert ((nBits == 1 || nBits == 4 || nBits == 8 || nBits == 16 || nBits == 24 || nBits == 32)
&& "vcl::OpenGLSalBitmap::AllocateUserData(), illegal bitcount!");
if (!isValidBitCount(nBits))
return 0;
return AlignedWidth4Bytes(nBits * nWidth);
}
typedef std::vector<std::unique_ptr< FixedTextureAtlasManager > > TextureAtlasVector;
......
......@@ -342,15 +342,8 @@ void BitmapTest::testConvert()
{
Bitmap::ScopedReadAccess pReadAccess(aBitmap);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), pReadAccess->GetBitCount());
#if defined MACOSX || defined IOS
//it would be nice to find and change the stride for quartz to be the same as everyone else
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(10), pReadAccess->GetScanlineSize());
#else
#if HAVE_FEATURE_OPENGL
if (!OpenGLHelper::isVCLOpenGLEnabled())
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(12), pReadAccess->GetScanlineSize());
#endif
#endif
// scanline should pad to 32-bit multiples
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(12), pReadAccess->GetScanlineSize());
CPPUNIT_ASSERT(pReadAccess->HasPalette());
const BitmapColor& rColor = pReadAccess->GetPaletteColor(pReadAccess->GetPixelIndex(1, 1));
CPPUNIT_ASSERT_EQUAL(sal_Int32(204), sal_Int32(rColor.GetRed()));
......@@ -365,22 +358,8 @@ void BitmapTest::testConvert()
Bitmap::ScopedReadAccess pReadAccess(aBitmap);
// 24 bit Bitmap on SVP backend can now use 24bit RGB everywhere.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(24), pReadAccess->GetBitCount());
#if defined LINUX || defined FREEBSD
// scanline should pad to 32-bit multiples
CPPUNIT_ASSERT_EQUAL(sal_uLong(32), pReadAccess->GetScanlineSize());
#else
#if defined(_WIN32)
if (!OpenGLHelper::isVCLOpenGLEnabled())
{
// GDI Scanlines padded to DWORD multiples, it seems
CPPUNIT_ASSERT_EQUAL(sal_uLong(32), pReadAccess->GetScanlineSize());
}
else
#endif
{
CPPUNIT_ASSERT_EQUAL(sal_uLong(30), pReadAccess->GetScanlineSize());
}
#endif
CPPUNIT_ASSERT(!pReadAccess->HasPalette());
Color aColor = pReadAccess->GetPixel(0, 0).GetColor();
......
......@@ -310,19 +310,10 @@ bool QuartzSalBitmap::AllocateUserData()
if( mnWidth && mnHeight )
{
mnBytesPerRow = 0;
assert((mnBits == 1 || mnBits == 4 || mnBits == 8 || mnBits == 16 || mnBits == 24 || mnBits == 32)
&& "vcl::QuartzSalBitmap::AllocateUserData(), illegal bitcount!");
switch( mnBits )
{
case 1: mnBytesPerRow = (mnWidth + 7) >> 3; break;
case 4: mnBytesPerRow = (mnWidth + 1) >> 1; break;
case 8: mnBytesPerRow = mnWidth; break;
case 16: mnBytesPerRow = mnWidth << 1; break;
case 24: mnBytesPerRow = (mnWidth << 1) + mnWidth; break;
case 32: mnBytesPerRow = mnWidth << 2; break;
default:
OSL_FAIL("vcl::QuartzSalBitmap::AllocateUserData(), illegal bitcount!");
}
mnBytesPerRow = AlignedWidth4Bytes(mnBits * mnWidth);
}
bool alloc = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment