[Libreoffice-commits] core.git: chart2/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Sun May 11 20:27:22 PDT 2014
chart2/source/view/inc/3DChartObjects.hxx | 2 -
chart2/source/view/inc/GL3DRenderer.hxx | 6 +--
chart2/source/view/main/3DChartObjects.cxx | 8 ++--
chart2/source/view/main/GL3DRenderer.cxx | 52 +++++++++++------------------
4 files changed, 28 insertions(+), 40 deletions(-)
New commits:
commit a0842e53b999cee3cddbd209b43e313874760f0b
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon May 12 05:22:52 2014 +0200
more sal_Int32 to sal_uInt32 and simplification
Change-Id: I061fdc9e0743715d1b358a16d72486cfb62a35aa
diff --git a/chart2/source/view/inc/3DChartObjects.hxx b/chart2/source/view/inc/3DChartObjects.hxx
index 8571fd8..f8138aa 100644
--- a/chart2/source/view/inc/3DChartObjects.hxx
+++ b/chart2/source/view/inc/3DChartObjects.hxx
@@ -37,7 +37,7 @@ protected:
class Bar : public Renderable3DObject
{
public:
- Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 nColor, sal_uInt32 nId);
+ Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 nColor, sal_uInt32 nId);
virtual void render() SAL_OVERRIDE;
private:
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 6d30b94..9d5f441 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -148,8 +148,8 @@ public:
~OpenGL3DRenderer();
void init();
- void Set3DSenceInfo(sal_Int32 color = 255, bool twoSidesLighting = true);
- void SetLightInfo(bool lightOn, sal_Int32 color, const glm::vec4& direction);
+ void Set3DSenceInfo(sal_uInt32 color = 255, bool twoSidesLighting = true);
+ void SetLightInfo(bool lightOn, sal_uInt32 color, const glm::vec4& direction);
void AddShapePolygon3DObject(sal_uInt32 color, bool lineOnly, sal_uInt32 lineColor,
long fillStyle, sal_uInt32 specular);
void EndAddShapePolygon3DObject();
@@ -157,7 +157,7 @@ public:
void EndAddPolygon3DObjectNormalPoint();
void AddPolygon3DObjectPoint(float x, float y, float z);
void EndAddPolygon3DObjectPoint();
- void AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color, sal_Int32 specular, glm::mat4 modelMatrix);
+ void AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 color, sal_uInt32 specular, glm::mat4 modelMatrix);
void EndAddShape3DExtrudeObject();
double GetTime();
void SetFPS(float fps);
diff --git a/chart2/source/view/main/3DChartObjects.cxx b/chart2/source/view/main/3DChartObjects.cxx
index f5c3596..e23c38b 100644
--- a/chart2/source/view/main/3DChartObjects.cxx
+++ b/chart2/source/view/main/3DChartObjects.cxx
@@ -28,7 +28,7 @@ void Renderable3DObject::render()
(void) mnUniqueId;
}
-Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aColor, sal_uInt32 nId)
+Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 aColor, sal_uInt32 nId)
: Renderable3DObject(pRenderer, nId)
, mbRoundedCorners(true)
, maPos(rPosition)
@@ -39,7 +39,7 @@ Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_Int32 aCol
void Bar::render()
{
- mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, (sal_Int32)maColor.GetColor(), 0xFFFFFF, maPos);
+ mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, maColor.GetColor(), 0xFFFFFF, maPos);
mpRenderer->EndAddShape3DExtrudeObject();
}
@@ -50,7 +50,7 @@ Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
void Line::render()
{
- mpRenderer->AddShapePolygon3DObject(0, true, (sal_Int32)maLineColor.GetColor(), 0, 0);
+ mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0);
mpRenderer->AddPolygon3DObjectPoint(maPosBegin.x, maPosBegin.y, maPosBegin.z);
mpRenderer->AddPolygon3DObjectPoint(maPosEnd.x, maPosEnd.y, maPosEnd.z);
mpRenderer->EndAddShapePolygon3DObject();
@@ -126,7 +126,7 @@ void Rectangle::render()
mpRenderer->EndAddPolygon3DObjectPoint();
mpRenderer->EndAddPolygon3DObjectNormalPoint();
//we should render the edge if the edge color is different from the fill color
- if ((sal_Int32)maColor.GetColor() != (sal_Int32)maLineColor.GetColor())
+ if (maColor.GetColor() != maLineColor.GetColor())
{
mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0xFFFFFF);
mpRenderer->AddPolygon3DObjectPoint(maBottomRight.x, maBottomRight.y, maBottomRight.z);
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6ace0eb..69e961b 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -59,6 +59,15 @@ GLfloat texCoords[] = {
0.0f, 1.0f
};
+glm::vec4 getColorAsVector(sal_uInt32 nColor)
+{
+ return glm::vec4(((nColor & 0x00FF0000) >> 16) / 255.0f,
+ ((nColor & 0x0000FF00) >> 8) / 255.0f,
+ (nColor & 0x000000FF) / 255.0f,
+ (0xFF - (nColor & 0xFF000000)/255.0));
+
+}
+
}
OpenGL3DRenderer::OpenGL3DRenderer():
@@ -802,20 +811,17 @@ void OpenGL3DRenderer::RenderPolygon3DObject()
return;
}
-void OpenGL3DRenderer::Set3DSenceInfo(sal_Int32 color, bool twoSidesLighting)
+void OpenGL3DRenderer::Set3DSenceInfo(sal_uInt32 nColor, bool twoSidesLighting)
{
m_Polygon3DInfo.material.twoSidesLighting = twoSidesLighting;
- m_LightsInfo.ambient = glm::vec4((float)(((color) & 0x00FF0000) >> 16) / 255.0f,
- (float)(((color) & 0x0000FF00) >> 8) / 255.0f,
- (float)(((color) & 0x000000FF)) / 255.0f,
- 1.0);
+ m_LightsInfo.ambient = getColorAsVector(nColor);
m_LightsInfo.lightNum = 0;
SetLightInfo(true, 0xFFFFFF, glm::vec4(1.0, 1.0, 1.0, 0.0));
}
-void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_Int32 color, const glm::vec4& direction)
+void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm::vec4& direction)
{
if (m_LightsInfo.lightNum > MAX_LIGHT_NUM)
{
@@ -824,22 +830,16 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_Int32 color, const glm::ve
if (lightOn)
{
- m_LightsInfo.light[m_LightsInfo.lightNum].lightColor = glm::vec4((float)(((color) & 0x00FF0000) >> 16) / 255.0f,
- (float)(((color) & 0x0000FF00) >> 8) / 255.0f,
- (float)(((color) & 0x000000FF)) / 255.0f,
- 1.0);
+ 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.lightNum++;
}
}
-void OpenGL3DRenderer::AddShapePolygon3DObject(sal_uInt32 color, bool lineOnly, sal_uInt32 lineColor,long fillStyle, sal_uInt32 specular)
+void OpenGL3DRenderer::AddShapePolygon3DObject(sal_uInt32 nColor, bool lineOnly, sal_uInt32 nLineColor,long fillStyle, sal_uInt32 specular)
{
- m_Polygon3DInfo.polygonColor = glm::vec4((float)(((color) & 0x00FF0000) >> 16) / 255.0f,
- (float)(((color) & 0x0000FF00) >> 8) / 255.0f,
- (float)(((color) & 0x000000FF)) / 255.0f,
- 1.0);
+ m_Polygon3DInfo.polygonColor = getColorAsVector(nColor);
m_Polygon3DInfo.material.materialColor = m_Polygon3DInfo.polygonColor;//material color seems to be the same for all parts, so we use the polygon color
//line or Polygon
m_Polygon3DInfo.lineOnly = lineOnly;
@@ -848,10 +848,7 @@ void OpenGL3DRenderer::AddShapePolygon3DObject(sal_uInt32 color, bool lineOnly,
// if line only, use line color
if (m_Polygon3DInfo.lineOnly)
{
- m_Polygon3DInfo.polygonColor = glm::vec4((float)(((lineColor) & 0x00FF0000) >> 16) / 255.0f,
- (float)(((lineColor) & 0x0000FF00) >> 8) / 255.0f,
- (float)(((lineColor) & 0x000000FF)) / 255.0f,
- 1.0);
+ m_Polygon3DInfo.polygonColor = getColorAsVector(nLineColor);
}
//fillStyle
@@ -859,10 +856,7 @@ void OpenGL3DRenderer::AddShapePolygon3DObject(sal_uInt32 color, bool lineOnly,
//material specular;
- m_Polygon3DInfo.material.specular = glm::vec4((float)(((specular) & 0x00FF0000) >> 16) / 255.0f,
- (float)(((specular) & 0x0000FF00) >> 8) / 255.0f,
- (float)(((specular) & 0x000000FF)) / 255.0f,
- 1.0);
+ m_Polygon3DInfo.material.specular = getColorAsVector(specular);
m_Polygon3DInfo.material.diffuse = glm::vec4(1.0, 1.0, 1.0, 1.0);
@@ -919,7 +913,7 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
m_Polygon3DInfo.vertices = NULL;
}
-void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 color,sal_Int32 specular, glm::mat4 modelMatrix)
+void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nColor, sal_uInt32 specular, glm::mat4 modelMatrix)
{
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);
@@ -933,17 +927,11 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_Int32 col
m_Extrude3DInfo.rotation = transformMatrixInverse * modelMatrix * scaleMatrixInverse;
//color
- m_Extrude3DInfo.extrudeColor = glm::vec4((float)(((color) & 0x00FF0000) >> 16) / 255.0f,
- (float)(((color) & 0x0000FF00) >> 8) / 255.0f,
- (float)(((color) & 0x000000FF)) / 255.0f,
- 1.0);
+ m_Extrude3DInfo.extrudeColor = getColorAsVector(nColor);
m_Extrude3DInfo.material.materialColor = m_Extrude3DInfo.extrudeColor;//material color seems to be the same for all parts, so we use the polygon color
//material specular;
- m_Extrude3DInfo.material.specular = glm::vec4((float)(((specular) & 0x00FF0000) >> 16) / 255.0f,
- (float)(((specular) & 0x0000FF00) >> 8) / 255.0f,
- (float)(((specular) & 0x000000FF)) / 255.0f,
- 1.0);
+ m_Extrude3DInfo.material.specular = getColorAsVector(specular);
m_Extrude3DInfo.material.diffuse = glm::vec4(1.0, 1.0, 1.0, 1.0);
More information about the Libreoffice-commits
mailing list