[Libreoffice-commits] core.git: vcl/inc vcl/opengl

Michael Meeks michael.meeks at collabora.com
Fri Dec 18 04:01:12 PST 2015


 vcl/inc/openglgdiimpl.hxx |    2 +-
 vcl/opengl/gdiimpl.cxx    |   36 +++++++++++++++++++-----------------
 2 files changed, 20 insertions(+), 18 deletions(-)

New commits:
commit ce326521f315893dedaffb3a851a1ed0fc6eb1b6
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Dec 10 18:31:04 2015 +0000

    vcl: opengl - lean on the default window's context much more.
    
    Avoid creating our own OpenGLContext to render until we need to
    refresh the screen.
    
    Change-Id: I29d4a1cb6193c92ed77ae98566f8b897a6bc67b5
    Reviewed-on: https://gerrit.libreoffice.org/20709
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 813a7be..a81b1e8 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -158,7 +158,7 @@ public:
     void PostDraw();
 
 protected:
-    bool AcquireContext();
+    bool AcquireContext(bool bForceCreate = false);
     bool ReleaseContext();
 
     /// retrieve the default context for offscreen rendering
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 860cdbc..41f8e93 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -92,7 +92,7 @@ OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
 
 rtl::Reference<OpenGLContext> OpenGLSalGraphicsImpl::GetOpenGLContext()
 {
-    if( !AcquireContext() )
+    if( !AcquireContext(true) )
         return nullptr;
     return mpContext;
 }
@@ -102,7 +102,7 @@ rtl::Reference<OpenGLContext> OpenGLSalGraphicsImpl::GetDefaultContext()
     return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
 }
 
-bool OpenGLSalGraphicsImpl::AcquireContext( )
+bool OpenGLSalGraphicsImpl::AcquireContext( bool bForceCreate )
 {
     ImplSVData* pSVData = ImplGetSVData();
 
@@ -134,7 +134,12 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
         mpContext = pContext;
     else if( mpWindowContext.is() )
         mpContext = mpWindowContext;
-    else
+    else if( bForceCreate && !IsOffscreen() )
+    {
+        mpWindowContext = CreateWinContext();
+        mpContext = mpWindowContext;
+    }
+    if( !mpContext.is() )
         mpContext = GetDefaultContext();
 
     return mpContext.is();
@@ -175,12 +180,8 @@ void OpenGLSalGraphicsImpl::Init()
         VCL_GL_INFO("::Init - re-size offscreen texture");
     }
 
-    if( !IsOffscreen() )
-    {
-        if( mpWindowContext.is() )
-            mpWindowContext->reset();
-        mpWindowContext = CreateWinContext();
-    }
+    if( mpWindowContext.is() )
+        mpWindowContext->reset();
 }
 
 // Currently only used to get windows ordering right.
@@ -245,11 +246,6 @@ void OpenGLSalGraphicsImpl::PostDraw()
 
     assert (maOffscreenTex);
 
-    if( IsOffscreen() )
-        assert( !mpWindowContext.is() );
-    else
-        assert( mpWindowContext.is() );
-
     // Always queue the flush.
     if( !IsOffscreen() )
         flush();
@@ -2022,15 +2018,13 @@ void OpenGLSalGraphicsImpl::doFlush()
     if( IsOffscreen() )
         return;
 
-    assert( mpWindowContext.is() );
-
     if( !maOffscreenTex )
     {
         VCL_GL_INFO( "flushAndSwap - odd no texture !" );
         return;
     }
 
-    if (mnDrawCountAtFlush == mnDrawCount)
+    if( mnDrawCountAtFlush == mnDrawCount )
     {
         VCL_GL_INFO( "eliding redundant flushAndSwap, no drawing since last!" );
         return;
@@ -2042,6 +2036,14 @@ void OpenGLSalGraphicsImpl::doFlush()
 
     VCL_GL_INFO( "flushAndSwap" );
 
+    if( !mpWindowContext.is() )
+    {
+        VCL_GL_INFO( "late creation of window context" );
+        mpWindowContext = CreateWinContext();
+    }
+
+    assert( mpWindowContext.is() );
+
     // Interesting ! -> this destroys a context [ somehow ] ...
     mpWindowContext->makeCurrent();
     CHECK_GL_ERROR();


More information about the Libreoffice-commits mailing list