vcl/inc/win/saldata.hxx     |   14 -
 vcl/win/app/salinst.cxx     |    8 -
 vcl/win/gdi/gdiimpl.cxx     |  183 +-----------------------
 vcl/win/gdi/salbmp.cxx      |   11 -
 vcl/win/gdi/salfont.cxx     |   13 -
 vcl/win/gdi/salgdi.cxx      |  323 --------------------------------------------
 vcl/win/gdi/salvd.cxx       |   15 --
 vcl/win/window/salframe.cxx |  203 ---------------------------
 vcl/win/window/salobj.cxx   |    9 -
 9 files changed, 13 insertions(+), 766 deletions(-)

New commits:
commit c4edd3e223eb49b914a99b6345df41565a082808
Author:     Noel Grandin <noelgran...@collabora.co.uk>
AuthorDate: Tue Feb 4 21:59:00 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Feb 5 06:15:10 2025 +0100

    remove dithering from Windows GDI backend
    
    This has not been necessary for some years now. In the unlikely
    event that we run on a 256-color display, the OS and the graphics
    driver will do the dithering for us.
    
    Change-Id: I23c7a3ded6ea63fcd0a5239bbf2a2cc91bba306f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181143
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 607788fbd34f..4ab4e2c0401a 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -98,13 +98,6 @@ public:
 public:
     HINSTANCE               mhInst;                 // default instance handle
     int                     mnCmdShow;              // default frame show style
-    HPALETTE                mhDitherPal;            // dither palette
-    HGLOBAL                 mhDitherDIB;            // dither memory handle
-    BYTE*                   mpDitherDIB;            // dither memory
-    BYTE*                   mpDitherDIBData;        // beginning of DIB data
-    std::unique_ptr<tools::Long[]> mpDitherDiff;    // Dither mapping table
-    std::unique_ptr<BYTE[]> mpDitherLow;            // Dither mapping table
-    std::unique_ptr<BYTE[]> mpDitherHigh;           // Dither mapping table
     HHOOK                   mhSalObjMsgHook;        // hook to get interesting 
msg for SalObject
     HWND                    mhWantLeaveMsg;         // window handle, that 
want a MOUSELEAVE message
     WinSalInstance*         mpInstance;
@@ -124,7 +117,6 @@ public:
     WPARAM                  mnSalObjWantKeyEvt;     // KeyEvent that should be 
processed by SalObj-Hook
     BYTE                    mnCacheDCInUse;         // count of CacheDC in use
     bool                    mbObjClassInit;         // is SALOBJECTCLASS 
initialised
-    bool                    mbInPalChange;          // is in WM_QUERYNEWPALETTE
     DWORD                   mnAppThreadId;          // Id from 
Application-Thread
     SalIcon*                mpFirstIcon;            // icon cache, points to 
first icon, NULL if none
     TempFontItem*           mpSharedTempFontItem;   // LibreOffice shared fonts
@@ -233,17 +225,11 @@ OUString ImplSalGetUniString(const char* pStr, sal_Int32 
nLen = -1);
 // wParam == 0; lParam == 0
 #define SAL_MSG_POSTFOCUS           (WM_USER+133)
 // wParam == wParam; lParam == lParam
-#define SAL_MSG_POSTQUERYNEWPAL     (WM_USER+134)
-// wParam == wParam; lParam == lParam
-#define SAL_MSG_POSTPALCHANGED      (WM_USER+135)
-// wParam == wParam; lParam == lParam
 #define SAL_MSG_POSTMOVE            (WM_USER+136)
 // wParam == wParam; lParam == lParam
 #define SAL_MSG_POSTCALLSIZE        (WM_USER+137)
 // wParam == pRECT; lParam == 0
 #define SAL_MSG_POSTPAINT           (WM_USER+138)
-// wParam == 0; lParam == pFrame; lResult 0
-#define SAL_MSG_FORCEPALETTE        (WM_USER+139)
 // wParam == 0; lParam == 0
 #define SAL_MSG_CAPTUREMOUSE        (WM_USER+140)
 // wParam == 0; lParam == 0
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index a5812bfdf30c..0a8f33c06f0c 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -248,13 +248,6 @@ SalData::SalData()
 {
     mhInst = nullptr;           // default instance handle
     mnCmdShow = 0;              // default frame show style
-    mhDitherPal = nullptr;      // dither palette
-    mhDitherDIB = nullptr;      // dither memory handle
-    mpDitherDIB = nullptr;      // dither memory
-    mpDitherDIBData = nullptr;  // beginning of DIB data
-    mpDitherDiff = nullptr;     // Dither mapping table
-    mpDitherLow = nullptr;      // Dither mapping table
-    mpDitherHigh = nullptr;     // Dither mapping table
     mhSalObjMsgHook = nullptr;  // hook to get interesting msg for SalObject
     mhWantLeaveMsg = nullptr;   // window handle, that want a MOUSELEAVE 
message
     mpInstance = nullptr;  // pointer of first instance
@@ -280,7 +273,6 @@ SalData::SalData()
     mnSalObjWantKeyEvt = 0;     // KeyEvent for the SalObj hook
     mnCacheDCInUse = 0;         // count of CacheDC in use
     mbObjClassInit = false;     // is SALOBJECTCLASS initialised
-    mbInPalChange = false;      // is in WM_QUERYNEWPALETTE
     mnAppThreadId = 0;          // Id from Application-Thread
     mpFirstIcon = nullptr;      // icon cache, points to first icon, NULL if 
none
     mpSharedTempFontItem = nullptr;
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index dbc0ab48806d..eb4ab2c18972 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -148,62 +148,6 @@ Color ImplGetROPColor( SalROPColor nROPColor )
     return nColor;
 }
 
-bool IsDitherColor(BYTE nRed, BYTE nGreen, BYTE nBlue)
-{
-    constexpr sal_uInt8 DITHER_PAL_DELTA = 51;
-
-    return !(nRed % DITHER_PAL_DELTA) &&
-           !(nGreen % DITHER_PAL_DELTA) &&
-           !(nBlue % DITHER_PAL_DELTA);
-}
-
-bool IsPaletteColor(BYTE nRed, BYTE nGreen, BYTE nBlue)
-{
-    static const 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 }
-    };
-
-    for (const auto& rPalEntry : aImplSalSysPalEntryAry)
-    {
-        if(rPalEntry.peRed == nRed &&
-           rPalEntry.peGreen == nGreen &&
-           rPalEntry.peBlue == nBlue)
-        {
-            return true;
-        }
-    }
-
-    return false;
-}
-
-bool IsExtraColor(BYTE nRed, BYTE nGreen, BYTE nBlue)
-{
-    return (nRed == 0) && (nGreen == 184) && (nBlue == 255);
-}
-
-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):
@@ -1295,17 +1239,9 @@ HPEN WinSalGraphicsImpl::SearchStockPen(COLORREF 
nPenColor)
 
 HPEN WinSalGraphicsImpl::MakePen(Color nColor)
 {
-    COLORREF nPenColor = PALETTERGB(nColor.GetRed(),
-                                    nColor.GetGreen(),
-                                    nColor.GetBlue());
-
-    if (!mrParent.isPrinter())
-    {
-        if (GetSalData()->mhDitherPal && ImplIsSysColorEntry(nColor))
-        {
-            nPenColor = PALRGB_TO_RGB(nPenColor);
-        }
-    }
+    COLORREF nPenColor = RGB(nColor.GetRed(),
+                            nColor.GetGreen(),
+                            nColor.GetBlue());
 
     return CreatePen(PS_SOLID, mrParent.mnPenWidth, nPenColor);
 }
@@ -1377,112 +1313,14 @@ HBRUSH WinSalGraphicsImpl::SearchStockBrush(COLORREF 
nBrushColor)
     return nullptr;
 }
 
-namespace
-{
-
-BYTE GetDitherMappingValue(BYTE nVal, BYTE nThres, const SalData* pSalData)
-{
-    return (pSalData->mpDitherDiff[nVal] > nThres) ?
-        pSalData->mpDitherHigh[nVal] : pSalData->mpDitherLow[nVal];
-}
-
-HBRUSH Make16BitDIBPatternBrush(Color nColor)
-{
-    const SalData* pSalData = GetSalData();
-
-    const BYTE nRed   = nColor.GetRed();
-    const BYTE nGreen = nColor.GetGreen();
-    const BYTE nBlue  = nColor.GetBlue();
-
-    static const BYTE aOrdDither16Bit[8][8] =
-    {
-       { 0, 6, 1, 7, 0, 6, 1, 7 },
-       { 4, 2, 5, 3, 4, 2, 5, 3 },
-       { 1, 7, 0, 6, 1, 7, 0, 6 },
-       { 5, 3, 4, 2, 5, 3, 4, 2 },
-       { 0, 6, 1, 7, 0, 6, 1, 7 },
-       { 4, 2, 5, 3, 4, 2, 5, 3 },
-       { 1, 7, 0, 6, 1, 7, 0, 6 },
-       { 5, 3, 4, 2, 5, 3, 4, 2 }
-    };
-
-    BYTE* pTmp = pSalData->mpDitherDIBData;
-
-    for(int nY = 0; nY < 8; ++nY)
-    {
-        for(int nX = 0; nX < 8; ++nX)
-        {
-            const BYTE nThres = aOrdDither16Bit[nY][nX];
-            *pTmp++ = GetDitherMappingValue(nBlue, nThres, pSalData);
-            *pTmp++ = GetDitherMappingValue(nGreen, nThres, pSalData);
-            *pTmp++ = GetDitherMappingValue(nRed, nThres, pSalData);
-        }
-    }
-
-    return CreateDIBPatternBrush(pSalData->mhDitherDIB, DIB_RGB_COLORS);
-}
-
-HBRUSH Make8BitDIBPatternBrush(Color nColor)
-{
-    const SalData* pSalData = GetSalData();
-
-    const BYTE nRed   = nColor.GetRed();
-    const BYTE nGreen = nColor.GetGreen();
-    const BYTE nBlue  = nColor.GetBlue();
-
-    static const BYTE aOrdDither8Bit[8][8] =
-    {
-       {  0, 38,  9, 48,  2, 40, 12, 50 },
-       { 25, 12, 35, 22, 28, 15, 37, 24 },
-       {  6, 44,  3, 41,  8, 47,  5, 44 },
-       { 32, 19, 28, 16, 34, 21, 31, 18 },
-       {  1, 40, 11, 49,  0, 39, 10, 48 },
-       { 27, 14, 36, 24, 26, 13, 36, 23 },
-       {  8, 46,  4, 43,  7, 45,  4, 42 },
-       { 33, 20, 30, 17, 32, 20, 29, 16 }
-    };
-
-    BYTE* pTmp = pSalData->mpDitherDIBData;
-
-    for (int nY = 0; nY < 8; ++nY)
-    {
-        for (int nX = 0; nX < 8; ++nX)
-        {
-            const BYTE nThres = aOrdDither8Bit[nY][nX];
-            *pTmp = GetDitherMappingValue(nRed, nThres, pSalData) +
-                    GetDitherMappingValue(nGreen, nThres, pSalData) * 6 +
-                    GetDitherMappingValue(nBlue, nThres, pSalData) * 36;
-            pTmp++;
-        }
-    }
-
-    return CreateDIBPatternBrush(pSalData->mhDitherDIB, DIB_PAL_COLORS);
-}
-
-} // namespace
-
 HBRUSH WinSalGraphicsImpl::MakeBrush(Color nColor)
 {
-    const SalData* pSalData = GetSalData();
-
     const BYTE        nRed        = nColor.GetRed();
     const BYTE        nGreen      = nColor.GetGreen();
     const BYTE        nBlue       = nColor.GetBlue();
-    const COLORREF    nBrushColor = PALETTERGB(nRed, nGreen, nBlue);
-
-    if (mrParent.isPrinter() || !pSalData->mhDitherDIB)
-        return CreateSolidBrush(nBrushColor);
+    const COLORREF    nBrushColor = RGB(nRed, nGreen, nBlue);
 
-    if (24 == 
reinterpret_cast<BITMAPINFOHEADER*>(pSalData->mpDitherDIB)->biBitCount)
-        return Make16BitDIBPatternBrush(nColor);
-
-    if (ImplIsSysColorEntry(nColor))
-        return CreateSolidBrush(PALRGB_TO_RGB(nBrushColor));
-
-    if (ImplIsPaletteEntry(nRed, nGreen, nBlue))
-        return CreateSolidBrush(nBrushColor);
-
-    return Make8BitDIBPatternBrush(nColor);
+    return CreateSolidBrush(nBrushColor);
 }
 
 void WinSalGraphicsImpl::ResetBrush(HBRUSH hNewBrush)
