[Libreoffice-commits] core.git: 2 commits - chart2/opengl chart2/source
weigao
weigao at multicorewareinc.com
Wed Jul 23 13:31:51 PDT 2014
chart2/opengl/shape3DFragmentShaderBatch.glsl | 3
chart2/source/view/charttypes/GL3DBarChart.cxx | 79 ++++++++++++++++++++++++-
chart2/source/view/inc/GL3DBarChart.hxx | 2
chart2/source/view/main/GL3DRenderer.cxx | 18 ++++-
4 files changed, 94 insertions(+), 8 deletions(-)
New commits:
commit a2282e290f3b1378021787c91d10207bf9389f9c
Author: weigao <weigao at multicorewareinc.com>
Date: Sat Jul 19 20:14:52 2014 +0800
modify the light to make the sence looks better
Change-Id: If6badae178ffc9be2192fcfdf41fc7d062dc32c4
diff --git a/chart2/opengl/shape3DFragmentShaderBatch.glsl b/chart2/opengl/shape3DFragmentShaderBatch.glsl
index b7bdc7e..be24dbf 100644
--- a/chart2/opengl/shape3DFragmentShaderBatch.glsl
+++ b/chart2/opengl/shape3DFragmentShaderBatch.glsl
@@ -66,8 +66,7 @@ void main()
vec3 lightAmbient = Lights.ambient.rgb *
MaterialDiffuseColor *
- Material.matralParameter.ambient.rgb
- * 5.0;
+ Material.matralParameter.ambient.rgb;
for (i = 0; i < Lights.lightNum; i++)
{
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index d692e7b..f1769c1 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -31,8 +31,8 @@ namespace opengl3D {
namespace {
-const int CORNER_DIVION_Y = 10;
-const int CORNER_DIVION_Z = 10;
+const int CORNER_DIVION_Y = 20;
+const int CORNER_DIVION_Z = 20;
int static checkGLError(const char *file, int line)
{
@@ -855,6 +855,10 @@ void OpenGL3DRenderer::RenderPolygon3D(const Polygon3DInfo& polygon)
size_t verticesNum = polygon.verticesList.size();
size_t normalsNum = polygon.normalsList.size();
//check whether the number of vertices and normals are equal
+ if (m_CameraInfo.cameraPos.z >= 0.0f)
+ glPolygonOffset(1.0, 1.0);
+ else
+ glPolygonOffset(-1.0, -1.0);
if (verticesNum != normalsNum)
{
return ;
@@ -1023,6 +1027,9 @@ void OpenGL3DRenderer::Set3DSenceInfo(sal_uInt32 nColor, bool twoSidesLighting)
m_iLightNum = 0;
m_Ambient = getColorAsVector(nColor);;
}
+ SetLightInfo(true, 0xFFFFFF, glm::vec4(-1.0, -1.0, 1.0, 0.0));
+ SetLightInfo(true, 0xFFFFFF, glm::vec4(-1.0, 1.0, 1.0, 0.0));
+ SetLightInfo(true, 0xFFFFFF, glm::vec4(1.0, -1.0, 1.0, 0.0));
SetLightInfo(true, 0xFFFFFF, glm::vec4(1.0, 1.0, 1.0, 0.0));
}
@@ -1038,7 +1045,7 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm::
}
m_LightsInfo.light[m_LightsInfo.lightNum].lightColor = getColorAsVector(nColor);
m_LightsInfo.light[m_LightsInfo.lightNum].positionWorldspace = direction;
- m_LightsInfo.light[m_LightsInfo.lightNum].lightPower = 1.0;
+ m_LightsInfo.light[m_LightsInfo.lightNum].lightPower = 0.3f;
m_LightsInfo.lightNum++;
}
else
@@ -1049,7 +1056,7 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm::
}
m_LightColor[m_iLightNum] = getColorAsVector(nColor);
m_PositionWorldspace[m_iLightNum] = direction;
- m_fLightPower[m_iLightNum] = 1.0;
+ m_fLightPower[m_iLightNum] = 0.3f;
m_iLightNum++;
}
}
@@ -2214,6 +2221,7 @@ void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
+ glPolygonOffset(0.0f, 0.0f);
glUseProgram(maResources.m_3DBatchProID);
UpdateBatch3DUniformBlock();
glBindBuffer(GL_UNIFORM_BUFFER, m_Batch3DUBOBuffer);
@@ -2268,7 +2276,7 @@ void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
if (m_Extrude3DInfo.rounded)
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 2; i++)
{
glBindBuffer(GL_ARRAY_BUFFER, m_BatchModelMatrixBuf);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::mat4) * m_BarSurface[i].modelMatrixList.size(), &m_BarSurface[i].modelMatrixList[0][0], GL_DYNAMIC_DRAW);
commit cd6029f2373c67ab39313fd6314610becb5095c5
Author: weigao <weigao at multicorewareinc.com>
Date: Sat Jul 19 20:12:37 2014 +0800
add benchmark render thread
Change-Id: I0770db8e2cb5ecb1ef7d3706082196a8fd8f1ede
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 62e5ec9..733d46f 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -19,6 +19,13 @@
#include <ExplicitCategoriesProvider.hxx>
#include <DataSeriesHelper.hxx>
+#include <osl/time.h>
+#ifdef WNT
+#include <windows.h>
+#endif
+
+#define BENCH_MARK_MODE 1
+
using namespace com::sun::star;
namespace chart {
@@ -125,6 +132,57 @@ void RenderAnimationThread::execute()
}
}
+class RenderBenchMarkThread : public RenderThread
+{
+public:
+ RenderBenchMarkThread(GL3DBarChart * pChart):
+ RenderThread(pChart)
+ {
+ }
+ void SetAnimationCamera(glm::vec3 startPos, glm::vec3 endPos, sal_Int32 steps);
+protected:
+ virtual void execute() SAL_OVERRIDE;
+private:
+ void ProcessMouseEvent();
+private:
+ glm::vec3 maStartPos;
+ glm::vec3 maEndPos;
+ sal_Int32 mnSteps;
+};
+
+void RenderBenchMarkThread::SetAnimationCamera(glm::vec3 startPos, glm::vec3 endPos, sal_Int32 steps)
+{
+ maStartPos = startPos;
+ maEndPos = endPos;
+ mnSteps = steps;
+}
+
+void RenderBenchMarkThread::ProcessMouseEvent()
+{
+}
+
+void RenderBenchMarkThread::execute()
+{
+ while (true)
+ {
+ {
+ osl::MutexGuard aGuard(mpChart->maMutex);
+ if (mpChart->mbRenderDie)
+ break;
+ ProcessMouseEvent();
+ renderFrame();
+ }
+ #ifdef WNT
+ Sleep(1);
+ #else
+ TimeValue nTV;
+ nTV.Seconds = 0;
+ nTV.Nanosec = 1000000;
+ osl_waitThread(&nTV);
+ #endif
+ }
+}
+
GL3DBarChart::GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType,
OpenGLWindow& rWindow) :
@@ -140,7 +198,8 @@ GL3DBarChart::GL3DBarChart(
mnCornerId(0),
mbBlockUserInput(false),
mbNeedsNewRender(true),
- mbCameraInit(false)
+ mbCameraInit(false),
+ mbRenderDie(false)
{
Size aSize = mrWindow.GetSizePixel();
mpRenderer->SetSize(aSize);
@@ -159,6 +218,11 @@ GL3DBarChart::BarInformation::BarInformation(const glm::vec3& rPos, float nVal,
GL3DBarChart::~GL3DBarChart()
{
+ if (BENCH_MARK_MODE)
+ {
+ osl::MutexGuard aGuard(maMutex);
+ mbRenderDie = true;
+ }
if(mpRenderThread.is())
mpRenderThread->join();
osl::MutexGuard aGuard(maMutex);
@@ -396,11 +460,21 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
mpCamera->setPosition(maCameraPosition);
mpCamera->setDirection(maCameraDirection);
}
+ if (BENCH_MARK_MODE && (!mpRenderThread.is()))
+ {
+ Size aSize = mrWindow.GetSizePixel();
+ mrWindow.getContext().setWinSize(aSize);
+ mpRenderThread = rtl::Reference<RenderThread>(new RenderBenchMarkThread(this));
+ mrWindow.getContext().resetCurrent();
+ mpRenderThread->launch();
+ }
mbNeedsNewRender = true;
}
void GL3DBarChart::update()
{
+ if (BENCH_MARK_MODE)
+ return;
if(mpRenderThread.is())
mpRenderThread->join();
Size aSize = mrWindow.GetSizePixel();
@@ -408,6 +482,7 @@ void GL3DBarChart::update()
mpRenderThread = rtl::Reference<RenderThread>(new RenderOneFrameThread(this));
mrWindow.getContext().resetCurrent();
mpRenderThread->launch();
+
}
namespace {
@@ -515,6 +590,8 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
void GL3DBarChart::render()
{
+ if (BENCH_MARK_MODE)
+ return;
osl::MutexGuard aGuard(maMutex);
update();
}
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index 2517627..fcc7908 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -46,6 +46,7 @@ class GL3DBarChart : public GL3DPlotterBase, public IRenderer
friend class RenderThread;
friend class RenderOneFrameThread;
friend class RenderAnimationThread;
+ friend class RenderBenchMarkThread;
public:
GL3DBarChart(
const css::uno::Reference<css::chart2::XChartType>& xChartType,
@@ -118,6 +119,7 @@ private:
osl::Mutex maMutex;
rtl::Reference<RenderThread> mpRenderThread;
+ bool mbRenderDie;
};
}
More information about the Libreoffice-commits
mailing list