diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-09-16 13:47:47 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-09-16 14:16:36 +0200 |
commit | 0165da09288b5f6573bda114af664a26557fad8a (patch) | |
tree | 66078063434851f3a1f4dcdc20719746d9ec69d1 /vcl/opengl | |
parent | 4823b6d4e989943c31e20027564ab4eca43f6f8d (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
Diffstat (limited to 'vcl/opengl')
-rw-r--r-- | vcl/opengl/texture.cxx | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx index 9b3c60592ea5..c0373cc46a5a 100644 --- a/vcl/opengl/texture.cxx +++ b/vcl/opengl/texture.cxx @@ -361,30 +361,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(); } |