diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-08 14:34:59 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-09 07:18:54 +0100 |
commit | c0847dc7b7a311d19b73d4943d1b0466b10cde4f (patch) | |
tree | b4cb48dd32dbbb709002f2bf387d75e0a03264a4 | |
parent | 46ab8c952aa535bd1c624aa95c8900460aa474bf (diff) |
convert COLOR_CHANNEL_MERGE to constexpr function
Change-Id: Ie46e0a47b433517b0bae0deabb447ff5c1000f22
Reviewed-on: https://gerrit.libreoffice.org/47595
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/tools/color.hxx | 6 | ||||
-rw-r--r-- | include/tools/colordata.hxx | 6 | ||||
-rw-r--r-- | include/vcl/salbtype.hxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/bitmap.cxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/transparent.cxx | 6 |
5 files changed, 16 insertions, 14 deletions
diff --git a/include/tools/color.hxx b/include/tools/color.hxx index 0173840d80ff..1d0d239d5af5 100644 --- a/include/tools/color.hxx +++ b/include/tools/color.hxx @@ -192,9 +192,9 @@ inline sal_uInt8 Color::GetLuminance() const inline void Color::Merge( const Color& rMergeColor, sal_uInt8 cTransparency ) { - SetRed(COLOR_CHANNEL_MERGE(COLORDATA_RED(mnColor), COLORDATA_RED(rMergeColor.mnColor), cTransparency)); - SetGreen(COLOR_CHANNEL_MERGE(COLORDATA_GREEN(mnColor), COLORDATA_GREEN(rMergeColor.mnColor), cTransparency)); - SetBlue(COLOR_CHANNEL_MERGE(COLORDATA_BLUE(mnColor), COLORDATA_BLUE(rMergeColor.mnColor), cTransparency)); + SetRed(ColorChannelMerge(COLORDATA_RED(mnColor), COLORDATA_RED(rMergeColor.mnColor), cTransparency)); + SetGreen(ColorChannelMerge(COLORDATA_GREEN(mnColor), COLORDATA_GREEN(rMergeColor.mnColor), cTransparency)); + SetBlue(ColorChannelMerge(COLORDATA_BLUE(mnColor), COLORDATA_BLUE(rMergeColor.mnColor), cTransparency)); } #endif diff --git a/include/tools/colordata.hxx b/include/tools/colordata.hxx index ffe5a2d14b44..6008d0c0fc24 100644 --- a/include/tools/colordata.hxx +++ b/include/tools/colordata.hxx @@ -92,8 +92,10 @@ constexpr ColorData RGB_COLORDATA(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b) { #define COL_AUTHOR9_NORMAL RGB_COLORDATA(255, 226, 185) #define COL_AUTHOR9_LIGHT RGB_COLORDATA(255, 231, 199) -#define COLOR_CHANNEL_MERGE( _def_cDst, _def_cSrc, _def_cSrcTrans ) \ - ((sal_uInt8)((((long)(_def_cDst)-(_def_cSrc))*(_def_cSrcTrans)+(((_def_cSrc)<<8)|(_def_cDst)))>>8)) +constexpr sal_uInt8 ColorChannelMerge(sal_uInt8 nDst, sal_uInt8 nSrc, sal_uInt8 nSrcTrans) +{ + return (sal_uInt8) ((((sal_Int32)nDst-nSrc)*nSrcTrans+((nSrc<<8)|nDst))>>8); +}; #endif diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx index ed38c9a41b8a..e9a3bdf599b7 100644 --- a/include/vcl/salbtype.hxx +++ b/include/vcl/salbtype.hxx @@ -480,9 +480,9 @@ inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uIn { assert( !mbIndex && "Pixel represents index into colortable" ); assert( !rBitmapColor.mbIndex && "Pixel represents index into colortable" ); - mcBlueOrIndex = COLOR_CHANNEL_MERGE( mcBlueOrIndex, rBitmapColor.mcBlueOrIndex, cTransparency ); - mcGreen = COLOR_CHANNEL_MERGE( mcGreen, rBitmapColor.mcGreen, cTransparency ); - mcRed = COLOR_CHANNEL_MERGE( mcRed, rBitmapColor.mcRed, cTransparency ); + mcBlueOrIndex = ColorChannelMerge( mcBlueOrIndex, rBitmapColor.mcBlueOrIndex, cTransparency ); + mcGreen = ColorChannelMerge( mcGreen, rBitmapColor.mcGreen, cTransparency ); + mcRed = ColorChannelMerge( mcRed, rBitmapColor.mcRed, cTransparency ); return *this; } diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index e33cfa60bd70..24b1c5403057 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -867,11 +867,11 @@ public: nAlpha = (nAlphaLine1 + nMapFY * ((nAlphaLine2 >> 7) - (nAlphaLine1 >> 7))) >> 7; - *pDestScanline = COLOR_CHANNEL_MERGE(*pDestScanline, nColor1, nAlpha); + *pDestScanline = ColorChannelMerge(*pDestScanline, nColor1, nAlpha); pDestScanline++; - *pDestScanline = COLOR_CHANNEL_MERGE(*pDestScanline, nColor2, nAlpha); + *pDestScanline = ColorChannelMerge(*pDestScanline, nColor2, nAlpha); pDestScanline++; - *pDestScanline = COLOR_CHANNEL_MERGE(*pDestScanline, nColor3, nAlpha); + *pDestScanline = ColorChannelMerge(*pDestScanline, nColor3, nAlpha); pDestScanline++; pDestScanline++; } diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index 31d4c946bb36..764389dcbe78 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -558,9 +558,9 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, } if( ( *pRScan & cBit ) == cBlack ) { - pWScan[ 0 ] = COLOR_CHANNEL_MERGE( pWScan[ 0 ], nB, cTrans ); - pWScan[ 1 ] = COLOR_CHANNEL_MERGE( pWScan[ 1 ], nG, cTrans ); - pWScan[ 2 ] = COLOR_CHANNEL_MERGE( pWScan[ 2 ], nR, cTrans ); + pWScan[ 0 ] = ColorChannelMerge( pWScan[ 0 ], nB, cTrans ); + pWScan[ 1 ] = ColorChannelMerge( pWScan[ 1 ], nG, cTrans ); + pWScan[ 2 ] = ColorChannelMerge( pWScan[ 2 ], nR, cTrans ); } } } |