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

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Tue Dec 2 06:09:59 PST 2014


 include/vcl/opengl/OpenGLContext.hxx |    2 --
 vcl/inc/opengl/win/gdiimpl.hxx       |    1 -
 vcl/inc/opengl/x11/gdiimpl.hxx       |    1 -
 vcl/inc/openglgdiimpl.hxx            |    6 +++---
 vcl/opengl/gdiimpl.cxx               |   21 +++++++++++----------
 vcl/opengl/win/gdiimpl.cxx           |   11 ++---------
 vcl/opengl/x11/gdiimpl.cxx           |   10 ----------
 vcl/source/opengl/OpenGLContext.cxx  |    8 --------
 8 files changed, 16 insertions(+), 44 deletions(-)

New commits:
commit e957683050f6598f00e9cebb13273c1c701d34cb
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Tue Dec 2 09:08:57 2014 -0500

    vcl: Release the OpenGL context for offscreen rendering after each operation
    
    Change-Id: If253a4c0a1f64b1cc54e0079d4455abf39620ac0

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 1a38b1c..1fb59a2 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -160,6 +160,11 @@ void OpenGLSalGraphicsImpl::PostDraw()
     mpFramebuffer = NULL;
 
     CHECK_GL_ERROR();
+
+    // release the context as there is no guarantee the underlying window
+    // will still be valid for the next draw operation
+    if( mbOffscreen )
+        ReleaseContext();
 }
 
 void OpenGLSalGraphicsImpl::freeResources()
commit 797f4443559339ef25bce6b124f346c7dbc12a96
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Tue Dec 2 09:05:19 2014 -0500

    vcl: Don't create new contexts for Virtual Devices on Windows
    
    Change-Id: I561a8142f986aca89e796ce2c4a0902fae41f9e6

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 679de09..6546dde 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -238,8 +238,6 @@ public:
         return mbInitialized;
     }
 
-    void resetToReInitialize();
-
     bool supportMultiSampling() const;
 
     static SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext);
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index 30ade23..03007c9 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -30,7 +30,6 @@ public:
 protected:
     virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE;
     virtual bool UseContext( OpenGLContext* pContext ) SAL_OVERRIDE;
-    virtual OpenGLContext* CreatePixmapContext() SAL_OVERRIDE;
 
 public:
     virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx
index d6ef010..feb3961 100644
--- a/vcl/inc/opengl/x11/gdiimpl.hxx
+++ b/vcl/inc/opengl/x11/gdiimpl.hxx
@@ -27,7 +27,6 @@ public:
 
 protected:
     virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE;
-    virtual OpenGLContext* CreatePixmapContext() SAL_OVERRIDE;
     virtual bool UseContext( OpenGLContext* pContext ) SAL_OVERRIDE;
 
 public:
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 42c5520..3a4222e 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -110,12 +110,12 @@ protected:
     bool AcquireContext();
     bool ReleaseContext();
 
+    // retrieve the default context for offscreen rendering
+    virtual OpenGLContext* GetDefaultContext();
+
     // create a new context for window rendering
     virtual OpenGLContext* CreateWinContext() = 0;
 
-    // create a new context for offscreen rendering
-    virtual OpenGLContext* CreatePixmapContext() = 0;
-
     // check whether the given context can be used by this instance
     virtual bool UseContext( OpenGLContext* pContext ) = 0;
 
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index e9ae4db..1a38b1c 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -61,6 +61,11 @@ OpenGLContext* OpenGLSalGraphicsImpl::GetOpenGLContext()
     return mpContext;
 }
 
+OpenGLContext* OpenGLSalGraphicsImpl::GetDefaultContext()
+{
+    return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
+}
+
 bool OpenGLSalGraphicsImpl::AcquireContext( )
 {
     ImplSVData* pSVData = ImplGetSVData();
@@ -80,7 +85,7 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
     if( pContext )
         pContext->AddRef();
     else
-        pContext = mbOffscreen ? CreatePixmapContext() : CreateWinContext();
+        pContext = mbOffscreen ? GetDefaultContext() : CreateWinContext();
 
     mpContext = pContext;
     return (mpContext != NULL);
@@ -111,15 +116,6 @@ void OpenGLSalGraphicsImpl::Init()
         maOffscreenTex.GetHeight() != GetHeight() )
     {
         maOffscreenTex = OpenGLTexture();
-#if defined(WNT)
-        // URGH ... VirtualDevice may have destroyed the underlying resource
-        // our context is associated with - FIXME: can we do better here ?
-        if (mpContext)
-        {
-            mpContext->resetToReInitialize();
-            ReleaseContext();
-        }
-#endif
     }
 }
 
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index caef995..f1dcc00 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -38,16 +38,9 @@ bool WinOpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext )
 {
     if( !pContext || !pContext->isInitialized() )
         return false;
+    if( IsOffscreen() )
+        return true;
     return ( pContext->getOpenGLWindow().hWnd == mrParent.mhWnd );
 }
 
-OpenGLContext* WinOpenGLSalGraphicsImpl::CreatePixmapContext()
-{
-    OpenGLContext* pContext = new OpenGLContext();
-    pContext->requestVirtualDevice();
-    pContext->requestSingleBufferedRendering();
-    pContext->init( mrParent.mhLocalDC, mrParent.mhWnd );
-    return pContext;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 0b5fd75..e844ded 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -56,16 +56,6 @@ OpenGLContext* X11OpenGLSalGraphicsImpl::CreateWinContext()
     return pContext;
 }
 
-OpenGLContext* X11OpenGLSalGraphicsImpl::CreatePixmapContext()
-{
-    X11OpenGLSalVirtualDevice* pVDev = dynamic_cast<X11OpenGLSalVirtualDevice*>(mrParent.m_pVDev);
-
-    if( pVDev == NULL )
-        return NULL;
-
-    return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
-}
-
 bool X11OpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext )
 {
     X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame);
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 7992ffd..5dfdd54 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -636,14 +636,6 @@ bool OpenGLContext::init(SystemChildWindow* pChildWindow)
     return ImplInit();
 }
 
-void OpenGLContext::resetToReInitialize()
-{
-    if( !mbInitialized )
-        return;
-    resetCurrent();
-    mbInitialized = false;
-}
-
 #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
 bool OpenGLContext::init(Display* dpy, Window win, int screen)
 {


More information about the Libreoffice-commits mailing list