diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-04-29 17:17:09 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2016-04-30 03:08:30 +0000 |
commit | 540fee2dc7553152914f7f1d8a41921e765087ef (patch) | |
tree | 6ceeb3c6ccdd1fdcc9e76fabbe82413fbd9673b4 /vcl | |
parent | a57d048f88ba6cac3ce1550e2a8a143a8887eb05 (diff) |
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@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/opengl/RenderState.hxx | 12 | ||||
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 7 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 4 |
3 files changed, 16 insertions, 7 deletions
diff --git a/vcl/inc/opengl/RenderState.hxx b/vcl/inc/opengl/RenderState.hxx index eeac1a508d3e..ac215a8d97c1 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 f98f5d26c248..4b67ed5fb871 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 5b441db4eaef..5a8334cf27f4 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; } |