summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-06-07 18:33:34 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-11-16 11:10:27 +0100
commit501e8f74520731462dbf9f27b05f28ae8bf0b7f1 (patch)
tree5d3e56e83e601127301a8784b6d44ffcb97ed2b3
parent1aa579feaa841efcaee7389447c15c43a3d15b6d (diff)
vcl: add "color channel bitcount" for an bitmap buffer (Linux)
In addition to "bitcount" on bitmap buffer, which represents the number of bits one pixel takes, we also need the bitcount that the color channels take of one pixel take. For example RGB can be contined in 32 bits (because that the underlaying buffer supports) In this case GetBitCount returns 32bit so we can traverse the buffer correctly. However, we also need to know the bitcount of the actual color channels - in this case this would be 24 bits. Change-Id: I0a64928336540dc66d60659c46d64f369e786c3a
-rw-r--r--include/vcl/salbtype.hxx11
-rw-r--r--vcl/headless/svpbmp.cxx15
-rw-r--r--vcl/inc/headless/svpbmp.hxx1
-rw-r--r--vcl/inc/opengl/salbmp.hxx1
-rw-r--r--vcl/inc/salbmp.hxx1
-rw-r--r--vcl/inc/unx/salbmp.h1
-rw-r--r--vcl/opengl/salbmp.cxx5
-rw-r--r--vcl/source/gdi/impbmp.cxx12
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx8
9 files changed, 43 insertions, 12 deletions
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx
index 04baf9095b9b..25f4159ad41e 100644
--- a/include/vcl/salbtype.hxx
+++ b/include/vcl/salbtype.hxx
@@ -267,7 +267,18 @@ struct VCL_DLLPUBLIC BitmapBuffer
long mnWidth;
long mnHeight;
long mnScanlineSize;
+
+ /**
+ * Bitcount of one pixel in the buffer.
+ * color + alpha channels with padding (for example in an RGBX format)
+ */
sal_uInt16 mnBitCount;
+
+ /**
+ * Bitcount color channels of one pixel.
+ * color + alpha channels only (i.e. 8, 16, 24, 32)
+ */
+ sal_uInt16 mnColorChannelBitCount;
ColorMask maColorMask;
BitmapPalette maPalette;
sal_uInt8* mpBits;
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 202d63c0a84e..1dc6c19827a4 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -70,6 +70,7 @@ BitmapBuffer* ImplCreateDIB(
{
const sal_uInt16 nColors = ( nBitCount <= 8 ) ? ( 1 << nBitCount ) : 0;
+ pDIB->mnColorChannelBitCount = nBitCount;
switch (nBitCount)
{
case 1:
@@ -229,16 +230,14 @@ Size SvpSalBitmap::GetSize() const
return aSize;
}
-sal_uInt16 SvpSalBitmap::GetBitCount() const
+sal_uInt16 SvpSalBitmap::GetColorChannelBitCount() const
{
- sal_uInt16 nBitCount;
-
- if (mpDIB)
- nBitCount = mpDIB->mnBitCount;
- else
- nBitCount = 0;
+ return (mpDIB) ? mpDIB->mnColorChannelBitCount : 0;
+}
- return nBitCount;
+sal_uInt16 SvpSalBitmap::GetBitCount() const
+{
+ return (mpDIB) ? mpDIB->mnBitCount : 0;
}
BitmapBuffer* SvpSalBitmap::AcquireBuffer(BitmapAccessMode)
diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx
index af50ecff6cf5..8e90399fe4ea 100644
--- a/vcl/inc/headless/svpbmp.hxx
+++ b/vcl/inc/headless/svpbmp.hxx
@@ -52,6 +52,7 @@ public:
virtual void Destroy() final override;
virtual Size GetSize() const override;
virtual sal_uInt16 GetBitCount() const override;
+ virtual sal_uInt16 GetColorChannelBitCount() const override;
virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index d10129ce8d0c..4579e34c06c6 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -68,6 +68,7 @@ public:
Size GetSize() const override;
sal_uInt16 GetBitCount() const override;
+ sal_uInt16 GetColorChannelBitCount() const override;
BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index 69d25392a448..91e4e5c1031e 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -61,6 +61,7 @@ public:
virtual void Destroy() = 0;
virtual Size GetSize() const = 0;
virtual sal_uInt16 GetBitCount() const = 0;
+ virtual sal_uInt16 GetColorChannelBitCount() const = 0;
virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) = 0;
virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) = 0;
diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h
index 81998ba35bea..a1cc20c45a35 100644
--- a/vcl/inc/unx/salbmp.h
+++ b/vcl/inc/unx/salbmp.h
@@ -139,6 +139,7 @@ public:
virtual Size GetSize() const override;
virtual sal_uInt16 GetBitCount() const override;
+ virtual sal_uInt16 GetColorChannelBitCount() const override;
virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) override;
virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 9fb8c474818b..d2eb8f23828d 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -627,6 +627,11 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const
return mnBits;
}
+sal_uInt16 OpenGLSalBitmap::GetColorChannelBitCount() const
+{
+ return mnBits;
+}
+
bool OpenGLSalBitmap::calcChecksumGL(OpenGLTexture& rInputTexture, ChecksumType& rChecksum) const
{
OUString FragShader("areaHashCRC64TFragmentShader");
diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx
index ab06a712d0e1..e232b5046d1f 100644
--- a/vcl/source/gdi/impbmp.cxx
+++ b/vcl/source/gdi/impbmp.cxx
@@ -73,9 +73,15 @@ Size ImpBitmap::ImplGetSize() const
sal_uInt16 ImpBitmap::ImplGetBitCount() const
{
- sal_uInt16 nBitCount = mpSalBitmap->GetBitCount();
- return ( nBitCount <= 4 ) ? ( ( nBitCount <= 1 ) ? 1 : 4 ):
- ( ( nBitCount <= 8 ) ? 8 : 24);
+ sal_uInt16 nBitCount = mpSalBitmap->GetColorChannelBitCount();
+ if (nBitCount <= 1)
+ return 1;
+ else if (nBitCount <= 4)
+ return 4;
+ else if (nBitCount <= 8)
+ return 8;
+ else
+ return 24;
}
BitmapBuffer* ImpBitmap::ImplAcquireBuffer( BitmapAccessMode nMode )
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index 158a2f52d0fc..844c9c749b4c 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -148,7 +148,7 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
if( pDIB )
{
const sal_uInt16 nColors = ( nBitCount <= 8 ) ? ( 1 << nBitCount ) : 0;
-
+ pDIB->mnColorChannelBitCount = nBitCount;
pDIB->mnFormat = ScanlineFormat::NONE;
switch( nBitCount )
@@ -259,6 +259,7 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
aSrcBuf.mnWidth = nWidth;
aSrcBuf.mnHeight = nHeight;
aSrcBuf.mnBitCount = pImage->bits_per_pixel;
+ aSrcBuf.mnColorChannelBitCount = aSrcBuf.mnBitCount;
aSrcBuf.mnScanlineSize = pImage->bytes_per_line;
aSrcBuf.mpBits = reinterpret_cast<sal_uInt8*>(pImage->data);
@@ -847,6 +848,11 @@ sal_uInt16 X11SalBitmap::GetBitCount() const
return nBitCount;
}
+sal_uInt16 X11SalBitmap::GetColorChannelBitCount() const
+{
+ return GetBitCount();
+}
+
BitmapBuffer* X11SalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
{
if( !mpDIB && mpDDB )