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

coverity#1242439 ALPHABITS == nAlphaShift == 8

Change-Id: Ifde395113524df03a2523115ab2234403d405455
üst 04301686
...@@ -267,18 +267,15 @@ inline void ImplConvertLine( const TrueColorPixelPtr<DSTFMT>& rDst, ...@@ -267,18 +267,15 @@ inline void ImplConvertLine( const TrueColorPixelPtr<DSTFMT>& rDst,
} }
// alpha blending truecolor pixels // alpha blending truecolor pixels
template <unsigned ALPHABITS, sal_uLong SRCFMT, sal_uLong DSTFMT> template <sal_uLong SRCFMT, sal_uLong DSTFMT>
inline void ImplBlendPixels( const TrueColorPixelPtr<DSTFMT>& rDst, inline void ImplBlendPixels( const TrueColorPixelPtr<DSTFMT>& rDst,
const TrueColorPixelPtr<SRCFMT>& rSrc, unsigned nAlphaVal ) const TrueColorPixelPtr<SRCFMT>& rSrc, unsigned nAlphaVal )
{ {
static const unsigned nAlphaShift = 8;
if( !nAlphaVal ) if( !nAlphaVal )
ImplConvertPixel( rDst, rSrc ); ImplConvertPixel( rDst, rSrc );
else if( nAlphaVal != ~(~0U << ALPHABITS) ) else if( nAlphaVal != ~(~0U << nAlphaShift) )
{ {
static const unsigned nAlphaShift = (ALPHABITS > 8) ? 8 : ALPHABITS;
if( ALPHABITS > nAlphaShift )
nAlphaVal >>= ALPHABITS - nAlphaShift;
int nR = rDst.GetRed(); int nR = rDst.GetRed();
int nS = rSrc.GetRed(); int nS = rSrc.GetRed();
nR = nS + (((nR - nS) * nAlphaVal) >> nAlphaShift); nR = nS + (((nR - nS) * nAlphaVal) >> nAlphaShift);
...@@ -297,7 +294,7 @@ inline void ImplBlendPixels( const TrueColorPixelPtr<DSTFMT>& rDst, ...@@ -297,7 +294,7 @@ inline void ImplBlendPixels( const TrueColorPixelPtr<DSTFMT>& rDst,
} }
} }
template <unsigned ALPHABITS, sal_uLong MASKFMT, sal_uLong SRCFMT, sal_uLong DSTFMT> template <sal_uLong MASKFMT, sal_uLong SRCFMT, sal_uLong DSTFMT>
inline void ImplBlendLines( const TrueColorPixelPtr<DSTFMT>& rDst, inline void ImplBlendLines( const TrueColorPixelPtr<DSTFMT>& rDst,
const TrueColorPixelPtr<SRCFMT>& rSrc, const TrueColorPixelPtr<MASKFMT>& rMsk, const TrueColorPixelPtr<SRCFMT>& rSrc, const TrueColorPixelPtr<MASKFMT>& rMsk,
int nPixelCount ) int nPixelCount )
...@@ -307,7 +304,7 @@ inline void ImplBlendLines( const TrueColorPixelPtr<DSTFMT>& rDst, ...@@ -307,7 +304,7 @@ inline void ImplBlendLines( const TrueColorPixelPtr<DSTFMT>& rDst,
TrueColorPixelPtr<SRCFMT> aSrc( rSrc ); TrueColorPixelPtr<SRCFMT> aSrc( rSrc );
while( --nPixelCount >= 0 ) while( --nPixelCount >= 0 )
{ {
ImplBlendPixels<ALPHABITS>( aDst, aSrc, aMsk.GetAlpha() ); ImplBlendPixels(aDst, aSrc, aMsk.GetAlpha());
++aDst; ++aDst;
++aSrc; ++aSrc;
++aMsk; ++aMsk;
...@@ -576,7 +573,7 @@ bool ImplBlendToBitmap( TrueColorPixelPtr<SRCFMT>& rSrcLine, ...@@ -576,7 +573,7 @@ bool ImplBlendToBitmap( TrueColorPixelPtr<SRCFMT>& rSrcLine,
assert(rDstBuffer.mnHeight <= rSrcBuffer.mnHeight && "not sure about that?"); assert(rDstBuffer.mnHeight <= rSrcBuffer.mnHeight && "not sure about that?");
for (int y = rDstBuffer.mnHeight; --y >= 0;) for (int y = rDstBuffer.mnHeight; --y >= 0;)
{ {
ImplBlendLines<8>( aDstLine, rSrcLine, aMskLine, rDstBuffer.mnWidth ); ImplBlendLines(aDstLine, rSrcLine, aMskLine, rDstBuffer.mnWidth);
aDstLine.AddByteOffset( nDstLinestep ); aDstLine.AddByteOffset( nDstLinestep );
rSrcLine.AddByteOffset( nSrcLinestep ); rSrcLine.AddByteOffset( nSrcLinestep );
aMskLine.AddByteOffset( nMskLinestep ); aMskLine.AddByteOffset( nMskLinestep );
......
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