Kaydet (Commit) bb6031fb authored tarafından Caolán McNamara's avatar Caolán McNamara

move CalcMaskShift to ColorMaskElement

Change-Id: I6ed7e9bfea8b4500724866214fabd179fba20f20
Reviewed-on: https://gerrit.libreoffice.org/18636Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 71ca5e4a
...@@ -194,6 +194,35 @@ struct VCL_DLLPUBLIC ColorMaskElement ...@@ -194,6 +194,35 @@ struct VCL_DLLPUBLIC ColorMaskElement
, mnOr(0) , 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 - // - ColorMask -
...@@ -204,8 +233,6 @@ class VCL_DLLPUBLIC ColorMask ...@@ -204,8 +233,6 @@ class VCL_DLLPUBLIC ColorMask
ColorMaskElement maB; ColorMaskElement maB;
sal_uInt32 mnAlphaChannel; sal_uInt32 mnAlphaChannel;
SAL_DLLPRIVATE inline bool ImplCalcMaskShift(ColorMaskElement &rOut) const;
public: public:
inline ColorMask( sal_uInt32 nRedMask = 0, inline ColorMask( sal_uInt32 nRedMask = 0,
...@@ -581,39 +608,9 @@ inline ColorMask::ColorMask( sal_uInt32 nRedMask, ...@@ -581,39 +608,9 @@ inline ColorMask::ColorMask( sal_uInt32 nRedMask,
, maB(nBlueMask) , maB(nBlueMask)
, mnAlphaChannel(nAlphaChannel) , mnAlphaChannel(nAlphaChannel)
{ {
ImplCalcMaskShift(maR); maR.CalcMaskShift(maR);
ImplCalcMaskShift(maG); maG.CalcMaskShift(maG);
ImplCalcMaskShift(maB); maB.CalcMaskShift(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;
} }
inline sal_uInt32 ColorMask::GetRedMask() const inline sal_uInt32 ColorMask::GetRedMask() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment