summaryrefslogtreecommitdiffstats
path: root/canvas
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-09-08 11:46:13 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-09-08 13:04:02 +0100
commit56900a441de1d4cc896ad1e36a44622ed1598fad (patch)
treeae176203c003dce23d188dbd198359da802d728f /canvas
parenttdf#94006 - re-factor to use rtl::Reference for OpenGLContexts. (diff)
downloadcore-56900a441de1d4cc896ad1e36a44622ed1598fad.tar.gz
core-56900a441de1d4cc896ad1e36a44622ed1598fad.zip
tdf#94006 - fix OpenGLContext mis-use in several places.
gltf rendering, OpenGL canvas, GL transitions & GL capable (charts) Avoid GLX operations on un-initialized contexts. Change-Id: I7f523640f66ab656896181e5c865879234f6640e
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/opengl/ogl_spritedevicehelper.cxx33
-rw-r--r--canvas/source/opengl/ogl_spritedevicehelper.hxx2
2 files changed, 18 insertions, 17 deletions
diff --git a/canvas/source/opengl/ogl_spritedevicehelper.cxx b/canvas/source/opengl/ogl_spritedevicehelper.cxx
index 3c58b4051bb5..ab7e76493f23 100644
--- a/canvas/source/opengl/ogl_spritedevicehelper.cxx
+++ b/canvas/source/opengl/ogl_spritedevicehelper.cxx
@@ -85,7 +85,8 @@ namespace oglcanvas
mnRadialTwoColorGradientProgram(0),
mnRadialMultiColorGradientProgram(0),
mnRectangularTwoColorGradientProgram(0),
- mnRectangularMultiColorGradientProgram(0)
+ mnRectangularMultiColorGradientProgram(0),
+ mxContext(OpenGLContext::Create())
{}
SpriteDeviceHelper::~SpriteDeviceHelper()
@@ -102,8 +103,8 @@ namespace oglcanvas
VCLUnoHelper::GetInterface(&rWindow),
uno::UNO_QUERY_THROW) );
- maContext.requestLegacyContext();
- maContext.init(&rWindow);
+ mxContext->requestLegacyContext();
+ mxContext->init(&rWindow);
// init window context
initContext();
@@ -125,7 +126,7 @@ namespace oglcanvas
mnRectangularTwoColorGradientProgram =
OpenGLHelper::LoadShaders("dummyVertexShader", "rectangularTwoColorGradientFragmentShader");
- maContext.makeCurrent();
+ mxContext->makeCurrent();
notifySizeUpdate(rViewArea);
// TODO(E3): check for GL_ARB_imaging extension
@@ -138,7 +139,7 @@ namespace oglcanvas
mpDevice = NULL;
mpTextureCache.reset();
- if( maContext.isInitialized() )
+ if( mxContext->isInitialized() )
{
glDeleteProgram( mnRectangularTwoColorGradientProgram );
glDeleteProgram( mnRectangularMultiColorGradientProgram );
@@ -151,11 +152,11 @@ namespace oglcanvas
geometry::RealSize2D SpriteDeviceHelper::getPhysicalResolution()
{
- if( !maContext.isInitialized() )
+ if( !mxContext->isInitialized() )
return ::canvas::tools::createInfiniteSize2D(); // we're disposed
// Map a one-by-one millimeter box to pixel
- SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ SystemChildWindow* pChildWindow = mxContext->getChildWindow();
const MapMode aOldMapMode( pChildWindow->GetMapMode() );
pChildWindow->SetMapMode( MapMode(MAP_MM) );
const Size aPixelSize( pChildWindow->LogicToPixel(Size(1,1)) );
@@ -166,11 +167,11 @@ namespace oglcanvas
geometry::RealSize2D SpriteDeviceHelper::getPhysicalSize()
{
- if( !maContext.isInitialized() )
+ if( !mxContext->isInitialized() )
return ::canvas::tools::createInfiniteSize2D(); // we're disposed
// Map the pixel dimensions of the output window to millimeter
- SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ SystemChildWindow* pChildWindow = mxContext->getChildWindow();
const MapMode aOldMapMode( pChildWindow->GetMapMode() );
pChildWindow->SetMapMode( MapMode(MAP_MM) );
const Size aLogSize( pChildWindow->PixelToLogic(pChildWindow->GetOutputSizePixel()) );
@@ -271,13 +272,13 @@ namespace oglcanvas
bool SpriteDeviceHelper::showBuffer( bool bIsVisible, bool /*bUpdateAll*/ )
{
// hidden or disposed?
- if( !bIsVisible || !maContext.isInitialized() || !mpSpriteCanvas )
+ if( !bIsVisible || !mxContext->isInitialized() || !mpSpriteCanvas )
return false;
if( !activateWindowContext() )
return false;
- SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ SystemChildWindow* pChildWindow = mxContext->getChildWindow();
const ::Size& rOutputSize = pChildWindow->GetSizePixel();
initTransformation(rOutputSize);
@@ -326,7 +327,7 @@ namespace oglcanvas
unx::glXWaitGL();
XSync( reinterpret_cast<unx::Display*>(mpDisplay), false );
*/
- maContext.swapBuffers();
+ mxContext->swapBuffers();
// flush texture cache, such that it does not build up
// indefinitely.
@@ -350,7 +351,7 @@ namespace oglcanvas
uno::Any SpriteDeviceHelper::getDeviceHandle() const
{
- const SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ const SystemChildWindow* pChildWindow = mxContext->getChildWindow();
return uno::makeAny( reinterpret_cast< sal_Int64 >(pChildWindow) );
}
@@ -369,9 +370,9 @@ namespace oglcanvas
void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds )
{
- if( maContext.isInitialized() )
+ if( mxContext->isInitialized() )
{
- SystemChildWindow* pChildWindow = maContext.getChildWindow();
+ SystemChildWindow* pChildWindow = mxContext->getChildWindow();
pChildWindow->setPosSizePixel(
0,0,rBounds.Width,rBounds.Height);
}
@@ -506,7 +507,7 @@ namespace oglcanvas
bool SpriteDeviceHelper::activateWindowContext()
{
- maContext.makeCurrent();
+ mxContext->makeCurrent();
return true;
}
diff --git a/canvas/source/opengl/ogl_spritedevicehelper.hxx b/canvas/source/opengl/ogl_spritedevicehelper.hxx
index ba85f542fbc5..2a9914506aeb 100644
--- a/canvas/source/opengl/ogl_spritedevicehelper.hxx
+++ b/canvas/source/opengl/ogl_spritedevicehelper.hxx
@@ -140,7 +140,7 @@ namespace oglcanvas
unsigned int mnRectangularTwoColorGradientProgram;
unsigned int mnRectangularMultiColorGradientProgram;
- OpenGLContext maContext;
+ rtl::Reference<OpenGLContext> mxContext;
};
}