summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/opengl/salbmp.cxx19
-rw-r--r--vcl/qa/cppunit/BitmapTest.cxx27
-rw-r--r--vcl/quartz/salbmp.cxx15
3 files changed, 13 insertions, 48 deletions
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 4127c46a509b..fab0f6d724d4 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -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;
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index f835c7b78bc3..0bbe6d294882 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -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();
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx
index f9a10a44020b..04fb820b08a3 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -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;