summaryrefslogtreecommitdiff
path: root/vcl/opengl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-12-04 22:25:56 -0500
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-12-11 07:57:33 +0100
commit01bed8089af907e7c0fb8e053d55bffb1eb81aac (patch)
treeaa8d3a819d0acb388ef2d6785a0dbc8098386178 /vcl/opengl
parent4c424d785275494835287aa3c171ee2fd5c4f884 (diff)
vcl: Re-use a framebuffer of the same size when possible
Conflicts: include/vcl/opengl/OpenGLContext.hxx Change-Id: Id9c7932976ce9d9282776c20d93d9cca4d290056
Diffstat (limited to 'vcl/opengl')
-rw-r--r--vcl/opengl/framebuffer.cxx4
-rw-r--r--vcl/opengl/gdiimpl.cxx12
2 files changed, 13 insertions, 3 deletions
diff --git a/vcl/opengl/framebuffer.cxx b/vcl/opengl/framebuffer.cxx
index 29f9a781130a..e760b53f614d 100644
--- a/vcl/opengl/framebuffer.cxx
+++ b/vcl/opengl/framebuffer.cxx
@@ -15,6 +15,8 @@
OpenGLFramebuffer::OpenGLFramebuffer() :
mnId( 0 ),
+ mnWidth( 0 ),
+ mnHeight( 0 ),
mpPrevFramebuffer( NULL ),
mpNextFramebuffer( NULL )
{
@@ -55,6 +57,8 @@ void OpenGLFramebuffer::AttachTexture( const OpenGLTexture& rTexture )
{
SAL_INFO( "vcl.opengl", "Attaching texture " << rTexture.Id() << " to framebuffer " << (int)mnId );
maAttachedTexture = rTexture;
+ mnWidth = rTexture.GetWidth();
+ mnHeight = rTexture.GetHeight();
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
maAttachedTexture.Id(), 0 );
CHECK_GL_ERROR();
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 4edd843355c3..9520c863f5d7 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -120,6 +120,8 @@ void OpenGLSalGraphicsImpl::Init()
maOffscreenTex.GetWidth() != GetWidth() ||
maOffscreenTex.GetHeight() != GetHeight() )
{
+ if( mpContext ) // valid context
+ mpContext->ReleaseFramebuffer( maOffscreenTex );
maOffscreenTex = OpenGLTexture();
}
}
@@ -161,15 +163,18 @@ void OpenGLSalGraphicsImpl::PostDraw()
mpProgram = NULL;
}
- mpContext->ReleaseFramebuffer( mpFramebuffer );
- mpFramebuffer = NULL;
-
CHECK_GL_ERROR();
}
void OpenGLSalGraphicsImpl::freeResources()
{
// TODO Delete shaders, programs and textures if not shared
+ if( mbOffscreen && mpContext && mpContext->isInitialized() )
+ {
+ mpContext->makeCurrent();
+ mpContext->ReleaseFramebuffer( maOffscreenTex );
+ }
+ ReleaseContext();
}
void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMask )
@@ -1429,6 +1434,7 @@ void OpenGLSalGraphicsImpl::endPaint()
if( mpContext->mnPainting == 0 && !mbOffscreen )
{
mpContext->makeCurrent();
+ mpContext->AcquireDefaultFramebuffer();
glFlush();
}
}