Kaydet (Commit) 4c41c030 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Andras Timar

tdf#118860 svx opengl: avoid SalBitmap creation without solar mutex

The bugdoc has 2 slides. When switching to the second slide, the graphic
is loaded in the background, but OpenGLSalBitmap::Create() can't work
correctly if the caller doesn't own the solar mutex.

This already asserts in OpenGLContext::prepareForYield() in a less
obvious way.

Focus on the correctness, so just hold the solar mutex during the whole
ImportGrpahic() call. If it turns out that the purpose of running this
on a thread is to avoid synchronous network traffic, then the data could
be first copied to a memory stream, and only then take the lock + import
the graphic.

(cherry picked from commit 919ccaba)

Change-Id: I88203c12b4e7a5f2b689928c01e2ba953c5b13c5
Reviewed-on: https://gerrit.libreoffice.org/58126
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 2038ab9d)
üst 59967690
...@@ -94,6 +94,9 @@ const Graphic ImpLoadLinkedGraphic( const OUString& aFileName, const OUString& a ...@@ -94,6 +94,9 @@ const Graphic ImpLoadLinkedGraphic( const OUString& aFileName, const OUString& a
aFilterData[ 0 ].Name = "CreateNativeLink"; aFilterData[ 0 ].Name = "CreateNativeLink";
aFilterData[ 0 ].Value <<= true; aFilterData[ 0 ].Value <<= true;
// Need to own the solar mutex while creating a SalBitmap.
SolarMutexGuard aGuard;
// #i123042# for e.g SVG the path is needed, so hand it over here. I have no real idea // #i123042# for e.g SVG the path is needed, so hand it over here. I have no real idea
// what consequences this may have; maybe this is not handed over by purpose here. Not // what consequences this may have; maybe this is not handed over by purpose here. Not
// handing it over means that any GraphicFormat that internally needs a path as base // handing it over means that any GraphicFormat that internally needs a path as base
......
...@@ -117,6 +117,7 @@ OpenGLSalBitmap::~OpenGLSalBitmap() ...@@ -117,6 +117,7 @@ OpenGLSalBitmap::~OpenGLSalBitmap()
bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight ) bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight )
{ {
DBG_TESTSOLARMUTEX();
static const BitmapPalette aEmptyPalette; static const BitmapPalette aEmptyPalette;
OpenGLVCLContextZone aContextZone; OpenGLVCLContextZone aContextZone;
...@@ -160,6 +161,7 @@ bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long ...@@ -160,6 +161,7 @@ bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long
bool OpenGLSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapPalette& rBitmapPalette ) bool OpenGLSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapPalette& rBitmapPalette )
{ {
DBG_TESTSOLARMUTEX();
OpenGLVCLContextZone aContextZone; OpenGLVCLContextZone aContextZone;
Destroy(); Destroy();
...@@ -185,16 +187,19 @@ bool OpenGLSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapP ...@@ -185,16 +187,19 @@ bool OpenGLSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapP
bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp ) bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp )
{ {
DBG_TESTSOLARMUTEX();
return Create( rSalBmp, rSalBmp.GetBitCount() ); return Create( rSalBmp, rSalBmp.GetBitCount() );
} }
bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics )
{ {
DBG_TESTSOLARMUTEX();
return Create( rSalBmp, pGraphics ? pGraphics->GetBitCount() : rSalBmp.GetBitCount() ); return Create( rSalBmp, pGraphics ? pGraphics->GetBitCount() : rSalBmp.GetBitCount() );
} }
bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ) bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount )
{ {
DBG_TESTSOLARMUTEX();
OpenGLZone aZone; OpenGLZone aZone;
// check that carefully only in the debug mode // check that carefully only in the debug mode
...@@ -233,6 +238,7 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ...@@ -233,6 +238,7 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
bool OpenGLSalBitmap::Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& /*xBitmapCanvas*/, Size& /*rSize*/, bool /*bMask*/ ) bool OpenGLSalBitmap::Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& /*xBitmapCanvas*/, Size& /*rSize*/, bool /*bMask*/ )
{ {
DBG_TESTSOLARMUTEX();
// TODO Is this method needed? // TODO Is this method needed?
return false; return false;
} }
......
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