Kaydet (Commit) 0165da09 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

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
üst 4823b6d4
...@@ -361,30 +361,32 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData ) ...@@ -361,30 +361,32 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData )
return; return;
} }
Bind();
glPixelStorei( GL_PACK_ALIGNMENT, 1 );
VCL_GL_INFO( "vcl.opengl", "Reading texture " << Id() << " " << GetWidth() << "x" << GetHeight() ); VCL_GL_INFO( "vcl.opengl", "Reading texture " << Id() << " " << GetWidth() << "x" << GetHeight() );
if( GetWidth() == mpImpl->mnWidth && GetHeight() == mpImpl->mnHeight ) if( GetWidth() == mpImpl->mnWidth && GetHeight() == mpImpl->mnHeight )
{ {
Bind();
glPixelStorei( GL_PACK_ALIGNMENT, 1 );
// XXX: Call not available with GLES 2.0 // XXX: Call not available with GLES 2.0
glGetTexImage( GL_TEXTURE_2D, 0, nFormat, nType, pData ); glGetTexImage( GL_TEXTURE_2D, 0, nFormat, nType, pData );
Unbind();
} }
else else
{ {
long nWidth = maRect.GetWidth();
long nHeight = maRect.GetHeight();
long nX = maRect.Left();
long nY = mpImpl->mnHeight - maRect.Top() - nHeight;
// Retrieve current context // Retrieve current context
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
rtl::Reference<OpenGLContext> pContext = pSVData->maGDIData.mpLastContext; rtl::Reference<OpenGLContext> pContext = pSVData->maGDIData.mpLastContext;
OpenGLFramebuffer* pFramebuffer; OpenGLFramebuffer* pFramebuffer = pContext->AcquireFramebuffer(*this);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
pFramebuffer = pContext->AcquireFramebuffer( *this ); glReadPixels(nX, nY, nWidth, nHeight, nFormat, nType, pData);
glReadPixels( maRect.Left(), mpImpl->mnHeight - maRect.Top(), GetWidth(), GetHeight(), nFormat, nType, pData ); OpenGLContext::ReleaseFramebuffer(pFramebuffer);
OpenGLContext::ReleaseFramebuffer( pFramebuffer );
CHECK_GL_ERROR();
} }
Unbind();
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment