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 @@
#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
......
......@@ -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: */
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