summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-09-16 13:47:47 +0200
committerMichael Meeks <michael.meeks@collabora.com>2015-09-16 12:42:47 +0000
commit4833f5a9c88726a03666ee58c156746ba489b8a2 (patch)
tree7c96aa2d7ffefb77837e645d6ba1f1de97a4a42e
parent5096dd689db9fdd97ae0399f78f95710196b7786 (diff)
tdf#93666: use x,y coords when reading texture part + don't bind
Fixes shrinking shapes with gradients when the VirtualDev is reused to create a alpha mask (and the texture is reused and reading back from just one part of the texture which uses glReadPixels code-path). Binding texture is not necessary when we use and bind it to the framebuffer. Change-Id: Ie3994f749e1a2c17d4d3df44710b7453d7a4f45f (cherry picked from commit 0165da09288b5f6573bda114af664a26557fad8a) Reviewed-on: https://gerrit.libreoffice.org/18621 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--vcl/opengl/texture.cxx22
1 files changed, 12 insertions, 10 deletions
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index afb2b47ad72d..24a7c3852707 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -369,30 +369,32 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData )
return;
}
- Bind();
- glPixelStorei( GL_PACK_ALIGNMENT, 1 );
-
VCL_GL_INFO( "vcl.opengl", "Reading texture " << Id() << " " << GetWidth() << "x" << GetHeight() );
if( GetWidth() == mpImpl->mnWidth && GetHeight() == mpImpl->mnHeight )
{
+ Bind();
+ glPixelStorei( GL_PACK_ALIGNMENT, 1 );
// XXX: Call not available with GLES 2.0
glGetTexImage( GL_TEXTURE_2D, 0, nFormat, nType, pData );
+ Unbind();
}
else
{
+ long nWidth = maRect.GetWidth();
+ long nHeight = maRect.GetHeight();
+ long nX = maRect.Left();
+ long nY = mpImpl->mnHeight - maRect.Top() - nHeight;
+
// Retrieve current context
ImplSVData* pSVData = ImplGetSVData();
rtl::Reference<OpenGLContext> pContext = pSVData->maGDIData.mpLastContext;
- OpenGLFramebuffer* pFramebuffer;
-
- pFramebuffer = pContext->AcquireFramebuffer( *this );
- glReadPixels( maRect.Left(), mpImpl->mnHeight - maRect.Top(), GetWidth(), GetHeight(), nFormat, nType, pData );
- OpenGLContext::ReleaseFramebuffer( pFramebuffer );
- CHECK_GL_ERROR();
+ OpenGLFramebuffer* pFramebuffer = pContext->AcquireFramebuffer(*this);
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ glReadPixels(nX, nY, nWidth, nHeight, nFormat, nType, pData);
+ OpenGLContext::ReleaseFramebuffer(pFramebuffer);
}
- Unbind();
CHECK_GL_ERROR();
}