@@ -1541,14 +1379,9 @@ void WinSalGraphicsImpl::drawPixel( tools::Long nX, 
tools::Long nY )
 
 void WinSalGraphicsImpl::drawPixel( tools::Long nX, tools::Long nY, Color 
nColor )
 {
-    COLORREF nCol = PALETTERGB( nColor.GetRed(),
-                                nColor.GetGreen(),
-                                nColor.GetBlue() );
-
-    if ( !mrParent.isPrinter() &&
-         GetSalData()->mhDitherPal &&
-         ImplIsSysColorEntry( nColor ) )
-        nCol = PALRGB_TO_RGB( nCol );
+    COLORREF nCol = RGB( nColor.GetRed(),
+                        nColor.GetGreen(),
+                        nColor.GetBlue() );
 
     DrawPixelImpl( nX, nY, nCol );
 }
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index 65960e5cc550..661684ac0084 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -553,14 +553,6 @@ bool WinSalBitmap::Create(const SalBitmap& rSSalBmp, 
vcl::PixelFormat eNewPixelF
     HDC         hDC = GetDC( nullptr );
     PBYTE       pBits = reinterpret_cast<PBYTE>(pBI) + pBI->bmiHeader.biSize +
                         ImplGetDIBColorCount( mhDIB ) * sizeof( RGBQUAD );
-    SalData*    pSalData = GetSalData();
-    HPALETTE    hOldPal = nullptr;
-
-    if ( pSalData->mhDitherPal )
-    {
-        hOldPal = SelectPalette( hDC, pSalData->mhDitherPal, TRUE );
-        RealizePalette( hDC );
-    }
 
     if( GetDIBits( hDC, rSalBmp.mhDDB, 0, nLines, pBits, pBI, DIB_RGB_COLORS ) 
== nLines )
     {
@@ -576,9 +568,6 @@ bool WinSalBitmap::Create(const SalBitmap& rSSalBmp, 
vcl::PixelFormat eNewPixelF
         mhDIB = nullptr;
     }
 
-    if( hOldPal )
-        SelectPalette( hDC, hOldPal, TRUE );
-
     ReleaseDC( nullptr, hDC );
 
     return bRet;
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 312f5c60b97f..518b7136aa1d 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -648,16 +648,9 @@ hb_blob_t* WinFontFace::GetHbTable(hb_tag_t nTag) const
 
 void WinSalGraphics::SetTextColor( Color nColor )
 {
-    COLORREF aCol = PALETTERGB( nColor.GetRed(),
-                                nColor.GetGreen(),
-                                nColor.GetBlue() );
-
-    if( !mbPrinter &&
-        GetSalData()->mhDitherPal &&
-        ImplIsSysColorEntry( nColor ) )
-    {
-        aCol = PALRGB_TO_RGB( aCol );
-    }
+    COLORREF aCol = RGB( nColor.GetRed(),
+                         nColor.GetGreen(),
+                         nColor.GetBlue() );
 
     ::SetTextColor( getHDC(), aCol );
 }
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 978f4cf95309..0e6e033d0c4d 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -43,65 +43,6 @@
 #endif
 
 
-#define DITHER_PAL_DELTA                51
-#define DITHER_PAL_STEPS                6
-#define DITHER_PAL_COUNT                
(DITHER_PAL_STEPS*DITHER_PAL_STEPS*DITHER_PAL_STEPS)
-#define DITHER_MAX_SYSCOLOR             16
-#define DITHER_EXTRA_COLORS             1
-
-namespace
-{
-
-struct SysColorEntry
-{
-    DWORD           nRGB;
-    SysColorEntry*  pNext;
-};
-
-SysColorEntry* pFirstSysColor = nullptr;
-SysColorEntry* pActSysColor = nullptr;
-
-void DeleteSysColorList()
-{
-    SysColorEntry* pEntry = pFirstSysColor;
-    pActSysColor = pFirstSysColor = nullptr;
-
-    while( pEntry )
-    {
-        SysColorEntry* pTmp = pEntry->pNext;
-        delete pEntry;
-        pEntry = pTmp;
-    }
-}
-
-} // namespace
-
-// Blue7
-static PALETTEENTRY aImplExtraColor1 =
-{
-    0, 184, 255, 0
-};
-
-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 }
-};
-
 // we must create pens with 1-pixel width; otherwise the S3-graphics card
 // map has many paint problems when drawing polygons/polyLines and a
 // complex is set
@@ -137,152 +78,6 @@ void ImplInitSalGDI()
     // initialize temporary font lists
     pSalData->mpSharedTempFontItem = nullptr;
     pSalData->mpOtherTempFontItem = nullptr;
-
-    // support palettes for 256 color displays
-    HDC hDC = GetDC( nullptr );
-    int nBitsPixel = GetDeviceCaps( hDC, BITSPIXEL );
-    int nPlanes = GetDeviceCaps( hDC, PLANES );
-    int nRasterCaps = GetDeviceCaps( hDC, RASTERCAPS );
-    int nBitCount = nBitsPixel * nPlanes;
-
-    if ( (nBitCount > 8) && (nBitCount < 24) )
-    {
-        // test if we have to dither
-        HDC         hMemDC = ::CreateCompatibleDC( hDC );
-        HBITMAP     hMemBmp = ::CreateCompatibleBitmap( hDC, 8, 8 );
-        HBITMAP     hBmpOld = static_cast<HBITMAP>(::SelectObject( hMemDC, 
hMemBmp ));
-        HBRUSH      hMemBrush = ::CreateSolidBrush( PALETTERGB( 175, 171, 169 
) );
-        HBRUSH      hBrushOld = static_cast<HBRUSH>(::SelectObject( hMemDC, 
hMemBrush ));
-        bool        bDither16 = true;
-
-        ::PatBlt( hMemDC, 0, 0, 8, 8, PATCOPY );
-        const COLORREF aCol( ::GetPixel( hMemDC, 0, 0 ) );
-
-        for( int nY = 0; ( nY < 8 ) && bDither16; nY++ )
-            for( int nX = 0; ( nX < 8 ) && bDither16; nX++ )
-                if( ::GetPixel( hMemDC, nX, nY ) != aCol )
-                    bDither16 = false;
-
-        ::SelectObject( hMemDC, hBrushOld );
-        ::DeleteObject( hMemBrush );
-        ::SelectObject( hMemDC, hBmpOld );
-        ::DeleteObject( hMemBmp );
-        ::DeleteDC( hMemDC );
-
-        if( bDither16 )
-        {
-            // create DIBPattern for 16Bit dithering
-            tools::Long n;
-
-            pSalData->mhDitherDIB = GlobalAlloc( GMEM_FIXED, sizeof( 
BITMAPINFOHEADER ) + 192 );
-            pSalData->mpDitherDIB = static_cast<BYTE*>(GlobalLock( 
pSalData->mhDitherDIB ));
-            pSalData->mpDitherDiff.reset(new tools::Long[ 256 ]);
-            pSalData->mpDitherLow.reset(new BYTE[ 256 ]);
-            pSalData->mpDitherHigh.reset(new BYTE[ 256 ]);
-            pSalData->mpDitherDIBData = pSalData->mpDitherDIB + sizeof( 
BITMAPINFOHEADER );
-            memset( pSalData->mpDitherDIB, 0, sizeof( BITMAPINFOHEADER ) );
-
-            BITMAPINFOHEADER* pBIH = 
reinterpret_cast<BITMAPINFOHEADER*>(pSalData->mpDitherDIB);
-
-            pBIH->biSize = sizeof( BITMAPINFOHEADER );
-            pBIH->biWidth = 8;
-            pBIH->biHeight = 8;
-            pBIH->biPlanes = 1;
-            pBIH->biBitCount = 24;
-
-            for( n = 0; n < 256; n++ )
-                pSalData->mpDitherDiff[ n ] = n - ( n & 248L );
-
-            for( n = 0; n < 256; n++ )
-                pSalData->mpDitherLow[ n ] = static_cast<BYTE>( n & 248 );
-
-            for( n = 0; n < 256; n++ )
-                pSalData->mpDitherHigh[ n ] = static_cast<BYTE>(std::min( 
pSalData->mpDitherLow[ n ] + 8, 255 ));
-        }
-    }
-    else if ( (nRasterCaps & RC_PALETTE) && (nBitCount == 8) )
-    {
-        BYTE            nRed, nGreen, nBlue;
-        BYTE            nR, nG, nB;
-        PALETTEENTRY*   pPalEntry;
-        LOGPALETTE*     pLogPal;
-        const sal_uInt16    nDitherPalCount = DITHER_PAL_COUNT;
-        sal_uLong           nTotalCount = DITHER_MAX_SYSCOLOR + 
nDitherPalCount + DITHER_EXTRA_COLORS;
-
-        // create logical palette
-        pLogPal = reinterpret_cast<LOGPALETTE*>(new char[ sizeof( LOGPALETTE ) 
+ ( nTotalCount * sizeof( PALETTEENTRY ) ) ]);
-        pLogPal->palVersion = 0x0300;
-        pLogPal->palNumEntries = static_cast<sal_uInt16>(nTotalCount);
-        pPalEntry = pLogPal->palPalEntry;
-
-        // Standard colors
-        memcpy( pPalEntry, aImplSalSysPalEntryAry, DITHER_MAX_SYSCOLOR * 
sizeof( PALETTEENTRY ) );
-        pPalEntry += DITHER_MAX_SYSCOLOR;
-
-        // own palette (6/6/6)
-        for( nB=0, nBlue=0; nB < DITHER_PAL_STEPS; nB++, nBlue += 
DITHER_PAL_DELTA )
-        {
-            for( nG=0, nGreen=0; nG < DITHER_PAL_STEPS; nG++, nGreen += 
DITHER_PAL_DELTA )
-            {
-                for( nR=0, nRed=0; nR < DITHER_PAL_STEPS; nR++, nRed += 
DITHER_PAL_DELTA )
-                {
-                    pPalEntry->peRed   = nRed;
-                    pPalEntry->peGreen = nGreen;
-                    pPalEntry->peBlue  = nBlue;
-                    pPalEntry->peFlags = 0;
-                    pPalEntry++;
-                }
-            }
-        }
-
-        // insert special 'Blue' as standard drawing color
-        *pPalEntry++ = aImplExtraColor1;
-
-        // create palette
-        pSalData->mhDitherPal = CreatePalette( pLogPal );
-        delete[] reinterpret_cast<char*>(pLogPal);
-
-        if( pSalData->mhDitherPal )
-        {
-            // create DIBPattern for 8Bit dithering
-            tools::Long const nSize = sizeof( BITMAPINFOHEADER ) + ( 256 * 
sizeof( short ) ) + 64;
-            tools::Long n;
-
-            pSalData->mhDitherDIB = GlobalAlloc( GMEM_FIXED, nSize );
-            pSalData->mpDitherDIB = static_cast<BYTE*>(GlobalLock( 
pSalData->mhDitherDIB ));
-            pSalData->mpDitherDiff.reset(new tools::Long[ 256 ]);
-            pSalData->mpDitherLow.reset(new BYTE[ 256 ]);
-            pSalData->mpDitherHigh.reset(new BYTE[ 256 ]);
-            pSalData->mpDitherDIBData = pSalData->mpDitherDIB + sizeof( 
BITMAPINFOHEADER ) + ( 256 * sizeof( short ) );
-            memset( pSalData->mpDitherDIB, 0, sizeof( BITMAPINFOHEADER ) );
-
-            BITMAPINFOHEADER*   pBIH = 
reinterpret_cast<BITMAPINFOHEADER*>(pSalData->mpDitherDIB);
-            short*              pColors = reinterpret_cast<short*>( 
pSalData->mpDitherDIB + sizeof( BITMAPINFOHEADER ) );
-
-            pBIH->biSize = sizeof( BITMAPINFOHEADER );
-            pBIH->biWidth = 8;
-            pBIH->biHeight = 8;
-            pBIH->biPlanes = 1;
-            pBIH->biBitCount = 8;
-
-            for( n = 0; n < nDitherPalCount; n++ )
-                pColors[ n ] = static_cast<short>( n + DITHER_MAX_SYSCOLOR );
-
-            for( n = 0; n < 256; n++ )
-                pSalData->mpDitherDiff[ n ] = n % 51;
-
-            for( n = 0; n < 256; n++ )
-                pSalData->mpDitherLow[ n ] = static_cast<BYTE>( n / 51 );
-
-            for( n = 0; n < 256; n++ )
-                pSalData->mpDitherHigh[ n ] = static_cast<BYTE>(std::min( 
pSalData->mpDitherLow[ n ] + 1, 5 ));
-        }
-
-        // get system color entries
-        ImplUpdateSysColorEntries();
-    }
-
-    ReleaseDC( nullptr, hDC );
 }
 
 void ImplFreeSalGDI()
@@ -315,26 +110,6 @@ void ImplFreeSalGDI()
 
     ImplClearHDCCache( pSalData );
 
-    // delete Ditherpalette, if existing
-    if ( pSalData->mhDitherPal )
-    {
-        DeleteObject( pSalData->mhDitherPal );
-        pSalData->mhDitherPal = nullptr;
-    }
-
-    // delete buffers for dithering DIB patterns, if necessary
-    if ( pSalData->mhDitherDIB )
-    {
-        GlobalUnlock( pSalData->mhDitherDIB );
-        GlobalFree( pSalData->mhDitherDIB );
-        pSalData->mhDitherDIB = nullptr;
-        pSalData->mpDitherDiff.reset();
-        pSalData->mpDitherLow.reset();
-        pSalData->mpDitherHigh.reset();
-    }
-
-    DeleteSysColorList();
-
     // delete icon cache
     SalIcon* pIcon = pSalData->mpFirstIcon;
     pSalData->mpFirstIcon = nullptr;
@@ -353,98 +128,6 @@ void ImplFreeSalGDI()
     pSalData->mbResourcesAlreadyFreed = true;
 }
 
-int ImplIsSysColorEntry( Color nColor )
-{
-    SysColorEntry*  pEntry = pFirstSysColor;
-    const DWORD     nTestRGB = static_cast<DWORD>(RGB( nColor.GetRed(),
-                                           nColor.GetGreen(),
-                                           nColor.GetBlue() ));
-
-    while ( pEntry )
-    {
-        if ( pEntry->nRGB == nTestRGB )
-            return TRUE;
-        pEntry = pEntry->pNext;
-    }
-
-    return FALSE;
-}
-
-static int ImplIsPaletteEntry( BYTE nRed, BYTE nGreen, BYTE nBlue )
-{
-    // dither color?
-    if ( !(nRed % DITHER_PAL_DELTA) && !(nGreen % DITHER_PAL_DELTA) && !(nBlue 
% DITHER_PAL_DELTA) )
-        return TRUE;
-
-    PALETTEENTRY* pPalEntry = aImplSalSysPalEntryAry;
-
-    // standard palette color?
-    for ( sal_uInt16 i = 0; i < DITHER_MAX_SYSCOLOR; i++, pPalEntry++ )
-    {
-        if( pPalEntry->peRed == nRed && pPalEntry->peGreen == nGreen && 
pPalEntry->peBlue == nBlue )
-            return TRUE;
-    }
-
-    // extra color?
-    if ( aImplExtraColor1.peRed == nRed &&
-         aImplExtraColor1.peGreen == nGreen &&
-         aImplExtraColor1.peBlue == nBlue )
-    {
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-static void ImplInsertSysColorEntry( int nSysIndex )
-{
-    const DWORD nRGB = GetSysColor( nSysIndex );
-
-    if ( ImplIsPaletteEntry( GetRValue( nRGB ), GetGValue( nRGB ), GetBValue( 
nRGB ) ) )
-        return;
-
-    if ( !pFirstSysColor )
-    {
-        pActSysColor = pFirstSysColor = new SysColorEntry;
-        pFirstSysColor->nRGB = nRGB;
-        pFirstSysColor->pNext = nullptr;
-    }
-    else
-    {
-        pActSysColor = pActSysColor->pNext = new SysColorEntry;
-        pActSysColor->nRGB = nRGB;
-        pActSysColor->pNext = nullptr;
-    }
-}
-
-void ImplUpdateSysColorEntries()
-{
-    DeleteSysColorList();
-
-    // create new sys color list
-    ImplInsertSysColorEntry( COLOR_ACTIVEBORDER );
-    ImplInsertSysColorEntry( COLOR_INACTIVEBORDER );
-    ImplInsertSysColorEntry( COLOR_GRADIENTACTIVECAPTION );
-    ImplInsertSysColorEntry( COLOR_GRADIENTINACTIVECAPTION );
-    ImplInsertSysColorEntry( COLOR_3DFACE );
-    ImplInsertSysColorEntry( COLOR_3DHILIGHT );
-    ImplInsertSysColorEntry( COLOR_3DLIGHT );
-    ImplInsertSysColorEntry( COLOR_3DSHADOW );
-    ImplInsertSysColorEntry( COLOR_3DDKSHADOW );
-    ImplInsertSysColorEntry( COLOR_INFOBK );
-    ImplInsertSysColorEntry( COLOR_INFOTEXT );
-    ImplInsertSysColorEntry( COLOR_BTNTEXT );
-    ImplInsertSysColorEntry( COLOR_WINDOW );
-    ImplInsertSysColorEntry( COLOR_WINDOWTEXT );
-    ImplInsertSysColorEntry( COLOR_HIGHLIGHT );
-    ImplInsertSysColorEntry( COLOR_HIGHLIGHTTEXT );
-    ImplInsertSysColorEntry( COLOR_MENU );
-    ImplInsertSysColorEntry( COLOR_MENUTEXT );
-    ImplInsertSysColorEntry( COLOR_ACTIVECAPTION );
-    ImplInsertSysColorEntry( COLOR_CAPTIONTEXT );
-    ImplInsertSysColorEntry( COLOR_INACTIVECAPTION );
-    ImplInsertSysColorEntry( COLOR_INACTIVECAPTIONTEXT );
-}
 
 void WinSalGraphics::InitGraphics()
 {
@@ -513,12 +196,6 @@ HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
         // create new DC with DefaultBitmap
         pC->mhDC = CreateCompatibleDC( hDC );
 
-        if( pSalData->mhDitherPal )
-        {
-            pC->mhDefPal = SelectPalette( pC->mhDC, pSalData->mhDitherPal, 
TRUE );
-            RealizePalette( pC->mhDC );
-        }
-
         pC->mhSelBmp = CreateCompatibleBitmap( hDC, CACHED_HDC_DEFEXT, 
CACHED_HDC_DEFEXT );
         pC->mhDefBmp = static_cast<HBITMAP>(SelectObject( pC->mhDC, 
pC->mhSelBmp ));
 
diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx
index 7465d56570cb..1903bfd3a533 100644
--- a/vcl/win/gdi/salvd.cxx
+++ b/vcl/win/gdi/salvd.cxx
@@ -91,8 +91,6 @@ std::unique_ptr<SalVirtualDevice> 
WinSalInstance::CreateVirtualDevice( SalGraphi
                                                            nDX, nDY, nBitCount,
                                                            
&o3tl::temporary<void*>(nullptr));
 
-    const SalData* pSalData = GetSalData();
-
     WinSalVirtualDevice* pVDev = new WinSalVirtualDevice(hDC, hBmp, nBitCount,
                                                          /*bForeignDC*/false, 
nDX, nDY);
 
@@ -103,12 +101,6 @@ std::unique_ptr<SalVirtualDevice> 
WinSalInstance::CreateVirtualDevice( SalGraphi
     pVirGraphics->SetLayout( SalLayoutFlags::NONE );
     pVirGraphics->setHDC(hDC);
 
-    if ( pSalData->mhDitherPal && pVirGraphics->isScreen() )
-    {
-        pVirGraphics->setPalette(pSalData->mhDitherPal);
-        RealizePalette( hDC );
-    }
-
     pVDev->setGraphics(pVirGraphics);
 
     return std::unique_ptr<SalVirtualDevice>(pVDev);
@@ -138,7 +130,6 @@ std::unique_ptr<SalVirtualDevice> 
WinSalInstance::CreateVirtualDevice( SalGraphi
 
     const sal_uInt16 nBitCount = 0;
     const bool bForeignDC = rData.hDC != nullptr;
-    const SalData* pSalData = GetSalData();
 
     WinSalVirtualDevice* pVDev = new WinSalVirtualDevice(hDC, /*hBmp*/nullptr, 
nBitCount,
                                                          bForeignDC, nDX, nDY);
@@ -150,12 +141,6 @@ std::unique_ptr<SalVirtualDevice> 
WinSalInstance::CreateVirtualDevice( SalGraphi
     pVirGraphics->SetLayout( SalLayoutFlags::NONE );
     pVirGraphics->setHDC(hDC);
 
-    if ( pSalData->mhDitherPal && pVirGraphics->isScreen() )
-    {
-        pVirGraphics->setPalette(pSalData->mhDitherPal);
-        RealizePalette( hDC );
-    }
-
     pVDev->setGraphics(pVirGraphics);
 
     return std::unique_ptr<SalVirtualDevice>(pVDev);
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index a9376209680c..2cf8a4020736 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -1023,9 +1023,6 @@ bool WinSalFrame::InitFrameGraphicsDC( WinSalGraphics 
*pGraphics, HDC hDC, HWND
     if ( !hDC )
         return false;
 
-    if ( pSalData->mhDitherPal )
-        pGraphics->setPalette(pSalData->mhDitherPal);
-
     if ( pGraphics == mpThreadGraphics )
         pSalData->mnCacheDCInUse++;
     return true;
@@ -4521,9 +4518,6 @@ static void ImplHandleSettingsChangeMsg(HWND hWnd, UINT 
nMsg, WPARAM /*wParam*/,
         GetSalData()->mbThemeChanged = true;
     }
 
-    if ( WM_SYSCOLORCHANGE == nMsg && GetSalData()->mhDitherPal )
-        ImplUpdateSysColorEntries();
-
     WinSalFrame* pFrame = ProcessOrDeferMessage( hWnd, 0, 0, 
DeferPolicy::Blocked );
     if (!pFrame)
         return;
@@ -4546,174 +4540,6 @@ static void ImplHandleUserEvent( HWND hWnd, LPARAM 
lParam )
     }
 }
 
-static void ImplHandleForcePalette( HWND hWnd )
-{
-    SalData*    pSalData = GetSalData();
-    HPALETTE    hPal = pSalData->mhDitherPal;
-    if (!hPal)
-        return;
-
-    WinSalFrame* pFrame = ProcessOrDeferMessage(hWnd, SAL_MSG_FORCEPALETTE);
-    if (!pFrame)
-        return;
-    const ::comphelper::ScopeGuard aScopeGuard([](){ 
ImplSalYieldMutexRelease(); });
-
-    WinSalGraphics* pGraphics = pFrame->mpLocalGraphics;
-    if (!pGraphics || !pGraphics->getHDC() || !pGraphics->getDefPal()
-            || (pGraphics->setPalette(hPal, FALSE) == GDI_ERROR))
-        return;
-
-    InvalidateRect(hWnd, nullptr, FALSE);
-    UpdateWindow(hWnd);
-    pFrame->CallCallback(SalEvent::DisplayChanged, nullptr);
-}
-
-static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg,
-                                  WPARAM wParam, LPARAM lParam, bool& rDef )
-{
-    SalData*    pSalData = GetSalData();
-    HPALETTE    hPal = pSalData->mhDitherPal;
-    if ( !hPal )
-        return 0;
-
-    rDef = false;
-    if ( pSalData->mbInPalChange )
-        return 0;
-
-    if ( (nMsg == WM_PALETTECHANGED) || (nMsg == SAL_MSG_POSTPALCHANGED) )
-    {
-        if ( reinterpret_cast<HWND>(wParam) == hWnd )
-            return 0;
-    }
-
-    bool bReleaseMutex = false;
-    if ( (nMsg == WM_QUERYNEWPALETTE) || (nMsg == WM_PALETTECHANGED) )
-    {
-        // as Windows can send these messages also, we have to use
-        // the Solar semaphore
-        if ( ImplSalYieldMutexTryToAcquire() )
-            bReleaseMutex = true;
-        else if ( nMsg == WM_QUERYNEWPALETTE )
-        {
-            bool const ret = PostMessageW(hWnd, SAL_MSG_POSTQUERYNEWPAL, 
wParam, lParam);
-            SAL_WARN_IF(!ret, "vcl", "ERROR: PostMessage() failed!");
-        }
-        else /* ( nMsg == WM_PALETTECHANGED ) */
-        {
-            bool const ret = PostMessageW(hWnd, SAL_MSG_POSTPALCHANGED, 
wParam, lParam);
-            SAL_WARN_IF(!ret, "vcl", "ERROR: PostMessage() failed!");
-        }
-    }
-
-    WinSalVirtualDevice*pTempVD;
-    WinSalFrame*        pTempFrame;
-    WinSalGraphics*     pGraphics;
-    HDC                 hDC;
-    HPALETTE hOldPal = nullptr;
-    UINT nCols = GDI_ERROR;
-    bool                bUpdate;
-
-    pSalData->mbInPalChange = true;
-
-    // reset all palettes in VirDevs and Frames
-    pTempVD = pSalData->mpFirstVD;
-    while ( pTempVD )
-    {
-        pGraphics = pTempVD->getGraphics();
-        pGraphics->setPalette(nullptr);
-        pTempVD = pTempVD->getNext();
-    }
-    pTempFrame = pSalData->mpFirstFrame;
-    while ( pTempFrame )
-    {
-        pGraphics = pTempFrame->mpLocalGraphics;
-        pGraphics->setPalette(nullptr);
-        pTempFrame = pTempFrame->mpNextFrame;
-    }
-
-    // re-initialize palette
-    WinSalFrame* pFrame = nullptr;
-    if ( bFrame )
-        pFrame = GetWindowPtr( hWnd );
-
-    UnrealizeObject(hPal);
-    const bool bStdDC = pFrame && pFrame->mpLocalGraphics && 
pFrame->mpLocalGraphics->getHDC();
-    if (!bStdDC)
-    {
-        hDC = GetDC(hWnd);
-        hOldPal = SelectPalette(hDC, hPal, TRUE);
-        if (hOldPal)
-            nCols = RealizePalette(hDC);
-    }
-    else
-    {
-        hDC = pFrame->mpLocalGraphics->getHDC();
-        nCols = pFrame->mpLocalGraphics->setPalette(hPal);
-    }
-
-    bUpdate = nCols != 0 && nCols != GDI_ERROR;
-
-    if ( !bStdDC )
-    {
-        if (hOldPal)
-            SelectPalette(hDC, hOldPal, TRUE);
-        ReleaseDC( hWnd, hDC );
-    }
-
-    // reset all palettes in VirDevs and Frames
-    pTempVD = pSalData->mpFirstVD;
-    while ( pTempVD )
-    {
-        pGraphics = pTempVD->getGraphics();
-        if ( pGraphics->getDefPal() )
-            pGraphics->setPalette(hPal);
-        pTempVD = pTempVD->getNext();
-    }
-
-    pTempFrame = pSalData->mpFirstFrame;
-    while ( pTempFrame )
-    {
-        if ( pTempFrame != pFrame )
-        {
-            pGraphics = pTempFrame->mpLocalGraphics;
-            if (pGraphics && pGraphics->getDefPal())
-            {
-                UINT nRes = pGraphics->setPalette(hPal);
-                if (nRes != 0 && nRes != GDI_ERROR)
-                    bUpdate = true;
-            }
-        }
-        pTempFrame = pTempFrame->mpNextFrame;
-    }
-
-    // if colors changed, update the window
-    if ( bUpdate )
-    {
-        pTempFrame = pSalData->mpFirstFrame;
-        while ( pTempFrame )
-        {
-            pGraphics = pTempFrame->mpLocalGraphics;
-            if (pGraphics && pGraphics->getDefPal())
-            {
-                InvalidateRect( pTempFrame->mhWnd, nullptr, FALSE );
-                UpdateWindow( pTempFrame->mhWnd );
-                pTempFrame->CallCallback( SalEvent::DisplayChanged, nullptr );
-            }
-            pTempFrame = pTempFrame->mpNextFrame;
-        }
-    }
-
-    pSalData->mbInPalChange = false;
-
-    if ( bReleaseMutex )
-        ImplSalYieldMutexRelease();
-
-    if ( nMsg == WM_PALETTECHANGED )
-        return 0;
-    else
-        return nCols;
-}
-
 static bool ImplHandleMinMax( HWND hWnd, LPARAM lParam )
 {
     bool bRet = false;
@@ -6199,26 +6025,6 @@ static LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT 
nMsg, WPARAM wParam, LP
             rDef = false;
             break;
 
-        case SAL_MSG_FORCEPALETTE:
-            ImplHandleForcePalette( hWnd );
-            rDef = false;
-            break;
-
-        case WM_QUERYNEWPALETTE:
-        case SAL_MSG_POSTQUERYNEWPAL:
-            nRet = ImplHandlePalette( true, hWnd, nMsg, wParam, lParam, rDef );
-            break;
-
-        case WM_ACTIVATE:
-            // Getting activated, we also want to set our palette.
-            // We do this in Activate, so that other external child windows
-            // can overwrite our palette. Thus our palette is set only once
-            // and not recursively, as at all other places it is set only as
-            // the background palette.
-            if ( LOWORD( wParam ) != WA_INACTIVE )
-                SendMessageW( hWnd, SAL_MSG_FORCEPALETTE, 0, 0 );
-            break;
-
         case WM_ENABLE:
             // #95133# a system dialog is opened/closed, using our app window 
as parent
             {
@@ -6431,17 +6237,12 @@ LRESULT CALLBACK SalFrameWndProcW( HWND hWnd, UINT 
nMsg, WPARAM wParam, LPARAM l
     return nRet;
 }
 
-bool ImplHandleGlobalMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, 
LRESULT& rlResult )
+bool ImplHandleGlobalMsg( HWND /*hWnd*/, UINT nMsg, WPARAM /*wParam*/, LPARAM 
/*lParam*/, LRESULT& /*rlResult*/ )
 {
     // handle all messages concerning all frames so they get processed only 
once
     // Must work for Unicode and none Unicode
     bool bResult = false;
-    if ( (nMsg == WM_PALETTECHANGED) || (nMsg == SAL_MSG_POSTPALCHANGED) )
-    {
-        bResult = true;
-        rlResult = ImplHandlePalette( false, hWnd, nMsg, wParam, lParam, 
bResult );
-    }
-    else if( nMsg == WM_DISPLAYCHANGE )
+    if( nMsg == WM_DISPLAYCHANGE )
     {
         WinSalSystem* pSys = static_cast<WinSalSystem*>(ImplGetSalSystem());
         if( pSys )
diff --git a/vcl/win/window/salobj.cxx b/vcl/win/window/salobj.cxx
index ce39575b9341..70b49a8f5b4b 100644
--- a/vcl/win/window/salobj.cxx
+++ b/vcl/win/window/salobj.cxx
@@ -534,19 +534,10 @@ WinSalObject::~WinSalObject()
     // destroy cache data
     delete [] reinterpret_cast<BYTE*>(mpStdClipRgnData);
 
-    HWND hWndParent = ::GetParent( mhWnd );
-
     if ( mhWndChild )
         DestroyWindow( mhWndChild );
     if ( mhWnd )
         DestroyWindow( mhWnd );
-
-    // reset palette, if no external child window is left,
-    // as they might have overwritten our palette
-    if ( hWndParent &&
-         ::GetActiveWindow() == hWndParent &&
-         !GetWindow( hWndParent, GW_CHILD ) )
-        SendMessageW( hWndParent, SAL_MSG_FORCEPALETTE, 0, 0 );
 }
 
 void WinSalObject::ResetClipRegion()

Reply via email to