Kaydet (Commit) c31ed700 authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Markus Mohrhard

vcl: create a GeometryProvider interface.

Implemented by both SalFrame and SalVirtualDevice, to help us to
un-tangle code that needs to operate on resources associated with
both of these without special cases.

Change-Id: If681a002647e20c57186577fe039d4ac85bba872
üst c22d5338
......@@ -47,6 +47,10 @@ public:
) SAL_OVERRIDE;
basebmp::BitmapDeviceSharedPtr getBitmapDevice() { return m_aDevice; }
// SalGeometryProvider
virtual long GetWidth() const SAL_OVERRIDE { return m_aDevice.get() ? m_aDevice->getSize().getX() : 0; }
virtual long GetHeight() const SAL_OVERRIDE { return m_aDevice.get() ? m_aDevice->getSize().getY() : 0; }
};
#endif // INCLUDED_VCL_INC_HEADLESS_SVPVD_HXX
......
......@@ -36,10 +36,12 @@ public:
const SystemGraphicsData *pData );
virtual ~X11OpenGLSalVirtualDevice();
// SalGeometryProvider
virtual long GetWidth() const SAL_OVERRIDE { return mnWidth; }
virtual long GetHeight() const SAL_OVERRIDE { return mnHeight; }
SalDisplay * GetDisplay() const { return mpDisplay; }
sal_uInt16 GetDepth() const { return mnDepth; }
int GetWidth() const { return mnWidth; }
int GetHeight() const { return mnHeight; }
SalX11Screen GetXScreenNumber() const { return mnXScreen; }
virtual SalGraphics* AcquireGraphics() SAL_OVERRIDE;
......
......@@ -96,7 +96,9 @@ typedef sal_uInt64 SalExtStyle;
struct SystemParentData;
class VCL_PLUGIN_PUBLIC SalFrame : public vcl::DeletionNotifier
class VCL_PLUGIN_PUBLIC SalFrame
: public vcl::DeletionNotifier
, public SalGeometryProvider
{
// the VCL window corresponding to this frame
vcl::Window* m_pWindow;
......@@ -108,6 +110,11 @@ public:
SalFrameGeometry maGeometry;
// SalGeometryProvider
virtual long GetWidth() const SAL_OVERRIDE { return maGeometry.nWidth; }
virtual long GetHeight() const SAL_OVERRIDE { return maGeometry.nHeight; }
virtual bool IsOffScreen() const SAL_OVERRIDE { return false; }
// SalGraphics or NULL, but two Graphics for all SalFrames
// must be returned
virtual SalGraphics* AcquireGraphics() = 0;
......
......@@ -20,6 +20,8 @@
#ifndef INCLUDED_VCL_INC_SALGEOM_HXX
#define INCLUDED_VCL_INC_SALGEOM_HXX
#include <vcl/dllapi.h>
typedef struct _SalFrameGeometry {
// screen position of upper left corner of drawable area in pixel
long nX, nY;
......@@ -40,6 +42,16 @@ typedef struct _SalFrameGeometry {
{}
} SalFrameGeometry;
/// Interface used to share logic on sizing between
/// SalVirtualDevices and SalFrames
class VCL_PLUGIN_PUBLIC SalGeometryProvider {
public:
virtual ~SalGeometryProvider() {}
virtual long GetWidth() const = 0;
virtual long GetHeight() const = 0;
virtual bool IsOffScreen() const = 0;
};
#endif // INCLUDED_VCL_INC_SALGEOM_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -22,15 +22,20 @@
#include <basebmp/bitmapdevice.hxx>
#include <vcl/dllapi.h>
#include <salgeom.hxx>
class SalGraphics;
class VCL_PLUGIN_PUBLIC SalVirtualDevice
: public SalGeometryProvider
{
public:
SalVirtualDevice() {}
virtual ~SalVirtualDevice();
// SalGeometryProvider
virtual bool IsOffScreen() const SAL_OVERRIDE { return true; }
// SalGraphics or NULL, but two Graphics for all SalVirtualDevices
// must be returned
virtual SalGraphics* AcquireGraphics() = 0;
......
......@@ -64,8 +64,6 @@ public:
}
Pixmap GetDrawable() const { return hDrawable_; }
sal_uInt16 GetDepth() const { return nDepth_; }
int GetWidth() const { return nDX_; }
int GetHeight() const { return nDY_; }
SalX11Screen GetXScreenNumber() const { return m_nXScreen; }
virtual SalGraphics* AcquireGraphics() SAL_OVERRIDE;
......@@ -73,6 +71,10 @@ public:
/// Set new size, without saving the old contents
virtual bool SetSize( long nNewDX, long nNewDY ) SAL_OVERRIDE;
// SalGeometryProvider
virtual long GetWidth() const SAL_OVERRIDE { return nDX_; }
virtual long GetHeight() const SAL_OVERRIDE { return nDY_; }
};
#endif // INCLUDED_VCL_INC_UNX_SALVD_H
......
......@@ -43,6 +43,8 @@ public:
sal_uInt16 mnBitCount; // BitCount (0 or 1)
bool mbGraphics; // is Graphics used
bool mbForeignDC; // uses a foreign DC instead of a bitmap
long mnWidth;
long mnHeight;
WinSalVirtualDevice();
virtual ~WinSalVirtualDevice();
......@@ -52,6 +54,10 @@ public:
virtual bool SetSize( long nNewDX, long nNewDY );
static HBITMAP ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, sal_uInt16 nBitCount, void **ppDummy);
// SalGeometryProvider
virtual long GetWidth() const SAL_OVERRIDE { return mnWidth; }
virtual long GetHeight() const SAL_OVERRIDE { return mnHeight; }
};
......
......@@ -80,6 +80,7 @@ void X11OpenGLSalVirtualDevice::ReleaseGraphics( SalGraphics* )
mbGraphics = false;
}
bool X11OpenGLSalVirtualDevice::SetSize( long nDX, long nDY )
{
if( !nDX ) nDX = 1;
......
......@@ -96,30 +96,26 @@ void X11CairoTextRender::clipRegion(cairo_t* cr)
size_t X11CairoTextRender::GetWidth() const
{
if( mrParent.m_pFrame )
return mrParent.m_pFrame->maGeometry.nWidth;
else if( mrParent.m_pVDev )
{
long nWidth = 0;
long nHeight = 0;
mrParent.m_pVDev->GetSize( nWidth, nHeight );
return nWidth;
}
return 1;
SalGeometryProvider *pProvider = mrParent.m_pFrame;
if( !pProvider )
pProvider = mrParent.m_pVDev;
if( pProvider )
return pProvider->GetWidth();
else
return 1;
}
size_t X11CairoTextRender::GetHeight() const
{
if( mrParent.m_pFrame )
return mrParent.m_pFrame->maGeometry.nHeight;
else if( mrParent.m_pVDev )
{
long nWidth = 0;
long nHeight = 0;
mrParent.m_pVDev->GetSize( nWidth, nHeight );
return nHeight;
}
return 1;
SalGeometryProvider *pProvider = mrParent.m_pFrame;
if( !pProvider )
pProvider = mrParent.m_pVDev;
if( pProvider )
return pProvider->GetHeight();
else
return 1;
}
void X11CairoTextRender::drawSurface(cairo_t* /*cr*/)
......
......@@ -115,6 +115,8 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics,
}
pVirGraphics->InitGraphics();
mnWidth = nDX;
mnHeight = nDY;
pVDev->setHDC(hDC);
pVDev->mhBmp = hBmp;
if( hBmp )
......@@ -152,6 +154,8 @@ WinSalVirtualDevice::WinSalVirtualDevice()
mnBitCount = 0; // BitCount (0 or 1)
mbGraphics = FALSE; // is Graphics used
mbForeignDC = FALSE; // uses a foreign DC instead of a bitmap
mnWidth = 0;
mnHeight = 0;
}
WinSalVirtualDevice::~WinSalVirtualDevice()
......
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