summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-11-18 20:21:07 +0000
committerMichael Meeks <michael.meeks@collabora.com>2014-11-18 20:21:07 +0000
commit36afb0e9557f1a600cd0fba83076b0e6b61503b5 (patch)
treea3d20ba1ed7b95389db1444338e855f3eb44133f
parentvcl: Make sure the texture unit is the right one before binding (diff)
downloadcore-36afb0e9557f1a600cd0fba83076b0e6b61503b5.tar.gz
core-36afb0e9557f1a600cd0fba83076b0e6b61503b5.zip
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
-rw-r--r--vcl/inc/opengl/salbmp.hxx4
-rw-r--r--vcl/opengl/gdiimpl.cxx2
-rw-r--r--vcl/opengl/salbmp.cxx21
-rw-r--r--vcl/opengl/scale.cxx2
4 files changed, 15 insertions, 14 deletions
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index c8626729a63c..972fee067e0e 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -39,7 +39,6 @@ class BitmapPalette;
class VCL_PLUGIN_PUBLIC OpenGLSalBitmap : public SalBitmap
{
private:
- OpenGLContext* mpContext;
OpenGLTexture maTexture;
bool mbDirtyTexture;
BitmapPalette maPalette;
@@ -83,8 +82,9 @@ 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;
+ OpenGLContext* GetBitmapContext() const;
private:
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 5883e7c8a0a7..a255804752fe 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1459,7 +1459,7 @@ SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long
SAL_INFO( "vcl.opengl", "::getBitmap " << nX << "," << nY <<
" " << nWidth << "x" << nHeight );
PreDraw();
- if( !pBitmap->Create( maContext, maOffscreenTex, nX, nY, nWidth, nHeight ) )
+ if( !pBitmap->Create( maOffscreenTex, nX, nY, nWidth, nHeight ) )
{
delete pBitmap;
pBitmap = NULL;
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index c664d7e7e8fd..155757a0b49d 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -35,8 +35,7 @@ static bool isValidBitCount( sal_uInt16 nBitCount )
}
OpenGLSalBitmap::OpenGLSalBitmap()
-: mpContext(NULL)
-, mbDirtyTexture(true)
+: mbDirtyTexture(true)
, mnBits(0)
, mnBytesPerRow(0)
, mnWidth(0)
@@ -59,14 +58,13 @@ OpenGLSalBitmap::~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;
Destroy();
SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO: [" << nX << ", " << nY << "] " << nWidth << "x" << nHeight );
- mpContext = &rContext;
mnWidth = nWidth;
mnHeight = nHeight;
mnBufWidth = 0;
@@ -131,7 +129,6 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
maPalette = rSourceBitmap.maPalette;
// execute any pending operations on the source bitmap
maTexture = rSourceBitmap.GetTexture();
- mpContext = rSourceBitmap.mpContext;
mbDirtyTexture = false;
maUserBuffer = rSourceBitmap.maUserBuffer;
@@ -468,13 +465,17 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const
return mnBits;
}
-void OpenGLSalBitmap::makeCurrent()
+OpenGLContext* OpenGLSalBitmap::GetBitmapContext() const
{
- if (!mpContext || !mpContext->isInitialized())
- mpContext = ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
+ return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
+}
- assert(mpContext && "Couldn't get default OpenGL context provider");
- mpContext->makeCurrent();
+void OpenGLSalBitmap::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*/ )
diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx
index c4e32db18a0e..9c52cc271f48 100644
--- a/vcl/opengl/scale.cxx
+++ b/vcl/opengl/scale.cxx
@@ -314,7 +314,7 @@ bool OpenGLSalBitmap::Scale( const double& rScaleX, const double& rScaleY, sal_u
nScaleFlag == BMP_SCALE_LANCZOS )
{
//TODO maUserBuffer.reset();
- if( mpContext == NULL )
+ if( GetBitmapContext() == NULL )
{
SAL_INFO( "vcl.opengl", "Add ScaleOp to pending operations" );
maPendingOps.push_back( new ScaleOp( this, rScaleX, rScaleY, nScaleFlag ) );