Kaydet (Commit) e299dd1d authored tarafından Luboš Luňák's avatar Luboš Luňák Kaydeden (comit) Tomaž Vajngerl

make OpenGLSalBitmap deallocate user data properly

In OpenGLSalBitmap::AcquireBuffer(), if ReadTexture() failed, then
the data from AllocateUserData() didn't get deallocated and a next
call to OpenGLSalBitmap::AcquireBuffer() skipped the whole block
because it assumed the data was valid. Triggered while fixing tdf#116888.

Change-Id: Ibfe5c42d6b18748ca649d6b4242ef268c1b13a71
Reviewed-on: https://gerrit.libreoffice.org/69746
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst df82c812
...@@ -93,6 +93,7 @@ private: ...@@ -93,6 +93,7 @@ private:
GLuint CreateTexture(); GLuint CreateTexture();
bool AllocateUserData(); bool AllocateUserData();
void DeallocateUserData();
bool ReadTexture(); bool ReadTexture();
private: private:
......
...@@ -258,7 +258,7 @@ void OpenGLSalBitmap::Destroy() ...@@ -258,7 +258,7 @@ void OpenGLSalBitmap::Destroy()
VCL_GL_INFO("Destroy OpenGLSalBitmap texture:" << maTexture.Id()); VCL_GL_INFO("Destroy OpenGLSalBitmap texture:" << maTexture.Id());
maTexture = OpenGLTexture(); maTexture = OpenGLTexture();
mpUserBuffer.reset(); DeallocateUserData();
} }
bool OpenGLSalBitmap::AllocateUserData() bool OpenGLSalBitmap::AllocateUserData()
...@@ -292,8 +292,7 @@ bool OpenGLSalBitmap::AllocateUserData() ...@@ -292,8 +292,7 @@ bool OpenGLSalBitmap::AllocateUserData()
if (!alloc) if (!alloc)
{ {
SAL_WARN("vcl.opengl", "bad alloc " << mnBytesPerRow << "x" << mnHeight); SAL_WARN("vcl.opengl", "bad alloc " << mnBytesPerRow << "x" << mnHeight);
mpUserBuffer.reset(); DeallocateUserData();
mnBytesPerRow = 0;
} }
#ifdef DBG_UTIL #ifdef DBG_UTIL
else else
...@@ -306,6 +305,12 @@ bool OpenGLSalBitmap::AllocateUserData() ...@@ -306,6 +305,12 @@ bool OpenGLSalBitmap::AllocateUserData()
return mpUserBuffer != nullptr; return mpUserBuffer != nullptr;
} }
void OpenGLSalBitmap::DeallocateUserData()
{
mpUserBuffer.reset();
mnBytesPerRow = 0;
}
namespace { namespace {
class ImplPixelFormat class ImplPixelFormat
...@@ -763,7 +768,10 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode ) ...@@ -763,7 +768,10 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode )
if( !AllocateUserData() ) if( !AllocateUserData() )
return nullptr; return nullptr;
if( maTexture && !ReadTexture() ) if( maTexture && !ReadTexture() )
{
DeallocateUserData();
return nullptr; return nullptr;
}
} }
} }
...@@ -870,6 +878,7 @@ bool OpenGLSalBitmap::GetSystemData( BitmapSystemData& /*rData*/ ) ...@@ -870,6 +878,7 @@ bool OpenGLSalBitmap::GetSystemData( BitmapSystemData& /*rData*/ )
if( !AllocateUserData() || !ReadTexture() ) if( !AllocateUserData() || !ReadTexture() )
{ {
rBitmap.ReleaseBuffer( pBuffer, false ); rBitmap.ReleaseBuffer( pBuffer, false );
DeallocateUserData();
return false; return false;
} }
} }
...@@ -955,7 +964,7 @@ bool OpenGLSalBitmap::ConvertToGreyscale() ...@@ -955,7 +964,7 @@ bool OpenGLSalBitmap::ConvertToGreyscale()
maPalette = Bitmap::GetGreyPalette(256); maPalette = Bitmap::GetGreyPalette(256);
// AllocateUserData will handle the rest. // AllocateUserData will handle the rest.
mpUserBuffer.reset(); DeallocateUserData();
mbDirtyTexture = false; mbDirtyTexture = false;
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