summaryrefslogtreecommitdiff
path: root/avmedia/source
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-04-27 12:20:13 +0200
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-04-27 12:34:07 +0200
commite112ac81d1c3a91d46ea660ac4e01e6c94ee900e (patch)
tree284226e20c4c25d0b1d04fc0fc4056aa66ffff33 /avmedia/source
parentb5529c8c457f442bfc43305becc0c02d6a09ee80 (diff)
First try to render OpenGL content in a window
Change-Id: Ibb7178330d356806cea2cfc972b361167d5a9340
Diffstat (limited to 'avmedia/source')
-rw-r--r--avmedia/source/opengl/oglplayer.cxx22
-rw-r--r--avmedia/source/opengl/oglplayer.hxx3
-rw-r--r--avmedia/source/opengl/oglwindow.cxx32
-rw-r--r--avmedia/source/opengl/oglwindow.hxx11
-rw-r--r--avmedia/source/viewer/mediawindow_impl.cxx11
5 files changed, 52 insertions, 27 deletions
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index 720825ab151e..9d5f730cbc12 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_bIsPlaying(false)
{
}
@@ -98,19 +99,21 @@ void SAL_CALL OGLPlayer::start() throw ( uno::RuntimeException, std::exception )
{
osl::MutexGuard aGuard(m_aMutex);
// TODO: Start playing of gltf model (see com::sun::star::media::XPlayer)
+ m_bIsPlaying = true;
}
void SAL_CALL OGLPlayer::stop() throw ( uno::RuntimeException, std::exception )
{
osl::MutexGuard aGuard(m_aMutex);
// TODO: Stop playing of gltf model (see com::sun::star::media::XPlayer)
+ m_bIsPlaying = false;
}
sal_Bool SAL_CALL OGLPlayer::isPlaying() throw ( uno::RuntimeException, std::exception )
{
osl::MutexGuard aGuard(m_aMutex);
// TODO: Check whether gltf model is played by now (see com::sun::star::media::XPlayer)
- return false;
+ return m_bIsPlaying;
}
double SAL_CALL OGLPlayer::getDuration() throw ( uno::RuntimeException, std::exception )
@@ -184,11 +187,19 @@ awt::Size SAL_CALL OGLPlayer::getPreferredPlayerWindowSize() throw ( uno::Runtim
return awt::Size( 480, 360 ); // TODO: It will be good for OpenGL too?
}
-uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( const uno::Sequence< uno::Any >& /*aArguments*/ )
+uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( const uno::Sequence< uno::Any >& rArguments )
throw ( uno::RuntimeException, std::exception )
{
osl::MutexGuard aGuard( m_aMutex );
- OGLWindow* pWindow = new OGLWindow(*this);
+
+ if( rArguments.getLength() > 2 )
+ {
+ sal_IntPtr pIntPtr = 0;
+ rArguments[ 2 ] >>= pIntPtr;
+ SystemChildWindow *pChildWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr );
+ m_aContext.init(pChildWindow);
+ }
+ OGLWindow* pWindow = new OGLWindow(m_pHandle, &m_aContext);
return uno::Reference< media::XPlayerWindow >( pWindow );
}
@@ -197,11 +208,10 @@ uno::Reference< media::XFrameGrabber > SAL_CALL OGLPlayer::createFrameGrabber()
{
osl::MutexGuard aGuard(m_aMutex);
m_aContext.init();
- //TODO: Use real values instead of constants.
m_pHandle->viewport.x = 0;
m_pHandle->viewport.y = 0;
- m_pHandle->viewport.width = 800;
- m_pHandle->viewport.height = 600;
+ m_pHandle->viewport.width = getPreferredPlayerWindowSize().Width;
+ m_pHandle->viewport.height = getPreferredPlayerWindowSize().Height;
gltf_renderer_set_content(m_pHandle);
OGLFrameGrabber *pFrameGrabber = new OGLFrameGrabber( m_pHandle );
return uno::Reference< media::XFrameGrabber >( pFrameGrabber );;
diff --git a/avmedia/source/opengl/oglplayer.hxx b/avmedia/source/opengl/oglplayer.hxx
index 2b9b4154b2a6..a40b43d808ac 100644
--- a/avmedia/source/opengl/oglplayer.hxx
+++ b/avmedia/source/opengl/oglplayer.hxx
@@ -47,7 +47,7 @@ public:
virtual void SAL_CALL setMute( sal_Bool bSet ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL isMute() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual com::sun::star::awt::Size SAL_CALL getPreferredPlayerWindowSize() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual com::sun::star::uno::Reference< com::sun::star::media::XPlayerWindow > SAL_CALL createPlayerWindow( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual com::sun::star::uno::Reference< com::sun::star::media::XPlayerWindow > SAL_CALL createPlayerWindow( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& rArguments ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual com::sun::star::uno::Reference< com::sun::star::media::XFrameGrabber > SAL_CALL createFrameGrabber() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -58,6 +58,7 @@ private:
OUString m_sURL;
glTFHandle* m_pHandle;
OpenGLContext m_aContext;
+ bool m_bIsPlaying;
};
} // namespace ogl
diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx
index 3a024ef64aca..6d4788a7e675 100644
--- a/avmedia/source/opengl/oglwindow.cxx
+++ b/avmedia/source/opengl/oglwindow.cxx
@@ -14,11 +14,12 @@ using namespace com::sun::star;
namespace avmedia { namespace ogl {
-OGLWindow::OGLWindow( OGLPlayer& rPlayer )
- : m_rPlayer( rPlayer )
+OGLWindow::OGLWindow( glTFHandle* pHandle, OpenGLContext* pContext )
+ : m_pHandle( pHandle )
+ , m_pContext( pContext )
+ , m_bVisible ( false )
, meZoomLevel( media::ZoomLevel_ORIGINAL )
{
- (void) m_rPlayer;
}
OGLWindow::~OGLWindow()
@@ -86,22 +87,37 @@ void SAL_CALL OGLWindow::removeEventListener( const uno::Reference< lang::XEvent
{
}
-void SAL_CALL OGLWindow::setPosSize( sal_Int32 /*X*/, sal_Int32 /*Y*/, sal_Int32 /*Width*/, sal_Int32 /*Height*/, sal_Int16 /* Flags */ )
+void SAL_CALL OGLWindow::setPosSize( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 /*nFlags*/ )
throw (uno::RuntimeException, std::exception)
{
- // TODO: store size
+ if( !m_bVisible )
+ return;
+
+ if( m_pHandle->viewport.x != nX || m_pHandle->viewport.x != nY ||
+ m_pHandle->viewport.width != nWidth || m_pHandle->viewport.height != nHeight )
+ {
+ m_pContext->setWinSize(Size(nWidth,nHeight));
+ m_pHandle->viewport.x = nX;
+ m_pHandle->viewport.y = nY;
+ m_pHandle->viewport.width = nWidth;
+ m_pHandle->viewport.height = nHeight;
+ gltf_renderer_set_content(m_pHandle);
+ gltf_renderer(m_pHandle);
+ m_pContext->swapBuffers();
+ }
}
awt::Rectangle SAL_CALL OGLWindow::getPosSize()
throw (uno::RuntimeException, std::exception)
{
- // TODO: get size
- return awt::Rectangle();
+ return awt::Rectangle(m_pHandle->viewport.x, m_pHandle->viewport.y,
+ m_pHandle->viewport.width, m_pHandle->viewport.height);
}
-void SAL_CALL OGLWindow::setVisible( sal_Bool )
+void SAL_CALL OGLWindow::setVisible( sal_Bool bSet )
throw (uno::RuntimeException, std::exception)
{
+ m_bVisible = bSet;
}
void SAL_CALL OGLWindow::setEnable( sal_Bool )
diff --git a/avmedia/source/opengl/oglwindow.hxx b/avmedia/source/opengl/oglwindow.hxx
index d373dd1c8e5a..95767c04d52c 100644
--- a/avmedia/source/opengl/oglwindow.hxx
+++ b/avmedia/source/opengl/oglwindow.hxx
@@ -17,13 +17,16 @@
#include <com/sun/star/media/XPlayerWindow.hpp>
#include <com/sun/star/media/ZoomLevel.hpp>
+#include <libgltf.h>
+#include <vcl/opengl/OpenGLContext.hxx>
+
namespace avmedia { namespace ogl {
class OGLWindow : public ::cppu::WeakImplHelper2 < com::sun::star::media::XPlayerWindow,
com::sun::star::lang::XServiceInfo >
{
public:
- OGLWindow( OGLPlayer& rPlayer );
+ OGLWindow( glTFHandle* pHandle, OpenGLContext* pContext );
virtual ~OGLWindow();
virtual void SAL_CALL update() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -39,7 +42,7 @@ public:
virtual void SAL_CALL addEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual void SAL_CALL setPosSize( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual com::sun::star::awt::Rectangle SAL_CALL getPosSize() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL setVisible( sal_Bool Visible ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL setEnable( sal_Bool Enable ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -58,7 +61,9 @@ public:
virtual void SAL_CALL removePaintListener( const com::sun::star::uno::Reference< com::sun::star::awt::XPaintListener >& xListener ) throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
private:
- OGLPlayer& m_rPlayer;
+ glTFHandle* m_pHandle;
+ OpenGLContext* m_pContext;
+ bool m_bVisible;
com::sun::star::media::ZoomLevel meZoomLevel;
};
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
index a84e42fe5f14..87d61cb3e736 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -86,11 +86,6 @@ MediaChildWindow::MediaChildWindow( Window* pParent ) :
MediaChildWindow::MediaChildWindow( Window* pParent, SystemWindowData* pData ) :
SystemChildWindow( pParent, 0, pData )
{
- SetMouseTransparent( true );
- SetParentClipMode( PARENTCLIPMODE_NOCLIP );
- EnableEraseBackground( false );
- SetControlForeground();
- SetControlBackground();
}
MediaChildWindow::~MediaChildWindow()
@@ -515,7 +510,6 @@ void MediaWindowImpl::onURLChanged()
mpChildWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
mxEventsIf.set( static_cast< ::cppu::OWeakObject* >( mpEvents = new MediaEventListenersImpl( *mpChildWindow.get() ) ) );
-
if( mxPlayer.is() )
{
uno::Sequence< uno::Any > aArgs( 3 );
@@ -569,6 +563,8 @@ 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 );
}
@@ -615,9 +611,6 @@ void MediaWindowImpl::Resize()
mpMediaWindowControl->SetPosSizePixel( Point( nOffset, nControlY ), Size( aCurSize.Width() - ( nOffset << 1 ), nControlHeight ) );
}
- if( mxPlayerWindow.is() )
- mxPlayerWindow->setPosSize( 0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0 );
-
if( mpChildWindow )
mpChildWindow->SetPosSizePixel( Point( 0, 0 ), aPlayerWindowSize );
}