Kaydet (Commit) fa6a174b authored tarafından Michael Meeks's avatar Michael Meeks

vcl: since we share Bitmaps across all GLContexts simplify lifecycle.

~X11SalVirtualDevice() was destroying X resources referred to by
OpenGLSalBitmap's mpContext, which were subsequently accessed by
Bitmap::AcquireReadAccess on the floating Bitmap. Better to use the
default window's GLContext for all bitmap operations.

Change-Id: I9009980e791cff1a1f36d626592d72c7a32efd39
üst 721fb110
...@@ -39,7 +39,6 @@ class BitmapPalette; ...@@ -39,7 +39,6 @@ class BitmapPalette;
class VCL_PLUGIN_PUBLIC OpenGLSalBitmap : public SalBitmap class VCL_PLUGIN_PUBLIC OpenGLSalBitmap : public SalBitmap
{ {
private: private:
OpenGLContext* mpContext;
OpenGLTexture maTexture; OpenGLTexture maTexture;
bool mbDirtyTexture; bool mbDirtyTexture;
BitmapPalette maPalette; BitmapPalette maPalette;
...@@ -83,8 +82,9 @@ public: ...@@ -83,8 +82,9 @@ public:
public: public:
bool Create( OpenGLContext& rContext, const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight ); bool Create( const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight );
OpenGLTexture& GetTexture() const; OpenGLTexture& GetTexture() const;
OpenGLContext* GetBitmapContext() const;
private: private:
......
...@@ -1391,7 +1391,7 @@ SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long ...@@ -1391,7 +1391,7 @@ SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long
SAL_INFO( "vcl.opengl", "::getBitmap " << nX << "," << nY << SAL_INFO( "vcl.opengl", "::getBitmap " << nX << "," << nY <<
" " << nWidth << "x" << nHeight ); " " << nWidth << "x" << nHeight );
PreDraw(); PreDraw();
if( !pBitmap->Create( maContext, maOffscreenTex, nX, nY, nWidth, nHeight ) ) if( !pBitmap->Create( maOffscreenTex, nX, nY, nWidth, nHeight ) )
{ {
delete pBitmap; delete pBitmap;
pBitmap = NULL; pBitmap = NULL;
......
...@@ -35,8 +35,7 @@ static bool isValidBitCount( sal_uInt16 nBitCount ) ...@@ -35,8 +35,7 @@ static bool isValidBitCount( sal_uInt16 nBitCount )
} }
OpenGLSalBitmap::OpenGLSalBitmap() OpenGLSalBitmap::OpenGLSalBitmap()
: mpContext(NULL) : mbDirtyTexture(true)
, mbDirtyTexture(true)
, mnBits(0) , mnBits(0)
, mnBytesPerRow(0) , mnBytesPerRow(0)
, mnWidth(0) , mnWidth(0)
...@@ -59,14 +58,13 @@ OpenGLSalBitmap::~OpenGLSalBitmap() ...@@ -59,14 +58,13 @@ OpenGLSalBitmap::~OpenGLSalBitmap()
SAL_INFO( "vcl.opengl", "~OpenGLSalBitmap" ); SAL_INFO( "vcl.opengl", "~OpenGLSalBitmap" );
} }
bool OpenGLSalBitmap::Create( OpenGLContext& rContext, 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 )
{ {
static const BitmapPalette aEmptyPalette; static const BitmapPalette aEmptyPalette;
Destroy(); Destroy();
SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO: [" << nX << ", " << nY << "] " << nWidth << "x" << nHeight ); SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO: [" << nX << ", " << nY << "] " << nWidth << "x" << nHeight );
mpContext = &rContext;
mnWidth = nWidth; mnWidth = nWidth;
mnHeight = nHeight; mnHeight = nHeight;
mnBufWidth = 0; mnBufWidth = 0;
...@@ -131,7 +129,6 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ...@@ -131,7 +129,6 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
maPalette = rSourceBitmap.maPalette; maPalette = rSourceBitmap.maPalette;
// execute any pending operations on the source bitmap // execute any pending operations on the source bitmap
maTexture = rSourceBitmap.GetTexture(); maTexture = rSourceBitmap.GetTexture();
mpContext = rSourceBitmap.mpContext;
mbDirtyTexture = false; mbDirtyTexture = false;
maUserBuffer = rSourceBitmap.maUserBuffer; maUserBuffer = rSourceBitmap.maUserBuffer;
...@@ -468,13 +465,17 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const ...@@ -468,13 +465,17 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const
return mnBits; return mnBits;
} }
void OpenGLSalBitmap::makeCurrent() OpenGLContext* OpenGLSalBitmap::GetBitmapContext() const
{ {
if (!mpContext || !mpContext->isInitialized()) return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
mpContext = ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext(); }
assert(mpContext && "Couldn't get default OpenGL context provider"); void OpenGLSalBitmap::makeCurrent()
mpContext->makeCurrent(); {
// Always use the default window's context for bitmap
OpenGLContext* pContext = GetBitmapContext();
assert(pContext && "Couldn't get default OpenGL context provider");
pContext->makeCurrent();
} }
BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ ) BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
......
...@@ -312,7 +312,7 @@ bool OpenGLSalBitmap::Scale( const double& rScaleX, const double& rScaleY, sal_u ...@@ -312,7 +312,7 @@ bool OpenGLSalBitmap::Scale( const double& rScaleX, const double& rScaleY, sal_u
nScaleFlag == BMP_SCALE_LANCZOS ) nScaleFlag == BMP_SCALE_LANCZOS )
{ {
//TODO maUserBuffer.reset(); //TODO maUserBuffer.reset();
if( mpContext == NULL ) if( GetBitmapContext() == NULL )
{ {
SAL_INFO( "vcl.opengl", "Add ScaleOp to pending operations" ); SAL_INFO( "vcl.opengl", "Add ScaleOp to pending operations" );
maPendingOps.push_back( new ScaleOp( this, rScaleX, rScaleY, nScaleFlag ) ); maPendingOps.push_back( new ScaleOp( this, rScaleX, rScaleY, nScaleFlag ) );
......
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