[Libreoffice-commits] core.git: chart2/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jun 8 08:55:11 UTC 2017


 chart2/source/view/charttypes/GL3DBarChart.cxx |   11 ++++++-----
 chart2/source/view/main/GL3DRenderer.cxx       |    9 +++++----
 chart2/source/view/main/OpenGLRender.cxx       |    5 +++--
 3 files changed, 14 insertions(+), 11 deletions(-)

New commits:
commit 22cf68296387eb613e3ee3b888ef1bfa0a6dd1e0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Jun 8 09:59:15 2017 +0200

    clang-tidy performance-type-promotion-in-math-fn
    
    Change-Id: I71405f1dbf0a1524e4e367ae5e05edaf6a8e98b8
    Reviewed-on: https://gerrit.libreoffice.org/38559
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 8c547b99e90c..8a91a62ef1f9 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -11,6 +11,7 @@
 
 #include <epoxy/gl.h>
 
+#include <cmath>
 #include <glm/glm.hpp>
 #include <glm/gtx/transform.hpp>
 
@@ -821,7 +822,7 @@ void GL3DBarChart::create3DShapes(const std::vector<std::unique_ptr<VDataSeries>
     mnMaxY = nSeriesIndex * (BAR_SIZE_Y + BAR_DISTANCE_Y) + 40;
     if (!mbCameraInit)
     {
-        mnDistance = sqrt(mnMaxX * mnMaxX + mnMaxY * mnMaxY + DEFAULT_CAMERA_HEIGHT * DEFAULT_CAMERA_HEIGHT);
+        mnDistance = std::sqrt(mnMaxX * mnMaxX + mnMaxY * mnMaxY + DEFAULT_CAMERA_HEIGHT * DEFAULT_CAMERA_HEIGHT);
         maDefaultCameraDirection = glm::vec3(mnMaxX * 0.4, mnMaxY * 0.35, 0);
         maDefaultCameraPosition = glm::vec3(maDefaultCameraDirection.x, maDefaultCameraDirection.y - mnDistance, DEFAULT_CAMERA_HEIGHT * 2);
         mnCornerId = 0;
@@ -1063,22 +1064,22 @@ glm::vec3 GL3DBarChart::getCornerPosition(sal_Int8 nId)
     {
         case 0:
         {
-            return glm::vec3(mnMaxX / 2 - mnDistance * sin(pi / 4), mnMaxY / 2 - mnDistance * cos(pi / 4), DEFAULT_CAMERA_HEIGHT * 2);
+            return glm::vec3(mnMaxX / 2 - mnDistance * std::sin(pi / 4), mnMaxY / 2 - mnDistance * std::cos(pi / 4), DEFAULT_CAMERA_HEIGHT * 2);
         }
         break;
         case 1:
         {
-            return glm::vec3(mnMaxX / 2 + mnDistance * sin(pi / 4), mnMaxY / 2 - mnDistance * cos(pi / 4), DEFAULT_CAMERA_HEIGHT * 2);
+            return glm::vec3(mnMaxX / 2 + mnDistance * std::sin(pi / 4), mnMaxY / 2 - mnDistance * std::cos(pi / 4), DEFAULT_CAMERA_HEIGHT * 2);
         }
         break;
         case 2:
         {
-            return glm::vec3(mnMaxX / 2 + mnDistance * sin(pi / 4), mnMaxY / 2 + mnDistance * cos(pi / 4), DEFAULT_CAMERA_HEIGHT * 2);
+            return glm::vec3(mnMaxX / 2 + mnDistance * std::sin(pi / 4), mnMaxY / 2 + mnDistance * std::cos(pi / 4), DEFAULT_CAMERA_HEIGHT * 2);
         }
         break;
         case 3:
         {
-            return glm::vec3(mnMaxX / 2 - mnDistance * sin(pi / 4), mnMaxY / 2 + mnDistance * cos(pi / 4), DEFAULT_CAMERA_HEIGHT * 2);
+            return glm::vec3(mnMaxX / 2 - mnDistance * std::sin(pi / 4), mnMaxY / 2 + mnDistance * std::cos(pi / 4), DEFAULT_CAMERA_HEIGHT * 2);
         }
         break;
         default:
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 6e6e2fcaa601..8c92ccd9a9b2 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -11,6 +11,7 @@
 
 #include "GL3DRenderer.hxx"
 
+#include <cmath>
 #include <vcl/opengl/OpenGLHelper.hxx>
 #include <vcl/font.hxx>
 #include <vcl/virdev.hxx>
@@ -606,8 +607,8 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
         {
             fNextAngleY = 360.0f;
         }
-        float fSineY = sin(fCurAngleY/180.0f*PI), fCosY = cos(fCurAngleY/180.0f*PI);
-        float fNextSineY = sin(fNextAngleY/180.0f*PI), fNextCosY = cos(fNextAngleY/180.0f*PI);
+        float fSineY = std::sin(fCurAngleY/180.0f*PI), fCosY = std::cos(fCurAngleY/180.0f*PI);
+        float fNextSineY = std::sin(fNextAngleY/180.0f*PI), fNextCosY = std::cos(fNextAngleY/180.0f*PI);
         glm::vec3 vDirY(fCosY, 0.0f, -fSineY), vNextDirY(fNextCosY, 0.0f, -fNextSineY);
         float fCurAngleZ = 0.0f;
         int iStepsZ = 1;
@@ -633,8 +634,8 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
             int yIndex = 0;
             float fNextAngleZ = fCurAngleZ+fAddAngleZ;
 
-            float fSineZ = sin(fCurAngleZ/180.0f*PI), fCosZ = cos(fCurAngleZ/180.0f*PI);
-            float fNextSineZ = sin(fNextAngleZ/180.0f*PI), fNextCosZ = cos(fNextAngleZ/180.0f*PI);
+            float fSineZ = std::sin(fCurAngleZ/180.0f*PI), fCosZ = std::cos(fCurAngleZ/180.0f*PI);
+            float fNextSineZ = std::sin(fNextAngleZ/180.0f*PI), fNextCosZ = std::cos(fNextAngleZ/180.0f*PI);
 
             if ((fCurAngleZ < 90.0f) && (fNextAngleZ >= 90.0f))
             {
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 27085513680f..c3a2c489efb5 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -8,6 +8,7 @@
  */
 
 #include <epoxy/gl.h>
+#include <cmath>
 #include <vector>
 #include "OpenGLRender.hxx"
 #include <vcl/graph.hxx>
@@ -387,8 +388,8 @@ int OpenGLRender::Create2DCircle(int detail)
     m_Bubble2DCircle.push_back(0);
     for(angle = 2.0f * GL_PI; angle > -(2.0f * GL_PI / detail); angle -= (2.0f * GL_PI / detail))
     {
-        m_Bubble2DCircle.push_back(sin(angle));
-        m_Bubble2DCircle.push_back(cos(angle));
+        m_Bubble2DCircle.push_back(std::sin(angle));
+        m_Bubble2DCircle.push_back(std::cos(angle));
     }
     return 0;
 }


More information about the Libreoffice-commits mailing list