summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/Module_chart2.mk1
-rw-r--r--chart2/Package_opengl.mk29
-rw-r--r--chart2/opengl/backgroundFragmentShader.glsl6
-rw-r--r--chart2/opengl/backgroundVertexShader.glsl10
-rw-r--r--chart2/opengl/commonFragmentShader.glsl6
-rw-r--r--chart2/opengl/commonVertexShader.glsl10
-rw-r--r--chart2/opengl/debugFragmentShader.glsl7
-rw-r--r--chart2/opengl/debugVertexShader.glsl9
-rw-r--r--chart2/opengl/renderFragmentShader.glsl7
-rw-r--r--chart2/opengl/renderVertexShader.glsl9
-rw-r--r--chart2/opengl/symbolFragmentShader.glsl12
-rw-r--r--chart2/opengl/symbolVertexShader.glsl13
-rw-r--r--chart2/opengl/textFragmentShader.glsl6
-rw-r--r--chart2/opengl/textVertexShader.glsl9
-rw-r--r--chart2/source/view/inc/DummyXShape.hxx6
-rw-r--r--chart2/source/view/main/DummyXShape.cxx557
-rwxr-xr-xchart2/source/view/main/OpenGLRender.cxx265
-rwxr-xr-xchart2/source/view/main/OpenGLRender.hxx10
18 files changed, 821 insertions, 151 deletions
diff --git a/chart2/Module_chart2.mk b/chart2/Module_chart2.mk
index f610a036b939..9d6e0191effa 100644
--- a/chart2/Module_chart2.mk
+++ b/chart2/Module_chart2.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_Module_add_targets,chart2,\
Library_chartcore \
$(if $(filter LINUX FREEBSD WNT,$(OS)), \
Library_chartopengl \
+ Package_opengl \
) \
))
diff --git a/chart2/Package_opengl.mk b/chart2/Package_opengl.mk
new file mode 100644
index 000000000000..499ca0ce165e
--- /dev/null
+++ b/chart2/Package_opengl.mk
@@ -0,0 +1,29 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_Package_Package,chart2_opengl_shader,$(SRCDIR)/chart2/opengl))
+
+$(eval $(call gb_Package_set_outdir,chart2_opengl_shader,$(INSTDIR)/program))
+
+$(eval $(call gb_Package_add_files,chart2_opengl_shader,opengl,\
+ backgroundFragmentShader.glsl \
+ backgroundVertexShader.glsl \
+ commonFragmentShader.glsl \
+ commonVertexShader.glsl \
+ debugFragmentShader.glsl \
+ debugVertexShader.glsl \
+ renderFragmentShader.glsl \
+ renderVertexShader.glsl \
+ symbolFragmentShader.glsl \
+ symbolVertexShader.glsl \
+ textFragmentShader.glsl \
+ textVertexShader.glsl \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/chart2/opengl/backgroundFragmentShader.glsl b/chart2/opengl/backgroundFragmentShader.glsl
new file mode 100644
index 000000000000..e772587c9835
--- /dev/null
+++ b/chart2/opengl/backgroundFragmentShader.glsl
@@ -0,0 +1,6 @@
+varying vec4 fragmentColor;
+
+void main()
+{
+ gl_FragColor = fragmentColor;
+}
diff --git a/chart2/opengl/backgroundVertexShader.glsl b/chart2/opengl/backgroundVertexShader.glsl
new file mode 100644
index 000000000000..2a3a34116256
--- /dev/null
+++ b/chart2/opengl/backgroundVertexShader.glsl
@@ -0,0 +1,10 @@
+attribute vec3 vPosition;
+uniform mat4 MVP;
+attribute vec4 vColor;
+varying vec4 fragmentColor;
+
+void main()
+{
+ gl_Position = MVP * vec4(vPosition, 1);
+ fragmentColor = vColor;
+}
diff --git a/chart2/opengl/commonFragmentShader.glsl b/chart2/opengl/commonFragmentShader.glsl
new file mode 100644
index 000000000000..e772587c9835
--- /dev/null
+++ b/chart2/opengl/commonFragmentShader.glsl
@@ -0,0 +1,6 @@
+varying vec4 fragmentColor;
+
+void main()
+{
+ gl_FragColor = fragmentColor;
+}
diff --git a/chart2/opengl/commonVertexShader.glsl b/chart2/opengl/commonVertexShader.glsl
new file mode 100644
index 000000000000..862a35b509f4
--- /dev/null
+++ b/chart2/opengl/commonVertexShader.glsl
@@ -0,0 +1,10 @@
+attribute vec3 vPosition;
+uniform mat4 MVP;
+uniform vec4 vColor;
+varying vec4 fragmentColor;
+
+void main()
+{
+ gl_Position = MVP * vec4(vPosition, 1);
+ fragmentColor = vColor;
+}
diff --git a/chart2/opengl/debugFragmentShader.glsl b/chart2/opengl/debugFragmentShader.glsl
new file mode 100644
index 000000000000..ce7f863f3394
--- /dev/null
+++ b/chart2/opengl/debugFragmentShader.glsl
@@ -0,0 +1,7 @@
+varying vec4 fragmentColor;
+
+void main()
+{
+ gl_FragColor = vec4(1.0, 1.0, 0.0, 0.5);
+}
+
diff --git a/chart2/opengl/debugVertexShader.glsl b/chart2/opengl/debugVertexShader.glsl
new file mode 100644
index 000000000000..c0f3d0322652
--- /dev/null
+++ b/chart2/opengl/debugVertexShader.glsl
@@ -0,0 +1,9 @@
+attribute vec3 vPosition;
+uniform vec4 vColor;
+varying vec4 fragmentColor;
+
+void main()
+{
+ gl_Position = vec4(vPosition, 1);
+}
+
diff --git a/chart2/opengl/renderFragmentShader.glsl b/chart2/opengl/renderFragmentShader.glsl
new file mode 100644
index 000000000000..dd08d9a4a2cd
--- /dev/null
+++ b/chart2/opengl/renderFragmentShader.glsl
@@ -0,0 +1,7 @@
+uniform sampler2D RenderTex;
+varying vec2 vTexCoord;
+
+void main()
+{
+ gl_FragColor = vec4(texture2D(RenderTex, vTexCoord).rgb, 1.0);
+}
diff --git a/chart2/opengl/renderVertexShader.glsl b/chart2/opengl/renderVertexShader.glsl
new file mode 100644
index 000000000000..1c9d3ce647dd
--- /dev/null
+++ b/chart2/opengl/renderVertexShader.glsl
@@ -0,0 +1,9 @@
+attribute vec4 vPosition;
+attribute vec2 texCoord;
+varying vec2 vTexCoord;
+
+void main()
+{
+ gl_Position = vPosition;
+ vTexCoord = texCoord;
+}
diff --git a/chart2/opengl/symbolFragmentShader.glsl b/chart2/opengl/symbolFragmentShader.glsl
new file mode 100644
index 000000000000..c340be274337
--- /dev/null
+++ b/chart2/opengl/symbolFragmentShader.glsl
@@ -0,0 +1,12 @@
+#version 130
+
+varying vec4 fragmentColor;
+
+void main()
+{
+ vec2 p = gl_PointCoord * 2.0 - vec2(1.0); // (0,0) in the center
+ if (abs(p.x) < abs(p.y))
+ discard;
+
+ gl_FragColor = fragmentColor;
+}
diff --git a/chart2/opengl/symbolVertexShader.glsl b/chart2/opengl/symbolVertexShader.glsl
new file mode 100644
index 000000000000..6aef1e8a2146
--- /dev/null
+++ b/chart2/opengl/symbolVertexShader.glsl
@@ -0,0 +1,13 @@
+#version 130
+
+attribute vec3 vPosition;
+uniform mat4 MVP;
+uniform vec4 vColor;
+varying vec4 fragmentColor;
+
+void main()
+{
+ gl_Position = MVP * vec4(vPosition, 1);
+ fragmentColor = vColor;
+ gl_PointSize = 10.0;
+}
diff --git a/chart2/opengl/textFragmentShader.glsl b/chart2/opengl/textFragmentShader.glsl
new file mode 100644
index 000000000000..83d0d82550be
--- /dev/null
+++ b/chart2/opengl/textFragmentShader.glsl
@@ -0,0 +1,6 @@
+uniform sampler2D TextTex;
+varying vec2 vTexCoord;
+void main()
+{
+ gl_FragColor = vec4(texture2D(TextTex, vTexCoord).rgba);
+}
diff --git a/chart2/opengl/textVertexShader.glsl b/chart2/opengl/textVertexShader.glsl
new file mode 100644
index 000000000000..013f43c6157a
--- /dev/null
+++ b/chart2/opengl/textVertexShader.glsl
@@ -0,0 +1,9 @@
+attribute vec3 vPosition;
+uniform mat4 MVP;
+attribute vec2 texCoord;
+varying vec2 vTexCoord;
+void main()
+{
+ gl_Position = MVP * vec4(vPosition, 1);
+ vTexCoord = texCoord;
+}
diff --git a/chart2/source/view/inc/DummyXShape.hxx b/chart2/source/view/inc/DummyXShape.hxx
index 9b3eed2a5fe5..2916aae8be15 100644
--- a/chart2/source/view/inc/DummyXShape.hxx
+++ b/chart2/source/view/inc/DummyXShape.hxx
@@ -311,9 +311,13 @@ class DummySymbol2D : public DummyXShape
public:
DummySymbol2D(const drawing::Position3D& rPosition, const drawing::Direction3D& rSize,
sal_Int32 nStandardSymbol, sal_Int32 nBorderColor, sal_Int32 nFillColor);
-
+ void render();
private:
+ drawing::Position3D mrPosition;
+ drawing::Direction3D mrSize;
sal_Int32 mnStandardSymbol;
+ sal_Int32 mnBorderColor;
+ sal_Int32 mnFillColor;
};
class DummyGraphic2D : public DummyXShape
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 6213d8d97fb7..4779c0f345ca 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -17,7 +17,9 @@
#include <stdlib.h>
#include <string.h>
+
#include "CommonConverters.hxx"
+
#include <rtl/ustring.hxx>
#include <vcl/window.hxx>
@@ -39,6 +41,25 @@ using namespace com::sun::star;
using namespace std;
+enum SymbolEnum { Symbol_Square=0
+ , Symbol_Diamond
+ , Symbol_DownArrow
+ , Symbol_UpArrow
+ , Symbol_RightArrow
+ , Symbol_LeftArrow
+ , Symbol_Bowtie
+ , Symbol_Sandglass
+ , Symbol_Circle
+ , Symbol_Star
+ , Symbol_X
+ , Symbol_Plus
+ , Symbol_Asterisk
+ , Symbol_HorizontalBar
+ , Symbol_VerticalBar
+ , Symbol_COUNT
+};
+
+
namespace chart {
namespace dummy {
@@ -431,11 +452,539 @@ void DummyArea2D::render()
}
DummySymbol2D::DummySymbol2D(const drawing::Position3D& rPos, const drawing::Direction3D& rSize,
- sal_Int32 nStandardSymbol, sal_Int32 , sal_Int32 ):
- mnStandardSymbol(nStandardSymbol)
+ sal_Int32 nStandardSymbol, sal_Int32 nBorderColor, sal_Int32 nFillColor):
+ mrPosition(rPos),
+ mrSize(rSize),
+ mnStandardSymbol(nStandardSymbol),
+ mnBorderColor(nBorderColor),
+ mnFillColor(nFillColor)
{
- setPosition(Position3DToAWTPoint(rPos));
- setSize(Direction3DToAWTSize(rSize));
+ //setPosition(Position3DToAWTPoint(rPos));
+ //setSize(Direction3DToAWTSize(rSize));
+}
+drawing::PolyPolygonShape3D oglCreatePolyPolygon_Symbol( const drawing::Position3D& rPos
+ , const drawing::Direction3D& rSize
+ , sal_Int32 nStandardSymbol )
+{
+ printf("*** createPolyPolygon_Symbol\n");
+ if(nStandardSymbol<0)
+ nStandardSymbol*=-1;
+ nStandardSymbol = nStandardSymbol%Symbol_COUNT;
+ SymbolEnum eSymbolType=static_cast<SymbolEnum>(nStandardSymbol);
+
+ const double& fX = rPos.PositionX;
+ const double& fY = rPos.PositionY;
+
+ const double fWidthH = rSize.DirectionX/2.0; //fWidthH stands for Half Width
+ const double fHeightH = rSize.DirectionY/2.0; //fHeightH stands for Half Height
+
+ const sal_Int32 nQuarterCount = 35; // points inside a quadrant, used in case circle
+
+ sal_Int32 nPointCount = 4; //all arrow symbols only need 4 points
+ switch( eSymbolType )
+ {
+ case Symbol_Square:
+ case Symbol_Diamond:
+ case Symbol_Bowtie:
+ case Symbol_Sandglass:
+ case Symbol_HorizontalBar:
+ case Symbol_VerticalBar:
+ nPointCount = 5;
+ break;
+ case Symbol_X:
+ nPointCount = 13;
+ break;
+ case Symbol_Plus:
+ nPointCount = 13;
+ break;
+ case Symbol_Star:
+ nPointCount = 9;
+ break;
+ case Symbol_Asterisk:
+ nPointCount = 19;
+ break;
+ case Symbol_Circle:
+ nPointCount = 5 + 4 * nQuarterCount;
+ break;
+ default:
+ break;
+ }
+
+ drawing::PolyPolygonShape3D aPP;
+
+ aPP.SequenceX.realloc(1);
+ aPP.SequenceY.realloc(1);
+ aPP.SequenceZ.realloc(1);
+
+ drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
+ drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
+ drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
+
+ pOuterSequenceX->realloc(nPointCount);
+ pOuterSequenceY->realloc(nPointCount);
+ pOuterSequenceZ->realloc(nPointCount);
+
+ double* pInnerSequenceX = pOuterSequenceX->getArray();
+ double* pInnerSequenceY = pOuterSequenceY->getArray();
+ double* pInnerSequenceZ = pOuterSequenceZ->getArray();
+
+ for(sal_Int32 nN = nPointCount; nN--;)
+ *pInnerSequenceZ++ = 0.0;
+
+ switch(eSymbolType)
+ {
+ case Symbol_Square:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+ break;
+ }
+ case Symbol_UpArrow:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+ break;
+ }
+ case Symbol_DownArrow:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+ break;
+ }
+ case Symbol_RightArrow:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+ break;
+ }
+ case Symbol_LeftArrow:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY;
+ break;
+ }
+ case Symbol_Bowtie:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+ break;
+ }
+ case Symbol_Sandglass:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+ break;
+ }
+ case Symbol_Diamond:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY;
+
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY;
+
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY;
+ break;
+ }
+ case Symbol_HorizontalBar:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-0.2*fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY-0.2*fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY+0.2*fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+0.2*fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-0.2*fHeightH;
+ break;
+ }
+ case Symbol_VerticalBar:
+ {
+ *pInnerSequenceX++ = fX-0.2*fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX+0.2*fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX+0.2*fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX-0.2*fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX-0.2*fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ break;
+ }
+ case Symbol_Circle:
+ {
+ double fOmega = 1.5707963267948966192 / (nQuarterCount + 1.0);
+ // one point in the middle of each edge to get full size bounding rectangle
+ *pInnerSequenceX++ = fX + fWidthH;
+ *pInnerSequenceY++ = fY;
+ // 0 to PI/2
+ for (sal_Int32 i = 1; i <= nQuarterCount; ++i)
+ {
+ *pInnerSequenceX++ = fX + fWidthH * cos( i * fOmega );
+ *pInnerSequenceY++ = fY - fHeightH * sin( i * fOmega );
+ }
+ // PI/2 to PI
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY - fHeightH;
+ for (sal_Int32 i = 1; i <= nQuarterCount; ++i)
+ {
+ *pInnerSequenceX++ = fX - fWidthH * sin( i * fOmega);
+ *pInnerSequenceY++ = fY - fHeightH * cos( i * fOmega);
+ }
+ // PI to 3/2*PI
+ *pInnerSequenceX++ = fX - fWidthH;
+ *pInnerSequenceY++ = fY;
+ for (sal_Int32 i = 1; i <= nQuarterCount; ++i)
+ {
+ *pInnerSequenceX++ = fX - fWidthH * cos( i * fOmega);
+ *pInnerSequenceY++ = fY + fHeightH * sin( i * fOmega);
+ }
+ // 3/2*PI to 2*PI
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY + fHeightH;
+ for (sal_Int32 i = 1; i <= nQuarterCount; ++i)
+ {
+ *pInnerSequenceX++ = fX + fWidthH * sin(i * fOmega);
+ *pInnerSequenceY++ = fY + fHeightH * cos(i * fOmega);
+ }
+ // close polygon
+ *pInnerSequenceX++ = fX + fWidthH;
+ *pInnerSequenceY++ = fY;
+ break;
+ }
+ case Symbol_Star:
+ {
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX+0.2*fWidthH;
+ *pInnerSequenceY++ = fY-0.2*fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY;
+
+ *pInnerSequenceX++ = fX+0.2*fWidthH;
+ *pInnerSequenceY++ = fY+0.2*fHeightH;
+
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX-0.2*fWidthH;
+ *pInnerSequenceY++ = fY+0.2*fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY;
+
+ *pInnerSequenceX++ = fX-0.2*fWidthH;
+ *pInnerSequenceY++ = fY-0.2*fHeightH;
+
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY-fHeightH;
+ break;
+ }
+ case Symbol_X:
+ {
+ const double fScaleX = fWidthH / 128.0;
+ const double fScaleY = fHeightH / 128.0;
+ const double fSmall = sqrt(200.0);
+ const double fLarge = 128.0 - fSmall;
+
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY - fScaleY * fSmall;
+
+ *pInnerSequenceX++ = fX - fScaleX * fLarge;
+ *pInnerSequenceY++ = fY - fHeightH;
+
+ *pInnerSequenceX++ = fX - fWidthH;
+ *pInnerSequenceY++ = fY - fScaleY * fLarge;
+
+ *pInnerSequenceX++ = fX - fScaleX * fSmall;
+ *pInnerSequenceY++ = fY;
+
+ *pInnerSequenceX++ = fX - fWidthH;
+ *pInnerSequenceY++ = fY + fScaleY * fLarge;
+
+ *pInnerSequenceX++ = fX - fScaleX * fLarge;
+ *pInnerSequenceY++ = fY + fHeightH;
+
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY + fScaleY * fSmall;
+
+ *pInnerSequenceX++ = fX + fScaleX * fLarge;
+ *pInnerSequenceY++ = fY + fHeightH;
+
+ *pInnerSequenceX++ = fX + fWidthH;
+ *pInnerSequenceY++ = fY + fScaleY * fLarge;
+
+ *pInnerSequenceX++ = fX + fScaleX * fSmall;
+ *pInnerSequenceY++ = fY;
+
+ *pInnerSequenceX++ = fX + fWidthH;
+ *pInnerSequenceY++ = fY - fScaleY * fLarge;
+
+ *pInnerSequenceX++ = fX + fScaleX * fLarge;
+ *pInnerSequenceY++ = fY - fHeightH;
+
+ *pInnerSequenceX++ = fX;
+ *pInnerSequenceY++ = fY - fScaleY * fSmall;
+ break;
+
+ }
+ case Symbol_Plus:
+ {
+ const double fScaleX = fWidthH / 128.0;
+ const double fScaleY = fHeightH / 128.0;
+ const double fHalf = 10.0; //half line width on 256 size square
+ const double fdX = fScaleX * fHalf;
+ const double fdY = fScaleY * fHalf;
+
+ *pInnerSequenceX++ = fX-fdX;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fdX;
+ *pInnerSequenceY++ = fY-fdY;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fdY;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fdY;
+
+ *pInnerSequenceX++ = fX-fdX;
+ *pInnerSequenceY++ = fY+fdY;
+
+ *pInnerSequenceX++ = fX-fdX;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fdX;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fdX;
+ *pInnerSequenceY++ = fY+fdY;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY+fdY;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY-fdY;
+
+ *pInnerSequenceX++ = fX+fdX;
+ *pInnerSequenceY++ = fY-fdY;
+
+ *pInnerSequenceX++ = fX+fdY;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fdX;
+ *pInnerSequenceY++ = fY-fHeightH;
+ break;
+
+ }
+ case Symbol_Asterisk:
+ {
+ const double fHalf = 10.0; // half line width on 256 size square
+ const double fTwoY = fHalf * sqrt(3.0);
+ const double fFourY = (128.0 - 2.0 * fHalf ) / sqrt(3.0);
+ const double fThreeX = 128.0 - fHalf;
+ const double fThreeY = fHalf * sqrt(3.0) + fFourY;
+ const double fFiveX = 2.0 * fHalf;
+
+ const double fScaleX = fWidthH / 128.0;
+ const double fScaleY = fHeightH / 128.0;
+
+ //1
+ *pInnerSequenceX++ = fX-fScaleX * fHalf;
+ *pInnerSequenceY++ = fY-fHeightH;
+ //2
+ *pInnerSequenceX++ = fX-fScaleX * fHalf;
+ *pInnerSequenceY++ = fY-fScaleY * fTwoY;
+ //3
+ *pInnerSequenceX++ = fX-fScaleX * fThreeX;
+ *pInnerSequenceY++ = fY-fScaleY * fThreeY;
+ //4
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fScaleY * fFourY;
+ //5
+ *pInnerSequenceX++ = fX-fScaleX * fFiveX;
+ *pInnerSequenceY++ = fY;
+ //6 as 4
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fScaleY * fFourY;
+ //7 as 3
+ *pInnerSequenceX++ = fX-fScaleX * fThreeX;
+ *pInnerSequenceY++ = fY+fScaleY * fThreeY;
+ //8 as 2
+ *pInnerSequenceX++ = fX-fScaleX * fHalf;
+ *pInnerSequenceY++ = fY+fScaleY * fTwoY;
+ //9 as 1
+ *pInnerSequenceX++ = fX-fScaleX * fHalf;
+ *pInnerSequenceY++ = fY+fHeightH;
+ //10 as 1
+ *pInnerSequenceX++ = fX+fScaleX * fHalf;
+ *pInnerSequenceY++ = fY+fHeightH;
+ //11 as 2
+ *pInnerSequenceX++ = fX+fScaleX * fHalf;
+ *pInnerSequenceY++ = fY+fScaleY * fTwoY;
+ //12 as 3
+ *pInnerSequenceX++ = fX+fScaleX * fThreeX;
+ *pInnerSequenceY++ = fY+fScaleY * fThreeY;
+ //13 as 4
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY+fScaleY * fFourY;
+ //14 as 5
+ *pInnerSequenceX++ = fX+fScaleX * fFiveX;
+ *pInnerSequenceY++ = fY;
+ //15 as 4
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY-fScaleY * fFourY;
+ //16 as 3
+ *pInnerSequenceX++ = fX+fScaleX * fThreeX;
+ *pInnerSequenceY++ = fY-fScaleY * fThreeY;
+ //17 as 2
+ *pInnerSequenceX++ = fX+fScaleX * fHalf;
+ *pInnerSequenceY++ = fY-fScaleY * fTwoY;
+ // 18 as 1
+ *pInnerSequenceX++ = fX+fScaleX * fHalf;
+ *pInnerSequenceY++ = fY-fHeightH;
+ // 19 = 1, closing
+ *pInnerSequenceX++ = fX-fScaleX * fHalf;
+ *pInnerSequenceY++ = fY-fHeightH;
+ break;
+ }
+ default: //case Symbol_Square:
+ {
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY+fHeightH;
+
+ *pInnerSequenceX++ = fX+fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+
+ *pInnerSequenceX++ = fX-fWidthH;
+ *pInnerSequenceY++ = fY-fHeightH;
+ break;
+ }
+ }
+
+ return aPP;
+}
+
+void DummySymbol2D::render()
+{
+ DummyChart* pChart = getRootShape();
+
+ pChart->m_GLRender.SetColor(mnFillColor);
+
+ drawing::PointSequenceSequence aPointss( PolyToPointSequence(
+ oglCreatePolyPolygon_Symbol( mrPosition, mrSize, mnStandardSymbol ) ));
+
+ sal_Int32 nPointssCount = aPointss.getLength();
+ for(sal_Int32 i = 0; i < nPointssCount; i++)
+ {
+ const com::sun::star::uno::Sequence<com::sun::star::awt::Point>& points = aPointss[i];
+ sal_Int32 nPointsCount = points.getLength();
+ for(sal_Int32 j = 0; j < nPointsCount; j++)
+ {
+ const com::sun::star::awt::Point& p = points[j];
+ pChart->m_GLRender.SetSymbol2DShapePoint((float)p.X, (float)p.Y, nPointsCount);
+ }
+ }
+ pChart->m_GLRender.RenderSymbol2DShape();
}
DummyCircle::DummyCircle(const awt::Point& rPos, const awt::Size& rSize)
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 980c074cda80..49ab3ea097c8 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -36,6 +36,10 @@
#include <vcl/virdev.hxx>
#include <vcl/dibtools.hxx>
+#include <osl/file.hxx>
+#include <rtl/bootstrap.hxx>
+#include <config_folders.h>
+
#include <boost/scoped_array.hpp>
using namespace com::sun::star;
@@ -51,8 +55,6 @@ using namespace std;
#include <vcl/pngwrite.hxx>
#endif
-#define OPENGL_SHADER( ... )# __VA_ARGS__
-
#define GL_PI 3.14159f
#if defined( _WIN32 )
@@ -60,140 +62,6 @@ using namespace std;
#define WGL_SAMPLES_ARB 0x2042
#endif
-//begin shaders
-
-#if DEBUG_POSITIONING
-
-const char* DebugVertexShader = OPENGL_SHADER (
-
-attribute vec3 vPosition;
-uniform vec4 vColor;
-varying vec4 fragmentColor;
-
-void main()
-{
- gl_Position = vec4(vPosition, 1);
-}
-
-);
-
-const char* DebugFragmentShader = OPENGL_SHADER (
-
-varying vec4 fragmentColor;
-
-void main()
-{
- gl_FragColor = vec4(1.0, 1.0, 0.0, 0.5);
-}
-
-);
-
-#endif
-
-const char *CommonFragmemtShader = OPENGL_SHADER (
-
-varying vec4 fragmentColor;
-
-void main()
-{
- gl_FragColor = fragmentColor;
-}
-
-);
-
-const char *CommonVertexShader = OPENGL_SHADER (
-
-attribute vec3 vPosition;
-uniform mat4 MVP;
-uniform vec4 vColor;
-varying vec4 fragmentColor;
-
-void main()
-{
- gl_Position = MVP * vec4(vPosition, 1);
- fragmentColor = vColor;
-}
-
-);
-
-
-const char *BackgroundFragmemtShader = OPENGL_SHADER (
-
-varying vec4 fragmentColor;
-
-void main()
-{
- gl_FragColor = fragmentColor;
-}
-
-);
-
-const char *BackgroundVertexShader = OPENGL_SHADER (
-
-attribute vec3 vPosition;
-uniform mat4 MVP;
-attribute vec4 vColor;
-varying vec4 fragmentColor;
-
-void main()
-{
- gl_Position = MVP * vec4(vPosition, 1);
- fragmentColor = vColor;
-}
-
-);
-
-
-const char *RenderFragmentShader = OPENGL_SHADER (
-
-uniform sampler2D RenderTex;
-varying vec2 vTexCoord;
-
-void main()
-{
- gl_FragColor = vec4(texture2D(RenderTex, vTexCoord).rgb, 1.0);
-}
-
-);
-
-const char *RenderVertexShader = OPENGL_SHADER (
-
-attribute vec4 vPosition;
-attribute vec2 texCoord;
-varying vec2 vTexCoord;
-
-void main()
-{
- gl_Position = vPosition;
- vTexCoord = texCoord;
-}
-
-);
-
-const char *TextFragmentShader = OPENGL_SHADER (
-uniform sampler2D TextTex;
-varying vec2 vTexCoord;
-void main()
-{
- gl_FragColor = vec4(texture2D(TextTex, vTexCoord).rgba);
-}
-
-);
-
-const char *TextVertexShader = OPENGL_SHADER (
-
-attribute vec3 vPosition;
-uniform mat4 MVP;
-attribute vec2 texCoord;
-varying vec2 vTexCoord;
-void main()
-{
- gl_Position = MVP * vec4(vPosition, 1);
- vTexCoord = texCoord;
-}
-
-);
-
// end shaders
static GLfloat squareVertices[] = {
@@ -321,7 +189,46 @@ int static checkGLError(const char *file, int line)
return -1;\
}
-GLint OpenGLRender::LoadShaders(const char *vertexShader,const char *fragmentShader)
+namespace {
+
+OUString getShaderFolder()
+{
+ OUString aUrl("$BRAND_BASE_DIR/" LIBO_ETC_FOLDER);
+ rtl::Bootstrap::expandMacros(aUrl);
+
+ return aUrl + "/opengl/";
+}
+
+OUString maShaderFolder = getShaderFolder();
+
+OString loadShader(const OUString& rFilename)
+{
+ OUString aFileURL = maShaderFolder + rFilename +".glsl";
+ osl::File aFile(aFileURL);
+ if(aFile.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None)
+ {
+ sal_uInt64 nSize = 0;
+ aFile.getSize(nSize);
+ char* content = new char[nSize+1];
+ sal_uInt64 nBytesRead = 0;
+ aFile.read(content, nSize, nBytesRead);
+ if(nSize != nBytesRead)
+ assert(false);
+
+ content[nSize] = 0;
+ return OString(content);
+ }
+ else
+ {
+ SAL_WARN("chart2.opengl", "could not load the file: " << aFileURL);
+ }
+
+ return OString();
+}
+
+}
+
+GLint OpenGLRender::LoadShaders(const OUString& rVertexShaderName,const OUString& rFragmentShaderName)
{
// Create the shaders
GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
@@ -331,7 +238,8 @@ GLint OpenGLRender::LoadShaders(const char *vertexShader,const char *fragmentSha
int InfoLogLength;
// Compile Vertex Shader
- char const * VertexSourcePointer = vertexShader;
+ OString aVertexShaderSource = loadShader(rVertexShaderName);
+ char const * VertexSourcePointer = aVertexShaderSource.getStr();
glShaderSource(VertexShaderID, 1, &VertexSourcePointer , NULL);
glCompileShader(VertexShaderID);
@@ -354,7 +262,8 @@ GLint OpenGLRender::LoadShaders(const char *vertexShader,const char *fragmentSha
}
// Compile Fragment Shader
- char const * FragmentSourcePointer = fragmentShader;
+ OString aFragmentShaderSource = loadShader(rFragmentShaderName);
+ char const * FragmentSourcePointer = aFragmentShaderSource.getStr();
glShaderSource(FragmentShaderID, 1, &FragmentSourcePointer , NULL);
glCompileShader(FragmentShaderID);
@@ -453,29 +362,29 @@ int OpenGLRender::InitOpenGL(GLWindow aWindow)
glGenBuffers(1, &m_VertexBuffer);
glGenBuffers(1, &m_ColorBuffer);
- m_RenderProID = LoadShaders(RenderVertexShader, RenderFragmentShader);
+ m_RenderProID = LoadShaders("renderVertexShader", "renderFragmentShader");
m_RenderVertexID = glGetAttribLocation(m_RenderProID, "vPosition");
m_RenderTexCoordID = glGetAttribLocation(m_RenderProID, "texCoord");
m_RenderTexID = glGetUniformLocation(m_RenderProID, "RenderTex");
- m_CommonProID = LoadShaders(CommonVertexShader, CommonFragmemtShader);
+ m_CommonProID = LoadShaders("commonVertexShader", "commonFragmentShader");
m_MatrixID = glGetUniformLocation(m_CommonProID, "MVP");
m_2DVertexID = glGetAttribLocation(m_CommonProID, "vPosition");
m_2DColorID = glGetUniformLocation(m_CommonProID, "vColor");
CHECK_GL_ERROR();
#if DEBUG_POSITIONING
- m_DebugProID = LoadShaders(DebugVertexShader, DebugFragmentShader);
+ m_DebugProID = LoadShaders("debugVertexShader", "debugFragmentShader");
m_DebugVertexID = glGetAttribLocation(m_DebugProID, "vPosition");
#endif
CHECK_GL_ERROR();
- m_BackgroundProID = LoadShaders(BackgroundVertexShader, BackgroundFragmemtShader);
+ m_BackgroundProID = LoadShaders("backgroundVertexShader", "backgroundFragmentShader");
m_BackgroundMatrixID = glGetUniformLocation(m_BackgroundProID, "MVP");
m_BackgroundVertexID = glGetAttribLocation(m_BackgroundProID, "vPosition");
m_BackgroundColorID = glGetAttribLocation(m_BackgroundProID, "vColor");
- m_TextProID = LoadShaders(TextVertexShader, TextFragmentShader);
+ m_TextProID = LoadShaders("textVertexShader", "textFragmentShader");
m_TextMatrixID = glGetUniformLocation(m_TextProID, "MVP");
m_TextVertexID = glGetAttribLocation(m_TextProID, "vPosition");
m_TextTexCoordID = glGetAttribLocation(m_TextProID, "texCoord");
@@ -1811,5 +1720,73 @@ int OpenGLRender::RenderPieSegment2DShape(float fSize, float fPosX, float fPosY)
CHECK_GL_ERROR();
return 0;
}
+int OpenGLRender::SetSymbol2DShapePoint(float x, float y, int listLength)
+{
+ if (m_Symbol2DPointList.empty())
+ {
+ m_Symbol2DPointList.reserve(listLength);
+ }
+ float actualX = (x / OPENGL_SCALE_VALUE);
+ float actualY = (y / OPENGL_SCALE_VALUE);
+ m_Symbol2DPointList.push_back(actualX);
+ m_Symbol2DPointList.push_back(actualY);
+ m_Symbol2DPointList.push_back(m_fZStep);
+
+ if (m_Symbol2DPointList.size() == size_t(listLength * 3))
+ {
+ m_Symbol2DShapePointList.push_back(m_Symbol2DPointList);
+ m_Symbol2DPointList.clear();
+ }
+ return 0;
+}
+
+int OpenGLRender::RenderSymbol2DShape()
+{
+ CHECK_GL_ERROR();
+
+ glDisable(GL_MULTISAMPLE);
+ size_t listNum = m_Symbol2DShapePointList.size();
+ PosVecf3 trans = {0.0f, 0.0f, 0.0f};
+ PosVecf3 angle = {0.0f, 0.0f, 0.0f};
+ PosVecf3 scale = {1.0f, 1.0f, 1.0f};
+ MoveModelf(trans, angle, scale);
+ m_MVP = m_Projection * m_View * m_Model;
+ for (size_t i = 0; i < listNum; ++i)
+ {
+ PointList &pointList = m_Symbol2DShapePointList.back();
+ //fill vertex buffer
+ glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+ glBufferData(GL_ARRAY_BUFFER, pointList.size() * sizeof(float), &pointList[0], GL_STATIC_DRAW);
+ // Use our shader
+ glUseProgram(m_CommonProID);
+
+ glUniform4fv(m_2DColorID, 1, &m_2DColor[0]);
+
+ glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &m_MVP[0][0]);
+
+ // 1rst attribute buffer : vertices
+ glEnableVertexAttribArray(m_2DVertexID);
+ glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+ glVertexAttribPointer(
+ m_2DVertexID, // attribute. No particular reason for 0, but must match the layout in the shader.
+ 3, // size
+ GL_FLOAT, // type
+ GL_FALSE, // normalized?
+ 0, // stride
+ (void*)0 // array buffer offset
+ );
+ glDrawArrays(GL_POLYGON, 0, pointList.size() / 3); // 12*3 indices starting at 0 -> 12 triangles
+ glDisableVertexAttribArray(m_2DVertexID);
+ glUseProgram(0);
+ m_Symbol2DShapePointList.pop_back();
+ }
+ glEnable(GL_MULTISAMPLE);
+ m_fZStep += 0.01f;
+
+ CHECK_GL_ERROR();
+
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 21a05cbb7c8a..2faf556e230b 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -101,6 +101,7 @@ typedef struct TextInfo
typedef std::vector<GLfloat> Area2DPointList;
typedef std::vector<GLfloat> PieSegment2DPointList;
+typedef std::vector<GLfloat> PointList;
/// Holds the information of our new child window
struct GLWindow
@@ -178,6 +179,9 @@ public:
void GeneratePieSegment2D(double, double, double, double);
int RenderPieSegment2DShape(float, float, float);
+
+ int SetSymbol2DShapePoint(float, float, int);
+ int RenderSymbol2DShape();
#if DEBUG_POSITIONING
void renderDebug();
#endif
@@ -185,7 +189,7 @@ public:
void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2);
private:
- GLint LoadShaders(const char *vertexShader,const char *fragmentShader);
+ GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
int CreateTextureObj(int width, int height);
int CreateRenderObj(int width, int height);
int CreateFrameBufferObj();
@@ -203,7 +207,7 @@ private:
glm::mat4 m_Projection;
// Camera matrix
glm::mat4 m_View;
- // Model matrix : an identity matrix (model will be at the origin)
+ // Model matrix : an identity matrix (model will be at the origin#elif defined( UNX )
glm::mat4 m_Model;
// Our ModelViewProjection : multiplication of our 3 matrices
glm::mat4 m_MVP;
@@ -299,6 +303,8 @@ private:
glm::vec4 m_ClearColor;
std::list <PieSegment2DPointList> m_PieSegment2DShapePointList;
+ PointList m_Symbol2DPointList;
+ std::list<PointList> m_Symbol2DShapePointList;
#if DEBUG_POSITIONING
GLuint m_DebugProID;