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

Michael Meeks michael.meeks at collabora.com
Sat Jan 2 09:27:36 PST 2016


 vcl/opengl/gdiimpl.cxx      |   48 ++++++++++++--------------------------------
 vcl/unx/gtk/gtksalframe.cxx |    3 +-
 2 files changed, 16 insertions(+), 35 deletions(-)

New commits:
commit 59cf4500965c7d15c5e4c88057d20de570fde183
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Jan 1 17:39:13 2016 +0000

    vcl: gtk2 - synchronous painting during initial expose to avoid flicker.
    
    Change-Id: Ib2520679c3d62991f4ae6c5a325a44ab3cce1d89

diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index f813e64..4865467 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -37,6 +37,7 @@
 #include <vcl/svapp.hxx>
 #include <vcl/window.hxx>
 #include <vcl/settings.hxx>
+#include <vcl/opengl/OpenGLHelper.hxx>
 
 #include <unx/x11/xlimits.hxx>
 #if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
@@ -2954,7 +2955,7 @@ gboolean GtkSalFrame::signalExpose( GtkWidget*, GdkEventExpose* pEvent, gpointer
     GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
     pThis->m_bPaintsBlocked = false;
 
-    struct SalPaintEvent aEvent( pEvent->area.x, pEvent->area.y, pEvent->area.width, pEvent->area.height );
+    struct SalPaintEvent aEvent( pEvent->area.x, pEvent->area.y, pEvent->area.width, pEvent->area.height, OpenGLHelper::isVCLOpenGLEnabled() );
 
     pThis->CallCallback( SALEVENT_PAINT, &aEvent );
 
commit 3723c3e0b20982ab46d4c04a342af22e88f42fa0
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Jan 1 17:45:06 2016 +0000

    vcl: opengl - ensure we have the right GL context for rendering.
    
    Also significantly simplify, and remove paranoid ramblings
    from the flushing code.
    
    Change-Id: Ie7cc742caac290d77ac931c54cc4fe777a7872de

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 539ae76..56da7c1 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -2038,8 +2038,10 @@ void OpenGLSalGraphicsImpl::doFlush()
 
     if( !mpWindowContext.is() )
     {
-        VCL_GL_INFO( "late creation of window context" );
+        // ensure everything is released from the old context.
+        OpenGLContext::clearCurrent();
         mpWindowContext = CreateWinContext();
+        VCL_GL_INFO( "late creation of window context" );
     }
 
     assert( mpWindowContext.is() );
@@ -2048,17 +2050,9 @@ void OpenGLSalGraphicsImpl::doFlush()
     mpWindowContext->makeCurrent();
     CHECK_GL_ERROR();
 
-    VCL_GL_INFO( "flushAndSwap - acquire default frame buffer" );
+    VCL_GL_INFO( "flushAndSwap - acquire default framebuffer" );
 
     mpWindowContext->AcquireDefaultFramebuffer();
-    glBindFramebuffer( GL_FRAMEBUFFER, 0 ); // FIXME: paranoid double check.
-    CHECK_GL_ERROR();
-
-    VCL_GL_INFO( "flushAndSwap - acquired default frame buffer" );
-
-    glDisable( GL_SCISSOR_TEST ); // FIXME: paranoia ...
-    CHECK_GL_ERROR();
-    glDisable( GL_STENCIL_TEST ); // FIXME: paranoia ...
     CHECK_GL_ERROR();
 
     glViewport( 0, 0, GetWidth(), GetHeight() );
@@ -2073,8 +2067,6 @@ void OpenGLSalGraphicsImpl::doFlush()
     glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
     CHECK_GL_ERROR();
 
-    SalTwoRect aPosAry( 0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight(),
-                        0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight() );
     VCL_GL_INFO( "Texture height " << maOffscreenTex.GetHeight() << " vs. window height " << GetHeight() );
 
     OpenGLProgram *pProgram =
@@ -2083,41 +2075,29 @@ void OpenGLSalGraphicsImpl::doFlush()
         VCL_GL_INFO( "Can't compile simple copying shader !" );
     else
     {
-        pProgram->Use(); // FIXME: paranoia ...
-        VCL_GL_INFO( "done paranoid re-use." );
         pProgram->SetTexture( "sampler", maOffscreenTex );
-        maOffscreenTex.Bind(); // FIXME: paranoia ...
 
-        VCL_GL_INFO( "bound bits etc." );
+        SalTwoRect aPosAry( 0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight(),
+                            0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight() );
 
         GLfloat aTexCoord[8];
         maOffscreenTex.GetCoord( aTexCoord, aPosAry );
         pProgram->SetTextureCoord( aTexCoord );
 
-        long nX1( aPosAry.mnDestX );
-        long nY1( aPosAry.mnDestY );
-        long nX2( nX1 + aPosAry.mnDestWidth );
-        long nY2( nY1 + aPosAry.mnDestHeight );
-        const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
-                                     { nX2, nY1 }, { nX2, nY2 }};
-
-        sal_uInt32 nPoints = 4;
-        std::vector<GLfloat> aVertices(nPoints * 2);
-        sal_uInt32 i, j;
-
-        for( i = 0, j = 0; i < nPoints; i++, j += 2 )
-        {
-            aVertices[j]   = GLfloat(aPoints[i].mnX);
-            aVertices[j+1] = GLfloat(aPoints[i].mnY);
-        }
+        GLfloat fWidth( maOffscreenTex.GetWidth() );
+        GLfloat fHeight( maOffscreenTex.GetHeight() );
+        const GLfloat aVertices[] = { 0, fHeight,
+                                      0, 0,
+                                      fWidth, 0,
+                                      fWidth, fHeight };
 
         pProgram->ApplyMatrix(GetWidth(), GetHeight(), 0.0);
         pProgram->SetVertices( &aVertices[0] );
-        glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
+        glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
 
         pProgram->Clean();
 
-        glBindTexture( GL_TEXTURE_2D, 0 );
+        maOffscreenTex.Unbind();
 
         static bool bNoSwap = getenv("SAL_GL_NO_SWAP");
         if (!bNoSwap)


More information about the Libreoffice-commits mailing list