diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-11-29 22:14:36 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2014-11-29 23:24:00 +0000 |
commit | 6c55e8ffe290c537aeabac8c280cd1dcefa6067d (patch) | |
tree | 54b63ce37900d4e65c7e18d774453b1092071930 | |
parent | 38511b4027c4268051925a5e5658cff489844b71 (diff) |
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
-rw-r--r-- | vcl/inc/headless/svpvd.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/opengl/x11/salvd.hxx | 6 | ||||
-rw-r--r-- | vcl/inc/salframe.hxx | 9 | ||||
-rw-r--r-- | vcl/inc/salgeom.hxx | 12 | ||||
-rw-r--r-- | vcl/inc/salvd.hxx | 5 | ||||
-rw-r--r-- | vcl/inc/unx/salvd.h | 6 | ||||
-rw-r--r-- | vcl/inc/win/salvd.h | 6 | ||||
-rw-r--r-- | vcl/opengl/x11/salvd.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/x11cairotextrender.cxx | 36 | ||||
-rw-r--r-- | vcl/win/source/gdi/salvd.cxx | 4 |
10 files changed, 64 insertions, 25 deletions
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx index 752e91cab119..27dba6016288 100644 --- a/vcl/inc/headless/svpvd.hxx +++ b/vcl/inc/headless/svpvd.hxx @@ -51,6 +51,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 diff --git a/vcl/inc/opengl/x11/salvd.hxx b/vcl/inc/opengl/x11/salvd.hxx index 7696e04c62ac..7f5f1f5d1a7c 100644 --- a/vcl/inc/opengl/x11/salvd.hxx +++ b/vcl/inc/opengl/x11/salvd.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; diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx index f427c249b2ad..cfc41b74ee27 100644 --- a/vcl/inc/salframe.hxx +++ b/vcl/inc/salframe.hxx @@ -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; diff --git a/vcl/inc/salgeom.hxx b/vcl/inc/salgeom.hxx index 138a6d96acdf..d54c58a0ee98 100644 --- a/vcl/inc/salgeom.hxx +++ b/vcl/inc/salgeom.hxx @@ -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: */ diff --git a/vcl/inc/salvd.hxx b/vcl/inc/salvd.hxx index 13979359919d..c07722f887a4 100644 --- a/vcl/inc/salvd.hxx +++ b/vcl/inc/salvd.hxx @@ -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; diff --git a/vcl/inc/unx/salvd.h b/vcl/inc/unx/salvd.h index 9b520a7c848c..0b08521c3704 100644 --- a/vcl/inc/unx/salvd.h +++ b/vcl/inc/unx/salvd.h @@ -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 diff --git a/vcl/inc/win/salvd.h b/vcl/inc/win/salvd.h index 9abb46bf4ebc..6ecba546b8ad 100644 --- a/vcl/inc/win/salvd.h +++ b/vcl/inc/win/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; } }; diff --git a/vcl/opengl/x11/salvd.cxx b/vcl/opengl/x11/salvd.cxx index 4fde8f84c8ad..7996cffcee04 100644 --- a/vcl/opengl/x11/salvd.cxx +++ b/vcl/opengl/x11/salvd.cxx @@ -80,6 +80,7 @@ void X11OpenGLSalVirtualDevice::ReleaseGraphics( SalGraphics* ) mbGraphics = false; } + bool X11OpenGLSalVirtualDevice::SetSize( long nDX, long nDY ) { if( !nDX ) nDX = 1; diff --git a/vcl/unx/generic/gdi/x11cairotextrender.cxx b/vcl/unx/generic/gdi/x11cairotextrender.cxx index 2533107908c2..0449b98148b1 100644 --- a/vcl/unx/generic/gdi/x11cairotextrender.cxx +++ b/vcl/unx/generic/gdi/x11cairotextrender.cxx @@ -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*/) diff --git a/vcl/win/source/gdi/salvd.cxx b/vcl/win/source/gdi/salvd.cxx index b5986b1b6056..cea8a768a36b 100644 --- a/vcl/win/source/gdi/salvd.cxx +++ b/vcl/win/source/gdi/salvd.cxx @@ -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() |