diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-09-15 21:23:28 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-09-16 20:09:10 +0000 |
commit | bb6031fbe14b1f4b2e2ca98f97e93efe3519baa7 (patch) | |
tree | 5d9bca44f269052fd29802c037de4f7887892855 /include/vcl | |
parent | 71ca5e4acc4cf4706329b462acefc625f4cc53c7 (diff) |
move CalcMaskShift to ColorMaskElement
Change-Id: I6ed7e9bfea8b4500724866214fabd179fba20f20
Reviewed-on: https://gerrit.libreoffice.org/18636
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include/vcl')
-rw-r--r-- | include/vcl/salbtype.hxx | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx index 547d9a2bcb86..4e0b4cd1c67e 100644 --- a/include/vcl/salbtype.hxx +++ b/include/vcl/salbtype.hxx @@ -194,6 +194,35 @@ struct VCL_DLLPUBLIC ColorMaskElement , mnOr(0) { } + bool CalcMaskShift(ColorMaskElement &rElem) const + { + if (rElem.mnMask == 0) + return true; + + // from which bit starts the mask? + int nShift = 31; + + while( nShift >= 0 && !( rElem.mnMask & ( 1 << nShift ) ) ) + --nShift; + + rElem.mnShift = nShift - 7; + int nLen = 0; + + // XXX determine number of bits set => walk right until null + while( nShift >= 0 && ( rElem.mnMask & ( 1 << nShift ) ) ) + { + nShift--; + nLen++; + } + + if (nLen > 8) // mask length must be 8 bits or less + return false; + + rElem.mnOrShift = 8 - nLen; + rElem.mnOr = static_cast<sal_uInt8>( ( 0xFF >> nLen ) << rElem.mnOrShift ); + + return true; + } }; // - ColorMask - @@ -204,8 +233,6 @@ class VCL_DLLPUBLIC ColorMask ColorMaskElement maB; sal_uInt32 mnAlphaChannel; - SAL_DLLPRIVATE inline bool ImplCalcMaskShift(ColorMaskElement &rOut) const; - public: inline ColorMask( sal_uInt32 nRedMask = 0, @@ -581,39 +608,9 @@ inline ColorMask::ColorMask( sal_uInt32 nRedMask, , maB(nBlueMask) , mnAlphaChannel(nAlphaChannel) { - ImplCalcMaskShift(maR); - ImplCalcMaskShift(maG); - ImplCalcMaskShift(maB); -} - -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 && !( rElem.mnMask & ( 1 << nShift ) ) ) - --nShift; - - rElem.mnShift = nShift - 7; - int nLen = 0; - - // XXX determine number of bits set => walk right until null - while( nShift >= 0 && ( rElem.mnMask & ( 1 << nShift ) ) ) - { - nShift--; - nLen++; - } - - if (nLen > 8) // mask length must be 8 bits or less - return false; - - rElem.mnOrShift = 8 - nLen; - rElem.mnOr = static_cast<sal_uInt8>( ( 0xFF >> nLen ) << rElem.mnOrShift ); - - return true; + maR.CalcMaskShift(maR); + maG.CalcMaskShift(maG); + maB.CalcMaskShift(maB); } inline sal_uInt32 ColorMask::GetRedMask() const |