diff options
author | Dmitriy Shilin <dshil@fastmail.com> | 2018-12-06 08:52:05 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-12-06 11:33:07 +0100 |
commit | 8eff8a7a37fe5183bb46f977582fccd463cafe99 (patch) | |
tree | 0194dec33797fe8e3e04ed8ea97c61748f1356bb /vcl | |
parent | 8ec5c249fc40fb80d2a00e54a0bd76451dbc6477 (diff) |
vcl: split ImplIsPaletteEntry into low-level functions
Change-Id: I785d70cf05452ce3dbe209f595670d68b9653e22
Reviewed-on: https://gerrit.libreoffice.org/64668
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/win/gdi/gdiimpl.cxx | 99 |
1 files changed, 54 insertions, 45 deletions
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index b24760a3cf95..d8fd23ed6847 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -61,8 +61,6 @@ #define SAL_POLYPOLYCOUNT_STACKBUF 8 #define SAL_POLYPOLYPOINTS_STACKBUF 64 -#define DITHER_PAL_DELTA 51 -#define DITHER_MAX_SYSCOLOR 16 #define DMAP( _def_nVal, _def_nThres ) ((pDitherDiff[_def_nVal]>(_def_nThres))?pDitherHigh[_def_nVal]:pDitherLow[_def_nVal]) #define SAL_POLY_STACKBUF 32 @@ -168,31 +166,6 @@ void ImplPreparePolyDraw( bool bCloseFigures, } -static PALETTEENTRY aImplSalSysPalEntryAry[ DITHER_MAX_SYSCOLOR ] = -{ -{ 0, 0, 0, 0 }, -{ 0, 0, 0x80, 0 }, -{ 0, 0x80, 0, 0 }, -{ 0, 0x80, 0x80, 0 }, -{ 0x80, 0, 0, 0 }, -{ 0x80, 0, 0x80, 0 }, -{ 0x80, 0x80, 0, 0 }, -{ 0x80, 0x80, 0x80, 0 }, -{ 0xC0, 0xC0, 0xC0, 0 }, -{ 0, 0, 0xFF, 0 }, -{ 0, 0xFF, 0, 0 }, -{ 0, 0xFF, 0xFF, 0 }, -{ 0xFF, 0, 0, 0 }, -{ 0xFF, 0, 0xFF, 0 }, -{ 0xFF, 0xFF, 0, 0 }, -{ 0xFF, 0xFF, 0xFF, 0 } -}; - -static PALETTEENTRY aImplExtraColor1 = -{ - 0, 184, 255, 0 -}; - static BYTE aOrdDither8Bit[8][8] = { { 0, 38, 9, 48, 2, 40, 12, 50 }, @@ -227,34 +200,71 @@ Color ImplGetROPColor( SalROPColor nROPColor ) return nColor; } -int ImplIsPaletteEntry( BYTE nRed, BYTE nGreen, BYTE nBlue ) +bool IsDitherColor(BYTE nRed, BYTE nGreen, BYTE nBlue) { - // dither color? - if ( !(nRed % DITHER_PAL_DELTA) && !(nGreen % DITHER_PAL_DELTA) && !(nBlue % DITHER_PAL_DELTA) ) - return TRUE; + constexpr sal_uInt8 DITHER_PAL_DELTA = 51; - PALETTEENTRY* pPalEntry = aImplSalSysPalEntryAry; + return !(nRed % DITHER_PAL_DELTA) && + !(nGreen % DITHER_PAL_DELTA) && + !(nBlue % DITHER_PAL_DELTA); +} + +bool IsPaletteColor(BYTE nRed, BYTE nGreen, BYTE nBlue) +{ + static PALETTEENTRY aImplSalSysPalEntryAry[] = + { + { 0, 0, 0, 0 }, + { 0, 0, 0x80, 0 }, + { 0, 0x80, 0, 0 }, + { 0, 0x80, 0x80, 0 }, + { 0x80, 0, 0, 0 }, + { 0x80, 0, 0x80, 0 }, + { 0x80, 0x80, 0, 0 }, + { 0x80, 0x80, 0x80, 0 }, + { 0xC0, 0xC0, 0xC0, 0 }, + { 0, 0, 0xFF, 0 }, + { 0, 0xFF, 0, 0 }, + { 0, 0xFF, 0xFF, 0 }, + { 0xFF, 0, 0, 0 }, + { 0xFF, 0, 0xFF, 0 }, + { 0xFF, 0xFF, 0, 0 }, + { 0xFF, 0xFF, 0xFF, 0 } + }; - // standard palette color? - for ( sal_uInt16 i = 0; i < DITHER_MAX_SYSCOLOR; i++, pPalEntry++ ) + for (auto& rPalEntry : aImplSalSysPalEntryAry) { - if( pPalEntry->peRed == nRed && pPalEntry->peGreen == nGreen && pPalEntry->peBlue == nBlue ) - return TRUE; + if(rPalEntry.peRed == nRed && + rPalEntry.peGreen == nGreen && + rPalEntry.peBlue == nBlue) + { + return true; + } } - // extra color? - if ( aImplExtraColor1.peRed == nRed && - aImplExtraColor1.peGreen == nGreen && - aImplExtraColor1.peBlue == nBlue ) + return false; +} + +bool IsExtraColor(BYTE nRed, BYTE nGreen, BYTE nBlue) +{ + static PALETTEENTRY aImplExtraColor1 = { - return TRUE; - } + 0, 184, 255, 0 + }; - return FALSE; + return aImplExtraColor1.peRed == nRed && + aImplExtraColor1.peGreen == nGreen && + aImplExtraColor1.peBlue == nBlue; } +bool ImplIsPaletteEntry(BYTE nRed, BYTE nGreen, BYTE nBlue) +{ + return IsDitherColor(nRed, nGreen, nBlue) || + IsPaletteColor(nRed, nGreen, nBlue) || + IsExtraColor(nRed, nGreen, nBlue); } +} // namespace + WinSalGraphicsImpl::WinSalGraphicsImpl(WinSalGraphics& rParent): mrParent(rParent), mbXORMode(false), @@ -280,7 +290,6 @@ WinSalGraphicsImpl::~WinSalGraphicsImpl() if ( !mbStockBrush ) DeleteBrush( mhBrush ); } - } void WinSalGraphicsImpl::Init() @@ -673,7 +682,7 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, const WinSalBitmap& rSa } } -} +} // namespace void WinSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) { |