summaryrefslogtreecommitdiff
path: root/vcl/inc/win
diff options
context:
space:
mode:
authorDmitriy Shilin <dshil@fastmail.com>2019-01-20 00:08:30 -0800
committerMike Kaganski <mike.kaganski@collabora.com>2019-01-30 07:14:37 +0100
commitc2c60eb9969716ef91a83952203948b5e334ec85 (patch)
tree52f717fa171967c4c05284c6e903abf7e2dd8446 /vcl/inc/win
parent44df356a075acadeb980bce80e99c73154e846ea (diff)
tdf#107792 vcl/win: introduce ScopedCachedHDC
Change-Id: Ia6c5ca98005642bbcce9d9d66bf16a4d4cbed04e Reviewed-on: https://gerrit.libreoffice.org/66648 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/inc/win')
-rw-r--r--vcl/inc/win/scoped_gdi.hxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/vcl/inc/win/scoped_gdi.hxx b/vcl/inc/win/scoped_gdi.hxx
index 0fb82112e68c..d02ad9545749 100644
--- a/vcl/inc/win/scoped_gdi.hxx
+++ b/vcl/inc/win/scoped_gdi.hxx
@@ -12,6 +12,7 @@
#include <win/svsys.h>
#include <win/wincomp.hxx>
+#include <win/saldata.hxx>
#include <memory>
@@ -53,6 +54,22 @@ using ScopedSelectedHPEN = ScopedSelectedGDI<ScopedHPEN, SelectPen>;
using ScopedSelectedHFONT = ScopedSelectedGDI<ScopedHFONT, SelectFont>;
using ScopedSelectedHBRUSH = ScopedSelectedGDI<ScopedHBRUSH, SelectBrush>;
+template <sal_uLong ID> class ScopedCachedHDC
+{
+public:
+ explicit ScopedCachedHDC(HBITMAP hBitmap)
+ : m_hDC(ImplGetCachedDC(ID, hBitmap))
+ {
+ }
+
+ ~ScopedCachedHDC() { ImplReleaseCachedDC(ID); }
+
+ HDC get() const { return m_hDC; }
+
+private:
+ HDC m_hDC;
+};
+
#endif // INCLUDED_VCL_INC_WIN_SCOPED_GDI_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */