chart2/source/view/inc/AbstractShapeFactory.hxx | 7 + chart2/source/view/inc/OpenglShapeFactory.hxx | 6 - chart2/source/view/inc/ShapeFactory.hxx | 4 - chart2/source/view/main/AbstractShapeFactory.cxx | 1 chart2/source/view/main/DummyXShape.cxx | 5 - chart2/source/view/main/OpenGLRender.cxx | 92 ++++++++++++++++++++--- chart2/source/view/main/OpenGLRender.hxx | 7 + chart2/source/view/main/OpenglShapeFactory.cxx | 14 +-- 8 files changed, 106 insertions(+), 30 deletions(-)
New commits: commit 1690b769722a3357e3bea18c86f12175c67a6b1b Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Mon Dec 9 07:40:23 2013 +0100 initial work on showing the bitmap in Libreoffice Change-Id: Id6543889509982bdb7487de484cf3d7f79c15f1e diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx index 36b2554..e9726c2 100644 --- a/chart2/source/view/inc/AbstractShapeFactory.hxx +++ b/chart2/source/view/inc/AbstractShapeFactory.hxx @@ -58,8 +58,15 @@ class Stripe; class AbstractShapeFactory { +protected: + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> + m_xShapeFactory; public: + 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); virtual ~AbstractShapeFactory() {}; diff --git a/chart2/source/view/inc/OpenglShapeFactory.hxx b/chart2/source/view/inc/OpenglShapeFactory.hxx index 8952eea..be4d01d 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( @@ -195,9 +192,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 10cd541..cb2b1bf 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -220,10 +220,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 96a919c..d6d6b2e 100644 --- a/chart2/source/view/main/AbstractShapeFactory.cxx +++ b/chart2/source/view/main/AbstractShapeFactory.cxx @@ -88,6 +88,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 ecf3c59..7372a44 100644 --- a/chart2/source/view/main/DummyXShape.cxx +++ b/chart2/source/view/main/DummyXShape.cxx @@ -845,8 +845,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 82c6ac6..a52430d 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 db36dbe..8ce8fab 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 bb956ee..8e529b8 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 @@ -524,11 +527,6 @@ void OpenglShapeFactory::renderSeries( const uno::Reference< SAL_WARN("chart2.opengl", "OpenglShapeFactory::renderSeries()-----test:"); } -OpenglShapeFactory::OpenglShapeFactory() -{ - m_pChart = NULL; -} - } //namespace dummy } //namespace chart _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits