summaryrefslogtreecommitdiffstats
path: root/src/datavisualization
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@digia.com>2014-09-03 15:00:07 +0300
committerMika Salmela <mika.salmela@digia.com>2014-09-04 11:20:14 +0300
commit18413de96ea907ea5c7defdcb40248fdfbaa4de7 (patch)
tree09910eefb5658556e1ddc97c1b8551b8e3248ef7 /src/datavisualization
parent28777a99f79bc9db1a28e1b93080b005be03353b (diff)
ES2 gradient support for static optimization
Change-Id: I3d5d5d006a26225a3a7ab5795fceb97630db0011 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavisualization')
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp16
-rw-r--r--src/datavisualization/engine/engine.qrc1
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp23
-rw-r--r--src/datavisualization/engine/scatter3drenderer_p.h2
-rw-r--r--src/datavisualization/engine/shaders/point_ES2_UV.vert12
5 files changed, 50 insertions, 4 deletions
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index dfb73d99..3d5ccba1 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -329,10 +329,18 @@ void Abstract3DRenderer::reInitShaders()
QStringLiteral(":/shaders/fragmentTexture3DLowDef"),
QStringLiteral(":/shaders/fragmentTexture3DSlice"));
#else
- initGradientShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentColorOnYES2"));
- initShaders(QStringLiteral(":/shaders/vertex"),
- QStringLiteral(":/shaders/fragmentES2"));
+ if (m_cachedOptimizationHint.testFlag(QAbstract3DGraph::OptimizationStatic)
+ && qobject_cast<Scatter3DRenderer *>(this)) {
+ initGradientShaders(QStringLiteral(":/shaders/vertexTexture"),
+ QStringLiteral(":/shaders/fragmentTextureES2"));
+ initBackgroundShaders(QStringLiteral(":/shaders/vertexNoMatrices"),
+ QStringLiteral(":/shaders/fragmentES2"));
+ } else {
+ initGradientShaders(QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragmentColorOnYES2"));
+ initShaders(QStringLiteral(":/shaders/vertex"),
+ QStringLiteral(":/shaders/fragmentES2"));
+ }
initBackgroundShaders(QStringLiteral(":/shaders/vertex"),
QStringLiteral(":/shaders/fragmentES2"));
initCustomItemShaders(QStringLiteral(":/shaders/vertexTexture"),
diff --git a/src/datavisualization/engine/engine.qrc b/src/datavisualization/engine/engine.qrc
index 0936bc16..eeddf92e 100644
--- a/src/datavisualization/engine/engine.qrc
+++ b/src/datavisualization/engine/engine.qrc
@@ -65,5 +65,6 @@
<file alias="vertexShadowNoMatrices">shaders/shadowNoMatrices.vert</file>
<file alias="vertexNoMatrices">shaders/defaultNoMatrices.vert</file>
<file alias="fragmentTexture3DLowDef">shaders/texture3dlowdef.frag</file>
+ <file alias="vertexPointES2_UV">shaders/point_ES2_UV.vert</file>
</qresource>
</RCC>
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index 8c4644c6..ba1019ad 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -50,6 +50,7 @@ Scatter3DRenderer::Scatter3DRenderer(Scatter3DController *controller)
m_selectionShader(0),
m_backgroundShader(0),
m_labelShader(0),
+ m_staticGradientPointShader(0),
m_bgrTexture(0),
m_selectionTexture(0),
m_depthFrameBuffer(0),
@@ -93,6 +94,7 @@ Scatter3DRenderer::~Scatter3DRenderer()
delete m_selectionShader;
delete m_backgroundShader;
delete m_labelShader;
+ delete m_staticGradientPointShader;
}
void Scatter3DRenderer::initializeOpenGL()
@@ -348,6 +350,13 @@ void Scatter3DRenderer::updateOptimizationHint(QAbstract3DGraph::OptimizationHin
Abstract3DRenderer::updateOptimizationHint(hint);
Abstract3DRenderer::reInitShaders();
+
+#if defined(QT_OPENGL_ES_2)
+ if (hint.testFlag(QAbstract3DGraph::OptimizationStatic) && !m_staticGradientPointShader) {
+ initStaticPointShaders(QStringLiteral(":/shaders/vertexPointES2_UV"),
+ QStringLiteral(":/shaders/fragmentLabel"));
+ }
+#endif
}
void Scatter3DRenderer::resetClickedStatus()
@@ -859,7 +868,11 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
}
if (!optimizationDefault && rangeGradientPoints) {
+#if !defined(QT_OPENGL_ES_2)
dotShader = m_labelShader;
+#else
+ dotShader = m_staticGradientPointShader;
+#endif
dotShader->bind();
gradientTexture = cache->baseGradientTexture();
}
@@ -2208,6 +2221,16 @@ void Scatter3DRenderer::initLabelShaders(const QString &vertexShader, const QStr
m_labelShader->initialize();
}
+void Scatter3DRenderer::initStaticPointShaders(const QString &vertexShader,
+ const QString &fragmentShader)
+{
+ if (m_staticGradientPointShader)
+ delete m_staticGradientPointShader;
+ m_staticGradientPointShader = new ShaderHelper(this, vertexShader, fragmentShader);
+ m_staticGradientPointShader->initialize();
+}
+
+
void Scatter3DRenderer::selectionColorToSeriesAndIndex(const QVector4D &color,
int &index,
QAbstract3DSeries *&series)
diff --git a/src/datavisualization/engine/scatter3drenderer_p.h b/src/datavisualization/engine/scatter3drenderer_p.h
index 353dc098..3fc517d0 100644
--- a/src/datavisualization/engine/scatter3drenderer_p.h
+++ b/src/datavisualization/engine/scatter3drenderer_p.h
@@ -60,6 +60,7 @@ private:
ShaderHelper *m_selectionShader;
ShaderHelper *m_backgroundShader;
ShaderHelper *m_labelShader;
+ ShaderHelper *m_staticGradientPointShader;
GLuint m_bgrTexture;
GLuint m_selectionTexture;
GLuint m_depthFrameBuffer;
@@ -129,6 +130,7 @@ private:
void initSelectionShader();
void initBackgroundShaders(const QString &vertexShader, const QString &fragmentShader);
void initLabelShaders(const QString &vertexShader, const QString &fragmentShader);
+ void initStaticPointShaders(const QString &vertexShader, const QString &fragmentShader);
void initSelectionBuffer();
#if !defined(QT_OPENGL_ES_2)
void initDepthShader();
diff --git a/src/datavisualization/engine/shaders/point_ES2_UV.vert b/src/datavisualization/engine/shaders/point_ES2_UV.vert
new file mode 100644
index 00000000..f181db4f
--- /dev/null
+++ b/src/datavisualization/engine/shaders/point_ES2_UV.vert
@@ -0,0 +1,12 @@
+uniform highp mat4 MVP;
+
+attribute highp vec3 vertexPosition_mdl;
+attribute highp vec2 vertexUV;
+
+varying highp vec2 UV;
+
+void main() {
+ gl_PointSize = 5.0;
+ gl_Position = MVP * vec4(vertexPosition_mdl, 1.0);
+ UV = vertexUV;
+}