include/vcl/salbtype.hxx | 131 ----------------------------------------------- 1 file changed, 1 insertion(+), 130 deletions(-)
New commits: commit 62e08e2230c673c4f96995fa778f533ea99acca6 Author: Caolán McNamara <caol...@redhat.com> Date: Thu Dec 18 16:54:18 2014 +0000 Related: coverity#1202743 Bad bit shift operation Change-Id: Ia2fe4abd17e09aecaef6d929dbd9b393f33c9de6 diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx index 1dc65fc..970d319 100644 --- a/include/vcl/salbtype.hxx +++ b/include/vcl/salbtype.hxx @@ -32,7 +32,6 @@ // - Memory - - typedef sal_uInt8* HPBYTE; typedef HPBYTE Scanline; typedef const sal_uInt8* ConstHPBYTE; @@ -41,7 +40,6 @@ typedef ConstHPBYTE ConstScanline; // - Bitmap formats - - #define BMP_FORMAT_BOTTOM_UP 0x00000000UL #define BMP_FORMAT_TOP_DOWN 0x80000000UL @@ -93,10 +91,8 @@ d_Col = BitmapColor( (sal_uInt8) ( _def_cR | ( ( _def_cR & mnROr ) >> mnROrShift ( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) | \ d_ALPHA ) - // - BitmapColor - - class Color; class VCL_DLLPUBLIC BitmapColor @@ -155,10 +151,7 @@ public: inline sal_uLong GetColorError( const BitmapColor& rBitmapColor ) const; }; - // - BitmapPalette - - - class Palette; class VCL_DLLPUBLIC BitmapPalette @@ -198,10 +191,7 @@ public: bool IsGreyPalette() const; }; - // - ColorMask - - - class VCL_DLLPUBLIC ColorMask { sal_uLong mnRMask; @@ -248,10 +238,7 @@ public: inline void SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const; }; - // - BitmapBuffer - - - struct VCL_DLLPUBLIC BitmapBuffer { sal_uLong mnFormat; @@ -267,7 +254,6 @@ struct VCL_DLLPUBLIC BitmapBuffer ~BitmapBuffer() {} }; - // - Access modes - typedef enum { @@ -277,16 +263,11 @@ typedef enum } BitmapAccessMode; - // - StretchAndConvert - - - VCL_DLLPUBLIC BitmapBuffer* StretchAndConvert( const BitmapBuffer& rSrcBuffer, const SalTwoRect& rTwoRect, sal_uLong nDstBitmapFormat, const BitmapPalette* pDstPal = NULL, const ColorMask* pDstMask = NULL ); - - inline BitmapColor::BitmapColor() : mcBlueOrIndex ( 0 ), mcGreen ( 0 ), @@ -295,8 +276,6 @@ inline BitmapColor::BitmapColor() : { } - - inline BitmapColor::BitmapColor( sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue ) : mcBlueOrIndex ( cBlue ), mcGreen ( cGreen ), @@ -305,8 +284,6 @@ inline BitmapColor::BitmapColor( sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBl { } - - inline BitmapColor::BitmapColor( const BitmapColor& rBitmapColor ) : mcBlueOrIndex ( rBitmapColor.mcBlueOrIndex ), mcGreen ( rBitmapColor.mcGreen ), @@ -315,8 +292,6 @@ inline BitmapColor::BitmapColor( const BitmapColor& rBitmapColor ) : { } - - inline BitmapColor::BitmapColor( const Color& rColor ) : mcBlueOrIndex ( rColor.GetBlue() ), mcGreen ( rColor.GetGreen() ), @@ -325,8 +300,6 @@ inline BitmapColor::BitmapColor( const Color& rColor ) : { } - - inline BitmapColor::BitmapColor( sal_uInt8 cIndex ) : mcBlueOrIndex ( cIndex ), mcGreen ( 0 ), @@ -335,8 +308,6 @@ inline BitmapColor::BitmapColor( sal_uInt8 cIndex ) : { } - - inline bool BitmapColor::operator==( const BitmapColor& rBitmapColor ) const { return( ( mcBlueOrIndex == rBitmapColor.mcBlueOrIndex ) && @@ -344,15 +315,11 @@ inline bool BitmapColor::operator==( const BitmapColor& rBitmapColor ) const ( mcGreen == rBitmapColor.mcGreen && mcRed == rBitmapColor.mcRed ) ) ); } - - inline bool BitmapColor::operator!=( const BitmapColor& rBitmapColor ) const { return !( *this == rBitmapColor ); } - - inline BitmapColor& BitmapColor::operator=( const BitmapColor& rBitmapColor ) { mcBlueOrIndex = rBitmapColor.mcBlueOrIndex; @@ -363,95 +330,71 @@ inline BitmapColor& BitmapColor::operator=( const BitmapColor& rBitmapColor ) return *this; } - - inline bool BitmapColor::IsIndex() const { return mbIndex; } - - inline sal_uInt8 BitmapColor::GetRed() const { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); return mcRed; } - - inline void BitmapColor::SetRed( sal_uInt8 cRed ) { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); mcRed = cRed; } - - inline sal_uInt8 BitmapColor::GetGreen() const { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); return mcGreen; } - - inline void BitmapColor::SetGreen( sal_uInt8 cGreen ) { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); mcGreen = cGreen; } - - inline sal_uInt8 BitmapColor::GetBlue() const { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); return mcBlueOrIndex; } - - inline void BitmapColor::SetBlue( sal_uInt8 cBlue ) { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); mcBlueOrIndex = cBlue; } - - inline sal_uInt8 BitmapColor::GetIndex() const { DBG_ASSERT( mbIndex, "Pixel represents color values!" ); return mcBlueOrIndex; } - - inline void BitmapColor::SetIndex( sal_uInt8 cIndex ) { DBG_ASSERT( mbIndex, "Pixel represents color values!" ); mcBlueOrIndex = cIndex; } - - inline BitmapColor::operator Color() const { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); return Color( mcRed, mcGreen, mcBlueOrIndex ); } - - inline sal_uInt8 BitmapColor::GetBlueOrIndex() const { // #i47518# Yield a value regardless of mbIndex return mcBlueOrIndex; } - - inline BitmapColor& BitmapColor::Invert() { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); @@ -460,16 +403,12 @@ inline BitmapColor& BitmapColor::Invert() return *this; } - - inline sal_uInt8 BitmapColor::GetLuminance() const { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); return( (sal_uInt8) ( ( mcBlueOrIndex * 28UL + mcGreen * 151UL + mcRed * 77UL ) >> 8UL ) ); } - - inline BitmapColor& BitmapColor::IncreaseLuminance( sal_uInt8 cGreyInc ) { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); @@ -480,8 +419,6 @@ inline BitmapColor& BitmapColor::IncreaseLuminance( sal_uInt8 cGreyInc ) return *this; } - - inline BitmapColor& BitmapColor::DecreaseLuminance( sal_uInt8 cGreyDec ) { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); @@ -492,8 +429,6 @@ inline BitmapColor& BitmapColor::DecreaseLuminance( sal_uInt8 cGreyDec ) return *this; } - - inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uInt8 cTransparency ) { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); @@ -505,8 +440,6 @@ inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uIn return *this; } - - inline BitmapColor& BitmapColor::Merge( sal_uInt8 cR, sal_uInt8 cG, sal_uInt8 cB, sal_uInt8 cTransparency ) { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); @@ -517,8 +450,6 @@ inline BitmapColor& BitmapColor::Merge( sal_uInt8 cR, sal_uInt8 cG, sal_uInt8 cB return *this; } - - inline sal_uLong BitmapColor::GetColorError( const BitmapColor& rBitmapColor ) const { DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); @@ -528,16 +459,12 @@ inline sal_uLong BitmapColor::GetColorError( const BitmapColor& rBitmapColor ) c labs( mcRed - rBitmapColor.mcRed ) ) ); } - - inline BitmapPalette::BitmapPalette() : mpBitmapColor ( NULL ), mnCount ( 0 ) { } - - inline BitmapPalette::BitmapPalette( const BitmapPalette& rBitmapPalette ) : mnCount( rBitmapPalette.mnCount ) { @@ -551,8 +478,6 @@ inline BitmapPalette::BitmapPalette( const BitmapPalette& rBitmapPalette ) : mpBitmapColor = NULL; } - - inline BitmapPalette::BitmapPalette( sal_uInt16 nCount ) : mnCount( nCount ) { @@ -566,15 +491,11 @@ inline BitmapPalette::BitmapPalette( sal_uInt16 nCount ) : mpBitmapColor = NULL; } - - inline BitmapPalette::~BitmapPalette() { delete[] (sal_uInt8*) mpBitmapColor; } - - inline BitmapPalette& BitmapPalette::operator=( const BitmapPalette& rBitmapPalette ) { delete[] (sal_uInt8*) mpBitmapColor; @@ -592,8 +513,6 @@ inline BitmapPalette& BitmapPalette::operator=( const BitmapPalette& rBitmapPale return *this; } - - inline bool BitmapPalette::operator==( const BitmapPalette& rBitmapPalette ) const { bool bRet = false; @@ -615,29 +534,21 @@ inline bool BitmapPalette::operator==( const BitmapPalette& rBitmapPalette ) con return bRet; } - - inline bool BitmapPalette::operator!=( const BitmapPalette& rBitmapPalette ) const { return !( *this == rBitmapPalette ); } - - inline bool BitmapPalette::operator!() { return( !mnCount || !mpBitmapColor ); } - - inline sal_uInt16 BitmapPalette::GetEntryCount() const { return mnCount; } - - inline void BitmapPalette::SetEntryCount( sal_uInt16 nCount ) { if( !nCount ) @@ -661,31 +572,24 @@ inline void BitmapPalette::SetEntryCount( sal_uInt16 nCount ) } } - - inline const BitmapColor& BitmapPalette::operator[]( sal_uInt16 nIndex ) const { DBG_ASSERT( nIndex < mnCount, "Palette index is out of range!" ); return mpBitmapColor[ nIndex ]; } - - inline BitmapColor& BitmapPalette::operator[]( sal_uInt16 nIndex ) { DBG_ASSERT( nIndex < mnCount, "Palette index is out of range!" ); return mpBitmapColor[ nIndex ]; } - - inline BitmapColor* BitmapPalette::ImplGetColorBuffer() const { DBG_ASSERT( mpBitmapColor, "No color buffer available!" ); return mpBitmapColor; } - inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const { sal_uInt16 nRetIndex = 0; @@ -711,8 +615,6 @@ inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const return nRetIndex; } - - inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong nBlueMask, @@ -733,8 +635,6 @@ inline ColorMask::ColorMask( sal_uLong nRedMask, mnBShift = ( mnBMask ? ImplCalcMaskShift( mnBMask, mnBOr, mnBOrShift ) : 0L ); } - - inline long ColorMask::ImplCalcMaskShift( sal_uLong nMask, sal_uLong& rOr, sal_uLong& rOrShift ) const { long nShift; @@ -755,50 +655,38 @@ inline long ColorMask::ImplCalcMaskShift( sal_uLong nMask, sal_uLong& rOr, sal_u } assert( nLen <= 8 ); // mask length must be 8 bits or less - rOrShift = 8L - nLen; + rOrShift = 8UL - nLen; rOr = (sal_uInt8) ( ( 0xffUL >> nLen ) << rOrShift ); return( nRet -= 7 ); } - - inline sal_uLong ColorMask::GetRedMask() const { return mnRMask; } - - inline sal_uLong ColorMask::GetGreenMask() const { return mnGMask; } - - inline sal_uLong ColorMask::GetBlueMask() const { return mnBMask; } - - inline void ColorMask::GetColorFor8Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const { const sal_uInt32 nVal = *pPixel; MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); } - - inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, HPBYTE pPixel ) const { *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel ); } - - inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, ConstHPBYTE pPixel ) const { const sal_uInt32 nVal = pPixel[ 1 ] | ( (sal_uInt32) pPixel[ 0 ] << 8UL ); @@ -806,8 +694,6 @@ inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, ConstHPBYTE pPi MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); } - - inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pPixel ) const { const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel ); @@ -816,8 +702,6 @@ inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pP pPixel[ 1 ] = (sal_uInt8) nVal; } - - inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, ConstHPBYTE pPixel ) const { const sal_uInt32 nVal = pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ); @@ -825,8 +709,6 @@ inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, ConstHPBYTE pPi MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); } - - inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pPixel ) const { const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel ); @@ -835,25 +717,18 @@ inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pP pPixel[ 1 ] = (sal_uInt8)(nVal >> 8U); } - - - inline void ColorMask::GetColorFor24Bit( BitmapColor& rColor, ConstHPBYTE 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, mnRShift, mnGShift, mnBShift, rColor ); } - - inline void ColorMask::SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixel ) const { const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel ); pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL ); pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL ); } - - inline void ColorMask::GetColorFor32Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const { const sal_uInt32 nVal = (sal_uInt32) pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ) | @@ -862,8 +737,6 @@ inline void ColorMask::GetColorFor32Bit( BitmapColor& rColor, ConstHPBYTE pPixel MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); } - - inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8& rAlpha, ConstHPBYTE pPixel ) const { const sal_uInt32 nVal = (sal_uInt32) pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ) | @@ -873,8 +746,6 @@ inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8& MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); } - - inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const { const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits