[Libreoffice-commits] core.git: 3 commits - avmedia/source chart2/source external/libgltf include/vcl vcl/source

Zolnai Tamás tamas.zolnai at collabora.com
Fri Apr 18 09:54:26 PDT 2014


 avmedia/source/opengl/oglmanager.cxx                      |    9 ++--
 avmedia/source/opengl/oglplayer.cxx                       |   11 ++++-
 avmedia/source/opengl/oglplayer.hxx                       |    6 ++-
 chart2/source/view/main/OpenGLRender.cxx                  |   21 ----------
 external/libgltf/UnpackedTarball_libgltf.mk               |    1 
 external/libgltf/patches/charbuffer_used_as_cstring.patch |   12 ++++++
 include/vcl/opengl/OpenGLHelper.hxx                       |    2 +
 vcl/source/opengl/OpenGLHelper.cxx                        |   28 ++++++++++++++
 8 files changed, 61 insertions(+), 29 deletions(-)

New commits:
commit 8afabd394214bb7c772c88b08ec3cadb56771cce
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Apr 18 15:24:25 2014 +0200

    Extract code of BitmapEx -> RGBA buffer conversion to OpenGLHelper
    
    Needed by gltf rendering.
    
    Change-Id: I1aa974f3c515c5fb19a07b54ff655331138553cb

diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 8ab05b7..79e408c 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -900,26 +900,7 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, const awt::Point&
 
     long bmpWidth = rBitmapEx.GetSizePixel().Width();
     long bmpHeight = rBitmapEx.GetSizePixel().Height();
-
-    Bitmap aBitmap (rBitmapEx.GetBitmap());
-    AlphaMask aAlpha (rBitmapEx.GetAlpha());
-    boost::scoped_array<sal_uInt8> bitmapBuf(new sal_uInt8[4* bmpWidth * bmpHeight ]);
-    Bitmap::ScopedReadAccess pReadAccces( aBitmap );
-    AlphaMask::ScopedReadAccess pAlphaReadAccess( aAlpha );
-
-    size_t i = 0;
-    for (long ny = 0; ny < bmpHeight; ny++)
-    {
-        Scanline pAScan = pAlphaReadAccess->GetScanline(ny);
-        for(long nx = 0; nx < bmpWidth; nx++)
-        {
-            BitmapColor aCol = pReadAccces->GetColor( ny, nx );
-            bitmapBuf[i++] = aCol.GetRed();
-            bitmapBuf[i++] = aCol.GetGreen();
-            bitmapBuf[i++] = aCol.GetBlue();
-            bitmapBuf[i++] = 255 - *pAScan++;
-        }
-    }
+    boost::scoped_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx));
 
     TextInfo aTextInfo;
     aTextInfo.rotation = -(double)rotation / 360.0 * 2* GL_PI;
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 77d1b28..5cb1078 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -12,6 +12,7 @@
 
 #include <GL/glew.h>
 #include <vcl/vclopengl_dllapi.hxx>
+#include <vcl/bitmapex.hxx>
 
 #include <rtl/ustring.hxx>
 
@@ -20,6 +21,7 @@ class VCLOPENGL_DLLPUBLIC OpenGLHelper
 public:
     static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
 
+    static sal_uInt8* ConvertBitmapExToRGBABuffer(const BitmapEx& rBitmapEx);
 };
 
 #endif
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 0042231..35760f2 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -12,6 +12,8 @@
 #include <osl/file.hxx>
 #include <rtl/bootstrap.hxx>
 #include <config_folders.h>
+#include <vcl/salbtype.hxx>
+#include <vcl/bmpacc.hxx>
 
 #include <vector>
 
@@ -140,4 +142,30 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString
     return ProgramID;
 }
 
