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

Markus Mohrhard markus.mohrhard at collabora.co.uk
Sun Jan 19 07:02:42 PST 2014


 chart2/source/view/main/DummyXShape.cxx  |   20 +++++-
 chart2/source/view/main/OpenGLRender.cxx |   95 +++++++++++++++++++++----------
 chart2/source/view/main/OpenGLRender.hxx |    5 -
 3 files changed, 85 insertions(+), 35 deletions(-)

New commits:
commit 38726b6d5fed0e2b714b14068f84824de2fe61ad
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun Jan 19 15:50:21 2014 +0100

    more work on correct rectangle handling
    
    We now render black borders around rectangles and correctly handle
    rectangles with just fill or just borders.
    
    Still to be done:
    
    * correct border style handling
    * correct border color handling (maybe switch GLSL program)
    * gradient handling
    * still using GL_QUADS
    * border line widths
    * transparence
    
    Change-Id: I3912ccf3dc5df686142a5d1758ee9b97fe435d7b

diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 103c58d..3c7c551 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -578,14 +578,14 @@ void DummyRectangle::render()
         return;
     }
 
+    bool bFill = true;
     itr = maProperties.find("FillStyle");
     if(itr != maProperties.end())
     {
         drawing::FillStyle eStyle = itr->second.get<drawing::FillStyle>();
         if(eStyle == drawing::FillStyle_NONE)
         {
-            SAL_WARN("chart2.opengl", "no fill style");
-            return;
+            bFill = false;
         }
     }
 
@@ -594,7 +594,19 @@ void DummyRectangle::render()
     {
         uno::Any co =  itr->second;
         sal_Int32 nColorValue = co.get<sal_Int32>();
-        pChart->m_GLRender.SetColor(nColorValue);
+        pChart->m_GLRender.SetBackGroundColor(nColorValue, nColorValue);
+    }
+
+    bool bBorder = true;
+    itr =  maProperties.find(UNO_NAME_LINESTYLE);
+    if (itr != maProperties.end())
+    {
+        uno::Any cow = itr->second;
+        drawing::LineStyle nStyle = cow.get<drawing::LineStyle>();
+        if (drawing::LineStyle_NONE == nStyle)
+        {
+            bBorder = false;
+        }
     }
 
     //TODO: moggi: correct handling of gradients
@@ -609,7 +621,7 @@ void DummyRectangle::render()
         }
     }
     pChart->m_GLRender.RectangleShapePoint(maPosition.X, maPosition.Y, maSize.Width, maSize.Height);
-    pChart->m_GLRender.RenderRectangleShape();
+    pChart->m_GLRender.RenderRectangleShape(bBorder, bFill);
 }
 
 DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 4366425..41728713 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1348,13 +1348,13 @@ int OpenGLRender::RectangleShapePoint(float x, float y, float directionX, float
     aRectangle.points[1] = actualY;
     aRectangle.points[2] = m_fZStep;
     aRectangle.points[3] = actualX + actualSizeX;
-    aRectangle.points[4] = actualX;
+    aRectangle.points[4] = actualY;
     aRectangle.points[5] = m_fZStep;
     aRectangle.points[6] = actualX + actualSizeX;
-    aRectangle.points[7] = actualX + actualSizeY;
+    aRectangle.points[7] = actualY + actualSizeY;
     aRectangle.points[8] = m_fZStep;
     aRectangle.points[9] = actualX;
-    aRectangle.points[10] = actualX + actualSizeY;
+    aRectangle.points[10] = actualY + actualSizeY;
     aRectangle.points[11] = m_fZStep;
 
     m_RectangleShapePointList.push_back(aRectangle);
@@ -1362,7 +1362,7 @@ int OpenGLRender::RectangleShapePoint(float x, float y, float directionX, float
 }
 
 
-int OpenGLRender::RenderRectangleShape()
+int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
 {
     m_fZStep += 0.001;
     size_t listNum = m_RectangleShapePointList.size();
@@ -1386,31 +1386,68 @@ int OpenGLRender::RenderRectangleShape()
         glUseProgram(m_BackgroundProID);
 
         glUniformMatrix4fv(m_BackgroundMatrixID, 1, GL_FALSE, &m_MVP[0][0]);
-        // 1rst attribute buffer : vertices
-        glEnableVertexAttribArray(m_BackgroundVertexID);
-        glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
-        glVertexAttribPointer(
-            m_BackgroundVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
-            2,                  // size
-            GL_FLOAT,           // type
-            GL_FALSE,           // normalized?
-            0,                  // stride
-            (void*)0            // array buffer offset
-            );
-
-        // 2nd attribute buffer : color
-        glEnableVertexAttribArray(m_BackgroundColorID);
-        glBindBuffer(GL_ARRAY_BUFFER, m_ColorBuffer);
-        glVertexAttribPointer(
-            m_BackgroundColorID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
-            4,                  // size
-            GL_FLOAT,           // type
-            GL_FALSE,           // normalized?
-            0,                  // stride
-            (void*)0            // array buffer offset
-            );
-        //TODO: moggi: get rid of GL_QUADS
-        glDrawArrays(GL_QUADS, 0, 4);
+        if(bFill)
+        {
+            glEnableVertexAttribArray(m_BackgroundVertexID);
+            glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+            glVertexAttribPointer(
+                    m_BackgroundVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+                    3,                  // size
+                    GL_FLOAT,           // type
+                    GL_FALSE,           // normalized?
+                    0,                  // stride
+                    (void*)0            // array buffer offset
+                    );
+
+            // 2nd attribute buffer : color
+            glEnableVertexAttribArray(m_BackgroundColorID);
+            glBindBuffer(GL_ARRAY_BUFFER, m_ColorBuffer);
+            glVertexAttribPointer(
+                    m_BackgroundColorID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+                    4,                  // size
+                    GL_FLOAT,           // type
+                    GL_FALSE,           // normalized?
+                    0,                  // stride
+                    (void*)0            // array buffer offset
+                    );
+            //TODO: moggi: get rid of GL_QUADS
+            glDrawArrays(GL_QUADS, 0, 4);
+            glDisableVertexAttribArray(m_BackgroundVertexID);
+            glDisableVertexAttribArray(m_BackgroundColorID);
+        }
+        if(bBorder)
+        {
+            SetBackGroundColor(COL_BLACK, COL_BLACK);
+
+            glBindBuffer(GL_ARRAY_BUFFER, m_ColorBuffer);
+            glBufferData(GL_ARRAY_BUFFER, sizeof(m_BackgroundColor), m_BackgroundColor, GL_STATIC_DRAW);
+            // 1rst attribute buffer : vertices
+            glEnableVertexAttribArray(m_BackgroundVertexID);
+            glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+            glVertexAttribPointer(
+                    m_BackgroundVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+                    3,                  // size
+                    GL_FLOAT,           // type
+                    GL_FALSE,           // normalized?
+                    0,                  // stride
+                    (void*)0            // array buffer offset
+                    );
+
+            // 2nd attribute buffer : color
+            glEnableVertexAttribArray(m_BackgroundColorID);
+            glBindBuffer(GL_ARRAY_BUFFER, m_ColorBuffer);
+            glVertexAttribPointer(
+                    m_BackgroundColorID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
+                    4,                  // size
+                    GL_FLOAT,           // type
+                    GL_FALSE,           // normalized?
+                    0,                  // stride
+                    (void*)0            // array buffer offset
+                    );
+            glDrawArrays(GL_LINE_LOOP, 0, 4);
+            glDisableVertexAttribArray(m_BackgroundVertexID);
+            glDisableVertexAttribArray(m_BackgroundColorID);
+        }
         glDisableVertexAttribArray(m_BackgroundVertexID);
         glDisableVertexAttribArray(m_BackgroundColorID);
         glUseProgram(0);
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index dc9beb5..e082be7 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -165,7 +165,7 @@ public:
 
 
     void SetTransparency(sal_uInt32 transparency);
-    int RenderRectangleShape();
+    int RenderRectangleShape(bool bBorder, bool bFill);
     int RectangleShapePoint(float x, float y, float directionX, float directionY);
 
     int CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, const Font& rFont,
@@ -180,6 +180,8 @@ public:
     void renderDebug();
 #endif
 
+    void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2);
+
 private:
     GLint LoadShaders(const char *vertexShader,const char *fragmentShader);
     int CreateTextureObj(int width, int height);
@@ -193,7 +195,6 @@ private:
 #endif
     int CreateMultiSampleFrameBufObj();
     int Create2DCircle(int detail);
-    void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2);
 
 private:
     // Projection matrix : default 45 degree Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units


More information about the Libreoffice-commits mailing list