[Libreoffice-commits] core.git: avmedia/source download.lst

Zolnai Tamás tamas.zolnai at collabora.com
Tue Aug 5 01:22:18 PDT 2014


 avmedia/source/opengl/oglframegrabber.cxx |    1 
 avmedia/source/opengl/oglframegrabber.hxx |    4 -
 avmedia/source/opengl/oglplayer.cxx       |   75 +++++++++++++-----------------
 avmedia/source/opengl/oglplayer.hxx       |    8 ++-
 avmedia/source/opengl/oglwindow.cxx       |    4 -
 avmedia/source/opengl/oglwindow.hxx       |    4 -
 download.lst                              |    3 -
 7 files changed, 49 insertions(+), 50 deletions(-)

New commits:
commit 48d1f860716720abdd7febdad4b57b9f31a6a1dc
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Tue Aug 5 09:54:05 2014 +0200

    Upload first official libgltf release: libgltf-0.0.0
    
    News relative to previous draft version:
    - Memory management improvements (fdo#81180)
    - Reduced OpenGL requirements (version 3.3 -> version 3.0)
    - Cleaned up API
    
    Change-Id: Ie3caf8684a9f5e6a872a1ac35beafb94df03bcf5
    Reviewed-on: https://gerrit.libreoffice.org/10744
    Reviewed-by: Zolnai Tamás <zolnaitamas2000 at gmail.com>
    Tested-by: Zolnai Tamás <zolnaitamas2000 at gmail.com>

diff --git a/avmedia/source/opengl/oglframegrabber.cxx b/avmedia/source/opengl/oglframegrabber.cxx
index 2f76436..23e97f1 100644
--- a/avmedia/source/opengl/oglframegrabber.cxx
+++ b/avmedia/source/opengl/oglframegrabber.cxx
@@ -20,6 +20,7 @@
 #include <boost/scoped_array.hpp>
 
 using namespace com::sun::star;
+using namespace libgltf;
 
 namespace avmedia { namespace ogl {
 
diff --git a/avmedia/source/opengl/oglframegrabber.hxx b/avmedia/source/opengl/oglframegrabber.hxx
index b6cc0e8..5beb15b 100644
--- a/avmedia/source/opengl/oglframegrabber.hxx
+++ b/avmedia/source/opengl/oglframegrabber.hxx
@@ -25,7 +25,7 @@ class OGLFrameGrabber : public FrameGrabber_BASE
 {
 public:
 
-    OGLFrameGrabber( glTFHandle& rHandle );
+    OGLFrameGrabber( libgltf::glTFHandle& rHandle );
     virtual ~OGLFrameGrabber();
 
     // XFrameGrabber
@@ -37,7 +37,7 @@ public:
     virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
 private:
-    glTFHandle& m_rHandle;
+    libgltf::glTFHandle& m_rHandle;
 };
 
 } // namespace ogl
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index 89ac3b1..431bdb8 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -21,6 +21,7 @@
 #include <cassert>
 
 using namespace com::sun::star;
+using namespace libgltf;
 
 namespace avmedia { namespace ogl {
 
@@ -37,16 +38,10 @@ OGLPlayer::~OGLPlayer()
     osl::MutexGuard aGuard(m_aMutex);
     if( m_pHandle )
     {
-        for (size_t i = 0; i < m_pHandle->size && m_pHandle->files[i].buffer; ++i)
-        {
-            if (m_pHandle->files[i].type != GLTF_JSON)
-            {
-                delete [] m_pHandle->files[i].buffer;
-            }
-        }
         m_aContext.makeCurrent();
         gltf_renderer_release(m_pHandle);
     }
+    releaseInputFiles();
 }
 
 static bool lcl_LoadFile( glTFFile* io_pFile, const OUString& rURL)
@@ -72,35 +67,27 @@ bool OGLPlayer::create( const OUString& rURL )
 
     m_sURL = rURL;
 
-    // Load *.json file and init renderer
-    glTFFile aJsonFile;
-    aJsonFile.type = GLTF_JSON;
-    OString sFileName = OUStringToOString(INetURLObject(m_sURL).GetLastName(),RTL_TEXTENCODING_UTF8);
-    aJsonFile.filename = (char*)sFileName.getStr();
-    if( !lcl_LoadFile(&aJsonFile, m_sURL) )
-    {
-        SAL_WARN("avmedia.opengl", "Can't load *.json file: " + sFileName);
-        return false;
-    }
-
-    m_pHandle = gltf_renderer_init(&aJsonFile);
+    // Convert URL to a system path
+    const INetURLObject aURLObj(m_sURL);
+    const std::string sFilePath = OUStringToOString( aURLObj.getFSysPath(INetURLObject::FSYS_DETECT), RTL_TEXTENCODING_UTF8 ).getStr();
 
-    delete [] aJsonFile.buffer;
+    // Load *.json file and init renderer
+    m_pHandle = gltf_renderer_init(sFilePath, m_vInputFiles);
 
-    if( !m_pHandle || !m_pHandle->files )
+    if( !m_pHandle )
     {
         SAL_WARN("avmedia.opengl", "gltf_renderer_init returned an invalid glTFHandle");
         return false;
     }
 
     // Load external resources
-    for( size_t i = 0; i < m_pHandle->size; ++i )
+    for( size_t i = 0; i < m_vInputFiles.size(); ++i )
     {
-        glTFFile& rFile = m_pHandle->files[i];
-        if( rFile.filename )
+        glTFFile& rFile = m_vInputFiles[i];
+        if( !rFile.filename.empty() )
         {
             const OUString sFilesURL =
-                INetURLObject::GetAbsURL(m_sURL,OStringToOUString(OString(rFile.filename),RTL_TEXTENCODING_UTF8));
+                INetURLObject::GetAbsURL(m_sURL,OStringToOUString(OString(rFile.filename.c_str()),RTL_TEXTENCODING_UTF8));
             if( rFile.type == GLTF_IMAGE )
             {
                 // Load images as bitmaps
@@ -139,6 +126,16 @@ bool OGLPlayer::create( const OUString& rURL )
     return true;
 }
 
+void OGLPlayer::releaseInputFiles()
+{
+    for (size_t i = 0; i < m_vInputFiles.size() && m_vInputFiles[i].buffer; ++i)
+    {
+        delete [] m_vInputFiles[i].buffer;
+        m_vInputFiles[i].buffer = 0;
+    }
+    m_vInputFiles.clear();
+}
+
 void SAL_CALL OGLPlayer::start() throw ( uno::RuntimeException, std::exception )
 {
     osl::MutexGuard aGuard(m_aMutex);
@@ -147,11 +144,7 @@ void SAL_CALL OGLPlayer::start() throw ( uno::RuntimeException, std::exception )
     if(!m_pOGLWindow)
         return;
 
-    // gltf_animation_start play animation from the time 0.0,
-    // but OGLPlayer::start used as play from that time where it was stopped before
-    double fTime = gltf_animation_get_time(m_pHandle);
-    gltf_animation_start(m_pHandle);
-    gltf_animation_set_time(m_pHandle, fTime);
+    gltf_animation_resume(m_pHandle);
     m_aTimer.Start();
     m_bIsRendering = true;
 }
@@ -202,14 +195,14 @@ void SAL_CALL OGLPlayer::setPlaybackLoop( sal_Bool bSet ) throw ( uno::RuntimeEx
 {
     osl::MutexGuard aGuard(m_aMutex);
     assert(m_pHandle);
-    gltf_animation_set_looping(m_pHandle, (int)bSet);
+    gltf_animation_set_looping(m_pHandle, bSet);
 }
 
 sal_Bool SAL_CALL OGLPlayer::isPlaybackLoop() throw ( uno::RuntimeException, std::exception )
 {
     osl::MutexGuard aGuard(m_aMutex);
     assert(m_pHandle);
-    return gltf_animation_get_looping(m_pHandle) != 0;
+    return gltf_animation_get_looping(m_pHandle);
 }
 
 void SAL_CALL OGLPlayer::setVolumeDB( sal_Int16 /*nVolumDB*/ ) throw ( uno::RuntimeException, std::exception )
@@ -242,17 +235,14 @@ awt::Size SAL_CALL OGLPlayer::getPreferredPlayerWindowSize() throw ( uno::Runtim
 static bool lcl_CheckOpenGLRequirements()
 {
     float fVersion = OpenGLHelper::getGLVersion();
-    if( fVersion >= 3.3 )
+
+    if( fVersion >= 3.0 )
     {
         return true;
     }
-    else if( fVersion >= 3.0 )
-    {
-        return glewIsSupported("GL_ARB_sampler_objects");
-    }
     else if( fVersion >= 2.1 )
     {
-        return glewIsSupported("GL_ARB_sampler_objects GL_ARB_framebuffer_object GL_ARB_vertex_array_object");
+        return glewIsSupported("GL_ARB_framebuffer_object GL_ARB_vertex_array_object");
     }
 
     return false;
@@ -296,9 +286,9 @@ uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( c
     m_pHandle->viewport.width = aSize.Width();
     m_pHandle->viewport.height = aSize.Height();
 
-    // TODO: In libgltf different return values are defined (for different errors)
-    // but these error codes are not part of the library interface
-    int nRet = gltf_renderer_set_content(m_pHandle);
+    // TODO: Use the error codes to print a readable error message
+    int nRet = gltf_renderer_set_content(m_pHandle, m_vInputFiles);
+    releaseInputFiles();
     if( nRet != 0 )
     {
         SAL_WARN("avmedia.opengl", "Error occured while parsing *.json file! Error code: " << nRet);
@@ -334,7 +324,8 @@ uno::Reference< media::XFrameGrabber > SAL_CALL OGLPlayer::createFrameGrabber()
     m_pHandle->viewport.width = getPreferredPlayerWindowSize().Width;
     m_pHandle->viewport.height = getPreferredPlayerWindowSize().Height;
 
-    int nRet = gltf_renderer_set_content(m_pHandle);
+    int nRet = gltf_renderer_set_content(m_pHandle, m_vInputFiles);
+    releaseInputFiles();
     if( nRet != 0 )
     {
         SAL_WARN("avmedia.opengl", "Error occured while parsing *.json file! Error code: " << nRet);
diff --git a/avmedia/source/opengl/oglplayer.hxx b/avmedia/source/opengl/oglplayer.hxx
index e25dfd3..bb11578 100644
--- a/avmedia/source/opengl/oglplayer.hxx
+++ b/avmedia/source/opengl/oglplayer.hxx
@@ -18,6 +18,8 @@
 #include <vcl/opengl/OpenGLContext.hxx>
 #include <vcl/timer.hxx>
 
+#include <vector>
+
 namespace avmedia { namespace ogl {
 
 class OGLWindow;
@@ -34,6 +36,7 @@ public:
     virtual ~OGLPlayer();
 
     bool create( const OUString& rURL );
+    void releaseInputFiles();
 
     // XPlayer
     virtual void SAL_CALL start() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -60,7 +63,10 @@ private:
     DECL_LINK( TimerHandler, Timer* );
 
     OUString m_sURL;
-    glTFHandle* m_pHandle;
+
+    libgltf::glTFHandle* m_pHandle;
+    std::vector<libgltf::glTFFile> m_vInputFiles;
+
     OpenGLContext m_aContext;
     AutoTimer m_aTimer;
     OGLWindow* m_pOGLWindow;
diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx
index ce8f462..31ee383 100644
--- a/avmedia/source/opengl/oglwindow.cxx
+++ b/avmedia/source/opengl/oglwindow.cxx
@@ -11,6 +11,7 @@
 #include <cppuhelper/supportsservice.hxx>
 
 using namespace com::sun::star;
+using namespace libgltf;
 
 namespace avmedia { namespace ogl {
 
@@ -312,7 +313,7 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent)
             {
                 if(m_bIsOrbitMode)
                 {
-                    gltf_orbit_view_stop(&m_rHandle);
+                    gltf_orbit_mode_stop(&m_rHandle);
                     m_bIsOrbitMode = false;
                 }
                 else
@@ -381,7 +382,6 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent)
         if(pMouseEvt && pMouseEvt->IsLeft() && pMouseEvt->GetClicks() == 1)
         {
             m_aLastMousePos = Point(0,0);
-            gltf_renderer_stop_rotate_model(&m_rHandle);
         }
     }
     return 0;
diff --git a/avmedia/source/opengl/oglwindow.hxx b/avmedia/source/opengl/oglwindow.hxx
index 68b1ed8..5697e47 100644
--- a/avmedia/source/opengl/oglwindow.hxx
+++ b/avmedia/source/opengl/oglwindow.hxx
@@ -27,7 +27,7 @@ class OGLWindow : public ::cppu::WeakImplHelper2 < com::sun::star::media::XPlaye
                                                    com::sun::star::lang::XServiceInfo >
 {
 public:
-    OGLWindow( glTFHandle& rHandle, OpenGLContext& rContext, Window& rEventHandlerParent );
+    OGLWindow( libgltf::glTFHandle& rHandle, OpenGLContext& rContext, Window& rEventHandlerParent );
     virtual ~OGLWindow();
 
     virtual void SAL_CALL update() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -65,7 +65,7 @@ private:
     DECL_LINK( FocusGrabber, VclWindowEvent* );
     DECL_LINK( CameraHandler, VclWindowEvent* );
 
-    glTFHandle& m_rHandle;
+    libgltf::glTFHandle& m_rHandle;
     OpenGLContext& m_rContext;
     Window& m_rEventHandler;
 
diff --git a/download.lst b/download.lst
index c4e1d7d..36bc91f 100644
--- a/download.lst
+++ b/download.lst
@@ -87,7 +87,8 @@ export LIBATOMIC_OPS_TARBALL := libatomic_ops-7_2d.zip
 export LIBEOT_MD5SUM := aa24f5dd2a2992f4a116aa72af817548
 export LIBEOT_TARBALL := libeot-0.01.tar.bz2
 export LIBEXTTEXTCAT_TARBALL := 10d61fbaa6a06348823651b1bd7940fe-libexttextcat-3.4.4.tar.bz2
-export LIBGLTF_TARBALL := c1af7fbc6dde8fcbdca4ec22dd78c4c1-libgltf-0.0.0.tar.bz2
+export LIBGLTF_MD5SUM := ca5436e916bfe70694adfe2607782786
+export LIBGLTF_TARBALL := libgltf-0.0.0.tar.bz2
 export LIBLANGTAG_TARBALL := 36271d3fa0d9dec1632029b6d7aac925-liblangtag-0.5.1.tar.bz2
 export LIBXMLSEC_TARBALL := 1f24ab1d39f4a51faf22244c94a6203f-xmlsec1-1.2.14.tar.gz
 export LIBXML_TARBALL := 9c0cfef285d5c4a5c80d00904ddab380-libxml2-2.9.1.tar.gz


More information about the Libreoffice-commits mailing list