[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl2' - include/vcl vcl/opengl vcl/source vcl/unx

Michael Meeks michael.meeks at collabora.com
Thu Nov 20 01:44:40 PST 2014


 include/vcl/opengl/OpenGLContext.hxx |    2 ++
 vcl/opengl/x11/gdiimpl.cxx           |    3 +++
 vcl/source/opengl/OpenGLContext.cxx  |   17 +++++++++++++++--
 vcl/unx/generic/gdi/salvd.cxx        |    9 +++++++++
 4 files changed, 29 insertions(+), 2 deletions(-)

New commits:
commit b7342eae42faa8110807861906288d13a2e9f762
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Nov 20 09:45:16 2014 +0000

    vcl: update the OpenGLContext's pixmap when re-sizing a VirtualDevice.
    
    Change-Id: Iee8089fc3bfbea60adee95dfb2c229f3efea28f8

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 058e174..c5e53e8 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 dcefcc2..3385cd9 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 6267a9f..d1c1b72 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 8e08cc2..71ec509 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;
 }
 


More information about the Libreoffice-commits mailing list