[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart2' - chart2/source

weigao weigao at multicorewareinc.com
Sun May 25 03:18:43 PDT 2014


 chart2/source/view/inc/GL3DRenderer.hxx  |   15 ++++--
 chart2/source/view/main/GL3DRenderer.cxx |   73 ++++++++++++++++++-------------
 2 files changed, 54 insertions(+), 34 deletions(-)

New commits:
commit 33921d26aabba22f24b2c49e9fedcea35ada81c6
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 b5a5c68..e0214a8 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -83,9 +83,9 @@ struct Polygon3DInfo
     Vertices3D *vertices;
     UVs3D *uvs;
     Normals3D *normals;
-    std::list <Vertices3D *> verticesList;
-    std::list <UVs3D *> uvsList;
-    std::list <Normals3D *> normalsList;
+    std::vector <Vertices3D *> verticesList;
+    std::vector <UVs3D *> uvsList;
+    std::vector <Normals3D *> normalsList;
     MaterialParameters material;
 };
 
@@ -209,6 +209,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
@@ -297,7 +302,7 @@ private:
 
     Polygon3DInfo m_Polygon3DInfo;
 
-    std::list <Polygon3DInfo> m_Polygon3DInfoList;
+    std::vector <Polygon3DInfo> m_Polygon3DInfoList;
 
     glm::mat4 m_D3DTrasform;
 
@@ -332,7 +337,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 a658536..ecab037 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -685,9 +685,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};
@@ -695,10 +693,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
@@ -725,8 +723,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);
 }
@@ -759,8 +755,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};
@@ -818,10 +814,6 @@ 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);
 }
@@ -839,13 +831,26 @@ struct DeletePointer
 
 }
 
+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
@@ -855,13 +860,6 @@ void OpenGL3DRenderer::RenderPolygon3DObject()
         {
             RenderPolygon3D(polygon);
         }
-        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.pop_front();
     }
     glDepthMask(GL_TRUE);
     return;
@@ -1281,6 +1279,10 @@ void OpenGL3DRenderer::RenderExtrudeSurface(const Extrude3DInfo& extrude3D)
         RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
     }
 }
+void OpenGL3DRenderer::ReleaseExtrude3DShapes()
+{
+    m_Extrude3DList.clear();
+}
 
 void OpenGL3DRenderer::RenderExtrude3DObject()
 {
@@ -1358,7 +1360,6 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
         if(!mbPickingMode)
             glDisableVertexAttribArray(maResources.m_3DNormalID);
     }
-    m_Extrude3DList.clear();
     glUseProgram(0);
     glBindBuffer(GL_ARRAY_BUFFER, 0);
     glDisable(GL_CULL_FACE);
@@ -1408,13 +1409,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};
@@ -1466,9 +1476,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();
 }
@@ -1541,6 +1548,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);
@@ -1576,6 +1584,13 @@ sal_uInt32 OpenGL3DRenderer::GetPixelColorFromPoint(long nX, long nY)
     return aColor.GetColor();
 }
 
+void OpenGL3DRenderer::ReleaseShapes()
+{
+    ReleasePolygonShapes();
+    ReleaseExtrude3DShapes();
+    ReleaseTextShapes();
+}
+
 }
 
 }


More information about the Libreoffice-commits mailing list