[Libreoffice-commits] core.git: vcl/win

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Dec 6 10:33:20 UTC 2018


 vcl/win/gdi/gdiimpl.cxx |   99 ++++++++++++++++++++++++++----------------------
 1 file changed, 54 insertions(+), 45 deletions(-)

New commits:
commit 8eff8a7a37fe5183bb46f977582fccd463cafe99
Author:     Dmitriy Shilin <dshil at fastmail.com>
AuthorDate: Thu Dec 6 08:52:05 2018 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Dec 6 11:33:07 2018 +0100

    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 at collabora.com>

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)
 {


More information about the Libreoffice-commits mailing list