diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-10-12 11:07:57 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-10-12 11:39:25 +0200 |
commit | d4b4483ecdc072b64158fb7376f73e9d83d88c58 (patch) | |
tree | 7586b4923bc3c8c679af19596c06142918075377 /vcl/opengl | |
parent | 2c91daa5bc317a3afcb314160df6ecb988aaffd3 (diff) |
opengl: Extract calculation - bytes per row into its own function
Change-Id: I24864df3e698704d84f62be25daa3dd54b4dd356
Diffstat (limited to 'vcl/opengl')
-rw-r--r-- | vcl/opengl/salbmp.cxx | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 1102f8237917..b38224c58304 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -38,11 +38,27 @@ namespace { -static bool isValidBitCount( sal_uInt16 nBitCount ) +bool isValidBitCount( sal_uInt16 nBitCount ) { return (nBitCount == 1) || (nBitCount == 4) || (nBitCount == 8) || (nBitCount == 16) || (nBitCount == 24) || (nBitCount == 32); } +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; +} + static std::vector<std::unique_ptr<FixedTextureAtlasManager>> sTextureAtlases; } @@ -192,19 +208,7 @@ bool OpenGLSalBitmap::AllocateUserData() if( mnWidth && mnHeight ) { - mnBytesPerRow = 0; - - 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::OpenGLSalBitmap::AllocateUserData(), illegal bitcount!"); - } + mnBytesPerRow = lclBytesPerRow(mnBits, mnWidth); } bool alloc = false; |