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 external/libgltf/ExternalProject_libgltf.mk | 6 external/libgltf/UnpackedTarball_libgltf.mk | 2 external/libgltf/pathces/fix_rendering_of_resized_model.patch | 71 --------- external/libgltf/pathces/missing_include.patch | 11 + 11 files changed, 67 insertions(+), 122 deletions(-)
New commits: commit ea596d69054bca96ac15fa46631c42422e859b19 Author: Zolnai Tamás <tamas.zol...@collabora.com> Date: Tue Aug 5 10:27:09 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 Reviewed-on: https://gerrit.libreoffice.org/10744 Reviewed-by: Zolnai Tamás <zolnaitamas2...@gmail.com> Tested-by: Zolnai Tamás <zolnaitamas2...@gmail.com> (cherry picked from commit 48d1f860716720abdd7febdad4b57b9f31a6a1dc) Conflicts: avmedia/source/opengl/oglplayer.cxx download.lst libgltf: fix dbgutil build (cherry picked from commit dabfe7dd025f95862e302b3c4526d382eeba19ea) libgltf: missing <cstdio> include (cherry picked from commit d085bba9139d882e191b46ee8056d364e7526f88) libgltf: remove obsolete patch (cherry picked from commit 841d50ec234e71e8e89d0e9135e2002f35fc42fa) Change-Id: Icc5105d0668d5e4e3eb58bbaed6b2f059c30be99 Reviewed-on: https://gerrit.libreoffice.org/10747 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.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 b827d2f..ba7e9f2 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; } @@ -209,14 +202,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 (sal_Bool)gltf_animation_get_looping(m_pHandle); + return gltf_animation_get_looping(m_pHandle); } void SAL_CALL OGLPlayer::setVolumeDB( sal_Int16 /*nVolumDB*/ ) throw ( uno::RuntimeException, std::exception ) @@ -249,17 +242,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; @@ -303,9 +293,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); @@ -341,7 +331,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 579e56b..03ad515 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; @@ -61,7 +64,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 72ccbfb..a770ff5 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 { @@ -325,7 +326,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 @@ -394,7 +395,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 35c54c8..a68f667 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 896646e..a34756c 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 := ae330b9493bd4503ac390106ff6060d7-libexttextcat-3.4.3.tar.bz2 -export LIBGLTF_TARBALL := 3d9ea1f2828c46f8ba94b88a87b3326d-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 diff --git a/external/libgltf/ExternalProject_libgltf.mk b/external/libgltf/ExternalProject_libgltf.mk index 3e390b9..8c8878d 100644 --- a/external/libgltf/ExternalProject_libgltf.mk +++ b/external/libgltf/ExternalProject_libgltf.mk @@ -53,8 +53,14 @@ $(call gb_ExternalProject_get_state_target,libgltf,build) : else +libgltf_CPPFLAGS := +ifneq (,$(gb_ENABLE_DBGUTIL)) + libgltf_CPPFLAGS += -D_GLIBCXX_DEBUG +endif + $(call gb_ExternalProject_get_state_target,libgltf,build) : $(call gb_ExternalProject_run,build,\ + CPPFLAGS='$(libgltf_CPPFLAGS)' \ export PKG_CONFIG="" \ && ./configure \ --with-pic \ diff --git a/external/libgltf/UnpackedTarball_libgltf.mk b/external/libgltf/UnpackedTarball_libgltf.mk index a7565ea..3b27c2a 100644 --- a/external/libgltf/UnpackedTarball_libgltf.mk +++ b/external/libgltf/UnpackedTarball_libgltf.mk @@ -16,7 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchflags,libgltf,--binary)) $(eval $(call gb_UnpackedTarball_set_patchlevel,libgltf,1)) $(eval $(call gb_UnpackedTarball_add_patches,libgltf,\ - external/libgltf/pathces/fix_rendering_of_resized_model.patch \ + external/libgltf/pathces/missing_include.patch \ )) # vim: set noet sw=4 ts=4: diff --git a/external/libgltf/pathces/fix_rendering_of_resized_model.patch b/external/libgltf/pathces/fix_rendering_of_resized_model.patch deleted file mode 100644 index 57af9f9..0000000 --- a/external/libgltf/pathces/fix_rendering_of_resized_model.patch +++ /dev/null @@ -1,71 +0,0 @@ -diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp ---- libgltf.org/src/RenderScene.cpp 2014-07-15 17:33:12.615059856 +0200 -+++ libgltf/src/RenderScene.cpp 2014-07-15 22:24:20.862307666 +0200 -@@ -639,7 +639,7 @@ - , pScene(0) - , mLoadJson() - , mBindBufferMap() -- , viewport() -+ , mCurrentViewport() - , fbo() - , mEnableTransparency(false) - , mEnableRotation(false) -@@ -1555,10 +1555,9 @@ - pFPSCounter->timeStamp(); - } - #endif -- viewport = *((glTFViewport*)lpParam); - { - TRACE_TIME; -- status = initSSAAFrameBuf(&viewport); -+ status = initSSAAFrameBuf(((glTFViewport*)lpParam)); - if (LIBGLTF_SUCCESS != status) - return status; - } -@@ -1569,6 +1568,15 @@ - { - if (0 == pViewport->width) - return LIBGLTF_INVALID_SIZE; -+ -+ // When viewport changes we need to release fbo and create a new one -+ if( mCurrentViewport.x != pViewport->x || mCurrentViewport.y != pViewport->y || -+ mCurrentViewport.width != pViewport->width || mCurrentViewport.height != pViewport->height ) -+ { -+ fbo.releaseFbo(); -+ mCurrentViewport = *pViewport; -+ } -+ - #if DEFAULT_VIEW - unsigned int width = SSAA * DEFAULT_VIEW; - unsigned int height = (SSAA * DEFAULT_VIEW * -@@ -1730,14 +1738,14 @@ - #if ENABLE_FPS - if (0 != pFPSCounter) - { -- pFPSCounter->printFPS(&viewport); -+ pFPSCounter->printFPS(&mCurrentViewport); - } - #endif - - { - TRACE_TIME; -- glViewport(viewport.x, viewport.y, -- viewport.width, viewport.height); -+ glViewport(mCurrentViewport.x, mCurrentViewport.y, -+ mCurrentViewport.width, mCurrentViewport.height); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - fbo.renderFboTexture(); - } -Only in libgltf/src: RenderScene.cpp~ -diff -ur libgltf.org/src/RenderScene.h libgltf/src/RenderScene.h ---- libgltf.org/src/RenderScene.h 2014-07-15 17:33:12.615059856 +0200 -+++ libgltf/src/RenderScene.h 2014-07-15 22:18:01.306324010 +0200 -@@ -349,7 +349,7 @@ - std::map<std::string, BindBufferInfo> mBindBufferMap; - - static ShaderProgram mShaderProgram; -- glTFViewport viewport; -+ glTFViewport mCurrentViewport; - RenderWithFBO fbo; - - bool mEnableTransparency; diff --git a/external/libgltf/pathces/missing_include.patch b/external/libgltf/pathces/missing_include.patch new file mode 100644 index 0000000..8b05224 --- /dev/null +++ b/external/libgltf/pathces/missing_include.patch @@ -0,0 +1,11 @@ +diff -ur libgltf.org/src/Shaders.cpp libgltf/src/Shaders.cpp +--- libgltf.org/src/Shaders.cpp 2014-08-05 11:40:30.387537876 +0200 ++++ libgltf/src/Shaders.cpp 2014-08-05 11:41:13.887536123 +0200 +@@ -10,6 +10,7 @@ + #include "Shaders.h" + + #include <GL/glew.h> ++#include <cstdio> + + namespace libgltf + {
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits