Kaydet (Commit) cd520894 authored tarafından Dmitriy Shilin's avatar Dmitriy Shilin Kaydeden (comit) Mike Kaganski

tdf#107792 vcl/win: use ScopedGDI in WinSalVirtualDevice

Change-Id: Ia804f4ab527870ded8d57aa0d49aae1d357b7ac9
Reviewed-on: https://gerrit.libreoffice.org/66649
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst cd5e4e1f
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define INCLUDED_VCL_INC_WIN_SALVD_H #define INCLUDED_VCL_INC_WIN_SALVD_H
#include <sal/config.h> #include <sal/config.h>
#include <win/scoped_gdi.hxx>
#include <memory> #include <memory>
...@@ -33,7 +34,7 @@ class WinSalVirtualDevice : public SalVirtualDevice ...@@ -33,7 +34,7 @@ class WinSalVirtualDevice : public SalVirtualDevice
{ {
private: private:
HDC mhLocalDC; // HDC or 0 for Cache Device HDC mhLocalDC; // HDC or 0 for Cache Device
HBITMAP mhBmp; // Memory Bitmap ScopedHBITMAP mhBmp; // Memory Bitmap
HBITMAP mhDefBmp; // Default Bitmap HBITMAP mhDefBmp; // Default Bitmap
std::unique_ptr<WinSalGraphics> mpGraphics; // current VirDev graphics std::unique_ptr<WinSalGraphics> mpGraphics; // current VirDev graphics
WinSalVirtualDevice* mpNext; // next VirDev WinSalVirtualDevice* mpNext; // next VirDev
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <win/salvd.h> #include <win/salvd.h>
#include <opengl/win/gdiimpl.hxx> #include <opengl/win/gdiimpl.hxx>
#include <sal/log.hxx> #include <sal/log.hxx>
#include <o3tl/temporary.hxx>
HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, sal_uInt16 nBitCount, void **ppData) HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, sal_uInt16 nBitCount, void **ppData)
{ {
...@@ -184,8 +185,8 @@ WinSalVirtualDevice::~WinSalVirtualDevice() ...@@ -184,8 +185,8 @@ WinSalVirtualDevice::~WinSalVirtualDevice()
SelectBitmap( mpGraphics->getHDC(), mhDefBmp ); SelectBitmap( mpGraphics->getHDC(), mhDefBmp );
if( !mbForeignDC ) if( !mbForeignDC )
DeleteDC( mpGraphics->getHDC() ); DeleteDC( mpGraphics->getHDC() );
if( mhBmp )
DeleteBitmap( mhBmp ); mhBmp.reset();
mpGraphics.reset(); mpGraphics.reset();
} }
...@@ -209,18 +210,21 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY ) ...@@ -209,18 +210,21 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY )
{ {
if( mbForeignDC || !mhBmp ) if( mbForeignDC || !mhBmp )
return true; // ??? return true; // ???
else
{ HBITMAP hNewBmp = ImplCreateVirDevBitmap(getHDC(), nDX, nDY, mnBitCount,
void *pDummy; &o3tl::temporary<void*>(nullptr));
HBITMAP hNewBmp = ImplCreateVirDevBitmap(getHDC(), nDX, nDY, mnBitCount, &pDummy); if (!hNewBmp)
if ( hNewBmp )
{ {
mnWidth = 0;
mnHeight = 0;
return false;
}
mnWidth = nDX; mnWidth = nDX;
mnHeight = nDY; mnHeight = nDY;
SelectBitmap( getHDC(), hNewBmp ); SelectBitmap(getHDC(), hNewBmp);
DeleteBitmap( mhBmp ); mhBmp.reset(hNewBmp);
mhBmp = hNewBmp;
if (mpGraphics) if (mpGraphics)
{ {
...@@ -229,15 +233,8 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY ) ...@@ -229,15 +233,8 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY )
if (pImpl) if (pImpl)
pImpl->Init(); pImpl->Init();
} }
return true; return true;
}
else
{
mnWidth = 0;
mnHeight = 0;
return false;
}
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment