[Libreoffice-commits] core.git: 7 commits - avmedia/Library_avmedia.mk avmedia/source include/vcl solenv/gbuild svx/Library_svxcore.mk vcl/source

Zolnai Tamás tamas.zolnai at collabora.com
Sun Apr 27 03:35:14 PDT 2014


 avmedia/Library_avmedia.mk                     |    7 -
 avmedia/source/opengl/oglframegrabber.cxx      |    2 
 avmedia/source/opengl/oglplayer.cxx            |   28 ++--
 avmedia/source/opengl/oglplayer.hxx            |    3 
 avmedia/source/opengl/oglwindow.cxx            |   32 +++-
 avmedia/source/opengl/oglwindow.hxx            |   11 +
 avmedia/source/viewer/mediawindow_impl.cxx     |   52 ++++---
 avmedia/source/viewer/mediawindow_impl.hxx     |    3 
 include/vcl/opengl/OpenGLContext.hxx           |   10 +
 solenv/gbuild/extensions/pre_MergedLibsList.mk |    2 
 svx/Library_svxcore.mk                         |    2 
 vcl/source/opengl/OpenGLContext.cxx            |  173 +++++++++++++++++--------
 12 files changed, 231 insertions(+), 94 deletions(-)

New commits:
commit e112ac81d1c3a91d46ea660ac4e01e6c94ee900e
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sun Apr 27 12:20:13 2014 +0200

    First try to render OpenGL content in a window
    
    Change-Id: Ibb7178330d356806cea2cfc972b361167d5a9340

diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index 720825a..9d5f730 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 2b9b415..a40b43d 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 3a024ef..6d4788a 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 d373dd1..95767c0 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 a84e42f..87d61cb 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 );
 }
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index b01e8fd..9d22ae6 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -147,6 +147,10 @@ public:
     ~OpenGLContext();
 
     bool init(Window* pParent = 0);
+    bool init(SystemChildWindow* pChildWindow);
+
+    void swapBuffers();
+
     void setWinSize(const Size& rSize);
     GLWindow& getOpenGLWindow();
 
@@ -161,11 +165,13 @@ public:
 
 private:
     SAL_DLLPRIVATE bool initWindow();
+    SAL_DLLPRIVATE bool ImplInit();
 
     GLWindow m_aGLWin;
     boost::scoped_ptr<Window> m_pWindow;
     Window* mpWindow; //points to m_pWindow or the parent window, don't delete it
-    boost::scoped_ptr<SystemChildWindow> m_pChildWindow;
+    SystemChildWindow* m_pChildWindow;
+    boost::scoped_ptr<SystemChildWindow> m_pChildWindowGC;
     bool mbInitialized;
 };
 
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 2b3cba6..107bcf0 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -331,8 +331,28 @@ bool OpenGLContext::init( Window* pParent )
 
     m_pWindow.reset(pParent ? NULL : new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL));
     mpWindow = pParent ? pParent : m_pWindow.get();
-    SAL_INFO("vcl.opengl", "OpenGLContext::OpenGLContext----start");
+    m_pChildWindow = 0;
     initWindow();
+    return ImplInit();
+}
+
+bool OpenGLContext::init(SystemChildWindow* pChildWindow)
+{
+    if(mbInitialized)
+        return true;
+
+    if( !pChildWindow )
+        return false;
+
+    mpWindow = pChildWindow->GetParent();
+    m_pChildWindow = pChildWindow;
+    initWindow();
+    return ImplInit();
+}
+
+bool OpenGLContext::ImplInit()
+{
+    SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start");
     if(m_pWindow)
         m_pWindow->setPosSizePixel(0,0,0,0);
     m_aGLWin.Width = 0;
@@ -474,7 +494,7 @@ bool OpenGLContext::init( Window* pParent )
             bGlewInit = true;
     }
 
-    SAL_INFO("vcl.opengl", "OpenGLContext::init----end");
+    SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----end");
     mbInitialized = true;
     return true;
 }
@@ -483,7 +503,8 @@ void OpenGLContext::setWinSize(const Size& rSize)
 {
     if(m_pWindow)
         m_pWindow->SetSizePixel(rSize);
-    m_pChildWindow->SetSizePixel(rSize);
+    if( m_pChildWindow )
+        m_pChildWindow->SetSizePixel(rSize);
 
     m_aGLWin.Width = rSize.Width();
     m_aGLWin.Height = rSize.Height();
@@ -544,8 +565,12 @@ bool OpenGLContext::initWindow()
 {
     const SystemEnvData* sysData(mpWindow->GetSystemData());
     m_aGLWin.hWnd = sysData->hWnd;
-    SystemWindowData winData = generateWinData(mpWindow);
-    m_pChildWindow.reset(new SystemChildWindow(mpWindow, 0, &winData, sal_False));
+    if( !m_pChildWindow )
+    {
+        SystemWindowData winData = generateWinData(mpWindow);
+        m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, sal_False);
+        m_pChildWindowGC.reset(m_pChildWindow);
+    }
 
     if( m_pChildWindow )
     {
@@ -572,13 +597,15 @@ bool OpenGLContext::initWindow()
 
 bool OpenGLContext::initWindow()
 {
-    m_pChildWindow.reset();
-
     const SystemEnvData* pChildSysData = 0;
     SystemWindowData winData = generateWinData(mpWindow);
     if( winData.pVisual )
     {
-        m_pChildWindow.reset(new SystemChildWindow(mpWindow, 0, &winData, false));
+        if( !m_pChildWindow )
+        {
+            m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, sal_False);
+            m_pChildWindowGC.reset(m_pChildWindow);
+        }
         pChildSysData = m_pChildWindow->GetSystemData();
     }
 
@@ -723,4 +750,13 @@ SystemWindowData OpenGLContext::generateWinData(Window* pParent)
 
 #endif
 
+void OpenGLContext::swapBuffers()
+{
+#if defined( _WIN32 )
+    SwapBuffers(m_aGLWin.hDC);
+#elif defined( UNX )
+    glXSwapBuffers(m_aGLWin.dpy, m_aGLWin.win);
+#endif
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit b5529c8c457f442bfc43305becc0c02d6a09ee80
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sun Apr 27 12:14:18 2014 +0200

    avmedia: create a special SystemChildWindow for 3D models
    
    Change-Id: Id5f5ba2cf72ea78506ba226b269fae59b1163858

diff --git a/avmedia/Library_avmedia.mk b/avmedia/Library_avmedia.mk
index 9352227..6dbcb53 100644
--- a/avmedia/Library_avmedia.mk
+++ b/avmedia/Library_avmedia.mk
@@ -23,7 +23,11 @@ $(eval $(call gb_Library_add_defs,avmedia,\
 	-DAVMEDIA_DLLIMPLEMENTATION \
 ))
 
-$(eval $(call gb_Library_use_external,avmedia,boost_headers))
+$(eval $(call gb_Library_use_externals,avmedia,\
+	boost_headers \
+	glew \
+	mesa_headers \
+))
 
 $(eval $(call gb_Library_use_libraries,avmedia,\
 	comphelper \
@@ -38,6 +42,7 @@ $(eval $(call gb_Library_use_libraries,avmedia,\
 	tl \
 	utl \
 	vcl \
+	vclopengl \
 	$(gb_UWINAPI) \
 ))
 
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx
index 515580c..a84e42f 100644
--- a/avmedia/source/viewer/mediawindow_impl.cxx
+++ b/avmedia/source/viewer/mediawindow_impl.cxx
@@ -35,6 +35,8 @@
 #include <com/sun/star/awt/SystemPointer.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/media/XManager.hpp>
+#include <vcl/sysdata.hxx>
+#include <vcl/opengl/OpenGLContext.hxx>
 
 using namespace ::com::sun::star;
 
@@ -81,7 +83,15 @@ 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()
 {
@@ -156,16 +166,10 @@ MediaWindowImpl::MediaWindowImpl( Window* pParent, MediaWindow* pMediaWindow, bo
     DropTargetHelper( this ),
     DragSourceHelper( this ),
     mpMediaWindow( pMediaWindow ),
-    mxEventsIf( static_cast< ::cppu::OWeakObject* >( mpEvents = new MediaEventListenersImpl( maChildWindow ) ) ),
-    maChildWindow( this ),
     mpMediaWindowControl( bInternalMediaControl ? new MediaWindowControl( this ) : NULL ),
     mpEmptyBmpEx( NULL ),
     mpAudioBmpEx( NULL )
 {
-    maChildWindow.SetBackground( Color( COL_BLACK ) );
-    maChildWindow.SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
-    maChildWindow.Hide();
-
     if( mpMediaWindowControl )
     {
         mpMediaWindowControl->SetSizePixel( mpMediaWindowControl->getMinSizePixel() );
@@ -497,17 +501,32 @@ void MediaWindowImpl::stopPlayingInternal( bool bStop )
 
 void MediaWindowImpl::onURLChanged()
 {
+    if( m_sMimeType == AVMEDIA_MIMETYPE_COMMON )
+    {
+        mpChildWindow.reset(new MediaChildWindow(this) );
+    }
+    else if ( m_sMimeType == AVMEDIA_MIMETYPE_JSON )
+    {
+        SystemWindowData aWinData = OpenGLContext::generateWinData(this);
+        mpChildWindow.reset(new MediaChildWindow(this,&aWinData));
+    }
+    if( !mpChildWindow )
+        return;
+    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 );
         uno::Reference< media::XPlayerWindow > xPlayerWindow;
         const Point                            aPoint;
-        const Size                             aSize( maChildWindow.GetSizePixel() );
+        const Size                             aSize( mpChildWindow->GetSizePixel() );
         const sal_Int32                        nWndHandle = 0;
 
         aArgs[ 0 ] = uno::makeAny( nWndHandle );
         aArgs[ 1 ] = uno::makeAny( awt::Rectangle( aPoint.X(), aPoint.Y(), aSize.Width(), aSize.Height() ) );
-        aArgs[ 2 ] = uno::makeAny( reinterpret_cast< sal_IntPtr >( &maChildWindow ) );
+        aArgs[ 2 ] = uno::makeAny( reinterpret_cast< sal_IntPtr >( mpChildWindow.get() ) );
 
         try
         {
@@ -532,9 +551,9 @@ void MediaWindowImpl::onURLChanged()
         mxPlayerWindow.clear();
 
     if( mxPlayerWindow.is() )
-        maChildWindow.Show();
+        mpChildWindow->Show();
     else
-        maChildWindow.Hide();
+        mpChildWindow->Hide();
 
     if( mpMediaWindowControl )
     {
@@ -557,7 +576,8 @@ void MediaWindowImpl::setPosSize( const Rectangle& rRect )
 void MediaWindowImpl::setPointer( const Pointer& rPointer )
 {
     SetPointer( rPointer );
-    maChildWindow.SetPointer( rPointer );
+    if( mpChildWindow )
+        mpChildWindow->SetPointer( rPointer );
 
     if( mxPlayerWindow.is() )
     {
@@ -598,7 +618,8 @@ void MediaWindowImpl::Resize()
     if( mxPlayerWindow.is() )
         mxPlayerWindow->setPosSize( 0, 0, aPlayerWindowSize.Width(), aPlayerWindowSize.Height(), 0 );
 
-    maChildWindow.SetPosSizePixel( Point( 0, 0 ), aPlayerWindowSize );
+    if( mpChildWindow )
+        mpChildWindow->SetPosSizePixel( Point( 0, 0 ), aPlayerWindowSize );
 }
 
 
@@ -651,8 +672,10 @@ void MediaWindowImpl::Paint( const Rectangle& )
         pLogo = mpAudioBmpEx;
     }
 
-    const Point     aBasePos( maChildWindow.GetPosPixel() );
-    const Rectangle aVideoRect( aBasePos, maChildWindow.GetSizePixel() );
+    if( !mpChildWindow )
+        return;
+    const Point     aBasePos( mpChildWindow->GetPosPixel() );
+    const Rectangle aVideoRect( aBasePos, mpChildWindow->GetSizePixel() );
 
     if( pLogo && !pLogo->IsEmpty() && ( aVideoRect.GetWidth() > 0 ) && ( aVideoRect.GetHeight() > 0 ) )
     {
diff --git a/avmedia/source/viewer/mediawindow_impl.hxx b/avmedia/source/viewer/mediawindow_impl.hxx
index 317cea8..906959d 100644
--- a/avmedia/source/viewer/mediawindow_impl.hxx
+++ b/avmedia/source/viewer/mediawindow_impl.hxx
@@ -66,6 +66,7 @@ namespace avmedia
         public:
 
                             MediaChildWindow( Window* pParent );
+                            MediaChildWindow( Window* pParent, SystemWindowData* pData );
                             virtual ~MediaChildWindow();
 
         protected:
@@ -173,7 +174,7 @@ namespace avmedia
 
             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >   mxEventsIf;
             MediaEventListenersImpl*                                                mpEvents;
-            MediaChildWindow                                                        maChildWindow;
+            boost::scoped_ptr<MediaChildWindow>                                     mpChildWindow;
             MediaWindowControl*                                                     mpMediaWindowControl;
             BitmapEx*                                                               mpEmptyBmpEx;
             BitmapEx*                                                               mpAudioBmpEx;
commit 4db3805a2dd2e36d9e0cb9cb7a8a9923119d3a52
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Apr 25 14:41:24 2014 +0200

    OpenGLContext: use generateWinData inside window initialization
    
    Change-Id: I618dacceb88ddab1ca6d45a8669199354e4b6a6d

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 4d5e595..2b3cba6 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -544,8 +544,7 @@ bool OpenGLContext::initWindow()
 {
     const SystemEnvData* sysData(mpWindow->GetSystemData());
     m_aGLWin.hWnd = sysData->hWnd;
-    SystemWindowData winData;
-    winData.nSize = sizeof(winData);
+    SystemWindowData winData = generateWinData(mpWindow);
     m_pChildWindow.reset(new SystemChildWindow(mpWindow, 0, &winData, sal_False));
 
     if( m_pChildWindow )
@@ -571,95 +570,14 @@ bool OpenGLContext::initWindow()
 
 #elif defined( UNX )
 
-namespace {
-
-// we need them before glew can initialize them
-// glew needs an OpenGL context so we need to get the address manually
-void initOpenGLFunctionPointers()
-{
-    glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig");
-    glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig");    // try to find a visual for the current set of attributes
-    glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib");
-}
-
-}
-
 bool OpenGLContext::initWindow()
 {
-    const SystemEnvData* sysData(mpWindow->GetSystemData());
-
-    m_aGLWin.dpy = reinterpret_cast<Display*>(sysData->pDisplay);
-
-    if( !glXQueryExtension( m_aGLWin.dpy, NULL, NULL ) )
-        return false;
-
-    m_aGLWin.win = sysData->aWindow;
-
-    SAL_INFO("vcl.opengl", "parent window: " << m_aGLWin.win);
-
-    XWindowAttributes xattr;
-    XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xattr );
-
-    m_aGLWin.screen = XScreenNumberOfScreen( xattr.screen );
-
-    static int visual_attribs[] =
-    {
-        GLX_RED_SIZE,           8,
-        GLX_GREEN_SIZE,         8,
-        GLX_BLUE_SIZE,          8,
-        GLX_ALPHA_SIZE,         8,
-        GLX_DEPTH_SIZE,         24,
-        GLX_X_VISUAL_TYPE,      GLX_TRUE_COLOR,
-        None
-    };
-
-    const SystemEnvData* pChildSysData = NULL;
     m_pChildWindow.reset();
 
-    initOpenGLFunctionPointers();
-
-    int fbCount = 0;
-    GLXFBConfig* pFBC = glXChooseFBConfig( m_aGLWin.dpy,
-            m_aGLWin.screen,
-            visual_attribs, &fbCount );
-
-    if(!pFBC)
-    {
-        SAL_WARN("vcl.opengl", "no suitable fb format found");
-        return false;
-    }
-
-    int best_fbc = -1, best_num_samp = -1;
-    for(int i = 0; i < fbCount; ++i)
-    {
-        XVisualInfo* pVi = glXGetVisualFromFBConfig( m_aGLWin.dpy, pFBC[i] );
-        if(pVi)
-        {
-            // pick the one with the most samples per pixel
-            int nSampleBuf = 0;
-            int nSamples = 0;
-            glXGetFBConfigAttrib( m_aGLWin.dpy, pFBC[i], GLX_SAMPLE_BUFFERS, &nSampleBuf );
-            glXGetFBConfigAttrib( m_aGLWin.dpy, pFBC[i], GLX_SAMPLES       , &nSamples  );
-
-            if ( best_fbc < 0 || (nSampleBuf && ( nSamples > best_num_samp )) )
-            {
-                best_fbc = i;
-                best_num_samp = nSamples;
-            }
-        }
-        XFree( pVi );
-    }
-
-    if(best_num_samp > 0)
-        m_aGLWin.bMultiSampleSupported = true;
-
-    XVisualInfo* vi = glXGetVisualFromFBConfig( m_aGLWin.dpy, pFBC[best_fbc] );
-    if( vi )
+    const SystemEnvData* pChildSysData = 0;
+    SystemWindowData winData = generateWinData(mpWindow);
+    if( winData.pVisual )
     {
-        SystemWindowData winData;
-        winData.nSize = sizeof(winData);
-        SAL_INFO("vcl.opengl", "using VisualID " << vi->visualid);
-        winData.pVisual = (void*)(vi->visual);
         m_pChildWindow.reset(new SystemChildWindow(mpWindow, 0, &winData, false));
         pChildSysData = m_pChildWindow->GetSystemData();
     }
@@ -675,7 +593,26 @@ bool OpenGLContext::initWindow()
 
     m_aGLWin.dpy = reinterpret_cast<Display*>(pChildSysData->pDisplay);
     m_aGLWin.win = pChildSysData->aWindow;
-    m_aGLWin.vi = vi;
+    m_aGLWin.screen = pChildSysData->nScreen;
+
+    // Get visual info
+    {
+        Visual* pVisual = (Visual*)pChildSysData->pVisual;
+        XVisualInfo aTemplate;
+        aTemplate.visualid = XVisualIDFromVisual( pVisual );;
+        int nVisuals = 0;
+        XVisualInfo* pInfos = XGetVisualInfo( m_aGLWin.dpy, VisualIDMask, &aTemplate, &nVisuals );
+        if( nVisuals != 1 )
+            SAL_WARN( "vcl.opengl", "match count for visual id is not 1" );
+        m_aGLWin.vi = pInfos;
+    }
+
+    // Check multi sample support
+    int nSamples = 0;
+    glXGetConfig(m_aGLWin.dpy, m_aGLWin.vi, GLX_SAMPLES, &nSamples);
+    if( nSamples > 0 )
+        m_aGLWin.bMultiSampleSupported = true;
+
     m_aGLWin.GLXExtensions = glXQueryExtensionsString( m_aGLWin.dpy, m_aGLWin.screen );
     SAL_INFO("vcl.opengl", "available GLX extensions: " << m_aGLWin.GLXExtensions);
 
@@ -695,6 +632,19 @@ SystemWindowData OpenGLContext::generateWinData(Window* /*pParent*/)
 
 #elif defined( UNX )
 
+namespace {
+
+// we need them before glew can initialize them
+// glew needs an OpenGL context so we need to get the address manually
+void initOpenGLFunctionPointers()
+{
+    glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig");
+    glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig");    // try to find a visual for the current set of attributes
+    glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib");
+}
+
+}
+
 SystemWindowData OpenGLContext::generateWinData(Window* pParent)
 {
     SystemWindowData aWinData;
commit d8719aa04aa219d95b84bee9e6bd416d3e0a9207
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sun Apr 27 12:09:20 2014 +0200

    OpenGLContext: Provide all data for SystemChildWindow creation.
    
    Change-Id: I7a0ceee6c784af8240fb908f19622d4ede1f5a6a

diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 559fbab..b01e8fd 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -157,6 +157,8 @@ public:
         return mbInitialized;
     }
 
+    static SystemWindowData generateWinData(Window* pParent);
+
 private:
     SAL_DLLPRIVATE bool initWindow();
 
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 4b420182..4d5e595 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -684,4 +684,93 @@ bool OpenGLContext::initWindow()
 
 #endif
 
+#if defined( WNT ) || defined( MACOSX ) || defined( IOS) || defined( ANDROID )
+
+SystemWindowData OpenGLContext::generateWinData(Window* /*pParent*/)
+{
+    SystemWindowData aWinData;
+    aWinData.nSize = sizeof(aWinData);
+    return aWinData;
+}
+
+#elif defined( UNX )
+
+SystemWindowData OpenGLContext::generateWinData(Window* pParent)
+{
+    SystemWindowData aWinData;
+    aWinData.nSize = sizeof(aWinData);
+
+    const SystemEnvData* sysData(pParent->GetSystemData());
+
+    Display *dpy = reinterpret_cast<Display*>(sysData->pDisplay);
+
+    if( !glXQueryExtension( dpy, NULL, NULL ) )
+        return aWinData;
+
+    XLIB_Window win = sysData->aWindow;
+
+    SAL_INFO("vcl.opengl", "parent window: " << win);
+
+    XWindowAttributes xattr;
+    XGetWindowAttributes( dpy, win, &xattr );
+
+    int screen = XScreenNumberOfScreen( xattr.screen );
+
+    static int visual_attribs[] =
+    {
+        GLX_RED_SIZE,           8,
+        GLX_GREEN_SIZE,         8,
+        GLX_BLUE_SIZE,          8,
+        GLX_ALPHA_SIZE,         8,
+        GLX_DEPTH_SIZE,         24,
+        GLX_X_VISUAL_TYPE,      GLX_TRUE_COLOR,
+        None
+    };
+
+    initOpenGLFunctionPointers();
+
+    int fbCount = 0;
+    GLXFBConfig* pFBC = glXChooseFBConfig( dpy,
+            screen,
+            visual_attribs, &fbCount );
+
+    if(!pFBC)
+    {
+        SAL_WARN("vcl.opengl", "no suitable fb format found");
+        return aWinData;
+    }
+
+    int best_fbc = -1, best_num_samp = -1;
+    for(int i = 0; i < fbCount; ++i)
+    {
+        XVisualInfo* pVi = glXGetVisualFromFBConfig( dpy, pFBC[i] );
+        if(pVi)
+        {
+            // pick the one with the most samples per pixel
+            int nSampleBuf = 0;
+            int nSamples = 0;
+            glXGetFBConfigAttrib( dpy, pFBC[i], GLX_SAMPLE_BUFFERS, &nSampleBuf );
+            glXGetFBConfigAttrib( dpy, pFBC[i], GLX_SAMPLES       , &nSamples  );
+
+            if ( best_fbc < 0 || (nSampleBuf && ( nSamples > best_num_samp )) )
+            {
+                best_fbc = i;
+                best_num_samp = nSamples;
+            }
+        }
+        XFree( pVi );
+    }
+
+    XVisualInfo* vi = glXGetVisualFromFBConfig( dpy, pFBC[best_fbc] );
+    if( vi )
+    {
+        SAL_INFO("vcl.opengl", "using VisualID " << vi->visualid);
+        aWinData.pVisual = (void*)(vi->visual);
+    }
+
+    return aWinData;
+}
+
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit d276ad15252ecd0ae2a4dfeae5b32c16082a9544
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Thu Apr 24 12:27:24 2014 +0200

    vclopengl is buildable on all platforms now
    
    Change-Id: I2d65035eb30e9a96ab4ddc695fc7bc3aaaa9ab6c

diff --git a/solenv/gbuild/extensions/pre_MergedLibsList.mk b/solenv/gbuild/extensions/pre_MergedLibsList.mk
index ad9b478..053a5d6 100644
--- a/solenv/gbuild/extensions/pre_MergedLibsList.mk
+++ b/solenv/gbuild/extensions/pre_MergedLibsList.mk
@@ -150,7 +150,7 @@ gb_MERGEDLIBS := \
 	utl \
 	uui \
 	vcl \
-	$(if $(filter FREEBSD LINUX MACOSX WNT,$(OS)),vclopengl) \
+	vclopengl \
 	xmlscript \
 	xo \
 	xstor \
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index ccb48ed..7ed776f 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -74,8 +74,8 @@ $(eval $(call gb_Library_use_libraries,svxcore,\
     ucbhelper \
     utl \
     vcl \
+    vclopengl \
     xo \
-    $(if $(filter FREEBSD LINUX MACOSX WNT,$(OS)),vclopengl) \
 	$(gb_UWINAPI) \
 ))
 
commit 67f6bff3ec9c56186bbd040ab21d5643640a3cd7
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Tue Apr 22 13:05:23 2014 +0200

    avmediaogl: Use INetURLObject for URL operations
    
    Change-Id: I7b9763489ca7ec64051b53b87ab1475167ffeb35

diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index 4224e35..720825a 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -55,7 +55,7 @@ bool OGLPlayer::create( const OUString& rURL )
     // Load *.json file and init renderer
     glTFFile aJsonFile;
     aJsonFile.type = GLTF_JSON;
-    OString sFileName = OUStringToOString(m_sURL.copy(m_sURL.lastIndexOf("/")+1),RTL_TEXTENCODING_UTF8);
+    OString sFileName = OUStringToOString(INetURLObject(m_sURL).GetLastName(),RTL_TEXTENCODING_UTF8);
     aJsonFile.filename = (char*)sFileName.getStr();
     if( !lcl_LoadFile(&aJsonFile, m_sURL) )
         return false;
@@ -71,8 +71,8 @@ bool OGLPlayer::create( const OUString& rURL )
         glTFFile* pFile = m_pHandle->files[i];
         if( pFile && pFile->filename )
         {
-            const OUString sFilesURL = m_sURL.copy(0,m_sURL.lastIndexOf("/")+1) +
-                OStringToOUString(OString(pFile->filename),RTL_TEXTENCODING_UTF8);
+            const OUString sFilesURL =
+                INetURLObject::GetAbsURL(m_sURL,OStringToOUString(OString(pFile->filename),RTL_TEXTENCODING_UTF8));
             if( pFile->type == GLTF_IMAGE )
             {
                 // Load images as bitmaps
commit 8df2785b487dd7a9fed563482579871a12f0afb3
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Tue Apr 22 12:42:15 2014 +0200

    avmediaogl: Use glTFHandle for size values
    
    Change-Id: I4741374ec269a5513214c6603e3e6956231bd853

diff --git a/avmedia/source/opengl/oglframegrabber.cxx b/avmedia/source/opengl/oglframegrabber.cxx
index 81be9c1..b2dcdc8 100644
--- a/avmedia/source/opengl/oglframegrabber.cxx
+++ b/avmedia/source/opengl/oglframegrabber.cxx
@@ -34,7 +34,7 @@ uno::Reference< css::graphic::XGraphic > SAL_CALL OGLFrameGrabber::grabFrame( do
 {
     // TODO: libgltf should provide an RGBA buffer, not just an RGB one. See: OpenGLRender::GetAsBitmap().
     char* pBuffer = new char[m_pHandle->viewport.width * m_pHandle->viewport.height * 3];
-    gltf_renderer_get_bitmap(m_pHandle, fMediaTime, pBuffer, 800, 600);
+    gltf_renderer_get_bitmap(m_pHandle, fMediaTime, pBuffer, m_pHandle->viewport.width, m_pHandle->viewport.height);
     Bitmap aBitmap( Size(m_pHandle->viewport.width, m_pHandle->viewport.height), 24 );
     {
         Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );


More information about the Libreoffice-commits mailing list