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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 18 14:36:55 UTC 2019


 vcl/inc/win/scoped_gdi.hxx |    1 +
 vcl/win/gdi/gdiimpl.cxx    |   13 ++++---------
 2 files changed, 5 insertions(+), 9 deletions(-)

New commits:
commit a40f12c3f18e4262336fcd51d26dd099eae1e070
Author:     Dmitriy Shilin <dshil at fastmail.com>
AuthorDate: Sun Jan 13 05:37:12 2019 -0800
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Jan 18 15:36:26 2019 +0100

    tdf#107792 vcl/win: introduce ScopedSelectedHBRUSH
    
    Change-Id: I39792ce8442f9e7776b44a489b3c15b908e2f773
    Reviewed-on: https://gerrit.libreoffice.org/66253
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/vcl/inc/win/scoped_gdi.hxx b/vcl/inc/win/scoped_gdi.hxx
index edbc086ada9c..34e0e60a33c4 100644
--- a/vcl/inc/win/scoped_gdi.hxx
+++ b/vcl/inc/win/scoped_gdi.hxx
@@ -50,6 +50,7 @@ private:
 
 using ScopedSelectedHPEN = ScopedSelectedGDI<ScopedHPEN, SelectPen>;
 using ScopedSelectedHFONT = ScopedSelectedGDI<ScopedHFONT, SelectFont>;
+using ScopedSelectedHBRUSH = ScopedSelectedGDI<ScopedHBRUSH, SelectBrush>;
 
 #endif // INCLUDED_VCL_INC_WIN_SCOPED_GDI_HXX
 
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 3b209075defc..e5013631d9ed 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -778,10 +778,9 @@ void WinSalGraphicsImpl::drawMask(const SalTwoRect& rPosAry,
     SalTwoRect  aPosAry = rPosAry;
     const HDC hDC = mrParent.getHDC();
 
-    ScopedHBRUSH hMaskBrush(CreateSolidBrush(RGB(nMaskColor.GetRed(),
-                                                 nMaskColor.GetGreen(),
-                                                 nMaskColor.GetBlue())));
-    HBRUSH  hOldBrush = SelectBrush(hDC, hMaskBrush.get());
+    ScopedSelectedHBRUSH(hDC, CreateSolidBrush(RGB(nMaskColor.GetRed(),
+                                                   nMaskColor.GetGreen(),
+                                                   nMaskColor.GetBlue())));
 
     // WIN/WNT seems to have a minor problem mapping the correct color of the
     // mask to the palette if we draw the DIB directly ==> draw DDB
@@ -794,8 +793,6 @@ void WinSalGraphicsImpl::drawMask(const SalTwoRect& rPosAry,
     }
     else
         ImplDrawBitmap( hDC, aPosAry, rSalBitmap, false, 0x00B8074AUL );
-
-    SelectBrush(hDC, hOldBrush);
 }
 
 std::shared_ptr<SalBitmap> WinSalGraphicsImpl::getBitmap( long nX, long nY, long nDX, long nDY )
@@ -1574,10 +1571,8 @@ void WinSalGraphicsImpl::DrawPixelImpl( long nX, long nY, COLORREF crColor )
         return;
     }
 
-    ScopedHBRUSH hBrush(CreateSolidBrush(crColor));
-    HBRUSH hOldBrush = SelectBrush(hDC, hBrush.get());
+    ScopedSelectedHBRUSH(hDC, CreateSolidBrush(crColor));
     PatBlt(hDC, static_cast<int>(nX), static_cast<int>(nY), int(1), int(1), PATINVERT);
-    SelectBrush(hDC, hOldBrush);
 }
 
 void WinSalGraphicsImpl::drawPixel( long nX, long nY )


More information about the Libreoffice-commits mailing list