summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Shilin <dshil@fastmail.com>2019-01-13 05:37:12 -0800
committerMike Kaganski <mike.kaganski@collabora.com>2019-01-18 15:36:26 +0100
commita40f12c3f18e4262336fcd51d26dd099eae1e070 (patch)
tree56b0c86ae1053ae53b2cb1d43d9e003764ef5380
parent2a1ea372daa12c0041d2c080a8fab33a6a87950d (diff)
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@collabora.com>
-rw-r--r--vcl/inc/win/scoped_gdi.hxx1
-rw-r--r--vcl/win/gdi/gdiimpl.cxx13
2 files changed, 5 insertions, 9 deletions
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 )