[Libreoffice-commits] core.git: 18 commits - chart2/inc chart2/Library_chartcore.mk chart2/source include/svx include/vcl sc/source svx/Library_svxcore.mk svx/source vcl/Library_vclopengl.mk vcl/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Mon Apr 7 19:41:00 PDT 2014
chart2/Library_chartcore.mk | 7
chart2/inc/ChartView.hxx | 2
chart2/source/inc/macros.hxx | 2
chart2/source/view/charttypes/3DBarChart.cxx | 74 ++++++++++
chart2/source/view/inc/3DBarChart.hxx | 48 ++++++
chart2/source/view/inc/3DChartObjects.hxx | 92 ++++++++++++
chart2/source/view/main/3DChartObjects.cxx | 46 ++++++
chart2/source/view/main/3DChartObjects.hxx | 55 -------
chart2/source/view/main/ChartView.cxx | 103 ++++++++++++--
chart2/source/view/main/DummyXShape.cxx | 4
chart2/source/view/main/DummyXShape.hxx | 1
chart2/source/view/main/OpenGLRender.cxx | 42 -----
chart2/source/view/main/OpenGLRender.hxx | 4
include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx | 3
include/svx/svdoopengl.hxx | 19 +-
include/vcl/OpenGLContext.hxx | 8 -
sc/source/filter/excel/xestyle.cxx | 3
svx/Library_svxcore.mk | 4
svx/source/svdraw/svdoopengl.cxx | 33 ++++
vcl/Library_vclopengl.mk | 1
vcl/source/opengl/OpenGLContext.cxx | 110 ++++++++++++---
21 files changed, 517 insertions(+), 144 deletions(-)
New commits:
commit d47d8fb222e6b8e196989d0761a5c03b9669acdf
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 8b29516..1406336 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 b6e5907f5a228b07824d61e90e668cda8e4079df
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 eb80033..29ac4d7 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()
commit 0869626e2b29ad9b2e81c8f4eee7bd1b2372d91b
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Tue Apr 8 01:17:16 2014 +0200
improve the code for temporary OpenGl context
Change-Id: Ia66bf54539e67066a56bb50fb606e50e581bee73
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 55aa610..e4b0051 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_Library_use_externals,chartcore,\
boost_headers \
mdds_headers \
glm_headers \
+ glew \
))
$(eval $(call gb_Library_use_custom_headers,chartcore,\
@@ -56,6 +57,7 @@ $(eval $(call gb_Library_use_libraries,chartcore,\
ucbhelper \
utl \
vcl \
+ vclopengl \
$(gb_UWINAPI) \
))
diff --git a/chart2/source/view/charttypes/3DBarChart.cxx b/chart2/source/view/charttypes/3DBarChart.cxx
index 79c02a6..3a13059 100644
--- a/chart2/source/view/charttypes/3DBarChart.cxx
+++ b/chart2/source/view/charttypes/3DBarChart.cxx
@@ -9,15 +9,16 @@
#include "3DBarChart.hxx"
-#include "3DChartObjects.hxx"
-
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>
+#include "3DChartObjects.hxx"
+
namespace chart {
Bar3DChart::Bar3DChart(const std::vector<VDataSeries*>& rDataSeries):
- maDataSeries(rDataSeries)
+ maDataSeries(rDataSeries),
+ mxContext(new opengl3D::temporary::TemporaryContext())
{
}
@@ -57,12 +58,13 @@ void Bar3DChart::create3DShapes()
void Bar3DChart::render()
{
- maContext.init();
+ mxContext->init();
for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
itrEnd = maShapes.end(); itr != itrEnd; ++itr)
{
itr->render();
}
+ mxContext->render();
}
}
diff --git a/chart2/source/view/inc/3DBarChart.hxx b/chart2/source/view/inc/3DBarChart.hxx
index 0cc5831..2f10ce2 100644
--- a/chart2/source/view/inc/3DBarChart.hxx
+++ b/chart2/source/view/inc/3DBarChart.hxx
@@ -19,7 +19,11 @@ namespace opengl3D {
class Renderable3DObject;
-}
+namespace temporary {
+
+class TemporaryContext;
+
+} }
class Bar3DChart
{
@@ -36,7 +40,7 @@ private:
std::vector<VDataSeries*> maDataSeries;
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
- OpenGLContext maContext;
+ boost::scoped_ptr<opengl3D::temporary::TemporaryContext> mxContext;
};
}
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index ec56ad8..f7eed23 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -12,6 +12,8 @@
#include <tools/color.hxx>
#include <vcl/bitmapex.hxx>
+#include <vcl/OpenGLContext.hxx>
+
namespace chart {
namespace opengl3D {
@@ -64,6 +66,21 @@ private:
Color maLineColor; // RGBA line color
};
+namespace temporary {
+
+class TemporaryContext
+{
+public:
+
+ void init();
+ void render();
+
+private:
+ OpenGLContext maContext;
+};
+
+}
+
}
}
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index 0a0696a..3c5a5b8 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -18,6 +18,20 @@ Bar::Bar(const glm::mat4& rPosition):
{
}
+namespace temporary {
+
+void TemporaryContext::init()
+{
+ maContext.init();
+}
+
+void TemporaryContext::render()
+{
+
+}
+
+}
+
}
}
diff --git a/include/vcl/OpenGLContext.hxx b/include/vcl/OpenGLContext.hxx
index e84e8fc..8c7eb55 100644
--- a/include/vcl/OpenGLContext.hxx
+++ b/include/vcl/OpenGLContext.hxx
@@ -10,6 +10,8 @@
#ifndef VCL_OPENGL_CONTEXT_HXX
#define VCL_OPENGL_CONTEXT_HXX
+#include <GL/glew.h>
+
#if defined( MACOSX )
#elif defined( UNX )
# include <prex.h>
@@ -21,8 +23,6 @@
# include "postwin.h"
#endif
-#include <GL/glew.h>
-
#if defined( _WIN32 )
#include <GL/glext.h>
#include <GL/wglext.h>
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 8dcaabb..eb80033 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -7,7 +7,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <GL/glew.h>
#include <vcl/OpenGLContext.hxx>
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
commit ed649cc4817b6d35e71d15331293afd91fba9358
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Tue Apr 8 00:34:29 2014 +0200
call glewInit in vcl's OpenGLContext just once
Change-Id: I9f9b50615e588e659c7fcdd016cf9ceb8407b974
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 304d9f4..8dcaabb 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <GL/glew.h>
#include <vcl/OpenGLContext.hxx>
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
@@ -447,6 +448,19 @@ bool OpenGLContext::init( Window* pParent )
#endif
+ static bool bGlewInit = false;
+ if(!bGlewInit)
+ {
+ glewExperimental = GL_TRUE;
+ if (glewInit() != GLEW_OK)
+ {
+ SAL_WARN("vcl.opengl", "Failed to initialize GLEW");
+ return false;
+ }
+ else
+ bGlewInit = true;
+ }
+
SAL_INFO("vcl.opengl", "OpenGLContext::init----end");
mbInitialized = true;
return true;
commit 375659b8641126cf1deae1c1789880771aa61308
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Tue Apr 8 00:30:23 2014 +0200
e temporarily a local OpenGL context
Change-Id: I086d826456d77bf978c3877ed6da92850878ad97
diff --git a/chart2/source/view/charttypes/3DBarChart.cxx b/chart2/source/view/charttypes/3DBarChart.cxx
index 2da54aa..79c02a6 100644
--- a/chart2/source/view/charttypes/3DBarChart.cxx
+++ b/chart2/source/view/charttypes/3DBarChart.cxx
@@ -57,6 +57,7 @@ void Bar3DChart::create3DShapes()
void Bar3DChart::render()
{
+ maContext.init();
for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
itrEnd = maShapes.end(); itr != itrEnd; ++itr)
{
diff --git a/chart2/source/view/inc/3DBarChart.hxx b/chart2/source/view/inc/3DBarChart.hxx
index 6eeea5b..0cc5831 100644
--- a/chart2/source/view/inc/3DBarChart.hxx
+++ b/chart2/source/view/inc/3DBarChart.hxx
@@ -11,6 +11,8 @@
#include <boost/ptr_container/ptr_vector.hpp>
#include "VDataSeries.hxx"
+#include <vcl/OpenGLContext.hxx>
+
namespace chart {
namespace opengl3D {
@@ -34,6 +36,7 @@ private:
std::vector<VDataSeries*> maDataSeries;
boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
+ OpenGLContext maContext;
};
}
commit 4d5d61e45435551088d6604f028cb9941974eafe
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Apr 7 23:54:25 2014 +0200
remove some OpenGL traces from OpenGLRender and DummyXShape
Change-Id: Ibc4877a7c98a0ee1920d6ff0137009f489e2e9a9
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index c3978f4..5a0f88e 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -1147,8 +1147,7 @@ DummyChart::DummyChart(uno::Reference< drawing::XShape > xTarget):
{
SAL_INFO("chart2.opengl", "DummyXShape::DummyChart()-----test: ");
setName("com.sun.star.chart2.shapes");
- m_aGLContext.init();
- m_GLRender.InitOpenGL(m_aGLContext.getOpenGLWindow());
+ m_GLRender.InitOpenGL();
}
void SAL_CALL DummyChart::setPosition( const awt::Point& aPosition )
@@ -1167,7 +1166,6 @@ void SAL_CALL DummyChart::setSize( const awt::Size& aSize )
SAL_INFO("chart2.opengl", "DummyChart::setSize()---aSize.Width = " << aSize.Width << ", aSize.Height = " << aSize.Height);
int width = aSize.Width / OPENGL_SCALE_VALUE;
int height = aSize.Height / OPENGL_SCALE_VALUE;
- m_aGLContext.setWinSize(Size(width, height));
DummyXShape::setSize(awt::Size(0,0));
m_GLRender.SetSize(width, height);
SAL_INFO("chart2.opengl", "DummyChart::GLRender.Width = " << width << ", GLRender.Height = " << height);
diff --git a/chart2/source/view/main/DummyXShape.hxx b/chart2/source/view/main/DummyXShape.hxx
index 3ea60b4..81a088a 100644
--- a/chart2/source/view/main/DummyXShape.hxx
+++ b/chart2/source/view/main/DummyXShape.hxx
@@ -404,7 +404,6 @@ public:
private:
TextCache maTextCache;
- OpenGLContext m_aGLContext;
public:
OpenGLRender m_GLRender;
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index a0f7573..610eb72 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -232,10 +232,10 @@ GLfloat texCoords[] = {
}
-int OpenGLRender::InitOpenGL(GLWindow aWindow)
+int OpenGLRender::InitOpenGL()
{
- glWin = aWindow;
- mbArbMultisampleSupported = glWin.bMultiSampleSupported;
+ //TODO: moggi: get the information from the context
+ mbArbMultisampleSupported = true;
if(!bGlewInit)
{
glewExperimental = GL_TRUE;
@@ -636,21 +636,6 @@ void OpenGLRender::Release()
glDeleteRenderbuffers(1, &m_RboID);
glDeleteRenderbuffers(1, &m_renderBufferColorMS);
glDeleteRenderbuffers(1, &m_renderBufferDepthMS);
-#if defined( WNT )
- wglMakeCurrent(NULL, NULL);
-#elif defined( MACOSX )
-
-#elif defined( UNX )
-
- glXMakeCurrent(glWin.dpy, None, NULL);
- if( glGetError() != GL_NO_ERROR ) {
- SAL_INFO("chart2.opengl", "glError: " << (char *)gluErrorString(glGetError()));
- }
- glXDestroyContext(glWin.dpy, glWin.ctx);
- glWin.ctx = NULL;
- glWin.win = 0;
-
-#endif
}
OpenGLRender::OpenGLRender(uno::Reference< drawing::XShape > xTarget)
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 725e32e..6fde176 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -67,7 +67,7 @@ public:
OpenGLRender(com::sun::star::uno::Reference<
com::sun::star::drawing::XShape > xTarget );
~OpenGLRender();
- int InitOpenGL(GLWindow);
+ int InitOpenGL();
int MoveModelf(PosVecf3 trans, PosVecf3 angle, PosVecf3 scale);
void SetSize(int width, int height);
void Release();
@@ -141,8 +141,6 @@ private:
int m_iHeight;
- GLWindow glWin;
-
Line2DPointList m_Line2DPointList;
float m_fLineWidth;
commit c06ab7e366ce7ddc8bf68259c3198df886ba37db
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun Apr 6 16:37:25 2014 +0200
remove whitespace
Change-Id: I16930834f75efcac8c710486d4e3286fcaaf64fd
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 7f7c90a..7365540 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -1665,7 +1665,6 @@ void XclExpCellBorder::SetFinalColors( const XclExpPalette& rPalette )
mnDiagColor = rPalette.GetColorIndex( mnDiagColorId );
}
-
void XclExpCellBorder::FillToXF5( sal_uInt32& rnBorder, sal_uInt32& rnArea ) const
{
::insert_value( rnBorder, mnTopLine, 0, 3 );
@@ -1869,7 +1868,6 @@ void XclExpCellArea::SaveXml( XclExpXmlStream& rStrm ) const
rStyleSheet->endElement( XML_fill );
}
-
bool XclExpColor::FillFromItemSet( const SfxItemSet& rItemSet )
{
if( !ScfTools::CheckItem( rItemSet, ATTR_BACKGROUND, true ) )
@@ -2842,7 +2840,6 @@ void XclExpXFBuffer::AddBorderAndFill( const XclExpXF& rXF )
}
}
-
XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
: XclExpRoot( rRoot ),
mxFormatter( new SvNumberFormatter( comphelper::getProcessComponentContext(), LANGUAGE_ENGLISH_US ) ),
commit f5a86d3ba079b32e063300c68071f105f5021ee8
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed Apr 2 04:09:43 2014 +0200
initial work on allowing to resize the OpenGL object
Change-Id: I29799522d32e31b4ffbba9d931fda352ee080e2d
diff --git a/include/svx/svdoopengl.hxx b/include/svx/svdoopengl.hxx
index 4510f56..4bd4bc2 100644
--- a/include/svx/svdoopengl.hxx
+++ b/include/svx/svdoopengl.hxx
@@ -11,21 +11,20 @@
#define INCLUDED_SVX_SVDO_OPENGL_HXX
#include <svx/svdobj.hxx>
-#include <svx/sdr/contact/viewcontactofopenglobj.hxx>
#include <vcl/OpenGLContext.hxx>
+namespace sdr { namespace contact {
+ class ViewContact;
+} }
+
class SVX_DLLPUBLIC SdrOpenGLObj : public SdrObject
{
public:
- virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() SAL_OVERRIDE
- {
- return new sdr::contact::ViewContactOfOpenGLObj(*this);
- }
-
- OpenGLContext& getOpenGLContext()
- {
- return maContext;
- }
+ virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() SAL_OVERRIDE;
+
+ OpenGLContext& getOpenGLContext();
+
+ virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
private:
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index b3c3521..8826d9f 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -297,6 +297,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/svdraw/svdomeas \
svx/source/svdraw/svdomedia \
svx/source/svdraw/svdoole2 \
+ svx/source/svdraw/svdoopengl \
svx/source/svdraw/svdopage \
svx/source/svdraw/svdopath \
svx/source/svdraw/svdorect \
diff --git a/svx/source/svdraw/svdoopengl.cxx b/svx/source/svdraw/svdoopengl.cxx
new file mode 100644
index 0000000..45d23ae
--- /dev/null
+++ b/svx/source/svdraw/svdoopengl.cxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <svx/svdoopengl.hxx>
+#include <svx/sdr/contact/viewcontactofopenglobj.hxx>
+
+sdr::contact::ViewContact* SdrOpenGLObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfOpenGLObj(*this);
+}
+
+OpenGLContext& SdrOpenGLObj::getOpenGLContext()
+{
+ return maContext;
+}
+
+void SdrOpenGLObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ SdrObject::NbcResize(rRef, xFact, yFact);
+
+ //now pass the information to the OpenGL context
+ maContext.setWinSize(aOutRect.GetSize());
+ SAL_WARN("svx.opengl", "resized opengl drawinglayer object");
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 6948bf58ce181b17f60ef81f10205ef4dac50cc6
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed Apr 2 03:42:03 2014 +0200
move the OpenGLContext to the model object
In the next step we need to initialize it again but in the ViewContact
it gets destroyed several times which is a problem.
Change-Id: I3efe4311bfb279b7407eabd0dd673f33603d8e9b
diff --git a/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx b/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx
index 00e1dff..f540624c 100644
--- a/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx
+++ b/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx
@@ -24,11 +24,8 @@ public:
ViewObjectContactOfOpenGLObj(ObjectContact& rObjectContact, ViewContact& rViewContact);
virtual ~ViewObjectContactOfOpenGLObj();
-protected:
- Window* getWindow() const;
-
private:
- OpenGLContext m_aOpenGLContext;
+ Window* getWindow() const;
};
} // namespace sdr
diff --git a/include/svx/svdoopengl.hxx b/include/svx/svdoopengl.hxx
index 857e313..4510f56 100644
--- a/include/svx/svdoopengl.hxx
+++ b/include/svx/svdoopengl.hxx
@@ -12,6 +12,7 @@
#include <svx/svdobj.hxx>
#include <svx/sdr/contact/viewcontactofopenglobj.hxx>
+#include <vcl/OpenGLContext.hxx>
class SVX_DLLPUBLIC SdrOpenGLObj : public SdrObject
{
@@ -20,6 +21,15 @@ public:
{
return new sdr::contact::ViewContactOfOpenGLObj(*this);
}
+
+ OpenGLContext& getOpenGLContext()
+ {
+ return maContext;
+ }
+
+private:
+
+ OpenGLContext maContext;
};
#endif
diff --git a/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx b/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx
index 1689468..2cf0086 100644
--- a/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx
@@ -18,9 +18,6 @@ ViewObjectContactOfOpenGLObj::ViewObjectContactOfOpenGLObj(
ObjectContact& rObjectContact, ViewContact& rViewContact )
: ViewObjectContactOfSdrObj( rObjectContact, rViewContact )
{
- m_aOpenGLContext.init(getWindow());
- // Set a dummy size to make the window visible
- m_aOpenGLContext.setWinSize(Size(200,200));
}
ViewObjectContactOfOpenGLObj::~ViewObjectContactOfOpenGLObj()
commit b458c16a431010712b0d5e18b125a9ec897372c9
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed Apr 2 03:31:38 2014 +0200
fix crash when passing external Window to OpenGLContext::init
The external window is not controlled by OpenGLContext so it is not
allowed to delete the window
Change-Id: Id2c79a3612cc875fd94b8cd1206b30af2f185875
diff --git a/include/vcl/OpenGLContext.hxx b/include/vcl/OpenGLContext.hxx
index 91355bf..e84e8fc 100644
--- a/include/vcl/OpenGLContext.hxx
+++ b/include/vcl/OpenGLContext.hxx
@@ -108,6 +108,7 @@ private:
GLWindow m_aGLWin;
boost::scoped_ptr<Window> m_pWindow;
+ Window* mpWindow; //points to m_pWindow or the parent window, don't delete it
boost::scoped_ptr<SystemChildWindow> m_pChildWindow;
bool mbInitialized;
};
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index b60e6f5..304d9f4 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -14,6 +14,7 @@
using namespace com::sun::star;
OpenGLContext::OpenGLContext():
+ mpWindow(NULL),
mbInitialized(false)
{
}
@@ -319,13 +320,15 @@ int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ )
bool OpenGLContext::init( Window* pParent )
{
- m_pWindow.reset(pParent ? pParent : new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL));
if(mbInitialized)
return true;
+ m_pWindow.reset(pParent ? NULL : new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL));
+ mpWindow = pParent ? pParent : m_pWindow.get();
SAL_INFO("vcl.opengl", "OpenGLContext::OpenGLContext----start");
initWindow();
- m_pWindow->setPosSizePixel(0,0,0,0);
+ if(m_pWindow)
+ m_pWindow->setPosSizePixel(0,0,0,0);
m_aGLWin.Width = 0;
m_aGLWin.Height = 0;
@@ -396,10 +399,10 @@ bool OpenGLContext::init( Window* pParent )
double nGLXVersion = 0;
if( glXQueryVersion( m_aGLWin.dpy, &glxMajor, &glxMinor ) )
nGLXVersion = glxMajor + 0.1*glxMinor;
- SAL_INFO("vcl.opengl", "available GLX version: %f", nGLXVersion);
+ SAL_INFO("vcl.opengl", "available GLX version: " << nGLXVersion);
m_aGLWin.GLExtensions = glGetString( GL_EXTENSIONS );
- SAL_INFO("vcl.opengl", "available GL extensions: %s", m_aGLWin.GLExtensions);
+ SAL_INFO("vcl.opengl", "available GL extensions: " << m_aGLWin.GLExtensions);
if( m_aGLWin.HasGLXExtension("GLX_SGI_swap_control" ) )
{
@@ -451,7 +454,8 @@ bool OpenGLContext::init( Window* pParent )
void OpenGLContext::setWinSize(const Size& rSize)
{
- m_pWindow->SetSizePixel(rSize);
+ if(m_pWindow)
+ m_pWindow->SetSizePixel(rSize);
m_pChildWindow->SetSizePixel(rSize);
}
@@ -464,11 +468,11 @@ GLWindow& OpenGLContext::getOpenGLWindow()
bool OpenGLContext::initWindow()
{
- const SystemEnvData* sysData(m_pWindow->GetSystemData());
+ const SystemEnvData* sysData(mpWindow->GetSystemData());
m_aGLWin.hWnd = sysData->hWnd;
SystemWindowData winData;
winData.nSize = sizeof(winData);
- m_pChildWindow.reset(new SystemChildWindow(m_pWindow.get(), 0, &winData, sal_False));
+ m_pChildWindow.reset(new SystemChildWindow(mpWindow, 0, &winData, sal_False));
if( m_pChildWindow )
{
@@ -502,14 +506,13 @@ void initOpenGLFunctionPointers()
glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig");
glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig"); // try to find a visual for the current set of attributes
glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib");
-
}
}
bool OpenGLContext::initWindow()
{
- const SystemEnvData* sysData(m_pWindow->GetSystemData());
+ const SystemEnvData* sysData(mpWindow->GetSystemData());
m_aGLWin.dpy = reinterpret_cast<Display*>(sysData->pDisplay);
@@ -518,7 +521,7 @@ bool OpenGLContext::initWindow()
m_aGLWin.win = sysData->aWindow;
- SAL_INFO("vcl.opengl", "parent window: %d", m_aGLWin.win);
+ SAL_INFO("vcl.opengl", "parent window: " << m_aGLWin.win);
XWindowAttributes xattr;
XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xattr );
@@ -581,9 +584,9 @@ bool OpenGLContext::initWindow()
{
SystemWindowData winData;
winData.nSize = sizeof(winData);
- SAL_INFO("vcl.opengl", "using VisualID %08X", vi->visualid);
+ SAL_INFO("vcl.opengl", "using VisualID " << vi->visualid);
winData.pVisual = (void*)(vi->visual);
- m_pChildWindow.reset(new SystemChildWindow(m_pWindow.get(), 0, &winData, false));
+ m_pChildWindow.reset(new SystemChildWindow(mpWindow, 0, &winData, false));
pChildSysData = m_pChildWindow->GetSystemData();
}
@@ -600,7 +603,7 @@ bool OpenGLContext::initWindow()
m_aGLWin.win = pChildSysData->aWindow;
m_aGLWin.vi = vi;
m_aGLWin.GLXExtensions = glXQueryExtensionsString( m_aGLWin.dpy, m_aGLWin.screen );
- SAL_INFO("vcl.opengl", "available GLX extensions: %s", m_aGLWin.GLXExtensions);
+ SAL_INFO("vcl.opengl", "available GLX extensions: " << m_aGLWin.GLXExtensions);
return true;
}
commit 8325b7b49ec095349571efb17fe0d520ab67f897
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed Apr 2 03:31:01 2014 +0200
prevent initializing the OpenGL context multiple times
Change-Id: I2ebdbcd51938bc1dc61693ac392eed5d5e497a8d
diff --git a/include/vcl/OpenGLContext.hxx b/include/vcl/OpenGLContext.hxx
index 82145b4..91355bf 100644
--- a/include/vcl/OpenGLContext.hxx
+++ b/include/vcl/OpenGLContext.hxx
@@ -109,6 +109,7 @@ private:
GLWindow m_aGLWin;
boost::scoped_ptr<Window> m_pWindow;
boost::scoped_ptr<SystemChildWindow> m_pChildWindow;
+ bool mbInitialized;
};
#endif
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index e5500d4..b60e6f5 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -13,7 +13,8 @@
using namespace com::sun::star;
-OpenGLContext::OpenGLContext()
+OpenGLContext::OpenGLContext():
+ mbInitialized(false)
{
}
@@ -319,6 +320,9 @@ int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ )
bool OpenGLContext::init( Window* pParent )
{
m_pWindow.reset(pParent ? pParent : new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL));
+ if(mbInitialized)
+ return true;
+
SAL_INFO("vcl.opengl", "OpenGLContext::OpenGLContext----start");
initWindow();
m_pWindow->setPosSizePixel(0,0,0,0);
@@ -441,6 +445,7 @@ bool OpenGLContext::init( Window* pParent )
#endif
SAL_INFO("vcl.opengl", "OpenGLContext::init----end");
+ mbInitialized = true;
return true;
}
commit feffcbb02c2cb17d615151f5587ae38510f3aa02
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Mar 31 23:09:24 2014 +0200
Revert "Remove opengl usage from svx until we can't solve building problems"
This reverts commit 10be411f33c69db83cc5de410eaddf2d297608ae.
diff --git a/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx b/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx
index 8781aa4..00e1dff 100644
--- a/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx
+++ b/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx
@@ -11,6 +11,7 @@
#define INCLUDED_SVX_SDR_CONTACT_VIEWOBJECTCONTACTOFOPENGL_HXX
#include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
+#include <vcl/OpenGLContext.hxx>
class Window;
@@ -25,6 +26,9 @@ public:
protected:
Window* getWindow() const;
+
+private:
+ OpenGLContext m_aOpenGLContext;
};
} // namespace sdr
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index f26479c..b3c3521 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -75,6 +75,7 @@ $(eval $(call gb_Library_use_libraries,svxcore,\
utl \
vcl \
xo \
+ $(if $(filter FREEBSD LINUX MACOSX WNT,$(OS)),vclopengl) \
$(gb_UWINAPI) \
))
@@ -82,6 +83,8 @@ $(eval $(call gb_Library_use_externals,svxcore,\
boost_headers \
icuuc \
icu_headers \
+ mesa_headers \
+ glew \
))
$(eval $(call gb_Library_add_exception_objects,svxcore,\
diff --git a/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx b/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx
index 2cf0086..1689468 100644
--- a/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx
@@ -18,6 +18,9 @@ ViewObjectContactOfOpenGLObj::ViewObjectContactOfOpenGLObj(
ObjectContact& rObjectContact, ViewContact& rViewContact )
: ViewObjectContactOfSdrObj( rObjectContact, rViewContact )
{
+ m_aOpenGLContext.init(getWindow());
+ // Set a dummy size to make the window visible
+ m_aOpenGLContext.setWinSize(Size(200,200));
}
ViewObjectContactOfOpenGLObj::~ViewObjectContactOfOpenGLObj()
commit cc8f652121eb6f43b718f344bed9619eb5785d8e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Mar 31 10:53:57 2014 +0200
remove file
Change-Id: I74d1116ae0d5f99bcfbbe67ec1ecbe1a5a89ad8f
diff --git a/chart2/source/view/main/3DChartObjects.hxx b/chart2/source/view/main/3DChartObjects.hxx
deleted file mode 100644
index ec56ad8..0000000
--- a/chart2/source/view/main/3DChartObjects.hxx
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <glm/glm.hpp>
-
-#include <tools/color.hxx>
-#include <vcl/bitmapex.hxx>
-
-namespace chart {
-
-namespace opengl3D {
-
-class Renderable3DObject
-{
-public:
-
- virtual ~Renderable3DObject() {};
-
- virtual void render() {}
-};
-
-class Bar : public Renderable3DObject
-{
-public:
- Bar( const glm::mat4& rPosition );
-private:
- bool mbRoundedCorners;
- glm::mat4 maPos;
- Color maColor; // RGBA fill color
- sal_Int32 nUniqueId;
-};
-
-class Line : public Renderable3DObject
-{
-private:
- glm::vec3 maPosBegin;
- glm::vec3 maPosEnd;
- Color maLineColor; // RGBA line color
- sal_Int32 nUniqueId;
-};
-
-class Text : public Renderable3DObject
-{
-private:
- BitmapEx maText;
- glm::vec3 maTopLeft;
- glm::vec3 maBottomRight;
- sal_Int32 nUniqueId;
-};
-
-class Rectangle : public Renderable3DObject
-{
-private:
- glm::vec3 maTopLeft;
- glm::vec3 maBottomRight;
- sal_Int32 nUniqueId;
- Color maColor; // RGBA fill color
- Color maLineColor; // RGBA line color
-};
-
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ee86c908d1d9f8ed19482b3f844e387018b1a904
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Mar 31 04:03:12 2014 +0200
OSL_TRACE to SAL_INFO in opengl code
Change-Id: I7bdefec1cf941d1a51b7777639c0979387e1b436
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 2b47d39..e5500d4 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -336,7 +336,7 @@ bool OpenGLContext::init( Window* pParent )
GL_TRUE);
if( m_aGLWin.ctx == NULL )
{
- OSL_TRACE("unable to create GLX context");
+ SAL_INFO("vcl.opengl", "unable to create GLX context");
return false;
}
#endif
@@ -384,7 +384,7 @@ bool OpenGLContext::init( Window* pParent )
#elif defined( UNX )
if( !glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx ) )
{
- OSL_TRACE("unable to select current GLX context");
+ SAL_INFO("vcl.opengl", "unable to select current GLX context");
return false;
}
@@ -392,10 +392,10 @@ bool OpenGLContext::init( Window* pParent )
double nGLXVersion = 0;
if( glXQueryVersion( m_aGLWin.dpy, &glxMajor, &glxMinor ) )
nGLXVersion = glxMajor + 0.1*glxMinor;
- OSL_TRACE("available GLX version: %f", nGLXVersion);
+ SAL_INFO("vcl.opengl", "available GLX version: %f", nGLXVersion);
m_aGLWin.GLExtensions = glGetString( GL_EXTENSIONS );
- OSL_TRACE("available GL extensions: %s", m_aGLWin.GLExtensions);
+ SAL_INFO("vcl.opengl", "available GL extensions: %s", m_aGLWin.GLExtensions);
if( m_aGLWin.HasGLXExtension("GLX_SGI_swap_control" ) )
{
@@ -417,9 +417,9 @@ bool OpenGLContext::init( Window* pParent )
XSync(m_aGLWin.dpy, false);
if( errorTriggered )
- OSL_TRACE("error when trying to set swap interval, NVIDIA or Mesa bug?");
+ SAL_INFO("vcl.opengl", "error when trying to set swap interval, NVIDIA or Mesa bug?");
else
- OSL_TRACE("set swap interval to 1 (enable vsync)");
+ SAL_INFO("vcl.opengl", "set swap interval to 1 (enable vsync)");
// restore the error handler
XSetErrorHandler( oldHandler );
@@ -513,7 +513,7 @@ bool OpenGLContext::initWindow()
m_aGLWin.win = sysData->aWindow;
- OSL_TRACE("parent window: %d", m_aGLWin.win);
+ SAL_INFO("vcl.opengl", "parent window: %d", m_aGLWin.win);
XWindowAttributes xattr;
XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xattr );
@@ -576,7 +576,7 @@ bool OpenGLContext::initWindow()
{
SystemWindowData winData;
winData.nSize = sizeof(winData);
- OSL_TRACE("using VisualID %08X", vi->visualid);
+ SAL_INFO("vcl.opengl", "using VisualID %08X", vi->visualid);
winData.pVisual = (void*)(vi->visual);
m_pChildWindow.reset(new SystemChildWindow(m_pWindow.get(), 0, &winData, false));
pChildSysData = m_pChildWindow->GetSystemData();
@@ -595,7 +595,7 @@ bool OpenGLContext::initWindow()
m_aGLWin.win = pChildSysData->aWindow;
m_aGLWin.vi = vi;
m_aGLWin.GLXExtensions = glXQueryExtensionsString( m_aGLWin.dpy, m_aGLWin.screen );
- OSL_TRACE("available GLX extensions: %s", m_aGLWin.GLXExtensions);
+ SAL_INFO("vcl.opengl", "available GLX extensions: %s", m_aGLWin.GLXExtensions);
return true;
}
commit f92ee8f9b0bb3c3b61e483c30d227fe4f8c484b6
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Mar 31 03:57:31 2014 +0200
no need to swap buffers in the offscreen rendering
Change-Id: Ibe25afaa71acc0a0c8995c6f0644eb08fe8920cf
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 76c19cb..a0f7573 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -327,14 +327,6 @@ int OpenGLRender::InitOpenGL(GLWindow aWindow)
glBufferData(GL_ARRAY_BUFFER, sizeof(texCoords), texCoords, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
-#if defined( WNT )
- SwapBuffers(glWin.hDC);
-#elif defined( MACOSX )
-
-#elif defined( UNX )
- glXSwapBuffers(glWin.dpy, glWin.win);
-#endif
- glFlush();
glEnable(GL_LIGHTING);
GLfloat light_direction[] = { 0.0 , 0.0 , 1.0 };
GLfloat materialDiffuse[] = { 1.0 , 1.0 , 1.0 , 1.0};
@@ -569,14 +561,6 @@ void OpenGLRender::renderToBitmap()
mxRenderTarget->setPosition(awt::Point(0,0));
#endif
glBindFramebuffer(GL_FRAMEBUFFER, 0);
-#if defined( WNT )
- SwapBuffers(glWin.hDC);
-#elif defined( MACOSX )
-
-#elif defined( UNX )
- glXSwapBuffers(glWin.dpy, glWin.win);
-#endif
- glFlush();
}
int OpenGLRender::CreateTextureObj(int width, int height)
@@ -946,7 +930,6 @@ int OpenGLRender::RectangleShapePoint(float x, float y, float directionX, float
return 0;
}
-
int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
{
size_t listNum = m_RectangleShapePointList.size();
@@ -1057,7 +1040,6 @@ int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
return 0;
}
-
int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, const awt::Point&, const awt::Size& aSize, long rotation,
const drawing::HomogenMatrix3& rTrans)
{
@@ -1484,5 +1466,4 @@ int OpenGLRender::RenderSymbol2DShape(float x, float y, float , float , sal_Int3
return 0;
}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+/* iim:set shiftwidth=4 softtabstop=4 expandtab: */
commit dfb2ab0cee2ba04ce8816580447e7db8160ffac4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Mar 31 00:28:14 2014 +0200
add initial code for creating 3D bar shapes
Change-Id: I55489fad8723f204003fe502eea5e02de4c8d6ef
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 6dafd71..55aa610 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_Library_set_precompiled_header,chartcore,$(SRCDIR)/chart2/inc/p
$(eval $(call gb_Library_use_externals,chartcore,\
boost_headers \
mdds_headers \
+ glm_headers \
))
$(eval $(call gb_Library_use_custom_headers,chartcore,\
@@ -81,6 +82,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/view/axes/VPolarCoordinateSystem \
chart2/source/view/axes/VPolarGrid \
chart2/source/view/axes/VPolarRadiusAxis \
+ chart2/source/view/charttypes/3DBarChart \
chart2/source/view/charttypes/AreaChart \
chart2/source/view/charttypes/BarChart \
chart2/source/view/charttypes/BarPositionHelper \
@@ -93,6 +95,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/view/charttypes/Splines \
chart2/source/view/charttypes/VSeriesPlotter \
chart2/source/view/diagram/VDiagram \
+ chart2/source/view/main/3DChartObjects \
chart2/source/view/main/ChartItemPool \
chart2/source/view/main/ChartView \
chart2/source/view/main/Clipping \
diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx
index 045843a..f6252bc 100644
--- a/chart2/inc/ChartView.hxx
+++ b/chart2/inc/ChartView.hxx
@@ -200,6 +200,8 @@ private: //methods
ChartView();
void createShapes();
+ void createShapes3D();
+ bool isReal3DChart();
void getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStream
, bool bUseHighContrast );
SdrPage* getSdrPage();
diff --git a/chart2/source/inc/macros.hxx b/chart2/source/inc/macros.hxx
index 21e5911..2319afe 100644
--- a/chart2/source/inc/macros.hxx
+++ b/chart2/source/inc/macros.hxx
@@ -30,7 +30,7 @@
typeid( ex ).name() << ", Message: " << \
ex.Message )
-#define ENABLE_GL3D_BARCHART 0
+#define ENABLE_GL3D_BARCHART 1
#endif
diff --git a/chart2/source/view/charttypes/3DBarChart.cxx b/chart2/source/view/charttypes/3DBarChart.cxx
new file mode 100644
index 0000000..2da54aa
--- /dev/null
+++ b/chart2/source/view/charttypes/3DBarChart.cxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "3DBarChart.hxx"
+
+#include "3DChartObjects.hxx"
+
+#include <glm/glm.hpp>
+#include <glm/gtx/transform.hpp>
+
+namespace chart {
+
+Bar3DChart::Bar3DChart(const std::vector<VDataSeries*>& rDataSeries):
+ maDataSeries(rDataSeries)
+{
+}
+
+Bar3DChart::~Bar3DChart()
+{
+}
+
+void Bar3DChart::create3DShapes()
+{
+ const float nBarSizeX = 10;
+ const float nBarSizeY = 10;
+ const float nBarDistanceX = nBarSizeX / 2;
+ const float nBarDistanceY = nBarSizeY / 2;
+
+ sal_Int32 nSeriesIndex = 0;
+ for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(),
+ itrEnd = maDataSeries.end(); itr != itrEnd; ++itr)
+ {
+ VDataSeries* pDataSeries = *itr;
+ sal_Int32 nPointCount = pDataSeries->getTotalPointCount();
+ for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
+ {
+ float nVal = pDataSeries->getYValue(nIndex);
+ float nXPos = nIndex * (nBarSizeX + nBarDistanceX);
+ float nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY);
+
+ glm::mat4 aBarPosition;
+ glm::scale(aBarPosition, nBarSizeX, nBarSizeY, nVal);
+ glm::translate(aBarPosition, nXPos, nYPos, nVal/2);
+
+ maShapes.push_back(new opengl3D::Bar(aBarPosition));
+ }
+
+ ++nSeriesIndex;
+ }
+}
+
+void Bar3DChart::render()
+{
+ for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = maShapes.begin(),
+ itrEnd = maShapes.end(); itr != itrEnd; ++itr)
+ {
+ itr->render();
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/inc/3DBarChart.hxx b/chart2/source/view/inc/3DBarChart.hxx
new file mode 100644
index 0000000..6eeea5b
--- /dev/null
+++ b/chart2/source/view/inc/3DBarChart.hxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <vector>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include "VDataSeries.hxx"
+
+namespace chart {
+
+namespace opengl3D {
+
+class Renderable3DObject;
+
+}
+
+class Bar3DChart
+{
+public:
+ Bar3DChart(const std::vector<VDataSeries*>& rDataSeries);
+ ~Bar3DChart();
+
+ void create3DShapes();
+
+ void render();
+
+private:
+
+ std::vector<VDataSeries*> maDataSeries;
+ boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
+
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
new file mode 100644
index 0000000..ec56ad8
--- /dev/null
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <glm/glm.hpp>
+
+#include <tools/color.hxx>
+#include <vcl/bitmapex.hxx>
+
+namespace chart {
+
+namespace opengl3D {
+
+class Renderable3DObject
+{
+public:
+
+ virtual ~Renderable3DObject() {};
+
+ virtual void render() {}
+};
+
+class Bar : public Renderable3DObject
+{
+public:
+ Bar( const glm::mat4& rPosition );
+private:
+ bool mbRoundedCorners;
+ glm::mat4 maPos;
+ Color maColor; // RGBA fill color
+ sal_Int32 nUniqueId;
+};
+
+class Line : public Renderable3DObject
+{
+private:
+ glm::vec3 maPosBegin;
+ glm::vec3 maPosEnd;
+ Color maLineColor; // RGBA line color
+ sal_Int32 nUniqueId;
+};
+
+class Text : public Renderable3DObject
+{
+private:
+ BitmapEx maText;
+ glm::vec3 maTopLeft;
+ glm::vec3 maBottomRight;
+ sal_Int32 nUniqueId;
+};
+
+class Rectangle : public Renderable3DObject
+{
+private:
+ glm::vec3 maTopLeft;
+ glm::vec3 maBottomRight;
+ sal_Int32 nUniqueId;
+ Color maColor; // RGBA fill color
+ Color maLineColor; // RGBA line color
+};
+
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
new file mode 100644
index 0000000..0a0696a
--- /dev/null
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "3DChartObjects.hxx"
+
+namespace chart {
+
+namespace opengl3D {
+
+Bar::Bar(const glm::mat4& rPosition):
+ maPos(rPosition)
+{
+}
+
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/3DChartObjects.hxx b/chart2/source/view/main/3DChartObjects.hxx
index 5851595..ec56ad8 100644
--- a/chart2/source/view/main/3DChartObjects.hxx
+++ b/chart2/source/view/main/3DChartObjects.hxx
@@ -7,29 +7,45 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <glm/glm.hpp>
+
+#include <tools/color.hxx>
+#include <vcl/bitmapex.hxx>
+
namespace chart {
-namespace 3d {
+namespace opengl3D {
-class Bar
+class Renderable3DObject
{
+public:
+
+ virtual ~Renderable3DObject() {};
+
+ virtual void render() {}
+};
+
+class Bar : public Renderable3DObject
+{
+public:
+ Bar( const glm::mat4& rPosition );
private:
bool mbRoundedCorners;
glm::mat4 maPos;
Color maColor; // RGBA fill color
sal_Int32 nUniqueId;
-}:
+};
-class Line
+class Line : public Renderable3DObject
{
private:
glm::vec3 maPosBegin;
glm::vec3 maPosEnd;
Color maLineColor; // RGBA line color
sal_Int32 nUniqueId;
-}:
+};
-class Text
+class Text : public Renderable3DObject
{
private:
BitmapEx maText;
@@ -38,7 +54,7 @@ private:
sal_Int32 nUniqueId;
};
-class Rectangle
+class Rectangle : public Renderable3DObject
{
private:
glm::vec3 maTopLeft;
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 7200b4e..8b29516 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -48,6 +48,7 @@
#include "DateHelper.hxx"
#include "defines.hxx"
#include <unonames.hxx>
+#include "3DBarChart.hxx"
#include <rtl/uuid.h>
#include <comphelper/scopeguard.hxx>
@@ -2398,6 +2399,40 @@ void ChartView::impl_refreshAddIn()
}
}
+/**
+ * Is it a real 3D chart with a true 3D scene or a 3D chart in a 2D scene.
+ */
+bool ChartView::isReal3DChart()
+{
+ uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() );
+ uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
+ if( !xCooSysContainer.is())
+ return false;
+
+ uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
+ for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
+ {
+ uno::Reference< XCoordinateSystem > xCooSys( aCooSysList[nCS] );
+ //
+ //iterate through all chart types in the current coordinate system
+ uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
+ OSL_ASSERT( xChartTypeContainer.is());
+ if( !xChartTypeContainer.is() )
+ continue;
+
+ uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
+ for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
+ {
+ uno::Reference< XChartType > xChartType( aChartTypeList[nT] );
+ OUString aChartType = xChartType->getChartType();
+ if( aChartType == "com.sun.star.chart2.GL3DBarChartType" )
+ return true;
+ }
+ }
+
+ return false;
+}
+
void ChartView::createShapes()
{
osl::ResettableMutexGuard aTimedGuard(maTimeMutex);
@@ -2443,6 +2478,12 @@ void ChartView::createShapes()
pShapeFactory->setPageSize(mxRootShape, aPageSize);
pShapeFactory->clearPage(mxRootShape);
+ if(isReal3DChart())
+ {
+ createShapes3D();
+ return;
+ }
+
{
SolarMutexGuard aSolarGuard;
@@ -3067,6 +3108,53 @@ IMPL_LINK_NOARG(ChartView, UpdateTimeBased)
return 0;
}
+void ChartView::createShapes3D()
+{
+ uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() );
+ uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
+ if( !xCooSysContainer.is())
+ 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 )
+ {
+ uno::Reference< XCoordinateSystem > xCooSys( aCooSysList[nCS] );
+
+ //iterate through all chart types in the current coordinate system
+ uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
+ OSL_ASSERT( xChartTypeContainer.is());
+ if( !xChartTypeContainer.is() )
+ continue;
+ uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
+ for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
+ {
+ uno::Reference< XChartType > xChartType( aChartTypeList[nT] );
+
+ uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
+ OSL_ASSERT( xDataSeriesContainer.is());
+ if( !xDataSeriesContainer.is() )
+ continue;
+
+ uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
+ for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS )
+ {
+ uno::Reference< XDataSeries > xDataSeries( aSeriesList[nS], uno::UNO_QUERY );
+ if(!xDataSeries.is())
+ continue;
+
+ VDataSeries* pSeries = new VDataSeries( xDataSeries );
+ aDataSeries.push_back(pSeries);
+ }
+ }
+ }
+
+ Bar3DChart aBarChart(aDataSeries);
+ aBarChart.create3DShapes();
+ aBarChart.render();
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e7b79ef04579c8b5a9957207062fd13a9ca5755c
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri Mar 28 00:08:56 2014 +0100
most likley nobody has used that profiling code in years
Change-Id: I6ad7aea0d77b54509c3c919d0015f3a94118a398
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 7d8bc07..7200b4e 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2400,11 +2400,6 @@ void ChartView::impl_refreshAddIn()
void ChartView::createShapes()
{
-#if OSL_DEBUG_LEVEL > 0
- clock_t nStart = clock();
- OSL_TRACE( "\nPPPPPPPPP>>>>>>>>>>>> chart view :: createShapes()" );
-#endif
-
osl::ResettableMutexGuard aTimedGuard(maTimeMutex);
if(mrChartModel.isTimeBased())
{
@@ -2646,13 +2641,6 @@ void ChartView::createShapes()
{
maTimeBased.nFrame++;
}
-
-#if OSL_DEBUG_LEVEL > 0
- clock_t nEnd = clock();
- double fDuration =(double(nEnd-nStart)*1000.0)/double(CLOCKS_PER_SEC);
-
- OSL_TRACE( "\nPPPPPPPPP<<<<<<<<<<<< chart view :: createShapes():: needed %f msec", fDuration );
-#endif
}
// util::XEventListener (base of XCloseListener)
commit 46edb178cb6df038832ad0bc97474b2da145bbe4
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri Mar 28 00:07:35 2014 +0100
put some functions into an anonzmous namespace
Change-Id: I39357685bfd3b2e556d0c6f83a3833fd64bc7e52
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index bbc0740..7d8bc07 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2000,6 +2000,8 @@ awt::Rectangle ExplicitValueProvider::substractAxisTitleSizes(
return aRet;
}
+namespace {
+
double lcl_getPageLayoutDistancePercentage()
{
return 0.02;
@@ -2365,6 +2367,8 @@ void lcl_removeEmptyGroupShapes( const Reference< drawing::XShapes>& xParent )
}
}
+}
+
bool ChartView::impl_AddInDrawsAllByItself()
{
return false;
More information about the Libreoffice-commits
mailing list