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

weigao weigao at multicorewareinc.com
Sun May 25 03:20:29 PDT 2014


 chart2/source/view/inc/GL3DRenderer.hxx  |   13 +++-
 chart2/source/view/main/GL3DRenderer.cxx |   93 ++++++++++++++++++++-----------
 2 files changed, 70 insertions(+), 36 deletions(-)

New commits:
commit 74042bc601fdf3faf25541fb4959d061bbf6abd1
Author: weigao <weigao at multicorewareinc.com>
Date:   Sun May 25 15:19:47 2014 +0800

    add delete shape function
    
    Change-Id: Ided3902a45c6bb7bf79827849aeca3caaaa40f83

diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 0fcf437..cf95f30 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -83,8 +83,8 @@ struct Polygon3DInfo
     Vertices3D *vertices;
     UVs3D *uvs;
     Normals3D *normals;
-    std::list <Vertices3D *> verticesList;
-    std::list <Normals3D *> normalsList;
+    std::vector <Vertices3D *> verticesList;
+    std::vector <Normals3D *> normalsList;
     MaterialParameters material;
 };
 
@@ -208,6 +208,11 @@ private:
                                int iSubDivZ, float width, float height, float depth);
     void CreateSceneBoxView();
     void RenderTexture(GLuint TexID);
+
+    void ReleaseShapes();
+    void ReleasePolygonShapes();
+    void ReleaseExtrude3DShapes();
+    void ReleaseTextShapes();
 private:
 
     struct ShaderResources
@@ -319,7 +324,7 @@ private:
 
     Polygon3DInfo m_Polygon3DInfo;
 
-    std::list <Polygon3DInfo> m_Polygon3DInfoList;
+    std::vector <Polygon3DInfo> m_Polygon3DInfoList;
 
     glm::mat4 m_D3DTrasform;
 
@@ -354,7 +359,7 @@ private:
     GLuint m_BoundBox;
     GLuint m_BoundBoxNormal;
      // add for text
-    std::list <TextInfo> m_TextInfoList;
+    std::vector <TextInfo> m_TextInfoList;
     GLuint m_TextTexCoordBuf;
 
     int m_uiSelectFrameCounter;
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index bb4d239..7d4db19 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -686,9 +686,7 @@ double OpenGL3DRenderer::GetTime()
 
 void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
 {
-    size_t listNum = polygon.verticesList.size();
     glUseProgram(maResources.m_CommonProID);
-
     PosVecf3 trans = {0.0f, 0, 0.0};
     PosVecf3 angle = {0.0f, 0.0f, 0.0f};
     PosVecf3 scale = {1.0f, 1.0f, m_fHeightWeight};
@@ -696,10 +694,10 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
 
     m_3DMVP = m_3DProjection * m_3DView * m_Model;
 
-    for (size_t i = 0; i < listNum; i++)
+    for (size_t i = 0; i < polygon.verticesList.size(); i++)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
-        Vertices3D *pointList = polygon.verticesList.front();
+        Vertices3D *pointList = polygon.verticesList[i];
         //if line only, using the common shader to render
 
         //fill vertex buffer
@@ -726,8 +724,6 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
         glDrawArrays(GL_LINE_STRIP, 0, pointList->size());
         glDisableVertexAttribArray(maResources.m_2DVertexID);
         glBindBuffer(GL_ARRAY_BUFFER, 0);
-        delete pointList;
-        polygon.verticesList.pop_front();
     }
     glUseProgram(0);
 }
@@ -760,8 +756,8 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
     for (size_t i = 0; i < verticesNum; i++)
     {
         //move the circle to the pos, and scale using the xScale and Y scale
-        Vertices3D *pointList = polygon.verticesList.front();
-        Normals3D *normalList = polygon.normalsList.front();
+        Vertices3D *pointList = polygon.verticesList[i];
+        Normals3D *normalList = polygon.normalsList[i];
         PosVecf3 trans = {0.0f, 0.0f, 0.0};
         PosVecf3 angle = {0.0f, 0.0f, 0.0f};
         PosVecf3 scale = {1.0f, 1.0f, m_fHeightWeight};
@@ -819,21 +815,44 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
             glDisableVertexAttribArray(maResources.m_3DNormalID);
 
         glBindBuffer(GL_ARRAY_BUFFER, 0);
-        delete pointList;
-        delete normalList;
-        polygon.verticesList.pop_front();
-        polygon.normalsList.pop_front();
     }
     glUseProgram(0);
 }
 
+namespace {
+
+template< typename T >
+struct DeletePointer
+{
+    void operator()(T* p)
+    {
+        delete p;
+    }
+};
+
+}
+
+void OpenGL3DRenderer::ReleasePolygonShapes()
+{
+    for (size_t i = 0; i < m_Polygon3DInfoList.size(); i++)
+    {
+        Polygon3DInfo &polygon = m_Polygon3DInfoList[i];
+        std::for_each(polygon.verticesList.begin(),
+                polygon.verticesList.end(), DeletePointer<Vertices3D>());
+        std::for_each(polygon.normalsList.begin(),
+                polygon.normalsList.end(), DeletePointer<Normals3D>());
+        delete polygon.vertices;
+        delete polygon.normals;
+    }
+    m_Polygon3DInfoList.clear();
+}
+
 void OpenGL3DRenderer::RenderPolygon3DObject()
 {
     glDepthMask(GL_FALSE);
-    size_t polygonNum = m_Polygon3DInfoList.size();
-    for (size_t i = 0; i < polygonNum; i++)
+    for (size_t i = 0; i < m_Polygon3DInfoList.size(); i++)
     {
-        Polygon3DInfo &polygon = m_Polygon3DInfoList.front();
+        Polygon3DInfo &polygon = m_Polygon3DInfoList[i];
         if (polygon.lineOnly || (!polygon.fillStyle))
         {
             //just use the common shader is ok for lines
@@ -843,13 +862,6 @@ void OpenGL3DRenderer::RenderPolygon3DObject()
         {
             RenderPolygon3D(polygon);
         }
-        std::for_each(polygon.verticesList.begin(),
-                      polygon.verticesList.end(), boost::checked_deleter<Vertices3D>());
-        std::for_each(polygon.normalsList.begin(),
-                      polygon.normalsList.end(), boost::checked_deleter<Normals3D>());
-        delete polygon.vertices;
-        delete polygon.normals;
-        m_Polygon3DInfoList.pop_front();
     }
     glDepthMask(GL_TRUE);
     return;
@@ -1269,6 +1281,10 @@ void OpenGL3DRenderer::RenderExtrudeSurface(const Extrude3DInfo& extrude3D)
         RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
     }
 }
+void OpenGL3DRenderer::ReleaseExtrude3DShapes()
+{
+    m_Extrude3DList.clear();
+}
 
 void OpenGL3DRenderer::RenderExtrude3DObject()
 {
@@ -1346,7 +1362,6 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         if(!mbPickingMode)
             glDisableVertexAttribArray(maResources.m_3DNormalID);
     }
-    m_Extrude3DList.clear();
     glUseProgram(0);
     glBindBuffer(GL_ARRAY_BUFFER, 0);
     glDisable(GL_CULL_FACE);
@@ -1396,13 +1411,22 @@ void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vT
     m_TextInfoList.push_back(aTextInfo);
 }
 
+void OpenGL3DRenderer::ReleaseTextShapes()
+{
+    for (size_t i = 0; i < m_TextInfoList.size(); i++)
+    {
+        TextInfo &textInfo = m_TextInfoList[i];
+        glDeleteTextures(1, &textInfo.texture);
+    }
+    m_TextInfoList.clear();
+}
+
 void OpenGL3DRenderer::RenderTextShape()
 {
     CHECK_GL_ERROR();
-    size_t listNum = m_TextInfoList.size();
-    for (size_t i = 0; i < listNum; i++)
+    for (size_t i = 0; i < m_TextInfoList.size(); i++)
     {
-        TextInfo &textInfo = m_TextInfoList.front();
+        TextInfo &textInfo = m_TextInfoList[i];
         PosVecf3 trans = {0, 0, 0};
         PosVecf3 angle = {0.0f, 0.0f, 0.0f};
         PosVecf3 scale = {1.0, 1.0, 1.0f};
@@ -1454,9 +1478,6 @@ void OpenGL3DRenderer::RenderTextShape()
         CHECK_GL_ERROR();
         glBindTexture(GL_TEXTURE_2D, 0);
         glUseProgram(0);
-        glDeleteTextures(1, &textInfo.texture);
-        CHECK_GL_ERROR();
-        m_TextInfoList.pop_front();
     }
     CHECK_GL_ERROR();
 }
@@ -1529,6 +1550,7 @@ void OpenGL3DRenderer::ProcessUnrenderedShape()
     RenderExtrude3DObject();
     //render text
     RenderTextShape();
+    ReleaseShapes();
 #if DEBUG_FBO
     OUString aFileName = OUString("D://shaderout_") + OUString::number(m_iWidth) + "_" + OUString::number(m_iHeight) + ".png";
     OpenGLHelper::renderToFile(m_iWidth, m_iHeight, aFileName);
@@ -1564,6 +1586,13 @@ sal_uInt32 OpenGL3DRenderer::GetPixelColorFromPoint(long nX, long nY)
     return aColor.GetColor();
 }
 
+void OpenGL3DRenderer::ReleaseShapes()
+{
+    ReleasePolygonShapes();
+    ReleaseExtrude3DShapes();
+    ReleaseTextShapes();
+}
+
 }
 
 }
commit 32b3f7876b3cc87e42b44e595aaefb532f361424
Author: weigao <weigao at multicorewareinc.com>
Date:   Sun May 25 13:47:44 2014 +0800

    fix the bar model generate
    
    Change-Id: I8df87b27dd93f0e11198998869b97754ded3bca1

diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index b49aa4c..bb4d239 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -330,7 +330,7 @@ void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int
     {
         return;
     }
-    float topThreshold = height - 2 * fRadius;
+    float topThreshold = depth - 2 * fRadius;
     float bottomThreshold = fRadius;
 
     std::vector<glm::vec3> vertices;
@@ -990,7 +990,8 @@ void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nC
     m_Extrude3DInfo.rounded = roundedCorner;
     if (m_Extrude3DInfo.rounded && (m_RoundBarMesh.iMeshSizes == 0))
     {
-        CreateActualRoundedCube(0.1f, 30, 30, 1.0f, m_Extrude3DInfo.yScale / m_Extrude3DInfo.xScale, 1.2f);
+        float radius = 0.2f;
+        CreateActualRoundedCube(radius, 30, 30, 1.0f, m_Extrude3DInfo.yScale / m_Extrude3DInfo.xScale, 1 + 2 * radius);
         AddVertexData(m_CubeVertexBuf);
         AddNormalData(m_CubeNormalBuf);
         AddIndexData(m_CubeElementBuf);
@@ -1185,7 +1186,6 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
     PosVecf3 trans = {extrude3D.xTransform,
                       extrude3D.yTransform,
                       extrude3D.zTransform};
-
     if (actualZTrans < 0.0f)
     {
         // the height of rounded corner is higher than the cube than use the org scale matrix


More information about the Libreoffice-commits mailing list