From 6c6a5dc0d358c7c895c9d05174cd8bba31478960 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Sat, 29 Nov 2014 22:55:31 +0000 Subject: vcl: Consolidate size information around the GeometryProvider. Change-Id: I1d764a8dba1850d2475f08e1014a085846f336c3 --- vcl/inc/opengl/win/gdiimpl.hxx | 7 ++--- vcl/inc/opengl/x11/gdiimpl.hxx | 7 +++-- vcl/inc/openglgdiimpl.hxx | 11 +++++--- vcl/inc/unx/salgdi.h | 2 ++ vcl/inc/win/salgdi.h | 4 ++- vcl/opengl/gdiimpl.cxx | 3 ++- vcl/opengl/win/gdiimpl.cxx | 54 +++----------------------------------- vcl/opengl/x11/gdiimpl.cxx | 35 ++++-------------------- vcl/unx/generic/gdi/salgdi.cxx | 8 ++++++ vcl/win/source/gdi/salgdi.cxx | 4 +-- vcl/win/source/gdi/salprn.cxx | 2 +- vcl/win/source/gdi/salvd.cxx | 11 +++++--- vcl/win/source/window/salframe.cxx | 4 +-- 13 files changed, 48 insertions(+), 104 deletions(-) diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx index da1a2780e8e2..30ade233b543 100644 --- a/vcl/inc/opengl/win/gdiimpl.hxx +++ b/vcl/inc/opengl/win/gdiimpl.hxx @@ -24,13 +24,10 @@ private: WinSalGraphics& mrParent; public: - WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics); + WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics, + SalGeometryProvider *mpProvider); protected: - virtual GLfloat GetWidth() const SAL_OVERRIDE; - virtual GLfloat GetHeight() const SAL_OVERRIDE; - virtual bool IsOffscreen() const SAL_OVERRIDE; - virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE; virtual bool UseContext( OpenGLContext* pContext ) SAL_OVERRIDE; virtual OpenGLContext* CreatePixmapContext() SAL_OVERRIDE; diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx index 53ebe5b30722..d6ef0101920b 100644 --- a/vcl/inc/opengl/x11/gdiimpl.hxx +++ b/vcl/inc/opengl/x11/gdiimpl.hxx @@ -26,10 +26,6 @@ public: virtual ~X11OpenGLSalGraphicsImpl(); protected: - GLfloat GetWidth() const SAL_OVERRIDE; - GLfloat GetHeight() const SAL_OVERRIDE; - bool IsOffscreen() const SAL_OVERRIDE; - virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE; virtual OpenGLContext* CreatePixmapContext() SAL_OVERRIDE; virtual bool UseContext( OpenGLContext* pContext ) SAL_OVERRIDE; @@ -38,6 +34,9 @@ public: // implementation of X11GraphicsImpl virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE; + + virtual void Init() SAL_OVERRIDE; + bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE; bool RenderPixmapToScreen( X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY ) SAL_OVERRIDE; }; diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 043bd9528fa4..ad13335d800a 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_VCL_OPENGLGDIIMPL_HXX #define INCLUDED_VCL_OPENGLGDIIMPL_HXX +#include "salgeom.hxx" #include "salgdiimpl.hxx" #include @@ -38,6 +39,8 @@ class VCL_PLUGIN_PUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl protected: OpenGLContext* mpContext; + /// Pointer to the SalFrame or SalVirtualDevice + SalGeometryProvider* mpParent; OpenGLFramebuffer* mpFramebuffer; // clipping @@ -142,13 +145,13 @@ public: public: // get the width of the device - virtual GLfloat GetWidth() const = 0; + GLfloat GetWidth() const { return mpParent ? mpParent->GetWidth() : 1; } // get the height of the device - virtual GLfloat GetHeight() const = 0; + GLfloat GetHeight() const { return mpParent ? mpParent->GetHeight() : 1; } // check whether this instance is used for offscreen rendering - virtual bool IsOffscreen() const = 0; + bool IsOffscreen() const { return mpParent ? mpParent->IsOffScreen() : true; } // operations to do before painting virtual void PreDraw(); @@ -170,7 +173,7 @@ protected: virtual bool UseContext( OpenGLContext* pContext ) = 0; public: - OpenGLSalGraphicsImpl(); + OpenGLSalGraphicsImpl(SalGeometryProvider* pParent); virtual ~OpenGLSalGraphicsImpl (); OpenGLContext* GetOpenGLContext(); diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index edf47b12eeef..29697a9f9e89 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -29,6 +29,7 @@ #include #include "salgdi.hxx" +#include "salgeom.hxx" #include "sallayout.hxx" #include "vclpluginapi.h" @@ -132,6 +133,7 @@ public: inline const SalDisplay* GetDisplay() const; inline Display* GetXDisplay() const; inline const SalVisual& GetVisual() const; + SalGeometryProvider *GetGeometryProvider() const; inline Drawable GetDrawable() const { return hDrawable_; } void SetDrawable( Drawable d, SalX11Screen nXScreen ); XRenderPictFormat* GetXRenderFormat() const; diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 443c1c2377af..5a46cb1ff8dd 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -21,6 +21,7 @@ #define INCLUDED_VCL_INC_WIN_SALGDI_H #include "sallayout.hxx" +#include "salgeom.hxx" #include "salgdi.hxx" #include "outfont.hxx" #include "PhysicalFontFace.hxx" @@ -243,7 +244,8 @@ public: HFONT ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontScale, HFONT& o_rOldFont ); public: - explicit WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hWnd); + explicit WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hWnd, + SalGeometryProvider *pProvider); virtual ~WinSalGraphics(); SalGraphicsImpl* GetImpl() const SAL_OVERRIDE; diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 28f7959567b1..03ac78139dd2 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -63,8 +63,9 @@ ((float) aColor.GetBlue()) * nFactor / 25500.0, \ 1.0f ) -OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl() +OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl(SalGeometryProvider* pParent) : mpContext(0) + , mpParent(pParent) , mpFramebuffer(NULL) , mbUseScissor(false) , mbUseStencil(false) diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx index fb05005f55ce..caef9953f314 100644 --- a/vcl/opengl/win/gdiimpl.cxx +++ b/vcl/opengl/win/gdiimpl.cxx @@ -13,7 +13,9 @@ #include #include -WinOpenGLSalGraphicsImpl::WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics): +WinOpenGLSalGraphicsImpl::WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics, + SalGeometryProvider *mpProvider): + OpenGLSalGraphicsImpl(mpProvider), mrParent(rGraphics) { } @@ -24,56 +26,6 @@ void WinOpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* OpenGLSalGraphicsImpl::DoCopyBits( rPosAry, pImpl ); } -GLfloat WinOpenGLSalGraphicsImpl::GetWidth() const -{ - if( mrParent.gethWnd() && IsWindow( mrParent.gethWnd() ) ) - { - WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() ); - if( pFrame ) - { - if( pFrame->maGeometry.nWidth ) - return pFrame->maGeometry.nWidth; - else - { - // TODO: perhaps not needed, maGeometry should always be up-to-date - RECT aRect; - GetClientRect( mrParent.gethWnd(), &aRect ); - return aRect.right; - } - } - } - - return 1; -} - -GLfloat WinOpenGLSalGraphicsImpl::GetHeight() const -{ - if( mrParent.gethWnd() && IsWindow( mrParent.gethWnd() ) ) - { - WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() ); - if( pFrame ) - { - if( pFrame->maGeometry.nHeight ) - return pFrame->maGeometry.nHeight; - else - { - // TODO: perhaps not needed, maGeometry should always be up-to-date - RECT aRect; - GetClientRect( mrParent.gethWnd(), &aRect ); - return aRect.bottom; - } - } - } - - return 1; -} - -bool WinOpenGLSalGraphicsImpl::IsOffscreen() const -{ - WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() ); - return ( pFrame == NULL ); -} - OpenGLContext* WinOpenGLSalGraphicsImpl::CreateWinContext() { OpenGLContext* pContext = new OpenGLContext(); diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index d4115fa0dcb5..0b5fd75aa888 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -26,7 +26,7 @@ #include X11OpenGLSalGraphicsImpl::X11OpenGLSalGraphicsImpl( X11SalGraphics& rParent ): - OpenGLSalGraphicsImpl(), + OpenGLSalGraphicsImpl(rParent.GetGeometryProvider()), mrParent(rParent) { } @@ -35,36 +35,11 @@ X11OpenGLSalGraphicsImpl::~X11OpenGLSalGraphicsImpl() { } -GLfloat X11OpenGLSalGraphicsImpl::GetWidth() const +void X11OpenGLSalGraphicsImpl::Init() { - if( mrParent.m_pFrame ) - return mrParent.m_pFrame->maGeometry.nWidth; - else if( mrParent.m_pVDev ) - return static_cast< X11OpenGLSalVirtualDevice* >(mrParent.m_pVDev)->GetWidth(); - return 1; -} - -GLfloat X11OpenGLSalGraphicsImpl::GetHeight() const -{ - if( mrParent.m_pFrame ) - return mrParent.m_pFrame->maGeometry.nHeight; - else if( mrParent.m_pVDev ) - return static_cast< X11OpenGLSalVirtualDevice* >(mrParent.m_pVDev)->GetHeight(); - return 1; -} - -bool X11OpenGLSalGraphicsImpl::IsOffscreen() const -{ - X11WindowProvider *pProvider = dynamic_cast(mrParent.m_pFrame); - if( pProvider ) - return false; - else if( mrParent.m_pVDev ) - return true; - else - { - SAL_WARN( "vcl.opengl", "what happened here?" ); - return true; - } + // The m_pFrame and m_pVDev pointers are updated late in X11 + mpParent = mrParent.GetGeometryProvider(); + OpenGLSalGraphicsImpl::Init(); } OpenGLContext* X11OpenGLSalGraphicsImpl::CreateWinContext() diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index d9eb7df2cf74..f3cb8a31323c 100644 --- a/vcl/unx/generic/gdi/salgdi.cxx +++ b/vcl/unx/generic/gdi/salgdi.cxx @@ -486,4 +486,12 @@ void X11SalGraphics::EndPaint() return mpImpl->endPaint(); } +SalGeometryProvider *X11SalGraphics::GetGeometryProvider() const +{ + if (m_pFrame) + return static_cast< SalGeometryProvider * >(m_pFrame); + else + return static_cast< SalGeometryProvider * >(m_pVDev); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx index 4c36bb341468..c2d644dbb7a5 100644 --- a/vcl/win/source/gdi/salgdi.cxx +++ b/vcl/win/source/gdi/salgdi.cxx @@ -613,7 +613,7 @@ OpenGLTexture* OpenGLCompatibleDC::getTexture() return new OpenGLTexture(maRects.mnSrcWidth, maRects.mnSrcHeight, GL_BGRA, GL_UNSIGNED_BYTE, reinterpret_cast(mpData)); } -WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hWnd): +WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hWnd, SalGeometryProvider *pProvider): mhLocalDC(0), mbPrinter(eType == WinSalGraphics::PRINTER), mbVirDev(eType == WinSalGraphics::VIRTUAL_DEVICE), @@ -634,7 +634,7 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW mnPenWidth(GSL_PEN_WIDTH) { if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter) - mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this)); + mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this, pProvider)); else mpImpl.reset(new WinSalGraphicsImpl(*this)); diff --git a/vcl/win/source/gdi/salprn.cxx b/vcl/win/source/gdi/salprn.cxx index ad22b4e817a2..78226624ddaa 100644 --- a/vcl/win/source/gdi/salprn.cxx +++ b/vcl/win/source/gdi/salprn.cxx @@ -1045,7 +1045,7 @@ static HDC ImplCreateSalPrnIC( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetup static WinSalGraphics* ImplCreateSalPrnGraphics( HDC hDC ) { - WinSalGraphics* pGraphics = new WinSalGraphics(WinSalGraphics::PRINTER, false, 0); + WinSalGraphics* pGraphics = new WinSalGraphics(WinSalGraphics::PRINTER, false, 0, /* CHECKME */ NULL); pGraphics->SetLayout( 0 ); pGraphics->setHDC(hDC); pGraphics->InitGraphics(); diff --git a/vcl/win/source/gdi/salvd.cxx b/vcl/win/source/gdi/salvd.cxx index cea8a768a36b..6758b098e112 100644 --- a/vcl/win/source/gdi/salvd.cxx +++ b/vcl/win/source/gdi/salvd.cxx @@ -105,7 +105,7 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics, { WinSalVirtualDevice* pVDev = new WinSalVirtualDevice; SalData* pSalData = GetSalData(); - WinSalGraphics* pVirGraphics = new WinSalGraphics(WinSalGraphics::VIRTUAL_DEVICE, pGraphics->isScreen(), 0); + WinSalGraphics* pVirGraphics = new WinSalGraphics(WinSalGraphics::VIRTUAL_DEVICE, pGraphics->isScreen(), 0, pVDev); pVirGraphics->SetLayout( 0 ); // by default no! mirroring for VirtualDevices, can be enabled with EnableRTL() pVirGraphics->setHDC(hDC); if ( pSalData->mhDitherPal && pVirGraphics->isScreen() ) @@ -115,8 +115,8 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics, } pVirGraphics->InitGraphics(); - mnWidth = nDX; - mnHeight = nDY; + pVDev->mnWidth = nDX; + pVDev->mnHeight = nDY; pVDev->setHDC(hDC); pVDev->mhBmp = hBmp; if( hBmp ) @@ -207,6 +207,9 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY ) HBITMAP hNewBmp = ImplCreateVirDevBitmap(getHDC(), nDX, nDY, mnBitCount, &pDummy); if ( hNewBmp ) { + mnWidth = nDX; + mnHeight = nDY; + SelectBitmap( getHDC(), hNewBmp ); DeleteBitmap( mhBmp ); mhBmp = hNewBmp; @@ -215,6 +218,8 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY ) else { ImplWriteLastError( GetLastError(), "ImplCreateVirDevBitmap in SetSize" ); + mnWidth = 0; + mnHeight = 0; return FALSE; } } diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx index d2fef8fc0903..e7cc2939762c 100644 --- a/vcl/win/source/window/salframe.cxx +++ b/vcl/win/source/window/salframe.cxx @@ -983,7 +983,7 @@ SalGraphics* WinSalFrame::AcquireGraphics() if ( !mpGraphics2 ) { - mpGraphics2 = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd); + mpGraphics2 = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd, this); mpGraphics2->setHDC(0); } @@ -1014,7 +1014,7 @@ SalGraphics* WinSalFrame::AcquireGraphics() HDC hDC = GetDC( mhWnd ); if ( hDC ) { - mpGraphics = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd); + mpGraphics = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd, this); mpGraphics->setHDC(hDC); if ( pSalData->mhDitherPal ) { -- cgit