diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-09-15 21:23:28 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2016-05-16 14:56:56 +0200 |
commit | 0850b4dbbb2e1590f3e8ede1eea71d83d7f99e51 (patch) | |
tree | 0f57296e489c35f13ae17d646f416f56f5e96ec8 | |
parent | 8bae722102ee987de2387878d4da24180d5b9933 (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>
-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 c11ae69d9330..6de6e5e92f94 100644 --- a/include/vcl/salbtype.hxx +++ b/include/vcl/salbtype.hxx @@ -202,6 +202,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 - @@ -212,8 +241,6 @@ class VCL_DLLPUBLIC ColorMask ColorMaskElement maB; sal_uInt32 mnAlphaChannel; - SAL_DLLPRIVATE inline bool ImplCalcMaskShift(ColorMaskElement &rOut) const; - public: inline ColorMask( sal_uLong nRedMask = 0UL, @@ -628,39 +655,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_uLong ColorMask::GetRedMask() const |