[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - vcl/opengl

Michael Meeks michael.meeks at collabora.com
Mon Jan 4 04:06:46 PST 2016


 vcl/opengl/gdiimpl.cxx |   48 ++++++++++++++----------------------------------
 1 file changed, 14 insertions(+), 34 deletions(-)

New commits:
commit bcaaae8066cff2a366ce95283652c9cb147410ab
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
    Reviewed-on: https://gerrit.libreoffice.org/21048
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 9a40e46..73a2c82 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -2021,8 +2021,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() );
@@ -2031,17 +2033,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() );
@@ -2056,8 +2050,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 =
@@ -2066,41 +2058,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, false );
         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