+sal_uInt8* OpenGLHelper::ConvertBitmapExToRGBABuffer(const BitmapEx& rBitmapEx)
+{
+    long nBmpWidth = rBitmapEx.GetSizePixel().Width();
+    long nBmpHeight = rBitmapEx.GetSizePixel().Height();
+
+    Bitmap aBitmap (rBitmapEx.GetBitmap());
+    AlphaMask aAlpha (rBitmapEx.GetAlpha());
+    sal_uInt8* pBitmapBuf(new sal_uInt8[4* nBmpWidth * nBmpHeight ]);
+    Bitmap::ScopedReadAccess pReadAccces( aBitmap );
+    AlphaMask::ScopedReadAccess pAlphaReadAccess( aAlpha );
+    size_t i = 0;
+    for (long ny = 0; ny < nBmpHeight; ny++)
+    {
+        Scanline pAScan = pAlphaReadAccess ? pAlphaReadAccess->GetScanline(ny) : 0;
+        for(long nx = 0; nx < nBmpWidth; nx++)
+        {
+            BitmapColor aCol = pReadAccces->GetColor( ny, nx );
+            pBitmapBuf[i++] = aCol.GetRed();
+            pBitmapBuf[i++] = aCol.GetGreen();
+            pBitmapBuf[i++] = aCol.GetBlue();
+            pBitmapBuf[i++] = pAScan ? 255 - *pAScan++ : 255;
+        }
+    }
+    return pBitmapBuf;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 9cf12d7544d501e6794cfbb6eabf508603d59966
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Apr 18 15:12:09 2014 +0200

    Patching libgltf: character buffer is used as cstring
    
    Change-Id: If0213fc5406ec9cbdc72be36ffc693fcbbf8ffcc

diff --git a/external/libgltf/UnpackedTarball_libgltf.mk b/external/libgltf/UnpackedTarball_libgltf.mk
index 1fbe09d..e83486d 100644
--- a/external/libgltf/UnpackedTarball_libgltf.mk
+++ b/external/libgltf/UnpackedTarball_libgltf.mk
@@ -24,6 +24,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,libgltf,\
 	external/libgltf/patches/include_typo_texture.patch \
 	external/libgltf/patches/adress_of_temporary.patch \
 	external/libgltf/patches/avoid_c++11.patch \
+	external/libgltf/patches/charbuffer_used_as_cstring.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/libgltf/patches/charbuffer_used_as_cstring.patch b/external/libgltf/patches/charbuffer_used_as_cstring.patch
new file mode 100644
index 0000000..58f5701
--- /dev/null
+++ b/external/libgltf/patches/charbuffer_used_as_cstring.patch
@@ -0,0 +1,12 @@
+diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
+--- libgltf.org/src/RenderScene.cpp	2014-04-18 13:52:31.148772285 +0200
++++ libgltf/src/RenderScene.cpp	2014-04-18 15:08:15.001604707 +0200
+@@ -211,7 +211,7 @@
+ {
+     if(0 == jsonfile)
+         return 0;
+-    string tmpStr(jsonfile->buffer);
++    string tmpStr(jsonfile->buffer,jsonfile->size);
+     loadJson.setJsonInfo(tmpStr);
+     if (!loadJson.parseJsonFile())
+         return 0;
commit aee75b57f042159d7a82734595cdce5a7903431b
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Apr 18 14:06:22 2014 +0200

    avmediaogl: use a create function for player
    
    Change-Id: I4c2cc6e99f84a5e4fe78b179891a03e50485056c

diff --git a/avmedia/source/opengl/oglmanager.cxx b/avmedia/source/opengl/oglmanager.cxx
index 71d36d3..96676ab 100644
--- a/avmedia/source/opengl/oglmanager.cxx
+++ b/avmedia/source/opengl/oglmanager.cxx
@@ -30,10 +30,11 @@ OGLManager::~OGLManager()
 uno::Reference< media::XPlayer > SAL_CALL OGLManager::createPlayer( const OUString& rURL )
     throw (uno::RuntimeException, std::exception)
 {
-    // TODO: Here we need to construct our OpenGL player.
-    // See com::sun::star::media::XManager
-    OGLPlayer* pPlayer( new OGLPlayer( rURL ) );
-    return uno::Reference< media::XPlayer >(pPlayer);
+    OGLPlayer* pPlayer( new OGLPlayer() );
+    if( pPlayer->create(rURL) )
+        return uno::Reference< media::XPlayer >(pPlayer);
+    else
+        return uno::Reference< media::XPlayer >();
 }
 
 OUString SAL_CALL OGLManager::getImplementationName() throw ( uno::RuntimeException, std::exception )
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index 5c68170..a595735 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -17,9 +17,8 @@ using namespace com::sun::star;
 
 namespace avmedia { namespace ogl {
 
-OGLPlayer::OGLPlayer( const OUString& rUrl)
+OGLPlayer::OGLPlayer()
     : Player_BASE(m_aMutex)
-    , m_sUrl(rUrl)
 {
 }
 
@@ -27,6 +26,12 @@ OGLPlayer::~OGLPlayer()
 {
 }
 
+bool OGLPlayer::create( const OUString& rURL )
+{
+    m_sURL = rURL;
+    return true;
+}
+
 void SAL_CALL OGLPlayer::start() throw ( uno::RuntimeException, std::exception )
 {
     osl::MutexGuard aGuard(m_aMutex);
@@ -129,7 +134,7 @@ uno::Reference< media::XFrameGrabber > SAL_CALL OGLPlayer::createFrameGrabber()
      throw ( uno::RuntimeException, std::exception )
 {
     osl::MutexGuard aGuard(m_aMutex);
-    OGLFrameGrabber *pFrameGrabber = new OGLFrameGrabber( m_sUrl );
+    OGLFrameGrabber *pFrameGrabber = new OGLFrameGrabber( m_sURL );
     return uno::Reference< media::XFrameGrabber >( pFrameGrabber );;
 }
 
diff --git a/avmedia/source/opengl/oglplayer.hxx b/avmedia/source/opengl/oglplayer.hxx
index 69101a6..50a9190 100644
--- a/avmedia/source/opengl/oglplayer.hxx
+++ b/avmedia/source/opengl/oglplayer.hxx
@@ -25,9 +25,11 @@ class OGLPlayer : public cppu::BaseMutex,
 {
 public:
 
-    OGLPlayer( const OUString& rURL );
+    OGLPlayer();
     virtual ~OGLPlayer();
 
+    bool create( const OUString& rURL );
+
     // XPlayer
     virtual void SAL_CALL start() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     virtual void SAL_CALL stop() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -51,7 +53,7 @@ public:
     virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
 private:
-    OUString m_sUrl;
+    OUString m_sURL;
 };
 
 } // namespace ogl


More information about the Libreoffice-commits mailing list