[Libreoffice-commits] core.git: 18 commits - chart2/opengl chart2/Package_opengl.mk chart2/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Wed Aug 6 11:54:16 PDT 2014
chart2/Package_opengl.mk | 2
chart2/opengl/pickingFragmentShader.glsl | 5
chart2/opengl/pickingVertexShader.glsl | 7
chart2/opengl/shape3DFragmentShaderBatchScroll.glsl | 111 ++++++++++++
chart2/opengl/shape3DFragmentShaderV300.glsl | 7
chart2/opengl/shape3DVertexShader.glsl | 4
chart2/opengl/shape3DVertexShaderBatchScroll.glsl | 39 ++++
chart2/opengl/shape3DVertexShaderV300.glsl | 8
chart2/source/view/charttypes/GL3DBarChart.cxx | 123 ++++++++++++-
chart2/source/view/inc/GL3DBarChart.hxx | 2
chart2/source/view/inc/GL3DRenderer.hxx | 36 +++
chart2/source/view/main/GL3DRenderer.cxx | 183 +++++++++++++++++---
12 files changed, 493 insertions(+), 34 deletions(-)
New commits:
commit ac6fabdc02fdcba8a502153099512946d2b7effd
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Wed Aug 6 12:26:11 2014 +0200
fix Wreorder
Change-Id: Icc9d9587ddf5610d6adaca9b2ea5eb32e2534947
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 1eed3cb..b9af4266 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -180,8 +180,8 @@ public:
RenderBenchMarkThread(GL3DBarChart * pChart):
RenderThread(pChart),
mbExecuting(false),
- miFrameCount(0),
- mbNeedFlyBack(false)
+ mbNeedFlyBack(false),
+ miFrameCount(0)
{
osl_getSystemTime(&mafpsRenderStartTime);
osl_getSystemTime(&mafpsRenderEndTime);
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index c993ecd..f4b4b67 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -464,9 +464,9 @@ private:
sal_uInt32 m_uiSelectID;
float m_fScrollSpeed;
float m_fScrollDistance;
- float m_fCurDistance;
float m_fMinCoordX;
float m_fMaxCoordX;
+ float m_fCurDistance;
glm::mat4 m_ScrollMoveMatrix;
bool m_bUndrawFlag;
};
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 57f016b..48d7da7 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -114,8 +114,8 @@ OpenGL3DRenderer::OpenGL3DRenderer():
, m_fMinCoordX(0.0f)
, m_fMaxCoordX(0.0f)
, m_fCurDistance(0.0f)
- , m_bUndrawFlag(false)
, m_ScrollMoveMatrix(glm::mat4(1.0))
+ , m_bUndrawFlag(false)
{
m_Polygon3DInfo.lineOnly = false;
m_Polygon3DInfo.twoSidesLighting = false;
@@ -162,6 +162,7 @@ OpenGL3DRenderer::~OpenGL3DRenderer()
OpenGL3DRenderer::ShaderResources::ShaderResources()
: m_b330Support(false)
+ , m_bScrollFlag(false)
, m_3DProID(0)
, m_3DProjectionID(0)
, m_3DViewID(0)
@@ -207,7 +208,6 @@ OpenGL3DRenderer::ShaderResources::ShaderResources()
, m_BatchTextVertexID(0)
, m_BatchTextTexCoordID(0)
, m_BatchTextTexID(0)
- , m_bScrollFlag(false)
{
}
commit 8f38b9e11eef43fbc47827eff432b3620aeee2d4
Author: weigao <weigao at multicorewareinc.com>
Date: Thu Aug 7 14:25:50 2014 +0800
remove test code of screen text
Change-Id: Ibcda49dc561b2778d17c03edaaaf2b8e2fff4a0a
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 186bbac..1eed3cb 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -377,16 +377,7 @@ void RenderBenchMarkThread::UpdateFPS()
osl_getSystemTime(&mafpsRenderStartTime);
}
osl_getSystemTime(&mafpsRenderEndTime);
-#if 1
- opengl3D::ScreenText tFPS(mpChart->mpRenderer.get(), *(mpChart->mpTextCache), mpChart->mTestString, 0);
- opengl3D::TextCacheItem tmpTextCache = mpChart->mpTextCache->getText(mpChart->mTestString);
-#else
- opengl3D::ScreenText tFPS(mpChart->mpRenderer.get(), *(mpChart->mpTextCache), maFPS, 0);
- opengl3D::TextCacheItem tmpTextCache = mpChart->mpTextCache->getText(maFPS);
-#endif
- float rectWidth = (float)tmpTextCache.maSize.Width() / (float)tmpTextCache.maSize.Height() * 0.05;
- tFPS.setPosition(glm::vec2(-0.99f, 0.99f), glm::vec2(-0.99f + rectWidth, 0.89f));
- tFPS.render();
+ //will add the fps render code here later
}
void RenderBenchMarkThread::UpdateScreenText()
@@ -648,7 +639,6 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), *mpTextCache,
aCats[i], nId));
- mTestString = aCats[i];
nId += ID_STEP;
p = static_cast<opengl3D::Text*>(&maShapes.back());
aTopLeft.x = nXPos + TEXT_HEIGHT + 0.5 * BAR_SIZE_X;
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index a4a92a4..7b1e7b6 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -137,7 +137,6 @@ private:
RenderEventType maRenderEvent;
sal_uInt32 mSelectBarId;
Point maClickPos;
- OUString mTestString;
sal_uInt32 miScrollRate;
bool mbScrollFlg;
};
commit b2b57d51b17704e1f7d031bda7d1549368838652
Author: weigao <weigao at multicorewareinc.com>
Date: Tue Aug 5 17:03:28 2014 +0800
add click fly back code
Change-Id: Ib4d5ce06f50ab7413fe8ecb5b61397b41e4fedd2
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 3e27e98..186bbac 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -180,12 +180,15 @@ public:
RenderBenchMarkThread(GL3DBarChart * pChart):
RenderThread(pChart),
mbExecuting(false),
- miFrameCount(0)
+ miFrameCount(0),
+ mbNeedFlyBack(false)
{
osl_getSystemTime(&mafpsRenderStartTime);
osl_getSystemTime(&mafpsRenderEndTime);
osl_getSystemTime(&maScreenTextUpdateStartTime);
osl_getSystemTime(&maScreenTextUpdateEndTime);
+ osl_getSystemTime(&maClickFlyBackStartTime);
+ osl_getSystemTime(&maClickFlyBackEndTime);
}
protected:
virtual void execute() SAL_OVERRIDE;
@@ -198,12 +201,14 @@ private:
void ProcessScroll();
void UpdateScreenText();
void UpdateFPS();
- int calcTimeInterval(TimeValue &startTime, TimeValue &endTime);
+ int CalcTimeInterval(TimeValue &startTime, TimeValue &endTime);
+ void ProcessClickFlyBack();
private:
glm::vec3 maStartPos;
glm::vec3 maEndPos;
sal_Int32 mnSteps;
bool mbExecuting;
+ bool mbNeedFlyBack;
glm::vec3 maStep;
glm::vec3 maStepDirection;
size_t mnStep;
@@ -212,6 +217,8 @@ private:
TimeValue mafpsRenderEndTime;
TimeValue maScreenTextUpdateStartTime;
TimeValue maScreenTextUpdateEndTime;
+ TimeValue maClickFlyBackStartTime;
+ TimeValue maClickFlyBackEndTime;
int miFrameCount;
OUString maFPS;
};
@@ -231,7 +238,14 @@ void RenderBenchMarkThread::MoveCamera()
mnStep = 0;
mbExecuting = false;
if (mpChart->maRenderEvent == EVENT_CLICK)
+ {
mpChart->mpRenderer->EndClick();
+ mbNeedFlyBack = true;
+ osl_getSystemTime(&maClickFlyBackStartTime);
+ osl_getSystemTime(&maClickFlyBackEndTime);
+ }
+ else
+ mbNeedFlyBack = false;
mpChart->maRenderEvent = EVENT_NONE;
}
}
@@ -307,8 +321,21 @@ void RenderBenchMarkThread::ProcessScroll()
mpChart->maRenderEvent = EVENT_NONE;
}
+void RenderBenchMarkThread::ProcessClickFlyBack()
+{
+ if (!mbNeedFlyBack)
+ return;
+ osl_getSystemTime(&maClickFlyBackEndTime);
+ int aDeltaMs = CalcTimeInterval(maClickFlyBackStartTime, maClickFlyBackEndTime);
+ if(aDeltaMs >= 10000)
+ {
+ mpChart->maRenderEvent = EVENT_MOVE_TO_DEFAULT;
+ }
+}
+
void RenderBenchMarkThread::ProcessMouseEvent()
{
+ ProcessClickFlyBack();
if (mpChart->maRenderEvent == EVENT_CLICK)
{
MoveToBar();
@@ -327,7 +354,7 @@ void RenderBenchMarkThread::ProcessMouseEvent()
}
}
-int RenderBenchMarkThread::calcTimeInterval(TimeValue &startTime, TimeValue &endTime)
+int RenderBenchMarkThread::CalcTimeInterval(TimeValue &startTime, TimeValue &endTime)
{
TimeValue aTime;
aTime.Seconds = endTime.Seconds - startTime.Seconds - 1;
@@ -339,11 +366,11 @@ int RenderBenchMarkThread::calcTimeInterval(TimeValue &startTime, TimeValue &end
void RenderBenchMarkThread::UpdateFPS()
{
- int aDeltaMs = calcTimeInterval(mafpsRenderStartTime, mafpsRenderEndTime);
+ int aDeltaMs = CalcTimeInterval(mafpsRenderStartTime, mafpsRenderEndTime);
if(aDeltaMs >= 500)
{
osl_getSystemTime(&mafpsRenderEndTime);
- aDeltaMs = calcTimeInterval(mafpsRenderStartTime, mafpsRenderEndTime);
+ aDeltaMs = CalcTimeInterval(mafpsRenderStartTime, mafpsRenderEndTime);
int iFPS = miFrameCount * 1000 / aDeltaMs;
maFPS = OUString("Render FPS: ") + OUString::number(iFPS);
miFrameCount = 0;
@@ -364,7 +391,7 @@ void RenderBenchMarkThread::UpdateFPS()
void RenderBenchMarkThread::UpdateScreenText()
{
- int aDeltaMs = calcTimeInterval(maScreenTextUpdateStartTime, maScreenTextUpdateEndTime);
+ int aDeltaMs = CalcTimeInterval(maScreenTextUpdateStartTime, maScreenTextUpdateEndTime);
if (aDeltaMs >= 20)
{
mpChart->mpRenderer->ReleaseScreenTextShapes();
commit e3d4a488a0c3eab68d4c77139f8d9b203e1ddafc
Author: weigao <weigao at multicorewareinc.com>
Date: Sun Aug 3 18:55:54 2014 +0800
make GL 3.0 support bars scroll
Change-Id: I71d8d94f410e6c67d0e188ea2e0f79eb151758e0
diff --git a/chart2/opengl/shape3DFragmentShaderV300.glsl b/chart2/opengl/shape3DFragmentShaderV300.glsl
index fee81d4..05e2770 100644
--- a/chart2/opengl/shape3DFragmentShaderV300.glsl
+++ b/chart2/opengl/shape3DFragmentShaderV300.glsl
@@ -23,9 +23,13 @@ uniform vec4 lightPosWorldspace[MAX_LIGHT_NUM];
uniform float lightPower[MAX_LIGHT_NUM];
uniform int lightNum;
uniform vec4 lightAmbient;
+uniform int undraw;
+uniform float minCoordX;
void main()
{
+ if ((positionWorldspace.x <= minCoordX) && (undraw == 1))
+ discard;
vec3 colorTotal = vec3(0.0f, 0.0f, 0.0f);
vec3 vertexPositionCameraspace = (V * vec4(positionWorldspace,1)).xyz;
diff --git a/chart2/opengl/shape3DVertexShaderV300.glsl b/chart2/opengl/shape3DVertexShaderV300.glsl
index 6737004..a8da294 100644
--- a/chart2/opengl/shape3DVertexShaderV300.glsl
+++ b/chart2/opengl/shape3DVertexShaderV300.glsl
@@ -16,12 +16,16 @@ uniform mat4 P;
uniform mat4 M;
uniform mat4 V;
uniform mat3 normalMatrix;
+uniform float minCoordX;
+uniform float maxCoordX;
void main()
{
- gl_Position = P * V * M * vec4(vertexPositionModelspace,1);
+ positionWorldspace = (M * vec4(vertexPositionModelspace,1)).xyz;
- positionWorldspace = (M * vec4(vertexPositionModelspace,1)).xyz;
+ positionWorldspace.x = clamp(positionWorldspace.x, minCoordX, maxCoordX);
+
+ gl_Position = P * V * vec4(positionWorldspace,1);
normalCameraspace = normalize(mat3(V) * normalMatrix * vertexNormalModelspace);
}
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 5a8b6ec..c993ecd 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -289,6 +289,9 @@ private:
GLint m_3DNormalMatrixID;
GLint m_3DVertexID;
GLint m_3DNormalID;
+ GLint m_3DMinCoordXID;
+ GLint m_3DMaxCoordXID;
+ GLint m_3DUndrawID;
//300 verson;
GLint m_3DMaterialAmbientID;
GLint m_3DMaterialDiffuseID;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index b09238d..57f016b 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -286,6 +286,9 @@ void OpenGL3DRenderer::ShaderResources::LoadShaders()
m_3DLightPowerID = glGetUniformLocation(m_3DProID, "lightPower");
m_3DLightNumID = glGetUniformLocation(m_3DProID, "lightNum");
m_3DLightAmbientID = glGetUniformLocation(m_3DProID, "lightAmbient");
+ m_3DMinCoordXID = glGetUniformLocation(m_3DProID, "minCoordX");
+ m_3DMaxCoordXID = glGetUniformLocation(m_3DProID, "maxCoordX");
+ m_3DUndrawID = glGetUniformLocation(m_3DProID, "undraw");
m_3DVertexID = glGetAttribLocation(m_3DProID, "vertexPositionModelspace");
m_3DNormalID = glGetAttribLocation(m_3DProID, "vertexNormalModelspace");
}
@@ -911,6 +914,11 @@ void OpenGL3DRenderer::RenderPolygon3D(const Polygon3DInfo& polygon)
}
else
{
+ float minCoordX = 0.0f;
+ float maxCoordX = m_fMinCoordX + m_fMaxCoordX;
+ glUniform1fv(maResources.m_3DMinCoordXID, 1, &minCoordX);
+ glUniform1fv(maResources.m_3DMaxCoordXID, 1, &maxCoordX);
+ glUniform1i(maResources.m_3DUndrawID, m_bUndrawFlag);
//update light information
glUniform4fv(maResources.m_3DLightColorID, m_iLightNum, (GLfloat*)m_LightColor);
glUniform4fv(maResources.m_3DLightPosID, m_iLightNum, (GLfloat*)m_PositionWorldspace);
@@ -1568,6 +1576,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
}
else
{
+ glUniform1fv(maResources.m_3DMinCoordXID, 1, &m_fMinCoordX);
+ glUniform1fv(maResources.m_3DMaxCoordXID, 1, &m_fMaxCoordX);
+ glUniform1i(maResources.m_3DUndrawID, m_bUndrawFlag);
//update light information
glUniform4fv(maResources.m_3DLightColorID, m_iLightNum, (GLfloat*)m_LightColor);
glUniform4fv(maResources.m_3DLightPosID, m_iLightNum, (GLfloat*)m_PositionWorldspace);
commit 495d53b1dc0f3c32e0b76344775b9fc728e09fe5
Author: weigao <weigao at multicorewareinc.com>
Date: Sun Aug 3 18:36:56 2014 +0800
make pick shader work when bars scroll
Change-Id: I9a3e0e36b212ff49ad22ac0ff267d04476b4c307
diff --git a/chart2/opengl/pickingFragmentShader.glsl b/chart2/opengl/pickingFragmentShader.glsl
index 805789e..e2fba03 100644
--- a/chart2/opengl/pickingFragmentShader.glsl
+++ b/chart2/opengl/pickingFragmentShader.glsl
@@ -6,11 +6,14 @@
* 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/.
*/
-
+uniform float minCoordX;
+varying vec3 positionWorldspace;
varying vec4 fragmentColor;
void main()
{
+ if (positionWorldspace.x <= minCoordX)
+ discard;
gl_FragColor = fragmentColor;
}
diff --git a/chart2/opengl/pickingVertexShader.glsl b/chart2/opengl/pickingVertexShader.glsl
index f32e3fd..df71ae1 100644
--- a/chart2/opengl/pickingVertexShader.glsl
+++ b/chart2/opengl/pickingVertexShader.glsl
@@ -9,11 +9,16 @@
attribute vec3 vPosition;
uniform mat4 MVP;
+uniform mat4 M;
uniform vec4 vColor;
+uniform float minCoordX;
+uniform float maxCoordX;
varying vec4 fragmentColor;
-
+varying vec3 positionWorldspace;
void main()
{
+ positionWorldspace = (M * vec4(vPosition,1)).xyz;
+ positionWorldspace.x = clamp(positionWorldspace.x, minCoordX, maxCoordX);
gl_Position = MVP * vec4(vPosition, 1);
fragmentColor = vColor;
}
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 8b879a5..5a8b6ec 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -356,7 +356,9 @@ private:
GLint m_2DVertexID;
GLint m_2DColorID;
GLint m_MatrixID;
-
+ GLint m_ModelID;
+ GLint m_MinCoordXID;
+ GLint m_MaxCoordXID;
PickingShaderResources();
~PickingShaderResources();
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 51f3a1e..b09238d 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -115,6 +115,7 @@ OpenGL3DRenderer::OpenGL3DRenderer():
, m_fMaxCoordX(0.0f)
, m_fCurDistance(0.0f)
, m_bUndrawFlag(false)
+ , m_ScrollMoveMatrix(glm::mat4(1.0))
{
m_Polygon3DInfo.lineOnly = false;
m_Polygon3DInfo.twoSidesLighting = false;
@@ -315,6 +316,9 @@ OpenGL3DRenderer::PickingShaderResources::PickingShaderResources()
, m_2DVertexID(0)
, m_2DColorID(0)
, m_MatrixID(0)
+ , m_ModelID(0)
+ , m_MinCoordXID(0)
+ , m_MaxCoordXID(0)
{
}
@@ -329,6 +333,9 @@ void OpenGL3DRenderer::PickingShaderResources::LoadShaders()
m_MatrixID = glGetUniformLocation(m_CommonProID, "MVP");
m_2DVertexID = glGetAttribLocation(m_CommonProID, "vPosition");
m_2DColorID = glGetUniformLocation(m_CommonProID, "vColor");
+ m_ModelID = glGetUniformLocation(m_CommonProID, "M");
+ m_MinCoordXID = glGetUniformLocation(m_CommonProID, "minCoordX");
+ m_MaxCoordXID = glGetUniformLocation(m_CommonProID, "maxCoordX");
}
void OpenGL3DRenderer::SetCameraInfo(const glm::vec3& pos, const glm::vec3& direction, const glm::vec3& up)
@@ -884,6 +891,10 @@ void OpenGL3DRenderer::RenderPolygon3D(const Polygon3DInfo& polygon)
if(mbPickingMode)
{
glUseProgram(maPickingResources.m_CommonProID);
+ float minCoordX = 0.0f;
+ float maxCoordX = m_fMinCoordX + m_fMaxCoordX;
+ glUniform1fv(maPickingResources.m_MinCoordXID, 1, &minCoordX);
+ glUniform1fv(maPickingResources.m_MaxCoordXID, 1, &maxCoordX);
}
else
{
@@ -1327,7 +1338,7 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
extrude3D.zTransform};
glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
glm::mat4 flatScale = glm::scale(glm::vec3(xyScale, xyScale, xyScale));
- m_Model = m_GlobalScaleMatrix * aTranslationMatrix * extrude3D.rotation * flatScale;
+ m_Model = m_ScrollMoveMatrix * m_GlobalScaleMatrix * aTranslationMatrix * extrude3D.rotation * flatScale;
if(!mbPickingMode)
{
glm::mat3 normalMatrix(m_Model);
@@ -1338,6 +1349,7 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
else
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
+ glUniformMatrix4fv(maPickingResources.m_ModelID, 1, GL_FALSE, &m_Model[0][0]);
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
@@ -1371,7 +1383,7 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
m_Model = aTranslationMatrix * extrude3D.rotation * topTrans * topScale;
}
- m_Model = m_GlobalScaleMatrix * m_Model;
+ m_Model = m_ScrollMoveMatrix * m_GlobalScaleMatrix * m_Model;
if(!mbPickingMode)
{
glm::mat3 normalMatrix(m_Model);
@@ -1382,6 +1394,7 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
else
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
+ glUniformMatrix4fv(maPickingResources.m_ModelID, 1, GL_FALSE, &m_Model[0][0]);
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
@@ -1416,7 +1429,7 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, 0.0, -1.0));
m_Model = m_Model * reverseMatrix;
}
- m_Model = m_GlobalScaleMatrix * m_Model;
+ m_Model = m_ScrollMoveMatrix * m_GlobalScaleMatrix * m_Model;
if(!mbPickingMode)
{
glm::mat3 normalMatrix(m_Model);
@@ -1427,6 +1440,7 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
else
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
+ glUniformMatrix4fv(maPickingResources.m_ModelID, 1, GL_FALSE, &m_Model[0][0]);
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
@@ -1461,7 +1475,7 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
m_Model = aTranslationMatrix * extrude3D.rotation * topTrans * topScale * orgTrans;
}
- m_Model = m_GlobalScaleMatrix * m_Model;
+ m_Model = m_ScrollMoveMatrix * m_GlobalScaleMatrix * m_Model;
if(!mbPickingMode)
{
glm::mat3 normalMatrix(m_Model);
@@ -1472,6 +1486,7 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
else
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
+ glUniformMatrix4fv(maPickingResources.m_ModelID, 1, GL_FALSE, &m_Model[0][0]);
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
@@ -1491,7 +1506,7 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
glm::mat4 reverseMatrix = glm::translate(glm::vec3(0.0, 0.0, -1.0));
m_Model = m_Model * reverseMatrix;
}
- m_Model = m_GlobalScaleMatrix * m_Model;
+ m_Model = m_ScrollMoveMatrix * m_GlobalScaleMatrix * m_Model;
if(!mbPickingMode)
{
glm::mat3 normalMatrix(m_Model);
@@ -1502,6 +1517,7 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
else
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
+ glUniformMatrix4fv(maPickingResources.m_ModelID, 1, GL_FALSE, &m_Model[0][0]);
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
@@ -1536,6 +1552,8 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
if(mbPickingMode)
{
glUseProgram(maPickingResources.m_CommonProID);
+ glUniform1fv(maPickingResources.m_MinCoordXID, 1, &m_fMinCoordX);
+ glUniform1fv(maPickingResources.m_MaxCoordXID, 1, &m_fMaxCoordX);
}
else
{
commit b819026e1994287dd6a27848981aebca805c4e09
Author: weigao <weigao at multicorewareinc.com>
Date: Sun Aug 3 17:37:38 2014 +0800
add scroll matrix and bars can scroll
Change-Id: Ic821faaa9dc02fd965f46a77136edaf7a87cf6fe
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 856d079..8b879a5 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -274,6 +274,7 @@ private:
sal_uInt32 nUniqueId);
void SetHighLightBar(BatchBarInfo &barInfo);
void DisableHighLightBar(BatchBarInfo &barInfo);
+ void CalcScrollMoveMatrix(bool bNewScene);
private:
struct ShaderResources
@@ -458,8 +459,11 @@ private:
sal_uInt32 m_uiSelectID;
float m_fScrollSpeed;
float m_fScrollDistance;
+ float m_fCurDistance;
float m_fMinCoordX;
float m_fMaxCoordX;
+ glm::mat4 m_ScrollMoveMatrix;
+ bool m_bUndrawFlag;
};
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 74318e2..51f3a1e 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -113,6 +113,8 @@ OpenGL3DRenderer::OpenGL3DRenderer():
, m_fScrollDistance(0.0f)
, m_fMinCoordX(0.0f)
, m_fMaxCoordX(0.0f)
+ , m_fCurDistance(0.0f)
+ , m_bUndrawFlag(false)
{
m_Polygon3DInfo.lineOnly = false;
m_Polygon3DInfo.twoSidesLighting = false;
@@ -2049,6 +2051,7 @@ void OpenGL3DRenderer::ProcessUnrenderedShape(bool bNewScene)
glViewport(0, 0, m_iWidth, m_iHeight);
ClearBuffer();
CreateSceneBoxView();
+ CalcScrollMoveMatrix(bNewScene);
//Polygon
RenderPolygon3DObject();
//Shape3DExtrudeObject
@@ -2300,6 +2303,17 @@ void OpenGL3DRenderer::SetSceneEdge(float minCoordX, float maxCoordX)
m_fMaxCoordX = maxCoordX * 0.01;
}
+void OpenGL3DRenderer::CalcScrollMoveMatrix(bool bNewScene)
+{
+ if (!maResources.m_bScrollFlag)
+ return;
+ if (bNewScene)
+ m_fCurDistance = -m_fScrollSpeed;
+ m_fCurDistance += m_fCurDistance >= m_fScrollDistance ? 0.0f : m_fScrollSpeed;
+ m_ScrollMoveMatrix = glm::translate(glm::vec3(-m_fCurDistance * 0.01, 0.0f, 0.0f));
+ m_bUndrawFlag = m_fCurDistance >= m_fScrollDistance ? true : false;
+}
+
void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
{
if(bNewScene)
@@ -2323,6 +2337,13 @@ void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
glBufferSubData(GL_UNIFORM_BUFFER, m_Batch3DActualSizeLight, sizeof(MaterialParameters), &m_Batchmaterial);
CHECK_GL_ERROR();
glBindBuffer(GL_UNIFORM_BUFFER, 0);
+ if (maResources.m_bScrollFlag)
+ {
+ glUniform1fv(maResources.m_3DBatchMinCoordXID, 1, &m_fMinCoordX);
+ glUniform1fv(maResources.m_3DBatchMaxCoordXID, 1, &m_fMaxCoordX);
+ glUniform1i(maResources.m_3DBatchUndrawID, m_bUndrawFlag);
+ glUniformMatrix4fv(maResources.m_3DBatchTransMatrixID, 1, GL_FALSE, &m_ScrollMoveMatrix[0][0]);
+ }
glUniformMatrix4fv(maResources.m_3DBatchViewID, 1, GL_FALSE, &m_3DView[0][0]);
glUniformMatrix4fv(maResources.m_3DBatchProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
CHECK_GL_ERROR();
commit f7fef1c333971ff92e390834df1d0eae8ffadec2
Author: weigao <weigao at multicorewareinc.com>
Date: Sun Aug 3 14:38:06 2014 +0800
add scene limit code for scroll mode
Change-Id: Id6ce3aa55b286a300476f3609d1e1994ce2c2768
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 69003e2..3e27e98 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -563,7 +563,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
glm::vec3 aBegin;
aBegin.y = nYPos;
glm::vec3 aEnd = aBegin;
- aEnd.x = nXEnd;
+ aEnd.x = BENCH_MARK_MODE ? (mbScrollFlg ? nXEnd - BAR_SIZE_X : nXEnd) : nXEnd;
pAxis->setPosition(aBegin, aEnd);
pAxis->setLineColor(COL_BLUE);
@@ -583,7 +583,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
opengl3D::Rectangle* pRect = static_cast<opengl3D::Rectangle*>(&maShapes.back());
glm::vec3 aTopLeft;
glm::vec3 aTopRight = aTopLeft;
- aTopRight.x = nXEnd + 2 * BAR_DISTANCE_X;
+ aTopRight.x = BENCH_MARK_MODE ? (mbScrollFlg ? nXEnd - BAR_SIZE_X : nXEnd + 2 * BAR_DISTANCE_X) : (nXEnd + 2 * BAR_DISTANCE_X);
glm::vec3 aBottomRight = aTopRight;
aBottomRight.y = nYPos;
pRect->setPosition(aTopLeft, aTopRight, aBottomRight);
@@ -597,6 +597,8 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
uno::Sequence<OUString> aCats = rCatProvider.getSimpleCategories();
for (sal_Int32 i = 0; i < aCats.getLength(); ++i)
{
+ if (BENCH_MARK_MODE && mbScrollFlg && (i + 1 == aCats.getLength()))
+ break;
maCategories.push_back(aCats[i]);
if(aCats[i].isEmpty())
continue;
commit af01f14c8752c38b900f3536cd6791778dd2d209
Author: weigao <weigao at multicorewareinc.com>
Date: Sun Aug 3 14:03:48 2014 +0800
add scene edge function
Change-Id: Id64e3dc06d0d853bc7cece2337dcc927e15a49b6
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 0e6057b..69003e2 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -589,7 +589,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
pRect->setPosition(aTopLeft, aTopRight, aBottomRight);
pRect->setFillColor(COL_BLACK);
pRect->setLineColor(COL_BLUE);
-
+ if (mbScrollFlg)
+ mpRenderer->SetSceneEdge(BAR_DISTANCE_X - 0.001f, aTopRight.x - BAR_DISTANCE_X);
+ else
+ mpRenderer->SetSceneEdge(-0.001f, aTopRight.x);
// Create category texts along X-axis at the bottom.
uno::Sequence<OUString> aCats = rCatProvider.getSimpleCategories();
for (sal_Int32 i = 0; i < aCats.getLength(); ++i)
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 3698b71..856d079 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -212,6 +212,7 @@ public:
void SetScroll();
void SetScrollSpeed(float scrollSpeed);
void SetScrollDistance(float scrollDistance);
+ void SetSceneEdge(float minCoordX, float maxCoordX);
private:
void MoveModelf( const PosVecf3& trans, const PosVecf3& angle, const PosVecf3& scale);
@@ -457,6 +458,8 @@ private:
sal_uInt32 m_uiSelectID;
float m_fScrollSpeed;
float m_fScrollDistance;
+ float m_fMinCoordX;
+ float m_fMaxCoordX;
};
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index a3a9edf..74318e2 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -111,6 +111,8 @@ OpenGL3DRenderer::OpenGL3DRenderer():
, m_uiSelectID(0)
, m_fScrollSpeed(0.0f)
, m_fScrollDistance(0.0f)
+ , m_fMinCoordX(0.0f)
+ , m_fMaxCoordX(0.0f)
{
m_Polygon3DInfo.lineOnly = false;
m_Polygon3DInfo.twoSidesLighting = false;
@@ -2292,6 +2294,12 @@ void OpenGL3DRenderer::SetScrollDistance(float scrollDistance)
m_fScrollDistance = scrollDistance;
}
+void OpenGL3DRenderer::SetSceneEdge(float minCoordX, float maxCoordX)
+{
+ m_fMinCoordX = minCoordX * 0.01;
+ m_fMaxCoordX = maxCoordX * 0.01;
+}
+
void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
{
if(bNewScene)
commit 2597da2de74620162a9931860ac8b96529f94204
Author: weigao <weigao at multicorewareinc.com>
Date: Sun Aug 3 13:32:36 2014 +0800
add functions of setting the speed and distance of bars
Change-Id: Id44adf11d445b9c30467e220465528a80ee31b18
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 47706ae..0e6057b 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -654,6 +654,12 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
}
if (BENCH_MARK_MODE && (!mpRenderThread.is()))
{
+ //if scroll the bars, set the speed and distance first
+ if (mbScrollFlg)
+ {
+ mpRenderer->SetScrollSpeed((float)(BAR_SIZE_X + BAR_DISTANCE_X) / (float)miScrollRate);
+ mpRenderer->SetScrollDistance((float)(BAR_SIZE_X + BAR_DISTANCE_X));
+ }
Size aSize = mrWindow.GetSizePixel();
mrWindow.getContext().setWinSize(aSize);
mpRenderThread = rtl::Reference<RenderThread>(new RenderBenchMarkThread(this));
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index a82b1bf..3698b71 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -210,6 +210,8 @@ public:
void StartClick(sal_uInt32 &selectID);
void EndClick();
void SetScroll();
+ void SetScrollSpeed(float scrollSpeed);
+ void SetScrollDistance(float scrollDistance);
private:
void MoveModelf( const PosVecf3& trans, const PosVecf3& angle, const PosVecf3& scale);
@@ -453,6 +455,8 @@ private:
std::vector<GLuint> m_Texturelist;
bool m_bHighLighting;
sal_uInt32 m_uiSelectID;
+ float m_fScrollSpeed;
+ float m_fScrollDistance;
};
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 20b88a7..a3a9edf 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -109,6 +109,8 @@ OpenGL3DRenderer::OpenGL3DRenderer():
, m_iLightNum(0)
, m_bHighLighting(false)
, m_uiSelectID(0)
+ , m_fScrollSpeed(0.0f)
+ , m_fScrollDistance(0.0f)
{
m_Polygon3DInfo.lineOnly = false;
m_Polygon3DInfo.twoSidesLighting = false;
@@ -2281,6 +2283,15 @@ void OpenGL3DRenderer::SetScroll()
maResources.m_bScrollFlag = true;
}
+void OpenGL3DRenderer::SetScrollSpeed(float scrollSpeed)
+{
+ m_fScrollSpeed = scrollSpeed;
+}
+void OpenGL3DRenderer::SetScrollDistance(float scrollDistance)
+{
+ m_fScrollDistance = scrollDistance;
+}
+
void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
{
if(bNewScene)
commit cc20cedcbcad2fd08d48b6ce687de7e3471a7ba3
Author: weigao <weigao at multicorewareinc.com>
Date: Sat Aug 2 19:18:11 2014 +0800
add codes to compile the scroll shaders
Change-Id: Ib69dbdb012e983e194b7ada04b455c80cf0abbaa
diff --git a/chart2/Package_opengl.mk b/chart2/Package_opengl.mk
index 6e1e298..820cf35 100644
--- a/chart2/Package_opengl.mk
+++ b/chart2/Package_opengl.mk
@@ -34,6 +34,8 @@ $(eval $(call gb_Package_add_files,chart2_opengl_shader,$(LIBO_BIN_FOLDER)/openg
shape3DVertexShaderV300.glsl \
textFragmentShaderBatch.glsl \
textVertexShaderBatch.glsl \
+ shape3DFragmentShaderBatchScroll.glsl \
+ shape3DVertexShaderBatchScroll.glsl \
))
# vim: set noet sw=4 ts=4:
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 5cba517..47706ae 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -350,7 +350,7 @@ void RenderBenchMarkThread::UpdateFPS()
osl_getSystemTime(&mafpsRenderStartTime);
}
osl_getSystemTime(&mafpsRenderEndTime);
-#if 0
+#if 1
opengl3D::ScreenText tFPS(mpChart->mpRenderer.get(), *(mpChart->mpTextCache), mpChart->mTestString, 0);
opengl3D::TextCacheItem tmpTextCache = mpChart->mpTextCache->getText(mpChart->mTestString);
#else
@@ -414,8 +414,23 @@ GL3DBarChart::GL3DBarChart(
mbNeedsNewRender(true),
mbCameraInit(false),
mbRenderDie(false),
- maRenderEvent(EVENT_NONE)
+ maRenderEvent(EVENT_NONE),
+ miScrollRate(0),
+ mbScrollFlg(false)
{
+ if (BENCH_MARK_MODE)
+ {
+ char *scrollFrame = getenv("SCROLL_RATE");
+ if (scrollFrame)
+ {
+ miScrollRate = atoi(scrollFrame);
+ if (miScrollRate > 0)
+ {
+ mbScrollFlg = true;
+ mpRenderer->SetScroll();
+ }
+ }
+ }
Size aSize = mrWindow.GetSizePixel();
mpRenderer->SetSize(aSize);
mrWindow.setRenderer(this);
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 38be7bd..a4a92a4 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -138,6 +138,8 @@ private:
sal_uInt32 mSelectBarId;
Point maClickPos;
OUString mTestString;
+ sal_uInt32 miScrollRate;
+ bool mbScrollFlg;
};
}
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 9ada8f8..a82b1bf 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -209,6 +209,7 @@ public:
void ReleaseTextTexture();
void StartClick(sal_uInt32 &selectID);
void EndClick();
+ void SetScroll();
private:
void MoveModelf( const PosVecf3& trans, const PosVecf3& angle, const PosVecf3& scale);
@@ -275,6 +276,7 @@ private:
struct ShaderResources
{
bool m_b330Support;
+ bool m_bScrollFlag;
// 3DProID
GLint m_3DProID;
GLint m_3DProjectionID;
@@ -324,6 +326,10 @@ private:
GLint m_3DBatchVertexID;
GLint m_3DBatchNormalID;
GLint m_3DBatchColorID;
+ GLint m_3DBatchTransMatrixID;
+ GLint m_3DBatchMinCoordXID;
+ GLint m_3DBatchMaxCoordXID;
+ GLint m_3DBatchUndrawID;
//Batch render text
bool mbTexBatchSupport;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index e6f5e95..20b88a7 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -200,6 +200,7 @@ OpenGL3DRenderer::ShaderResources::ShaderResources()
, m_BatchTextVertexID(0)
, m_BatchTextTexCoordID(0)
, m_BatchTextTexID(0)
+ , m_bScrollFlag(false)
{
}
@@ -230,8 +231,16 @@ void OpenGL3DRenderer::ShaderResources::LoadShaders()
m_3DNormalMatrixID = glGetUniformLocation(m_3DProID, "normalMatrix");
m_3DVertexID = glGetAttribLocation(m_3DProID, "vertexPositionModelspace");
m_3DNormalID = glGetAttribLocation(m_3DProID, "vertexNormalModelspace");
-
- m_3DBatchProID = OpenGLHelper::LoadShaders("shape3DVertexShaderBatch", "shape3DFragmentShaderBatch");
+ if (m_bScrollFlag)
+ {
+ m_3DBatchProID = OpenGLHelper::LoadShaders("shape3DVertexShaderBatchScroll", "shape3DFragmentShaderBatchScroll");
+ m_3DBatchTransMatrixID = glGetUniformLocation(m_3DBatchProID, "transMatrix");
+ m_3DBatchMinCoordXID = glGetUniformLocation(m_3DBatchProID, "minCoordX");
+ m_3DBatchMaxCoordXID = glGetUniformLocation(m_3DBatchProID, "maxCoordX");
+ m_3DBatchUndrawID = glGetUniformLocation(m_3DBatchProID, "undraw");
+ }
+ else
+ m_3DBatchProID = OpenGLHelper::LoadShaders("shape3DVertexShaderBatch", "shape3DFragmentShaderBatch");
m_3DBatchProjectionID = glGetUniformLocation(m_3DBatchProID, "P");
m_3DBatchViewID = glGetUniformLocation(m_3DBatchProID, "V");
m_3DBatchModelID = glGetAttribLocation(m_3DBatchProID, "M");
@@ -2267,6 +2276,11 @@ void OpenGL3DRenderer::EndClick()
}
}
+void OpenGL3DRenderer::SetScroll()
+{
+ maResources.m_bScrollFlag = true;
+}
+
void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
{
if(bNewScene)
commit d15dcc08b83aac0d30826bbba2e4136e4501eda7
Author: weigao <weigao at multicorewareinc.com>
Date: Sat Aug 2 17:36:43 2014 +0800
add bars scroll shaders
Change-Id: I006062986534950485ffa9e280caad3e37c2f35f
diff --git a/chart2/opengl/shape3DFragmentShaderBatchScroll.glsl b/chart2/opengl/shape3DFragmentShaderBatchScroll.glsl
new file mode 100644
index 0000000..33e970f
--- /dev/null
+++ b/chart2/opengl/shape3DFragmentShaderBatchScroll.glsl
@@ -0,0 +1,111 @@
+/* -*- 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/.
+ */
+#version 330 core
+#define MAX_LIGHT_NUM 8
+
+in vec3 positionWorldspace;
+in vec3 normalCameraspace;
+in vec4 fragBarColor;
+uniform mat4 V;
+uniform int undraw;
+uniform float minCoordX;
+out vec4 actualColor;
+struct MaterialParameters
+{
+ vec4 ambient;
+ vec4 diffuse;
+ vec4 specular;
+ vec4 materialColor;
+
+ int twoSidesLighting;
+ float shininess;
+ float pad;
+ float pad1;
+};
+
+layout(std140) uniform GlobalMaterialParameters
+{
+ MaterialParameters matralParameter;
+}Material;
+
+struct LightSource
+{
+ vec4 lightColor;
+ vec4 positionWorldspace;
+ float lightPower;
+ float pad1;
+ float pad2;
+ float pad3;
+};
+
+layout(std140) uniform GlobalLights
+{
+ int lightNum;
+ vec4 ambient;
+ LightSource light[MAX_LIGHT_NUM];
+} Lights;
+
+void main()
+{
+ if ((positionWorldspace.x <= minCoordX) && (undraw == 1))
+ discard;
+ vec3 colorTotal = vec3(0.0f, 0.0f, 0.0f);
+
+ vec3 vertexPositionCameraspace = (V * vec4(positionWorldspace,1)).xyz;
+
+ vec3 MaterialDiffuseColor = fragBarColor.rgb;
+
+ vec3 normalDirectionCameraspace = normalCameraspace;
+ vec3 eyeDirectionCameraspace = normalize(vec3(0, 0, 0) - vertexPositionCameraspace);
+ float attenuation = 1.0;
+ int i = 0;
+ vec3 lightDirectionCameraspace;
+ vec3 vertexToLightSource;
+
+ vec3 lightAmbient = Lights.ambient.rgb *
+ MaterialDiffuseColor *
+ Material.matralParameter.ambient.rgb;
+
+ for (i = 0; i < Lights.lightNum; i++)
+ {
+ float LightPower = Lights.light[i].lightPower;
+ lightDirectionCameraspace = normalize((V * Lights.light[i].positionWorldspace).xyz);
+
+ float cosTheta = clamp(dot(normalDirectionCameraspace,lightDirectionCameraspace), 0,1);
+ vec3 lightDiffuse = LightPower *
+ attenuation *
+ Lights.light[i].lightColor.rgb *
+ MaterialDiffuseColor *
+ Material.matralParameter.diffuse.rgb *
+ cosTheta;
+
+ vec3 specularReflection;
+ if (dot(normalDirectionCameraspace, lightDirectionCameraspace) < 0)
+ {
+ specularReflection = vec3(0.0, 0.0, 0.0);
+ }
+ else
+ {
+ vec3 R = reflect(-lightDirectionCameraspace,normalDirectionCameraspace);
+ float cosAlpha = clamp(dot(eyeDirectionCameraspace, R), 0,1);
+ specularReflection = attenuation *
+ LightPower *
+ Lights.light[i].lightColor.rgb *
+ Material.matralParameter.specular.rgb *
+ MaterialDiffuseColor *
+ pow(max(0.0, cosAlpha), Material.matralParameter.shininess);
+ }
+ colorTotal += lightDiffuse + specularReflection;
+
+ }
+ colorTotal += lightAmbient;
+ actualColor = vec4(colorTotal, 1.0);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/opengl/shape3DVertexShader.glsl b/chart2/opengl/shape3DVertexShader.glsl
index d0bd693..7f8a6f0 100644
--- a/chart2/opengl/shape3DVertexShader.glsl
+++ b/chart2/opengl/shape3DVertexShader.glsl
@@ -20,10 +20,10 @@ uniform mat3 normalMatrix;
void main()
{
- gl_Position = P * V * M * vec4(vertexPositionModelspace,1);
-
positionWorldspace = (M * vec4(vertexPositionModelspace,1)).xyz;
+ gl_Position = P * V * vec4(positionWorldspace,1);
+
normalCameraspace = normalize(mat3(V) * normalMatrix * vertexNormalModelspace);
}
diff --git a/chart2/opengl/shape3DVertexShaderBatchScroll.glsl b/chart2/opengl/shape3DVertexShaderBatchScroll.glsl
new file mode 100644
index 0000000..87946f7
--- /dev/null
+++ b/chart2/opengl/shape3DVertexShaderBatchScroll.glsl
@@ -0,0 +1,39 @@
+/* -*- 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/.
+ */
+#version 330 core
+in vec3 vertexPositionModelspace;
+in vec3 vertexNormalModelspace;
+in mat4 M;
+in mat3 normalMatrix;
+in vec4 barColor;
+
+out vec3 positionWorldspace;
+out vec3 normalCameraspace;
+out vec4 fragBarColor;
+
+uniform mat4 P;
+uniform mat4 V;
+uniform mat4 transMatrix;
+uniform float minCoordX;
+uniform float maxCoordX;
+
+void main()
+{
+ positionWorldspace = (transMatrix * M * vec4(vertexPositionModelspace,1)).xyz;
+
+ positionWorldspace.x = clamp(positionWorldspace.x, minCoordX, maxCoordX);
+
+ gl_Position = P * V * vec4(positionWorldspace,1);
+
+ normalCameraspace = normalize(mat3(V) * normalMatrix * vertexNormalModelspace);
+
+ fragBarColor = barColor;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 22b45c0adc4693075d3958e1b2d696cb40619f3a
Author: weigao <weigao at multicorewareinc.com>
Date: Sat Aug 2 16:35:48 2014 +0800
add high light bar code for click
Change-Id: I412173d01fe6611027b45169fe4cd9be5b4cc4df
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 3631937..5cba517 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -230,6 +230,8 @@ void RenderBenchMarkThread::MoveCamera()
{
mnStep = 0;
mbExecuting = false;
+ if (mpChart->maRenderEvent == EVENT_CLICK)
+ mpChart->mpRenderer->EndClick();
mpChart->maRenderEvent = EVENT_NONE;
}
}
@@ -282,6 +284,7 @@ void RenderBenchMarkThread::MoveToBar()
maStepDirection = (maTargetDirection - mpChart->maCameraDirection)/((float)mnStepsTotal);
mpChart->maClickCond.set();
mbExecuting = true;
+ mpChart->mpRenderer->StartClick(mpChart->mSelectBarId);
}
MoveCamera();
}
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 3e731a3..9ada8f8 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -93,6 +93,7 @@ struct Extrude3DInfo
bool twoSidesLighting;
glm::vec4 extrudeColor;
glm::vec4 id;
+ sal_uInt32 orgID;
float xScale;
float yScale;
float zScale;
@@ -165,6 +166,8 @@ struct BatchBarInfo
std::vector <glm::mat4> modelMatrixList;
std::vector <glm::mat3> normalMatrixList;
std::vector <glm::vec4> colorList;
+ std::map<sal_uInt32, unsigned int> mapId2Color;
+ glm::vec4 selectBarColor;
};
class OpenGL3DRenderer
@@ -204,6 +207,8 @@ public:
void ReleaseShapes();
void ReleaseScreenTextShapes();
void ReleaseTextTexture();
+ void StartClick(sal_uInt32 &selectID);
+ void EndClick();
private:
void MoveModelf( const PosVecf3& trans, const PosVecf3& angle, const PosVecf3& scale);
@@ -263,6 +268,8 @@ private:
glm::vec3 vTopLeft,glm::vec3 vTopRight,
glm::vec3 vBottomRight, glm::vec3 vBottomLeft,
sal_uInt32 nUniqueId);
+ void SetHighLightBar(BatchBarInfo &barInfo);
+ void DisableHighLightBar(BatchBarInfo &barInfo);
private:
struct ShaderResources
@@ -436,7 +443,10 @@ private:
glm::vec4 m_LightColor[MAX_LIGHT_NUM];
glm::vec4 m_PositionWorldspace[MAX_LIGHT_NUM];
float m_fLightPower[MAX_LIGHT_NUM];
+ //for 3.0 end
std::vector<GLuint> m_Texturelist;
+ bool m_bHighLighting;
+ sal_uInt32 m_uiSelectID;
};
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 693a8f9..e6f5e95 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -107,6 +107,8 @@ OpenGL3DRenderer::OpenGL3DRenderer():
, m_Batch3DUBOBuffer(0)
, m_Batch3DActualSizeLight(0)
, m_iLightNum(0)
+ , m_bHighLighting(false)
+ , m_uiSelectID(0)
{
m_Polygon3DInfo.lineOnly = false;
m_Polygon3DInfo.twoSidesLighting = false;
@@ -1140,6 +1142,7 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nColor, sal_uInt32 specular, const glm::mat4& modelMatrix, sal_uInt32 nUniqueId)
{
m_Extrude3DInfo.id = getColorAsVector(nUniqueId);
+ m_Extrude3DInfo.orgID = nUniqueId;
glm::vec4 tranform = modelMatrix * glm::vec4(0.0, 0.0, 0.0, 1.0);
glm::vec4 DirX = modelMatrix * glm::vec4(1.0, 0.0, 0.0, 0.0);
glm::vec4 DirY = modelMatrix * glm::vec4(0.0, 1.0, 0.0, 0.0);
@@ -2107,6 +2110,7 @@ void OpenGL3DRenderer::ReleaseBatchBarInfo()
m_BarSurface[i].modelMatrixList.clear();
m_BarSurface[i].normalMatrixList.clear();
m_BarSurface[i].colorList.clear();
+ m_BarSurface[i].mapId2Color.clear();
}
}
@@ -2145,6 +2149,7 @@ void OpenGL3DRenderer::GetBatchMiddleInfo(const Extrude3DInfo &extrude3D)
m_BarSurface[MIDDLE_SURFACE].modelMatrixList.push_back(m_Model);
m_BarSurface[MIDDLE_SURFACE].normalMatrixList.push_back(normalInverseTranspos);
m_BarSurface[MIDDLE_SURFACE].colorList.push_back(extrude3D.material.materialColor);
+ m_BarSurface[MIDDLE_SURFACE].mapId2Color[extrude3D.orgID] = m_BarSurface[MIDDLE_SURFACE].colorList.size() - 1;
}
void OpenGL3DRenderer::GetBatchTopAndFlatInfo(const Extrude3DInfo &extrude3D)
@@ -2181,6 +2186,7 @@ void OpenGL3DRenderer::GetBatchTopAndFlatInfo(const Extrude3DInfo &extrude3D)
m_BarSurface[TOP_SURFACE].modelMatrixList.push_back(m_Model);
m_BarSurface[TOP_SURFACE].normalMatrixList.push_back(normalInverseTranspos);
m_BarSurface[TOP_SURFACE].colorList.push_back(extrude3D.material.materialColor);
+ m_BarSurface[TOP_SURFACE].mapId2Color[extrude3D.orgID] = m_BarSurface[TOP_SURFACE].colorList.size() - 1;
glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
glm::mat4 flatScale = glm::scale(glm::vec3(xyScale, xyScale, xyScale));
@@ -2192,6 +2198,7 @@ void OpenGL3DRenderer::GetBatchTopAndFlatInfo(const Extrude3DInfo &extrude3D)
m_BarSurface[FLAT_BOTTOM_SURFACE].modelMatrixList.push_back(m_Model);
m_BarSurface[FLAT_BOTTOM_SURFACE].normalMatrixList.push_back(normalInverseTranspos);
m_BarSurface[FLAT_BOTTOM_SURFACE].colorList.push_back(extrude3D.material.materialColor);
+ m_BarSurface[FLAT_BOTTOM_SURFACE].mapId2Color[extrude3D.orgID] = m_BarSurface[FLAT_BOTTOM_SURFACE].colorList.size() - 1;
}
void OpenGL3DRenderer::GetBatchBarsInfo()
@@ -2215,14 +2222,64 @@ void OpenGL3DRenderer::GetBatchBarsInfo()
m_BarSurface[0].modelMatrixList.push_back(m_Model);
m_BarSurface[0].normalMatrixList.push_back(normalInverseTranspos);
m_BarSurface[0].colorList.push_back(extrude3DInfo.material.materialColor);
+ m_BarSurface[0].mapId2Color[extrude3DInfo.orgID] = m_BarSurface[0].colorList.size() - 1;
}
}
}
+void OpenGL3DRenderer::SetHighLightBar(BatchBarInfo &barInfo)
+{
+ std::map<sal_uInt32, unsigned int> ::iterator it = barInfo.mapId2Color.find(m_uiSelectID);
+ if (it != barInfo.mapId2Color.end())
+ {
+ unsigned int idx = it->second;
+ barInfo.selectBarColor = barInfo.colorList[idx];
+ barInfo.colorList[idx] = glm::vec4(1.0, 1.0, 1.0, 1.0);
+ }
+}
+
+void OpenGL3DRenderer::DisableHighLightBar(BatchBarInfo &barInfo)
+{
+ std::map<sal_uInt32, unsigned int> ::iterator it = barInfo.mapId2Color.find(m_uiSelectID);
+ if (it != barInfo.mapId2Color.end())
+ {
+ unsigned int idx = it->second;
+ barInfo.colorList[idx] = barInfo.selectBarColor;
+ }
+}
+
+void OpenGL3DRenderer::StartClick(sal_uInt32 &selectID)
+{
+ m_bHighLighting = true;
+ m_uiSelectID = selectID;
+ for (unsigned int i = 0; i < 3; i++)
+ {
+ SetHighLightBar(m_BarSurface[i]);
+ }
+}
+
+void OpenGL3DRenderer::EndClick()
+{
+ m_bHighLighting = false;
+ for (unsigned int i = 0; i < 3; i++)
+ {
+ DisableHighLightBar(m_BarSurface[i]);
+ }
+}
+
void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
{
if(bNewScene)
+ {
GetBatchBarsInfo();
+ if (m_bHighLighting)
+ {
+ for (unsigned int i = 0; i < 3; i++)
+ {
+ SetHighLightBar(m_BarSurface[i]);
+ }
+ }
+ }
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
commit 7dcc31ed61bad3d3d649667f2fb890c878ac69c3
Author: weigao <weigao at multicorewareinc.com>
Date: Sat Aug 2 13:11:28 2014 +0800
pick bar path should use the IDs in pick resource
Change-Id: Ifd20a7a9ecb85ffc080204f4f3e9f200b07b9a9c
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 19a513e..693a8f9 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -930,7 +930,7 @@ void OpenGL3DRenderer::RenderPolygon3D(const Polygon3DInfo& polygon)
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
- glUniform4fv(maResources.m_2DColorID, 1, &polygon.id[0]);
+ glUniform4fv(maPickingResources.m_2DColorID, 1, &polygon.id[0]);
}
GLint maVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID;
// 1rst attribute buffer : vertices
@@ -1321,7 +1321,7 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
- glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
+ glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
glDrawElements(GL_TRIANGLES, extrude3D.size[surIndex], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[surIndex]));
@@ -1365,7 +1365,7 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
- glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
+ glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
glDrawElements(GL_TRIANGLES, extrude3D.size[BOTTOM_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[BOTTOM_SURFACE]));
}
@@ -1410,7 +1410,7 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
- glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
+ glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
glDrawElements(GL_TRIANGLES, extrude3D.size[MIDDLE_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[MIDDLE_SURFACE]));
}
@@ -1455,7 +1455,7 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
- glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
+ glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
glDrawElements(GL_TRIANGLES, extrude3D.size[TOP_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[TOP_SURFACE]));
}
@@ -1485,7 +1485,7 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
{
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
- glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
+ glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3D.id[0]);
}
glDrawArrays(GL_TRIANGLES, 0, 36);
}
@@ -1549,7 +1549,7 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
if(mbPickingMode)
- glUniform4fv(maResources.m_2DColorID, 1, &extrude3DInfo.id[0]);
+ glUniform4fv(maPickingResources.m_2DColorID, 1, &extrude3DInfo.id[0]);
// 1st attribute buffer : vertices
GLint aVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID;
commit 00f097b627e7106dca2813371a524e260a4baddd
Author: weigao <weigao at multicorewareinc.com>
Date: Fri Aug 1 21:05:08 2014 +0800
test patch of creating bitmap in render thread
Change-Id: Ic0879dba3ad6a80359931edb65f0b72c1cc4d597
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 2924eeb..3631937 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -171,6 +171,7 @@ void RenderAnimationThread::execute()
*/
renderFrame();
}
+ mpChart->mpRenderer->ReleaseScreenTextShapes();
}
class RenderBenchMarkThread : public RenderThread
@@ -178,8 +179,13 @@ class RenderBenchMarkThread : public RenderThread
public:
RenderBenchMarkThread(GL3DBarChart * pChart):
RenderThread(pChart),
- mbExecuting(false)
+ mbExecuting(false),
+ miFrameCount(0)
{
+ osl_getSystemTime(&mafpsRenderStartTime);
+ osl_getSystemTime(&mafpsRenderEndTime);
+ osl_getSystemTime(&maScreenTextUpdateStartTime);
+ osl_getSystemTime(&maScreenTextUpdateEndTime);
}
protected:
virtual void execute() SAL_OVERRIDE;
@@ -190,6 +196,9 @@ private:
void MoveToDefault();
void MoveToCorner();
void ProcessScroll();
+ void UpdateScreenText();
+ void UpdateFPS();
+ int calcTimeInterval(TimeValue &startTime, TimeValue &endTime);
private:
glm::vec3 maStartPos;
glm::vec3 maEndPos;
@@ -199,6 +208,12 @@ private:
glm::vec3 maStepDirection;
size_t mnStep;
size_t mnStepsTotal;
+ TimeValue mafpsRenderStartTime;
+ TimeValue mafpsRenderEndTime;
+ TimeValue maScreenTextUpdateStartTime;
+ TimeValue maScreenTextUpdateEndTime;
+ int miFrameCount;
+ OUString maFPS;
};
void RenderBenchMarkThread::MoveCamera()
@@ -309,6 +324,53 @@ void RenderBenchMarkThread::ProcessMouseEvent()
}
}
+int RenderBenchMarkThread::calcTimeInterval(TimeValue &startTime, TimeValue &endTime)
+{
+ TimeValue aTime;
+ aTime.Seconds = endTime.Seconds - startTime.Seconds - 1;
+ aTime.Nanosec = 1000000000 + endTime.Nanosec - startTime.Nanosec;
+ aTime.Seconds += aTime.Nanosec / 1000000000;
+ aTime.Nanosec %= 1000000000;
+ return aTime.Seconds * 1000+aTime.Nanosec / 1000000;
+}
+
+void RenderBenchMarkThread::UpdateFPS()
+{
+ int aDeltaMs = calcTimeInterval(mafpsRenderStartTime, mafpsRenderEndTime);
+ if(aDeltaMs >= 500)
+ {
+ osl_getSystemTime(&mafpsRenderEndTime);
+ aDeltaMs = calcTimeInterval(mafpsRenderStartTime, mafpsRenderEndTime);
+ int iFPS = miFrameCount * 1000 / aDeltaMs;
+ maFPS = OUString("Render FPS: ") + OUString::number(iFPS);
+ miFrameCount = 0;
+ osl_getSystemTime(&mafpsRenderStartTime);
+ }
+ osl_getSystemTime(&mafpsRenderEndTime);
+#if 0
+ opengl3D::ScreenText tFPS(mpChart->mpRenderer.get(), *(mpChart->mpTextCache), mpChart->mTestString, 0);
+ opengl3D::TextCacheItem tmpTextCache = mpChart->mpTextCache->getText(mpChart->mTestString);
+#else
+ opengl3D::ScreenText tFPS(mpChart->mpRenderer.get(), *(mpChart->mpTextCache), maFPS, 0);
+ opengl3D::TextCacheItem tmpTextCache = mpChart->mpTextCache->getText(maFPS);
+#endif
+ float rectWidth = (float)tmpTextCache.maSize.Width() / (float)tmpTextCache.maSize.Height() * 0.05;
+ tFPS.setPosition(glm::vec2(-0.99f, 0.99f), glm::vec2(-0.99f + rectWidth, 0.89f));
+ tFPS.render();
+}
+
+void RenderBenchMarkThread::UpdateScreenText()
+{
+ int aDeltaMs = calcTimeInterval(maScreenTextUpdateStartTime, maScreenTextUpdateEndTime);
+ if (aDeltaMs >= 20)
+ {
+ mpChart->mpRenderer->ReleaseScreenTextShapes();
+ UpdateFPS();
+ osl_getSystemTime(&maScreenTextUpdateStartTime);
+ }
+ osl_getSystemTime(&maScreenTextUpdateEndTime);
+}
+
void RenderBenchMarkThread::execute()
{
while (true)
@@ -317,6 +379,7 @@ void RenderBenchMarkThread::execute()
osl::MutexGuard aGuard(mpChart->maMutex);
if (mpChart->mbRenderDie)
break;
+ UpdateScreenText();
ProcessMouseEvent();
renderFrame();
}
@@ -328,6 +391,7 @@ void RenderBenchMarkThread::execute()
nTV.Nanosec = 1000000;
osl_waitThread(&nTV);
#endif
+ miFrameCount++;
}
}
@@ -534,6 +598,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
maShapes.push_back(new opengl3D::Text(mpRenderer.get(), *mpTextCache,
aCats[i], nId));
+ mTestString = aCats[i];
nId += ID_STEP;
p = static_cast<opengl3D::Text*>(&maShapes.back());
aTopLeft.x = nXPos + TEXT_HEIGHT + 0.5 * BAR_SIZE_X;
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 1969290..38be7bd 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -137,6 +137,7 @@ private:
RenderEventType maRenderEvent;
sal_uInt32 mSelectBarId;
Point maClickPos;
+ OUString mTestString;
};
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 1243853..19a513e 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -2115,7 +2115,7 @@ void OpenGL3DRenderer::ReleaseShapes()
ReleasePolygonShapes();
ReleaseExtrude3DShapes();
ReleaseTextShapes();
- ReleaseScreenTextShapes();
+ //ReleaseScreenTextShapes();
ReleaseBatchBarInfo();
ReleaseTextShapesBatch();
}
commit f9d2de854b737f98d4d74a2885965c7df2d52da8
Author: weigao <weigao at multicorewareinc.com>
Date: Fri Aug 1 14:39:57 2014 +0800
texture should be released in render thread
Change-Id: I4ae03163a2bf9aff831e6fd3a8c1c91fa3eba675
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 8a10e70..2924eeb 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -99,6 +99,7 @@ void RenderThread::renderFrame()
mpChart->mpRenderer->SetSize(aSize);
if(mpChart->mbNeedsNewRender)
{
+ mpChart->mpRenderer->ReleaseTextTexture();
for(boost::ptr_vector<opengl3D::Renderable3DObject>::iterator itr = mpChart->maShapes.begin(),
itrEnd = mpChart->maShapes.end(); itr != itrEnd; ++itr)
{
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index ffad3e0..3e731a3 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -203,6 +203,7 @@ public:
void ReleaseShapes();
void ReleaseScreenTextShapes();
+ void ReleaseTextTexture();
private:
void MoveModelf( const PosVecf3& trans, const PosVecf3& angle, const PosVecf3& scale);
@@ -435,6 +436,7 @@ private:
glm::vec4 m_LightColor[MAX_LIGHT_NUM];
glm::vec4 m_PositionWorldspace[MAX_LIGHT_NUM];
float m_fLightPower[MAX_LIGHT_NUM];
+ std::vector<GLuint> m_Texturelist;
};
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index f1769c1..1243853 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -1707,6 +1707,7 @@ void OpenGL3DRenderer::CreateTextTextureSingle(const boost::shared_array<sal_uIn
glBindTexture(GL_TEXTURE_2D, 0);
CHECK_GL_ERROR();
m_TextInfoList.push_back(aTextInfo);
+ m_Texturelist.push_back(aTextInfo.texture);
}
@@ -1796,12 +1797,16 @@ void OpenGL3DRenderer::CreateTextTexture(const boost::shared_array<sal_uInt8> &b
void OpenGL3DRenderer::ReleaseTextShapes()
{
- for (size_t i = 0; i < m_TextInfoList.size(); i++)
+ m_TextInfoList.clear();
+}
+
+void OpenGL3DRenderer::ReleaseTextTexture()
+{
+ for (size_t i = 0; i < m_Texturelist.size(); i++)
{
- TextInfo &textInfo = m_TextInfoList[i];
- glDeleteTextures(1, &textInfo.texture);
+ glDeleteTextures(1, &m_Texturelist[i]);
}
- m_TextInfoList.clear();
+ m_Texturelist.clear();
}
void OpenGL3DRenderer::ReleaseScreenTextShapes()
commit b757ac0b20ed2c6d34c0fee9ba638887fd8e7743
Author: weigao <weigao at multicorewareinc.com>
Date: Fri Aug 1 14:36:15 2014 +0800
fix the light power in 3.0 version
Change-Id: I0a8e86f513386b7ce0eebb38d3257c275e86085c
diff --git a/chart2/opengl/shape3DFragmentShaderV300.glsl b/chart2/opengl/shape3DFragmentShaderV300.glsl
index 31a32e0..fee81d4 100644
--- a/chart2/opengl/shape3DFragmentShaderV300.glsl
+++ b/chart2/opengl/shape3DFragmentShaderV300.glsl
@@ -41,8 +41,7 @@ void main()
vec3 totalAmbient = lightAmbient.rgb *
MaterialDiffuseColor *
- materialAmbient.rgb
- * 5.0;
+ materialAmbient.rgb;
if ((twoSidesLighting == 1) && (!gl_FrontFacing))
{
commit 5d50115229c21cbd865ba9d54e7c4626b7e1dcc3
Author: weigao <weigao at multicorewareinc.com>
Date: Sat Jul 26 19:29:44 2014 +0800
add drag animation for benchmark
Change-Id: Ie9146272dd88b7b51edace7023048629874c360f
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 6e66ca7..8a10e70 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -180,7 +180,6 @@ public:
mbExecuting(false)
{
}
-
protected:
virtual void execute() SAL_OVERRIDE;
private:
@@ -194,7 +193,6 @@ private:
glm::vec3 maStartPos;
glm::vec3 maEndPos;
sal_Int32 mnSteps;
-
bool mbExecuting;
glm::vec3 maStep;
glm::vec3 maStepDirection;
commit 483cfd6ff77cdcdfe75085835ee51686e9d5d5aa
Author: weigao <weigao at multicorewareinc.com>
Date: Fri Jul 25 03:59:11 2014 +0200
add click event animation for benchmark
Change-Id: I1e5a879fa315a775a77d3fddc6de1d02963b5f7d
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 80b40fe..6e66ca7 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -193,6 +193,8 @@ private:
private:
glm::vec3 maStartPos;
glm::vec3 maEndPos;
+ sal_Int32 mnSteps;
+
bool mbExecuting;
glm::vec3 maStep;
glm::vec3 maStepDirection;
@@ -288,7 +290,6 @@ void RenderBenchMarkThread::ProcessScroll()
mpChart->maRenderEvent = EVENT_NONE;
}
-
void RenderBenchMarkThread::ProcessMouseEvent()
{
if (mpChart->maRenderEvent == EVENT_CLICK)
More information about the Libreoffice-commits
mailing list