summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-12-09 07:40:23 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-01-29 08:09:18 +0100
commitbe0befbc5faec0b401724439a22fb38323a6b5fc (patch)
treef3d0bbfdf991a5d03d8da7e06d6f9a0803e34f89 /chart2
parentb03388e415d5fa3cda8bf543fd267776000421a5 (diff)
initial work on showing the bitmap in Libreoffice
Change-Id: Id6543889509982bdb7487de484cf3d7f79c15f1e
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/inc/AbstractShapeFactory.hxx6
-rw-r--r--chart2/source/view/inc/OpenglShapeFactory.hxx6
-rw-r--r--chart2/source/view/inc/ShapeFactory.hxx4
-rw-r--r--chart2/source/view/main/AbstractShapeFactory.cxx1
-rw-r--r--chart2/source/view/main/DummyXShape.cxx5
-rw-r--r--chart2/source/view/main/OpenGLRender.cxx92
-rw-r--r--chart2/source/view/main/OpenGLRender.hxx7
-rw-r--r--chart2/source/view/main/OpenglShapeFactory.cxx14
8 files changed, 105 insertions, 30 deletions
diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx
index 73fbf6989736..8ff9513b7979 100644
--- a/chart2/source/view/inc/AbstractShapeFactory.hxx
+++ b/chart2/source/view/inc/AbstractShapeFactory.hxx
@@ -58,9 +58,15 @@ class Stripe;
class AbstractShapeFactory
{
+protected:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>
+ m_xShapeFactory;
public:
enum StackPosition { Top, Bottom };
+ void setShapeFactory(com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> xFactory)
+ { m_xShapeFactory = xFactory; }
static AbstractShapeFactory* getOrCreateShapeFactory(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> xFactory);
diff --git a/chart2/source/view/inc/OpenglShapeFactory.hxx b/chart2/source/view/inc/OpenglShapeFactory.hxx
index fc9568717269..3274102f0443 100644
--- a/chart2/source/view/inc/OpenglShapeFactory.hxx
+++ b/chart2/source/view/inc/OpenglShapeFactory.hxx
@@ -19,9 +19,6 @@ namespace opengl {
class OpenglShapeFactory : public chart::AbstractShapeFactory
{
public:
- OpenglShapeFactory();
- OpenglShapeFactory(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> xFactory)
- {m_xShapeFactory = xFactory;}
virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
createGroup2D(
@@ -196,9 +193,6 @@ public:
virtual void setPageSize( com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > xChartShapes, const com::sun::star::awt::Size& rSize );
private:
void *m_pChart;
- //member:
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>
- m_xShapeFactory;
};
diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx
index ed592d2a277b..00c532e94cf5 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -221,10 +221,6 @@ private:
, const ::com::sun::star::drawing::Direction3D& rSize
, double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree
, bool bCylinder = false);
-
- //member:
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>
- m_xShapeFactory;
};
} //namespace chart
diff --git a/chart2/source/view/main/AbstractShapeFactory.cxx b/chart2/source/view/main/AbstractShapeFactory.cxx
index bf155dbb40f8..d72c2bb15b71 100644
--- a/chart2/source/view/main/AbstractShapeFactory.cxx
+++ b/chart2/source/view/main/AbstractShapeFactory.cxx
@@ -90,6 +90,7 @@ AbstractShapeFactory* AbstractShapeFactory::getOrCreateShapeFactory(uno::Referen
{
pShapeFactory = reinterpret_cast<__getOpenglShapeFactory>(fn)();
+ pShapeFactory->setShapeFactory(xFactory);
}
}
}
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index a42571402fe2..0442e7584d13 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -839,8 +839,9 @@ bool DummyChart::initOpengl()
}
-DummyChart::DummyChart():
- mpWindow(new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL))
+DummyChart::DummyChart(uno::Reference< drawing::XShape > xTarget):
+ mpWindow(new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL)),
+ m_GLRender(xTarget)
{
SAL_WARN("chart2.opengl", "DummyXShape::DummyChart()-----test: ");
setName("com.sun.star.chart2.shapes");
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 82c6ac6ebf72..a52430da278e 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -11,6 +11,16 @@
#include <vector>
#include <iostream>
#include "OpenGLRender.hxx"
+#include <vcl/bitmapex.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/graph.hxx>
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+
+using namespace com::sun::star;
+
+#include <boost/scoped_array.hpp>
using namespace std;
@@ -483,7 +493,7 @@ int OpenGLRender::RenderModelf2FBO(float *vertexArray, unsigned int vertexArrayS
{
result = -1;
}
-#if 1
+#if 0
sal_uInt8 *buf = (sal_uInt8 *)malloc(m_iWidth * m_iHeight * 3 + BMP_HEADER_LEN);
CreateBMPHeader(buf, m_iWidth, -m_iHeight);
glReadPixels(0, 0, m_iWidth, m_iHeight, GL_BGR, GL_UNSIGNED_BYTE, buf + BMP_HEADER_LEN);
@@ -493,13 +503,36 @@ int OpenGLRender::RenderModelf2FBO(float *vertexArray, unsigned int vertexArrayS
fclose(pfile);
#else
- boost::scoped_array<sal_uInt8> buf = new sal_uInt8[m_iWidth * m_iHeight * 4];
- glBindTexture(GL_TEXTURE_2D, m_TextureObj);
- glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf.get());
- FILE *pfile = fopen(fileName,"wb");
- fwrite(buf,m_iWidth * m_iHeight * 3, 1, pfile);
- fclose(pfile);
- glBindTexture(GL_TEXTURE_2D, 0);
+ boost::scoped_array<sal_uInt8> buf(new sal_uInt8[m_iWidth * m_iHeight * 4]);
+ glReadPixels(0, 0, m_iWidth, m_iHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf.get());
+ BitmapEx aBmp;
+ aBmp.SetSizePixel(Size(m_iWidth, m_iHeight));
+
+ Bitmap aBitmap( aBmp.GetBitmap() );
+ Bitmap aAlpha( aBmp.GetAlpha().GetBitmap() );
+
+ Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );
+ Bitmap::ScopedWriteAccess pAlphaWriteAccess( aAlpha );
+
+ size_t nCurPos = 0;
+ for( size_t y = 0; y < m_iHeight; ++y)
+ {
+ Scanline pScan = pWriteAccess->GetScanline(y);
+ Scanline pAlphaScan = pAlphaWriteAccess->GetScanline(y);
+
+ for( size_t x = 0; x < m_iWidth; ++x )
+ {
+ *pScan++ = buf[nCurPos];
+ *pScan++ = buf[nCurPos+1];
+ *pScan++ = buf[nCurPos+2];
+
+ nCurPos += 3;
+
+ *pAlphaScan++ = static_cast<sal_uInt8>( 255 - buf[nCurPos++] );
+ }
+ }
+
+ aBmp = BitmapEx(aBitmap, aAlpha);
#endif
glBindFramebuffer(GL_FRAMEBUFFER, 0);
RenderTexture(m_TextureObj[0]);
@@ -606,6 +639,7 @@ int OpenGLRender::RenderLine2FBO(int wholeFlag)
{
result = -1;
}
+#if 0
sal_uInt8 *buf = (sal_uInt8 *)malloc(m_iWidth * m_iHeight * 3 + BMP_HEADER_LEN);
CreateBMPHeader(buf, m_iWidth, m_iHeight);
glReadPixels(0, 0, m_iWidth, m_iHeight, GL_BGR, GL_UNSIGNED_BYTE, buf + BMP_HEADER_LEN);
@@ -613,6 +647,43 @@ int OpenGLRender::RenderLine2FBO(int wholeFlag)
fwrite(buf,m_iWidth * m_iHeight * 3 + BMP_HEADER_LEN, 1, pfile);
free(buf);
fclose(pfile);
+#else
+ boost::scoped_array<sal_uInt8> buf(new sal_uInt8[m_iWidth * m_iHeight * 4]);
+ glReadPixels(0, 0, m_iWidth, m_iHeight, GL_BGR, GL_UNSIGNED_BYTE, buf.get());
+ BitmapEx aBmp;
+ aBmp.SetSizePixel(Size(m_iWidth, m_iHeight));
+
+ Bitmap aBitmap( aBmp.GetBitmap() );
+ Bitmap aAlpha( aBmp.GetAlpha().GetBitmap() );
+
+ Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );
+ Bitmap::ScopedWriteAccess pAlphaWriteAccess( aAlpha );
+
+ size_t nCurPos = 0;
+ for( size_t y = 0; y < m_iHeight; ++y)
+ {
+ Scanline pScan = pWriteAccess->GetScanline(y);
+ Scanline pAlphaScan = pAlphaWriteAccess->GetScanline(y);
+
+ for( size_t x = 0; x < m_iWidth; ++x )
+ {
+ *pScan++ = buf[nCurPos];
+ *pScan++ = buf[nCurPos+1];
+ *pScan++ = buf[nCurPos+2];
+
+ nCurPos += 3;
+
+ *pAlphaScan++ = static_cast<sal_uInt8>( 255 - buf[nCurPos++] );
+ }
+ }
+
+ aBmp = BitmapEx(aBitmap, aAlpha);
+ Graphic aGraphic(aBmp);
+ uno::Reference< awt::XBitmap> xBmp( aGraphic.GetXGraphic(), uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xPropSet ( mxRenderTarget, uno::UNO_QUERY );
+ xPropSet->setPropertyValue("Graphic", uno::makeAny(aGraphic.GetXGraphic()));
+
+#endif
glBindFramebuffer(GL_FRAMEBUFFER, 0);
#if defined( WNT )
SwapBuffers(glWin.hDC);
@@ -842,7 +913,7 @@ void OpenGLRender::Release()
}
-OpenGLRender::OpenGLRender()
+OpenGLRender::OpenGLRender(uno::Reference< drawing::XShape > xTarget)
{
//[mod] by gaowei
m_Model = glm::mat4(1.0f);
@@ -862,6 +933,9 @@ OpenGLRender::OpenGLRender()
m_RboID[0] = 0;
m_RboID[1] = 0;
m_fLineAlpha = 1.0;
+
+ mxRenderTarget = xTarget;
+ mxRenderTarget->setPosition(awt::Point(0,0));
}
OpenGLRender::~OpenGLRender()
{
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index db36dbe6a8f1..8ce8fab13eee 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <com/sun/star/drawing/XDrawPage.hpp>
+
#if defined( _WIN32 )
#include "prewin.h"
#include "windows.h"
@@ -103,7 +105,8 @@ struct GLWindow
class OpenGLRender
{
public:
- OpenGLRender();
+ OpenGLRender(com::sun::star::uno::Reference<
+ com::sun::star::drawing::XShape > xTarget );
~OpenGLRender();
int InitOpenGL(GLWindow);
int SetViewPoint(PosVeci3 camPos, PosVeci3 orgPos, int headUpFlag);
@@ -204,6 +207,8 @@ private:
float m_fLineAlpha;
list <Line2DPointList> m_Line2DShapePointList;
+
+ com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxRenderTarget;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/OpenglShapeFactory.cxx b/chart2/source/view/main/OpenglShapeFactory.cxx
index 6276b7b5f662..65a73084a793 100644
--- a/chart2/source/view/main/OpenglShapeFactory.cxx
+++ b/chart2/source/view/main/OpenglShapeFactory.cxx
@@ -59,8 +59,8 @@ namespace chart
{
extern "C" {
- SAL_DLLPUBLIC_EXPORT opengl::OpenglShapeFactory* getOpenglShapeFactory(uno::Reference< lang::XMultiServiceFactory> xFactory)
- { return new opengl::OpenglShapeFactory(xFactory);}
+ SAL_DLLPUBLIC_EXPORT opengl::OpenglShapeFactory* getOpenglShapeFactory()
+ { return new opengl::OpenglShapeFactory();}
}
@@ -114,7 +114,10 @@ uno::Reference< drawing::XShapes > OpenglShapeFactory::getOrCreateChartRootShape
{
//create the root shape
SAL_WARN("chart2.opengl", "getOrCreateChartRootShape");
- dummy::DummyChart *pChart = new dummy::DummyChart();
+
+ uno::Reference< drawing::XShape > xTarget (m_xShapeFactory->createInstance(
+ "com.sun.star.drawing.GraphicObjectShape" ), uno::UNO_QUERY );
+ dummy::DummyChart *pChart = new dummy::DummyChart(xTarget);
m_pChart = (void *)pChart;
xRet = pChart;
#if 0
@@ -526,11 +529,6 @@ void OpenglShapeFactory::renderSeries( const uno::Reference<
SAL_WARN("chart2.opengl", "OpenglShapeFactory::renderSeries()-----test:");
}
-OpenglShapeFactory::OpenglShapeFactory()
-{
- m_pChart = NULL;
-}
-
} //namespace dummy
} //namespace chart