From 0a1746e942224851b584f5902d7b1e0ca496fdab Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Mon, 28 Apr 2014 15:42:32 +0200 Subject: avmedia: make OpenGL window render model when play button is pushed. Redraw player window (call update) when Paint() is called on its parent. Use a temp variable to save playing state. Change-Id: I3d9b716c7f77587d98e4c06dca6d43a7dc8e32dd --- avmedia/source/opengl/oglplayer.cxx | 5 ++++- avmedia/source/opengl/oglplayer.hxx | 1 + avmedia/source/opengl/oglwindow.cxx | 9 +++++---- avmedia/source/viewer/mediawindow_impl.cxx | 9 ++++++--- 4 files changed, 16 insertions(+), 8 deletions(-) (limited to 'avmedia') diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx index 3200f16bdd15..a0a27b01328e 100644 --- a/avmedia/source/opengl/oglplayer.cxx +++ b/avmedia/source/opengl/oglplayer.cxx @@ -24,6 +24,7 @@ namespace avmedia { namespace ogl { OGLPlayer::OGLPlayer() : Player_BASE(m_aMutex) + , m_bIsPlayingTmp(false) { } @@ -100,18 +101,20 @@ void SAL_CALL OGLPlayer::start() throw ( uno::RuntimeException, std::exception ) { osl::MutexGuard aGuard(m_aMutex); gltf_animation_start(m_pHandle); + m_bIsPlayingTmp = true; } void SAL_CALL OGLPlayer::stop() throw ( uno::RuntimeException, std::exception ) { osl::MutexGuard aGuard(m_aMutex); gltf_animation_stop(m_pHandle); + m_bIsPlayingTmp = false; } sal_Bool SAL_CALL OGLPlayer::isPlaying() throw ( uno::RuntimeException, std::exception ) { osl::MutexGuard aGuard(m_aMutex); - return (sal_Bool)gltf_animation_is_playing(m_pHandle); + return m_bIsPlayingTmp; //(sal_Bool)gltf_animation_is_playing(m_pHandle) } double SAL_CALL OGLPlayer::getDuration() throw ( uno::RuntimeException, std::exception ) diff --git a/avmedia/source/opengl/oglplayer.hxx b/avmedia/source/opengl/oglplayer.hxx index 1f1efce2440d..6d7077ac8283 100644 --- a/avmedia/source/opengl/oglplayer.hxx +++ b/avmedia/source/opengl/oglplayer.hxx @@ -58,6 +58,7 @@ private: OUString m_sURL; glTFHandle* m_pHandle; OpenGLContext m_aContext; + bool m_bIsPlayingTmp; // Temporarly while libgltf does not implement the corresponding methods }; } // namespace ogl diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx index 04c00e0bfaad..b67456250e46 100644 --- a/avmedia/source/opengl/oglwindow.cxx +++ b/avmedia/source/opengl/oglwindow.cxx @@ -28,6 +28,10 @@ OGLWindow::~OGLWindow() void SAL_CALL OGLWindow::update() throw (css::uno::RuntimeException, std::exception) { + m_pContext->makeCurrent(); + gltf_renderer_set_content(m_pHandle); + gltf_renderer(m_pHandle); + m_pContext->swapBuffers(); } sal_Bool SAL_CALL OGLWindow::setZoomLevel( css::media::ZoomLevel eZoomLevel ) throw (css::uno::RuntimeException, std::exception) @@ -100,10 +104,7 @@ void SAL_CALL OGLWindow::setPosSize( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidt m_pHandle->viewport.height = nHeight; if( m_bVisible ) { - m_pContext->makeCurrent(); - gltf_renderer_set_content(m_pHandle); - gltf_renderer(m_pHandle); - m_pContext->swapBuffers(); + update(); } } } diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index 87d61cb3e736..46900ede13e9 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -563,8 +563,6 @@ void MediaWindowImpl::onURLChanged() void MediaWindowImpl::setPosSize( const Rectangle& rRect ) { SetPosSizePixel( rRect.TopLeft(), rRect.GetSize() ); - if( mxPlayerWindow.is() ) - mxPlayerWindow->setPosSize( 0, 0, rRect.GetSize().Width(), rRect.GetSize().Height(), 0 ); } @@ -610,9 +608,11 @@ void MediaWindowImpl::Resize() aPlayerWindowSize.Height() = ( nControlY - ( nOffset << 1 ) ); mpMediaWindowControl->SetPosSizePixel( Point( nOffset, nControlY ), Size( aCurSize.Width() - ( nOffset << 1 ), nControlHeight ) ); } - if( mpChildWindow ) mpChildWindow->SetPosSizePixel( Point( 0, 0 ), aPlayerWindowSize ); + + if( mxPlayerWindow.is() ) + mxPlayerWindow->setPosSize( 0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0 ); } @@ -648,6 +648,9 @@ void MediaWindowImpl::StateChanged( StateChangedType eType ) void MediaWindowImpl::Paint( const Rectangle& ) { + if( mxPlayerWindow.is() ) + mxPlayerWindow->update(); + BitmapEx* pLogo = NULL; if( !mxPlayer.is() ) -- cgit v1.2.3