diff options
-rw-r--r-- | include/vcl/opengl/OpenGLContext.hxx | 2 | ||||
-rw-r--r-- | vcl/opengl/x11/gdiimpl.cxx | 3 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 17 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salvd.cxx | 9 |
4 files changed, 29 insertions, 2 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx index 60746df178ec..471e6ce7e498 100644 --- a/include/vcl/opengl/OpenGLContext.hxx +++ b/include/vcl/opengl/OpenGLContext.hxx @@ -195,6 +195,8 @@ public: return mbInitialized; } + void resetToReInitialize(); + bool supportMultiSampling() const; static SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext); diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index b3cee49383c2..bfc1bbbb79f5 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -62,6 +62,9 @@ GLfloat X11OpenGLSalGraphicsImpl::GetHeight() const void X11OpenGLSalGraphicsImpl::Init() { X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame); + + // Called after eg. a vdev re-size where we need to update the underlying pixmap + maContext.resetToReInitialize(); if (pProvider) { Window aWin = pProvider->GetX11Window(); diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 6267a9f0e517..d1c1b729fcaf 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -610,6 +610,14 @@ bool OpenGLContext::init(Display* dpy, Window win, int screen) return ImplInit(); } +void OpenGLContext::resetToReInitialize() +{ + if( !mbInitialized ) + return; + resetCurrent(); + mbInitialized = false; +} + bool OpenGLContext::init(Display* dpy, Pixmap pix, unsigned int width, unsigned int height, int nScreen) { if(mbInitialized) @@ -712,7 +720,12 @@ bool OpenGLContext::ImplInit() SAL_INFO("vcl.opengl", "available GL extensions: " << m_aGLWin.GLExtensions); XWindowAttributes xWinAttr; - if( !XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xWinAttr ) ) + if( mbPixmap ) + { + m_aGLWin.Width = 0; // FIXME: correct ? + m_aGLWin.Height = 0; + } + else if( !XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xWinAttr ) ) { SAL_WARN("vcl.opengl", "Failed to get window attributes on " << m_aGLWin.win); m_aGLWin.Width = 0; @@ -1159,7 +1172,7 @@ void OpenGLContext::makeCurrent() SAL_INFO("vcl.opengl", "OpenGLContext::makeCurrent(): Avoid setting the same context"); } else if (!glXMakeCurrent( m_aGLWin.dpy, nDrawable, m_aGLWin.ctx )) - SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent failed"); + SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent failed on drawable " << nDrawable << " pixmap? " << mbPixmap); #endif } diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx index 8e08cc2019fa..71ec509d1a2b 100644 --- a/vcl/unx/generic/gdi/salvd.cxx +++ b/vcl/unx/generic/gdi/salvd.cxx @@ -196,6 +196,8 @@ SalGraphics* X11SalVirtualDevice::AcquireGraphics() void X11SalVirtualDevice::ReleaseGraphics( SalGraphics* ) { bGraphics_ = false; } +#include "opengl/x11/gdiimpl.hxx" + bool X11SalVirtualDevice::SetSize( long nDX, long nDY ) { if( bExternPixmap_ ) @@ -229,8 +231,15 @@ bool X11SalVirtualDevice::SetSize( long nDX, long nDY ) nDY_ = nDY; if( pGraphics_ ) + { InitGraphics( this ); + // re-initialize OpenGLContext [!] having freed it's underlying pixmap above + X11OpenGLSalGraphicsImpl *pImpl = dynamic_cast< X11OpenGLSalGraphicsImpl* >(pGraphics_->GetImpl()); + if( pImpl ) + pImpl->Init(); + } + return true; } |