[Libreoffice-commits] core.git: include/vcl

Caolán McNamara caolanm at redhat.com
Wed Sep 16 12:56:20 PDT 2015


 include/vcl/salbtype.hxx |   71 +++++++++++++++++++++++------------------------
 1 file changed, 35 insertions(+), 36 deletions(-)

New commits:
commit 71ca5e4acc4cf4706329b462acefc625f4cc53c7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Sep 15 21:22:05 2015 +0100

    move mask into ColorMaskElement too
    
    Change-Id: I1bd5e2ee71aba088ed8b395a31977e7b567d8b48
    Reviewed-on: https://gerrit.libreoffice.org/18635
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx
index 6d04bba..547d9a2 100644
--- a/include/vcl/salbtype.hxx
+++ b/include/vcl/salbtype.hxx
@@ -183,11 +183,13 @@ public:
 
 struct VCL_DLLPUBLIC ColorMaskElement
 {
+    sal_uInt32              mnMask;
     int                     mnShift;
     int                     mnOrShift;
     sal_uInt8               mnOr;
-    ColorMaskElement()
-        : mnShift(0)
+    ColorMaskElement(sal_uInt32 nMask)
+        : mnMask(nMask)
+        , mnShift(0)
         , mnOrShift(0)
         , mnOr(0)
     {
@@ -197,15 +199,12 @@ struct VCL_DLLPUBLIC ColorMaskElement
 // - ColorMask -
 class VCL_DLLPUBLIC ColorMask
 {
-    sal_uInt32              mnRMask;
-    sal_uInt32              mnGMask;
-    sal_uInt32              mnBMask;
-    sal_uInt32              mnAlphaChannel;
     ColorMaskElement        maR;
     ColorMaskElement        maG;
     ColorMaskElement        maB;
+    sal_uInt32              mnAlphaChannel;
 
-    SAL_DLLPRIVATE inline bool ImplCalcMaskShift(sal_uInt32 nMask, ColorMaskElement &rOut) const;
+    SAL_DLLPRIVATE inline bool ImplCalcMaskShift(ColorMaskElement &rOut) const;
 
 public:
 
@@ -577,32 +576,32 @@ inline ColorMask::ColorMask( sal_uInt32 nRedMask,
                              sal_uInt32 nGreenMask,
                              sal_uInt32 nBlueMask,
                              sal_uInt32 nAlphaChannel )
-    : mnRMask(nRedMask)
-    , mnGMask(nGreenMask)
-    , mnBMask(nBlueMask)
+    : maR(nRedMask)
+    , maG(nGreenMask)
+    , maB(nBlueMask)
     , mnAlphaChannel(nAlphaChannel)
 {
-    if (mnRMask)
-        ImplCalcMaskShift(mnRMask, maR);
-    if (mnGMask)
-        ImplCalcMaskShift(mnGMask, maG);
-    if (mnBMask)
-        ImplCalcMaskShift(mnBMask, maB);
+    ImplCalcMaskShift(maR);
+    ImplCalcMaskShift(maG);
+    ImplCalcMaskShift(maB);
 }
 
-inline bool ColorMask::ImplCalcMaskShift(sal_uInt32 nMask, ColorMaskElement &rOut) const
+inline bool ColorMask::ImplCalcMaskShift(ColorMaskElement &rElem) const
 {
+    if (rElem.mnMask == 0)
+        return true;
+
     // from which bit starts the mask?
     int nShift = 31;
 
-    while( nShift >= 0 && !( nMask & ( 1 << nShift ) ) )
+    while( nShift >= 0 && !( rElem.mnMask & ( 1 << nShift ) ) )
         --nShift;
 
-    rOut.mnShift = nShift - 7;
+    rElem.mnShift = nShift - 7;
     int nLen = 0;
 
     // XXX determine number of bits set => walk right until null
-    while( nShift >= 0 && ( nMask & ( 1 << nShift ) ) )
+    while( nShift >= 0 && ( rElem.mnMask & ( 1 << nShift ) ) )
     {
         nShift--;
         nLen++;
@@ -611,48 +610,48 @@ inline bool ColorMask::ImplCalcMaskShift(sal_uInt32 nMask, ColorMaskElement &rOu
     if (nLen > 8) // mask length must be 8 bits or less
         return false;
 
-    rOut.mnOrShift = 8 - nLen;
-    rOut.mnOr = static_cast<sal_uInt8>( ( 0xFF >> nLen ) << rOut.mnOrShift );
+    rElem.mnOrShift = 8 - nLen;
+    rElem.mnOr = static_cast<sal_uInt8>( ( 0xFF >> nLen ) << rElem.mnOrShift );
 
     return true;
 }
 
 inline sal_uInt32 ColorMask::GetRedMask() const
 {
-    return mnRMask;
+    return maR.mnMask;
 }
 
 inline sal_uInt32 ColorMask::GetGreenMask() const
 {
-    return mnGMask;
+    return maG.mnMask;
 }
 
 inline sal_uInt32 ColorMask::GetBlueMask() const
 {
-    return mnBMask;
+    return maB.mnMask;
 }
 
 inline void ColorMask::GetColorFor8Bit( BitmapColor& rColor, const sal_uInt8* pPixel ) const
 {
     const sal_uInt32 nVal = *pPixel;
-    MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maR.mnShift, rColor );
+    MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maR.mnShift, rColor );
 }
 
 inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, sal_uInt8* pPixel ) const
 {
-    *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
+    *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
 }
 
 inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, const sal_uInt8* pPixel ) const
 {
     const sal_uInt32 nVal = pPixel[ 1 ] | ( (sal_uInt32) pPixel[ 0 ] << 8UL );
 
-    MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
+    MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
 }
 
 inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, sal_uInt8* pPixel ) const
 {
-    const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
+    const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
 
     pPixel[ 0 ] = (sal_uInt8)(nVal >> 8U);
     pPixel[ 1 ] = (sal_uInt8) nVal;
@@ -662,12 +661,12 @@ inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, const sal_uInt8
 {
     const sal_uInt32 nVal = pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL );
 
-    MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
+    MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
 }
 
 inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, sal_uInt8* pPixel ) const
 {
-    const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
+    const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
 
     pPixel[ 0 ] = (sal_uInt8) nVal;
     pPixel[ 1 ] = (sal_uInt8)(nVal >> 8U);
@@ -676,12 +675,12 @@ inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, sal_uInt8
 inline void ColorMask::GetColorFor24Bit( BitmapColor& rColor, const sal_uInt8* pPixel ) const
 {
     const sal_uInt32 nVal = pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ) | ( (sal_uInt32) pPixel[ 2 ] << 16UL );
-    MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
+    MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
 }
 
 inline void ColorMask::SetColorFor24Bit( const BitmapColor& rColor, sal_uInt8* pPixel ) const
 {
-    const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
+    const sal_uInt32 nVal = COLOR_TO_MASK( rColor, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
     pPixel[ 0 ] = (sal_uInt8) nVal;
     pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL );
     pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL );
@@ -692,7 +691,7 @@ inline void ColorMask::GetColorFor32Bit( BitmapColor& rColor, const sal_uInt8* p
     const sal_uInt32 nVal = (sal_uInt32) pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ) |
                         ( (sal_uInt32) pPixel[ 2 ] << 16UL ) | ( (sal_uInt32) pPixel[ 3 ] << 24UL );
 
-    MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
+    MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
 }
 
 inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8& rAlpha, const sal_uInt8* pPixel ) const
@@ -701,12 +700,12 @@ inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8&
                         ( (sal_uInt32) pPixel[ 2 ] << 16UL ) | ( (sal_uInt32) pPixel[ 3 ] << 24UL );
     rAlpha = (sal_uInt8)(nVal >> 24);
 
-    MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
+    MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor );
 }
 
 inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, sal_uInt8* pPixel ) const
 {
-    const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
+    const sal_uInt32 nVal = COLOR_TO_MASK( rColor, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, mnAlphaChannel );
     pPixel[ 0 ] = (sal_uInt8) nVal;
     pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL );
     pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL );


More information about the Libreoffice-commits mailing list