summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-11-20 09:45:16 +0000
committerMichael Meeks <michael.meeks@collabora.com>2014-11-20 09:45:16 +0000
commitb7342eae42faa8110807861906288d13a2e9f762 (patch)
tree4dd9352e3d916fdb6ddc50b407679a307ddb6571
parent1f3a20c2d1fffe996cb06fc6f102157ae0bccce3 (diff)
vcl: update the OpenGLContext's pixmap when re-sizing a VirtualDevice.
Change-Id: Iee8089fc3bfbea60adee95dfb2c229f3efea28f8
-rw-r--r--include/vcl/opengl/OpenGLContext.hxx2
-rw-r--r--vcl/opengl/x11/gdiimpl.cxx3
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx17
-rw-r--r--vcl/unx/generic/gdi/salvd.cxx9
4 files changed, 29 insertions, 2 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 058e174bfb6a..c5e53e873ff0 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -194,6 +194,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 dcefcc23172f..3385cd9da9fc 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;
}