diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-03-21 15:04:25 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-03-21 15:14:45 +0100 |
commit | ebe247642d85d39b6e1ffae3cf92c31748f2e983 (patch) | |
tree | 2d7ef84826a9be1ae3a2cb1d37d497c471b2cdc8 /vcl | |
parent | 17407f808ed0ca5d65a98da186f7e2ab60dc641b (diff) |
Revert "tdf#116213 OS X and OpenGL bitmap scaline sizes are not 32-bit aligned"
This reverts commit 460f39e687393b3a8906d2adc3e8f7a0c749851a.
For one, it had started to make bitmap checksum equality check in
svx/qa/unit/XTableImportExportTest.cxx, CppunitTest_svx_unit, fail most of the
time in macOS --disable-dbgutil builds, as the bitmap checksum is now computed
also over padding bytes containing random values (but --enable-dbgutil
initializes those bytes). And why would fixing tdf#116213 for Windows require
touching the macOS-specific code, anyway?
For another, tdf#116213 comments 6 and 7 report further problems that are likely
linked to this commit.
Change-Id: I3e158813ab89a1ead3780abbf6b120ec52660231
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/opengl/salbmp.cxx | 19 | ||||
-rw-r--r-- | vcl/qa/cppunit/BitmapTest.cxx | 27 | ||||
-rw-r--r-- | vcl/quartz/salbmp.cxx | 15 |
3 files changed, 48 insertions, 13 deletions
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index a83c2c820e0f..69c6c5481c35 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -81,13 +81,18 @@ inline bool isValidBitCount( sal_uInt16 nBitCount ) sal_uInt32 lclBytesPerRow(sal_uInt16 nBits, int nWidth) { - 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); + 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; } typedef std::vector<std::unique_ptr< FixedTextureAtlasManager > > TextureAtlasVector; diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index 0bbe6d294882..f835c7b78bc3 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -342,8 +342,15 @@ void BitmapTest::testConvert() { Bitmap::ScopedReadAccess pReadAccess(aBitmap); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), pReadAccess->GetBitCount()); - // scanline should pad to 32-bit multiples - CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(12), pReadAccess->GetScanlineSize()); +#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 CPPUNIT_ASSERT(pReadAccess->HasPalette()); const BitmapColor& rColor = pReadAccess->GetPaletteColor(pReadAccess->GetPixelIndex(1, 1)); CPPUNIT_ASSERT_EQUAL(sal_Int32(204), sal_Int32(rColor.GetRed())); @@ -358,8 +365,22 @@ 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()); - // scanline should pad to 32-bit multiples + +#if defined LINUX || defined FREEBSD 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(); diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx index 04fb820b08a3..f9a10a44020b 100644 --- a/vcl/quartz/salbmp.cxx +++ b/vcl/quartz/salbmp.cxx @@ -310,10 +310,19 @@ bool QuartzSalBitmap::AllocateUserData() if( mnWidth && mnHeight ) { - assert((mnBits == 1 || mnBits == 4 || mnBits == 8 || mnBits == 16 || mnBits == 24 || mnBits == 32) - && "vcl::QuartzSalBitmap::AllocateUserData(), illegal bitcount!"); + mnBytesPerRow = 0; - mnBytesPerRow = AlignedWidth4Bytes(mnBits * mnWidth); + 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!"); + } } bool alloc = false; |