diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-09-08 11:46:13 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-09-08 13:04:02 +0100 |
commit | 56900a441de1d4cc896ad1e36a44622ed1598fad (patch) | |
tree | ae176203c003dce23d188dbd198359da802d728f /avmedia | |
parent | 2456cf8306be22e32130e789ab939c059e5e79e5 (diff) |
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 'avmedia')
-rw-r--r-- | avmedia/source/opengl/oglplayer.cxx | 15 | ||||
-rw-r--r-- | avmedia/source/opengl/oglplayer.hxx | 2 | ||||
-rw-r--r-- | avmedia/source/opengl/oglwindow.cxx | 10 | ||||
-rw-r--r-- | avmedia/source/opengl/oglwindow.hxx | 4 |
4 files changed, 16 insertions, 15 deletions
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx index a8a9f7d56db2..c7bb7fb1adf8 100644 --- a/avmedia/source/opengl/oglplayer.cxx +++ b/avmedia/source/opengl/oglplayer.cxx @@ -28,6 +28,7 @@ namespace avmedia { namespace ogl { OGLPlayer::OGLPlayer() : Player_BASE(m_aMutex) , m_pHandle(NULL) + , m_xContext(OpenGLContext::Create()) , m_pOGLWindow(NULL) , m_bIsRendering(false) { @@ -38,7 +39,7 @@ OGLPlayer::~OGLPlayer() osl::MutexGuard aGuard(m_aMutex); if( m_pHandle ) { - m_aContext.makeCurrent(); + m_xContext->makeCurrent(); gltf_renderer_release(m_pHandle); } releaseInputFiles(); @@ -258,13 +259,13 @@ uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( c } assert(pChildWindow->GetParent()); - if( !m_aContext.init(pChildWindow) ) + if( !m_xContext->init(pChildWindow) ) { SAL_WARN("avmedia.opengl", "Context initialization failed"); return uno::Reference< media::XPlayerWindow >(); } - if( !m_aContext.supportMultiSampling() ) + if( !m_xContext->supportMultiSampling() ) { SAL_WARN("avmedia.opengl", "Context does not support multisampling!"); return uno::Reference< media::XPlayerWindow >(); @@ -277,7 +278,7 @@ uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( c } Size aSize = pChildWindow->GetSizePixel(); - m_aContext.setWinSize(aSize); + m_xContext->setWinSize(aSize); m_pHandle->viewport.x = 0; m_pHandle->viewport.y = 0; m_pHandle->viewport.width = aSize.Width(); @@ -294,7 +295,7 @@ uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( c // The background color is white by default, but we need to separate the // OpenGL window from the main window so set background color to grey glClearColor(0.5f, 0.5f, 0.5f, 0.5f); - m_pOGLWindow = new OGLWindow(*m_pHandle, m_aContext, *pChildWindow->GetParent()); + m_pOGLWindow = new OGLWindow(*m_pHandle, m_xContext, *pChildWindow->GetParent()); return uno::Reference< media::XPlayerWindow >( m_pOGLWindow ); } @@ -304,13 +305,13 @@ uno::Reference< media::XFrameGrabber > SAL_CALL OGLPlayer::createFrameGrabber() osl::MutexGuard aGuard(m_aMutex); assert(m_pHandle); - if( !m_aContext.init() ) + if( !m_xContext->init() ) { SAL_WARN("avmedia.opengl", "Offscreen context initialization failed"); return uno::Reference< media::XFrameGrabber >(); } - if( !m_aContext.supportMultiSampling() ) + if( !m_xContext->supportMultiSampling() ) { SAL_WARN("avmedia.opengl", "Context does not support multisampling!"); return uno::Reference< media::XFrameGrabber >(); diff --git a/avmedia/source/opengl/oglplayer.hxx b/avmedia/source/opengl/oglplayer.hxx index 64f85400e071..1a90f7bf1faa 100644 --- a/avmedia/source/opengl/oglplayer.hxx +++ b/avmedia/source/opengl/oglplayer.hxx @@ -68,7 +68,7 @@ private: libgltf::glTFHandle* m_pHandle; std::vector<libgltf::glTFFile> m_vInputFiles; - OpenGLContext m_aContext; + rtl::Reference<OpenGLContext> m_xContext; AutoTimer m_aTimer; OGLWindow* m_pOGLWindow; bool m_bIsRendering; diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx index 956ce967d0b1..fe637f882c46 100644 --- a/avmedia/source/opengl/oglwindow.cxx +++ b/avmedia/source/opengl/oglwindow.cxx @@ -15,9 +15,9 @@ using namespace libgltf; namespace avmedia { namespace ogl { -OGLWindow::OGLWindow( glTFHandle& rHandle, OpenGLContext& rContext, vcl::Window& rEventHandlerParent ) +OGLWindow::OGLWindow( glTFHandle& rHandle, const rtl::Reference<OpenGLContext> &rContext, vcl::Window& rEventHandlerParent ) : m_rHandle( rHandle ) - , m_rContext( rContext ) + , m_xContext( rContext ) , m_rEventHandler( rEventHandlerParent ) , m_bVisible ( false ) , m_aLastMousePos(Point(0,0)) @@ -32,7 +32,7 @@ OGLWindow::~OGLWindow() void SAL_CALL OGLWindow::update() throw (css::uno::RuntimeException, std::exception) { - m_rContext.makeCurrent(); + m_xContext->makeCurrent(); int nRet = gltf_prepare_renderer(&m_rHandle); if( nRet != 0 ) { @@ -41,7 +41,7 @@ void SAL_CALL OGLWindow::update() throw (css::uno::RuntimeException, std::except } gltf_renderer(&m_rHandle); gltf_complete_renderer(&m_rHandle); - m_rContext.swapBuffers(); + m_xContext->swapBuffers(); } sal_Bool SAL_CALL OGLWindow::setZoomLevel( css::media::ZoomLevel /*eZoomLevel*/ ) throw (css::uno::RuntimeException, std::exception) @@ -98,7 +98,7 @@ void SAL_CALL OGLWindow::setPosSize( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidt if( m_rHandle.viewport.x != nX || m_rHandle.viewport.x != nY || m_rHandle.viewport.width != nWidth || m_rHandle.viewport.height != nHeight ) { - m_rContext.setWinSize(Size(nWidth,nHeight)); + m_xContext->setWinSize(Size(nWidth,nHeight)); m_rHandle.viewport.x = nX; m_rHandle.viewport.y = nY; m_rHandle.viewport.width = nWidth; diff --git a/avmedia/source/opengl/oglwindow.hxx b/avmedia/source/opengl/oglwindow.hxx index 9abc30776418..71ca91adf03d 100644 --- a/avmedia/source/opengl/oglwindow.hxx +++ b/avmedia/source/opengl/oglwindow.hxx @@ -27,7 +27,7 @@ namespace avmedia { namespace ogl { class OGLWindow : public ::cppu::WeakImplHelper< css::media::XPlayerWindow, css::lang::XServiceInfo > { public: - OGLWindow( libgltf::glTFHandle& rHandle, OpenGLContext& rContext, vcl::Window& rEventHandlerParent ); + OGLWindow( libgltf::glTFHandle& rHandle, const rtl::Reference<OpenGLContext> & rContext, vcl::Window& rEventHandlerParent ); virtual ~OGLWindow(); virtual void SAL_CALL update() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; @@ -66,7 +66,7 @@ private: DECL_LINK( CameraHandler, VclWindowEvent* ); libgltf::glTFHandle& m_rHandle; - OpenGLContext& m_rContext; + rtl::Reference<OpenGLContext> m_xContext; vcl::Window& m_rEventHandler; bool m_bVisible; |