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

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Sat Apr 30 03:08:54 UTC 2016


 vcl/inc/opengl/RenderState.hxx      |   12 ++++++++++++
 vcl/opengl/gdiimpl.cxx              |    7 ++-----
 vcl/source/opengl/OpenGLContext.cxx |    4 ++--
 3 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 540fee2dc7553152914f7f1d8a41921e765087ef
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Apr 29 17:17:09 2016 +0900

    opengl: track the state of glViewport
    
    We don't want to set the viewport over and over again.
    
    Change-Id: I60b84a009d4058743e30587616604f9b6fc0f601
    Reviewed-on: https://gerrit.libreoffice.org/24507
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/inc/opengl/RenderState.hxx b/vcl/inc/opengl/RenderState.hxx
index eeac1a50..ac215a8 100644
--- a/vcl/inc/opengl/RenderState.hxx
+++ b/vcl/inc/opengl/RenderState.hxx
@@ -123,10 +123,22 @@ class RenderState
     ScissorState maScissor;
     StencilState maStencil;
 
+    Rectangle maCurrentViewport;
+
 public:
     RenderState()
     {}
 
+    void viewport(Rectangle aViewPort)
+    {
+        if (aViewPort != maCurrentViewport)
+        {
+            glViewport(aViewPort.Left(), aViewPort.Top(), aViewPort.GetWidth(), aViewPort.GetHeight());
+            CHECK_GL_ERROR();
+            maCurrentViewport = aViewPort;
+        }
+    }
+
     TextureState& texture() { return maTexture; }
     ScissorState& scissor() { return maScissor; }
     StencilState& stencil() { return maStencil; }
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index f98f5d2..4b67ed5 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -211,8 +211,7 @@ void OpenGLSalGraphicsImpl::InitializePreDrawState(XOROption eOpt)
     CheckOffscreenTexture();
     CHECK_GL_ERROR();
 
-    glViewport( 0, 0, GetWidth(), GetHeight() );
-    CHECK_GL_ERROR();
+    mpContext->state()->viewport(Rectangle(Point(0, 0), Size(GetWidth(), GetHeight())));
 
     ImplInitClipRegion();
     CHECK_GL_ERROR();
@@ -2562,9 +2561,7 @@ void OpenGLSalGraphicsImpl::doFlush()
     mpWindowContext->AcquireDefaultFramebuffer();
     CHECK_GL_ERROR();
 
-    glViewport( 0, 0, GetWidth(), GetHeight() );
-    CHECK_GL_ERROR();
-
+    mpWindowContext->state()->viewport(Rectangle(Point(0, 0), Size(GetWidth(), GetHeight())));
     mpWindowContext->state()->scissor().disable();
     mpWindowContext->state()->stencil().disable();
 
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 5b441db..5a8334c 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1679,8 +1679,8 @@ OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rText
     assert( pFramebuffer );
     BindFramebuffer( pFramebuffer );
     pFramebuffer->AttachTexture( rTexture );
-    glViewport( 0, 0, rTexture.GetWidth(), rTexture.GetHeight() );
-    CHECK_GL_ERROR();
+
+    state()->viewport(Rectangle(Point(), Size(rTexture.GetWidth(), rTexture.GetHeight())));
 
     return pFramebuffer;
 }


More information about the Libreoffice-commits mailing list