[Libreoffice-commits] core.git: vcl/inc vcl/win
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Feb 1 11:46:05 UTC 2019
vcl/inc/win/salvd.h | 3 +-
vcl/win/gdi/salvd.cxx | 55 +++++++++++++++++++++++---------------------------
2 files changed, 28 insertions(+), 30 deletions(-)
New commits:
commit cd520894e7092349f1a7aad07066376bb28571fc
Author: Dmitriy Shilin <dshil at fastmail.com>
AuthorDate: Sun Jan 20 01:24:02 2019 -0800
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Feb 1 12:45:38 2019 +0100
tdf#107792 vcl/win: use ScopedGDI in WinSalVirtualDevice
Change-Id: Ia804f4ab527870ded8d57aa0d49aae1d357b7ac9
Reviewed-on: https://gerrit.libreoffice.org/66649
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/vcl/inc/win/salvd.h b/vcl/inc/win/salvd.h
index f4825836036e..4121d2c89979 100644
--- a/vcl/inc/win/salvd.h
+++ b/vcl/inc/win/salvd.h
@@ -21,6 +21,7 @@
#define INCLUDED_VCL_INC_WIN_SALVD_H
#include <sal/config.h>
+#include <win/scoped_gdi.hxx>
#include <memory>
@@ -33,7 +34,7 @@ class WinSalVirtualDevice : public SalVirtualDevice
{
private:
HDC mhLocalDC; // HDC or 0 for Cache Device
- HBITMAP mhBmp; // Memory Bitmap
+ ScopedHBITMAP mhBmp; // Memory Bitmap
HBITMAP mhDefBmp; // Default Bitmap
std::unique_ptr<WinSalGraphics> mpGraphics; // current VirDev graphics
WinSalVirtualDevice* mpNext; // next VirDev
diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx
index f0cf1fc9f47b..6dc94f0b12a2 100644
--- a/vcl/win/gdi/salvd.cxx
+++ b/vcl/win/gdi/salvd.cxx
@@ -30,6 +30,7 @@
#include <win/salvd.h>
#include <opengl/win/gdiimpl.hxx>
#include <sal/log.hxx>
+#include <o3tl/temporary.hxx>
HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, sal_uInt16 nBitCount, void **ppData)
{
@@ -184,8 +185,8 @@ WinSalVirtualDevice::~WinSalVirtualDevice()
SelectBitmap( mpGraphics->getHDC(), mhDefBmp );
if( !mbForeignDC )
DeleteDC( mpGraphics->getHDC() );
- if( mhBmp )
- DeleteBitmap( mhBmp );
+
+ mhBmp.reset();
mpGraphics.reset();
}
@@ -209,35 +210,31 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY )
{
if( mbForeignDC || !mhBmp )
return true; // ???
- else
+
+ HBITMAP hNewBmp = ImplCreateVirDevBitmap(getHDC(), nDX, nDY, mnBitCount,
+ &o3tl::temporary<void*>(nullptr));
+ if (!hNewBmp)
{
- void *pDummy;
- HBITMAP hNewBmp = ImplCreateVirDevBitmap(getHDC(), nDX, nDY, mnBitCount, &pDummy);
- if ( hNewBmp )
- {
- mnWidth = nDX;
- mnHeight = nDY;
-
- SelectBitmap( getHDC(), hNewBmp );
- DeleteBitmap( mhBmp );
- mhBmp = hNewBmp;
-
- if (mpGraphics)
- {
- WinOpenGLSalGraphicsImpl *pImpl;
- pImpl = dynamic_cast< WinOpenGLSalGraphicsImpl * >(mpGraphics->GetImpl());
- if (pImpl)
- pImpl->Init();
- }
- return true;
- }
- else
- {
- mnWidth = 0;
- mnHeight = 0;
- return false;
- }
+ mnWidth = 0;
+ mnHeight = 0;
+ return false;
}
+
+ mnWidth = nDX;
+ mnHeight = nDY;
+
+ SelectBitmap(getHDC(), hNewBmp);
+ mhBmp.reset(hNewBmp);
+
+ if (mpGraphics)
+ {
+ WinOpenGLSalGraphicsImpl *pImpl;
+ pImpl = dynamic_cast< WinOpenGLSalGraphicsImpl * >(mpGraphics->GetImpl());
+ if (pImpl)
+ pImpl->Init();
+ }
+
+ return true;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list