[Libreoffice-commits] core.git: Branch 'private/moggi/opengl-3D-bar-rendering' - 2 commits - chart2/Library_chartcore.mk chart2/source include/vcl vcl/Library_vclopengl.mk vcl/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Mon Apr 7 17:20:17 PDT 2014


 chart2/Library_chartcore.mk                  |    2 -
 chart2/source/view/charttypes/3DBarChart.cxx |    2 +
 chart2/source/view/inc/3DChartObjects.hxx    |    4 ++
 chart2/source/view/main/3DChartObjects.cxx   |    9 ++++
 chart2/source/view/main/ChartView.cxx        |    1 
 include/vcl/OpenGLContext.hxx                |    2 +
 vcl/Library_vclopengl.mk                     |    1 
 vcl/source/opengl/OpenGLContext.cxx          |   53 +++++++++++++++++++++++++++
 8 files changed, 70 insertions(+), 4 deletions(-)

New commits:
commit 54c59b66cecdea2d14057520565764d6c5f2088f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Apr 8 02:17:28 2014 +0200

    remove unused variable
    
    Change-Id: I8291aa433fb8f9d8fd3a5c2c756c006321a6deb4

diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index b30b367..1a3a5cd 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -3116,7 +3116,6 @@ void ChartView::createShapes3D()
         return;
 
     uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
-    sal_Int32 nGlobalSeriesIndex = 0;//for automatic symbols
     std::vector<VDataSeries*> aDataSeries;
     for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
     {
commit 85f0819b6cce011e5e2859eb6ec62c24e8ef094f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Apr 8 02:16:08 2014 +0200

    temporarily render to a file
    
    Change-Id: Ibfc8101f261489bf11f990ea3fe6ae2e74b99df9

diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index e4b0051..e027865 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -249,6 +249,4 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
     chart2/source/tools/XMLRangeHelper \
 ))
 
-
-
 # vim: set noet sw=4 ts=4:
diff --git a/chart2/source/view/charttypes/3DBarChart.cxx b/chart2/source/view/charttypes/3DBarChart.cxx
index 3a13059..e8db5bf 100644
--- a/chart2/source/view/charttypes/3DBarChart.cxx
+++ b/chart2/source/view/charttypes/3DBarChart.cxx
@@ -7,6 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <GL/glew.h>
+
 #include "3DBarChart.hxx"
 
 #include <glm/glm.hpp>
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index f7eed23..257653f 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -71,12 +71,16 @@ namespace temporary {
 class TemporaryContext
 {
 public:
+    TemporaryContext();
 
     void init();
     void render();
 
 private:
     OpenGLContext maContext;
+
+    int miWidth;
+    int miHeight;
 };
 
 }
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 3c5a5b8..c74b475 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -20,14 +20,21 @@ Bar::Bar(const glm::mat4& rPosition):
 
 namespace temporary {
 
+TemporaryContext::TemporaryContext():
+    miWidth(200),
+    miHeight(200)
+{
+}
+
 void TemporaryContext::init()
 {
     maContext.init();
+    maContext.setWinSize(Size(miWidth, miHeight));
 }
 
 void TemporaryContext::render()
 {
-
+    maContext.renderToFile();
 }
 
 }
diff --git a/include/vcl/OpenGLContext.hxx b/include/vcl/OpenGLContext.hxx
index 8c7eb55..b62448a 100644
--- a/include/vcl/OpenGLContext.hxx
+++ b/include/vcl/OpenGLContext.hxx
@@ -103,6 +103,8 @@ public:
     void setWinSize(const Size& rSize);
     GLWindow& getOpenGLWindow();
 
+    void renderToFile();
+
 private:
     SAL_DLLPRIVATE bool initWindow();
 
diff --git a/vcl/Library_vclopengl.mk b/vcl/Library_vclopengl.mk
index 793f09f..e14899b 100644
--- a/vcl/Library_vclopengl.mk
+++ b/vcl/Library_vclopengl.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_Library_use_libraries,vclopengl,\
     cppu \
     cppuhelper \
     sal \
+	tl \
     vcl \
     $(gb_UWINAPI) \
 ))
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 985018b..6069471 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -11,6 +11,12 @@
 #include <vcl/syschild.hxx>
 #include <vcl/sysdata.hxx>
 
+#include <boost/scoped_array.hpp>
+#include <vcl/pngwrite.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/bitmapex.hxx>
+
 using namespace com::sun::star;
 
 OpenGLContext::OpenGLContext():
@@ -470,6 +476,9 @@ void OpenGLContext::setWinSize(const Size& rSize)
     if(m_pWindow)
         m_pWindow->SetSizePixel(rSize);
     m_pChildWindow->SetSizePixel(rSize);
+
+    m_aGLWin.Width = rSize.Width();
+    m_aGLWin.Height = rSize.Height();
 }
 
 GLWindow& OpenGLContext::getOpenGLWindow()
@@ -477,6 +486,50 @@ GLWindow& OpenGLContext::getOpenGLWindow()
     return m_aGLWin;
 }
 
+void OpenGLContext::renderToFile()
+{
+    int iWidth = m_aGLWin.Width;
+    int iHeight = m_aGLWin.Height;
+    boost::scoped_array<sal_uInt8> buf(new sal_uInt8[iWidth * iHeight * 4]);
+    glReadPixels(0, 0, iWidth, iHeight, GL_BGRA, GL_UNSIGNED_BYTE, buf.get());
+
+    Bitmap aBitmap( Size(iWidth, iHeight), 24 );
+    AlphaMask aAlpha( Size(iWidth, iHeight) );
+
+    {
+        Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );
+        AlphaMask::ScopedWriteAccess pAlphaWriteAccess( aAlpha );
+
+        size_t nCurPos = 0;
+        for( int y = 0; y < iHeight; ++y)
+        {
+            Scanline pScan = pWriteAccess->GetScanline(y);
+            Scanline pAlphaScan = pAlphaWriteAccess->GetScanline(y);
+            for( int x = 0; x < iWidth; ++x )
+            {
+                *pScan++ = buf[nCurPos];
+                *pScan++ = buf[nCurPos+1];
+                *pScan++ = buf[nCurPos+2];
+
+                nCurPos += 3;
+                *pAlphaScan++ = static_cast<sal_uInt8>( 255 - buf[nCurPos++] );
+            }
+        }
+    }
+
+    BitmapEx aBmp(aBitmap, aAlpha);
+    static int nIdx = 0;
+    OUString aName = OUString( "file:///home/moggi/Documents/work/text" ) + OUString::number( nIdx++ ) + ".png";
+    try {
+        vcl::PNGWriter aWriter( aBmp );
+        SvFileStream sOutput( aName, STREAM_WRITE );
+        aWriter.Write( sOutput );
+        sOutput.Close();
+    } catch (...) {
+        SAL_WARN("chart2.opengl", "Error writing png to " << aName);
+    }
+}
+
 #if defined( WNT )
 
 bool OpenGLContext::initWindow()


More information about the Libreoffice-commits mailing list