diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-08-05 09:54:05 +0200 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2014-08-05 08:21:59 +0000 |
commit | 48d1f860716720abdd7febdad4b57b9f31a6a1dc (patch) | |
tree | a5da3e2c7d3ffe58458d554a15c9bfd52ee26bf6 /avmedia | |
parent | fdo#81516 Support fonts like Source Han Sans with > 16 FDArray elements (diff) | |
download | core-48d1f860716720abdd7febdad4b57b9f31a6a1dc.tar.gz core-48d1f860716720abdd7febdad4b57b9f31a6a1dc.zip |
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@gmail.com>
Tested-by: Zolnai Tamás <zolnaitamas2000@gmail.com>
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/opengl/oglframegrabber.cxx | 1 | ||||
-rw-r--r-- | avmedia/source/opengl/oglframegrabber.hxx | 4 | ||||
-rw-r--r-- | avmedia/source/opengl/oglplayer.cxx | 75 | ||||
-rw-r--r-- | avmedia/source/opengl/oglplayer.hxx | 8 | ||||
-rw-r--r-- | avmedia/source/opengl/oglwindow.cxx | 4 | ||||
-rw-r--r-- | avmedia/source/opengl/oglwindow.hxx | 4 |
6 files changed, 47 insertions, 49 deletions
diff --git a/avmedia/source/opengl/oglframegrabber.cxx b/avmedia/source/opengl/oglframegrabber.cxx index 2f76436bed23..23e97f100444 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 b6cc0e8dd346..5beb15bcf308 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 89ac3b1899fa..431bdb8bf9dc 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 e25dfd321285..bb115787296f 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 ce8f46242da0..31ee3831c852 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 68b1ed8b84ad..5697e475faf1 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; |