summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-12-02 16:42:32 -0500
committerJan Holesovsky <kendy@collabora.com>2014-12-03 14:41:20 +0100
commit1a5f00fd1da5d3ff13dd3ddb961ad09dc7d919c4 (patch)
tree7288142683f228f009d8752f50e5c284834225fa
parent2ab7c0c055939a3219fc6fd3e4053fe4b82d4cda (diff)
vcl: Acquire framebuffer from current context when reading back texture
Change-Id: I410ac2d10ec2e498d9d8444e5584bfb14727c90b
-rw-r--r--vcl/opengl/texture.cxx22
1 files changed, 10 insertions, 12 deletions
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index cc5be7800fa1..e4bc5326a47b 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -18,10 +18,14 @@
*/
#include <sal/config.h>
+#include <vcl/opengl/OpenGLContext.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
+#include "svdata.hxx"
+
#include "vcl/salbtype.hxx"
+#include "opengl/framebuffer.hxx"
#include "opengl/texture.hxx"
// texture with allocated size
@@ -299,21 +303,15 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData )
}
else
{
- GLuint nFramebufferId;
- glGenFramebuffers( 1, &nFramebufferId );
- glBindFramebuffer( GL_FRAMEBUFFER, nFramebufferId );
- CHECK_GL_ERROR();
+ // Retrieve current context
+ ImplSVData* pSVData = ImplGetSVData();
+ OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
+ OpenGLFramebuffer* pFramebuffer;
- glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Id(), 0 );
- CHECK_GL_ERROR();
+ pFramebuffer = pContext->AcquireFramebuffer( *this );
glReadPixels( maRect.Left(), mpImpl->mnHeight - maRect.Top(), GetWidth(), GetHeight(), nFormat, nType, pData );
+ pContext->ReleaseFramebuffer( pFramebuffer );
CHECK_GL_ERROR();
-
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- glDeleteFramebuffers( 1, &nFramebufferId );
-
- int bpp = (nFormat == GL_RGB) ? 3 : 4;
- memset( pData, 255, GetWidth() * GetHeight() * bpp );
}
Unbind();