summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-13 21:38:58 -0500
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-11-15 12:17:43 +0100
commitfbe77f453cc9f6840b12d10982d972d6ef276549 (patch)
tree43e185583648fd7d9a3401a0c9e828fc5fc3b5c0 /vcl
parentdce9610afed674ecec23497a1a004193a6cf3bf1 (diff)
vcl: Make sure the offscreen texture is unique before rendering to it
Change-Id: I265ce62e983e6f44ba51675993c9ec1f071c160e
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/openglgdiimpl.hxx2
-rw-r--r--vcl/opengl/gdiimpl.cxx24
2 files changed, 25 insertions, 1 deletions
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 965365e8760a..c6093b589c8d 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -75,6 +75,8 @@ protected:
void ImplSetClipBit( const vcl::Region& rClip, GLuint nMask );
+ bool CheckOffscreenTexture();
+
bool CreateSolidProgram( void );
bool CreateTextureProgram( void );
bool CreateMaskedTextureProgram( void );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 6a4ee80d2e7c..8f60489c38d2 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -97,7 +97,7 @@ void OpenGLSalGraphicsImpl::PreDraw()
maContext.makeCurrent();
// TODO: lfrb: make sure the render target has the right size
if( mbOffscreen )
- glBindFramebuffer( GL_FRAMEBUFFER, mnFramebufferId );
+ CheckOffscreenTexture();
glViewport( 0, 0, GetWidth(), GetHeight() );
if( mbUseScissor )
glEnable( GL_SCISSOR_TEST );
@@ -282,6 +282,28 @@ void OpenGLSalGraphicsImpl::SetOffscreen( bool bOffscreen )
CHECK_GL_ERROR();
}
+bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
+{
+ glBindFramebuffer( GL_FRAMEBUFFER, mnFramebufferId );
+
+ if( maOffscreenTex.IsUnique() )
+ return true;
+
+ SalTwoRect aPosAry;
+ aPosAry.mnSrcX = aPosAry.mnDestX = 0;
+ aPosAry.mnSrcY = aPosAry.mnDestY = 0;
+ aPosAry.mnSrcWidth = aPosAry.mnDestWidth = GetWidth();
+ aPosAry.mnSrcHeight = aPosAry.mnDestHeight = GetHeight();
+
+ // TODO: lfrb: User GL_ARB_copy_image?
+ OpenGLTexture aNewTex = OpenGLTexture( GetWidth(), GetHeight() );
+ glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, aNewTex.Id(), 0 );
+ glViewport( 0, 0, GetWidth(), GetHeight() );
+ DrawTexture( maOffscreenTex, aPosAry );
+
+ return true;
+}
+
bool OpenGLSalGraphicsImpl::CreateSolidProgram( void )
{
SAL_INFO( "vcl.opengl", "::CreateSolidProgram" );