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

Julien Nabet serval2412 at yahoo.fr
Sun Nov 26 11:39:32 UTC 2017


 chart2/source/view/main/OpenGLRender.cxx |   32 ++++++++++---------------------
 chart2/source/view/main/OpenGLRender.hxx |   14 ++++++-------
 2 files changed, 18 insertions(+), 28 deletions(-)

New commits:
commit d8c0051c6c0400aae6e0a440e83c2c29979347f7
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Nov 26 11:28:49 2017 +0100

    Replace lists by vectors in chart2
    
    Change-Id: I634363fb881776a089d4bcca366c8caebcdde117
    Reviewed-on: https://gerrit.libreoffice.org/45283
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 2d8d816d6a47..788d5e9fc45f 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -191,15 +191,13 @@ int OpenGLRender::RenderLine2FBO()
 {
     CHECK_GL_ERROR();
     glLineWidth(m_fLineWidth);
-    size_t listNum = m_Line2DShapePointList.size();
     PosVecf3 const trans = {0.0f, 0.0f, 0.0f};
     PosVecf3 const angle = {0.0f, 0.0f, 0.0f};
     PosVecf3 const scale = {1.0f, 1.0f, 1.0f};
     MoveModelf(trans, angle, scale);
     m_MVP = m_Projection * m_View * m_Model;
-    for (size_t i = 0; i < listNum; i++)
+    for (auto const& pointList : m_Line2DShapePointList)
     {
-        PointList &pointList = m_Line2DShapePointList.front();
         //fill vertex buffer
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
         CHECK_GL_ERROR();
@@ -230,8 +228,8 @@ int OpenGLRender::RenderLine2FBO()
         glUseProgram(0);
         glDisableVertexAttribArray(m_2DVertexID);
         CHECK_GL_ERROR();
-        m_Line2DShapePointList.pop_front();
     }
+    m_Line2DShapePointList.clear();
     CHECK_GL_ERROR();
     CHECK_GL_FRAME_BUFFER_STATUS();
     m_fZStep += Z_STEP;
@@ -416,11 +414,9 @@ int OpenGLRender::RenderBubble2FBO()
 {
     CHECK_GL_ERROR();
     glm::vec4 edgeColor = glm::vec4(0.0, 0.0, 0.0, 1.0);
-    size_t listNum = m_Bubble2DShapePointList.size();
-    for (size_t i = 0; i < listNum; i++)
+    for (auto const& pointList : m_Bubble2DShapePointList)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
-        Bubble2DPointList &pointList = m_Bubble2DShapePointList.front();
         PosVecf3 const trans = {pointList.x, pointList.y, m_fZStep};
         PosVecf3 const angle = {0.0f, 0.0f, 0.0f};
         PosVecf3 const scale = {pointList.xScale / 2, pointList.yScale / 2 , 1.0f};
@@ -476,9 +472,9 @@ int OpenGLRender::RenderBubble2FBO()
         glDisableVertexAttribArray(m_2DVertexID);
         glUseProgram(0);
         glBindBuffer(GL_ARRAY_BUFFER, 0);
-        m_Bubble2DShapePointList.pop_front();
         glLineWidth(m_fLineWidth);
     }
+    m_Bubble2DShapePointList.clear();
     //if use MSAA, we should copy the data to the FBO texture
     GLenum fbResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
     if( fbResult != GL_FRAMEBUFFER_COMPLETE )
@@ -514,11 +510,9 @@ int OpenGLRender::RectangleShapePoint(float x, float y, float directionX, float
 
 int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
 {
-    size_t listNum = m_RectangleShapePointList.size();
-    for (size_t i = 0; i < listNum; i++)
+    for (auto const& pointList : m_RectangleShapePointList)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
-        RectanglePointList &pointList = m_RectangleShapePointList.front();
         {
             PosVecf3 const trans = {0, 0, 0};
             PosVecf3 const angle = {0.0f, 0.0f, 0.0f};
@@ -614,8 +608,8 @@ int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
         glDisableVertexAttribArray(m_BackgroundColorID);
         glUseProgram(0);
         glBindBuffer(GL_ARRAY_BUFFER, 0);
-        m_RectangleShapePointList.pop_front();
     }
+    m_RectangleShapePointList.clear();
     CHECK_GL_ERROR();
 
     m_fZStep += Z_STEP;
@@ -693,17 +687,15 @@ int OpenGLRender::CreateTextTexture(const boost::shared_array<sal_uInt8> &rPixel
     CHECK_GL_ERROR();
     glBindTexture(GL_TEXTURE_2D, 0);
     CHECK_GL_ERROR();
-    m_TextInfoList.push_back(aTextInfo);
+    m_TextInfoVector.push_back(aTextInfo);
     return 0;
 }
 
 int OpenGLRender::RenderTextShape()
 {
     CHECK_GL_ERROR();
-    size_t listNum = m_TextInfoList.size();
-    for (size_t i = 0; i < listNum; i++)
+    for (auto const& textInfo : m_TextInfoVector)
     {
-        TextInfo &textInfo = m_TextInfoList.front();
         PosVecf3 const trans = { textInfo.nDx, textInfo.nDy, 0};
         PosVecf3 const angle = {0.0f, 0.0f, float(textInfo.rotation)};
         PosVecf3 const scale = {1.0, 1.0, 1.0f};
@@ -757,8 +749,8 @@ int OpenGLRender::RenderTextShape()
         glUseProgram(0);
         glDeleteTextures(1, &textInfo.texture);
         CHECK_GL_ERROR();
-        m_TextInfoList.pop_front();
     }
+    m_TextInfoVector.clear();
     CHECK_GL_ERROR();
     m_fZStep += Z_STEP;
     return 0;
@@ -812,15 +804,13 @@ int OpenGLRender::RenderArea2DShape()
     CHECK_GL_ERROR();
 
     glDisable(GL_MULTISAMPLE);
-    size_t listNum = m_Area2DShapePointList.size();
     PosVecf3 const trans = {0.0f, 0.0f, 0.0f};
     PosVecf3 const angle = {0.0f, 0.0f, 0.0f};
     PosVecf3 const scale = {1.0f, 1.0f, 1.0f};
     MoveModelf(trans, angle, scale);
     m_MVP = m_Projection * m_View * m_Model;
-    for (size_t i = 0; i < listNum; ++i)
+    for (auto const& pointList : m_Area2DShapePointList)
     {
-        PointList &pointList = m_Area2DShapePointList.front();
         bool bIsCCW = checkCCW(pointList); // is it counter clockwise (CCW) or clockwise (CW)
         if(!bIsCCW)
             glFrontFace(GL_CW);
@@ -851,8 +841,8 @@ int OpenGLRender::RenderArea2DShape()
         glUseProgram(0);
         if(!bIsCCW)
             glFrontFace(GL_CCW);
-        m_Area2DShapePointList.pop_front();
     }
+    m_Area2DShapePointList.clear();
     glEnable(GL_MULTISAMPLE);
     m_fZStep += Z_STEP;
 
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index ae33560efb0f..025b83297a09 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -19,7 +19,7 @@
 #include <boost/shared_array.hpp>
 
 // Include GLM
-#include <list>
+#include <vector>
 #include <map>
 #include <glm/glm.hpp>
 #include <glm/gtx/transform.hpp>
@@ -152,22 +152,22 @@ private:
 
     float m_fLineWidth;
 
-    std::list <PointList> m_Line2DShapePointList;
+    std::vector<PointList> m_Line2DShapePointList;
 
     glm::vec4 m_2DColor;
 
     std::vector<GLfloat> m_Bubble2DCircle;
 
-    std::list <Bubble2DPointList> m_Bubble2DShapePointList;
+    std::vector<Bubble2DPointList> m_Bubble2DShapePointList;
     GLint m_CommonProID;
     GLint m_2DVertexID;
     GLint m_2DColorID;
 
     float m_fZStep;
 
-    std::list <RectanglePointList> m_RectangleShapePointList;
+    std::vector<RectanglePointList> m_RectangleShapePointList;
     // add for text
-    std::list <TextInfo> m_TextInfoList;
+    std::vector<TextInfo> m_TextInfoVector;
     GLint m_TextProID;
     GLint m_TextMatrixID;
     GLint m_TextVertexID;
@@ -176,7 +176,7 @@ private:
     GLint m_TextTexID;
 
     PointList m_Area2DPointList;
-    std::list <PointList> m_Area2DShapePointList;
+    std::vector<PointList> m_Area2DShapePointList;
 
     GLint m_BackgroundProID;
     GLint m_BackgroundMatrixID;
@@ -185,7 +185,7 @@ private:
 
     float m_BackgroundColor[16];
 
-    std::list <PointList> m_PieSegment2DShapePointList;
+    std::vector<PointList> m_PieSegment2DShapePointList;
 
     GLuint m_SymbolProID;
     GLuint m_SymbolVertexID;


More information about the Libreoffice-commits mailing list