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

Markus Mohrhard markus.mohrhard at collabora.co.uk
Tue Mar 4 12:38:22 PST 2014


 chart2/source/view/main/DummyXShape.cxx  |   13 +++++++++++--
 chart2/source/view/main/OpenGLRender.cxx |   24 ++++++++++++++++++++++++
 chart2/source/view/main/OpenGLRender.hxx |    2 --
 3 files changed, 35 insertions(+), 4 deletions(-)

New commits:
commit fc6543e04d22afc66fc1282cf6cc74822f4e8ae3
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Mar 4 21:33:17 2014 +0100

    remove mfAlpha again
    
    The concept with separate alpha will result in nasty alpha bugs.
    
    Change-Id: I9c18d2a850aeed2bf14f43d247029204013d3c93

diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 579a8a2..82285c7 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -444,21 +444,23 @@ void DummyCircle::render()
     SAL_WARN("chart2.opengl", "render DummyCircle");
     debugProperties(maProperties);
     DummyChart* pChart = getRootShape();
-    std::map<OUString, uno::Any>::const_iterator itr = maProperties.find("FillColor");
+
+    sal_uInt8 nAlpha = 255;
+    std::map<OUString, uno::Any>::const_iterator itr = maProperties.find("FillTransparence");
     if(itr != maProperties.end())
     {
-        sal_Int32 nColor = itr->second.get<sal_Int32>();
-        pChart->m_GLRender.SetColor(nColor, 255);
+        sal_Int32 nTrans = itr->second.get<sal_Int32>();
+        nAlpha = static_cast<sal_uInt8>(nTrans & 0xFF);
     }
-    else
-        SAL_WARN("chart2.opengl", "missing color");
 
-    itr = maProperties.find("FillTransparence");
+    itr = maProperties.find("FillColor");
     if(itr != maProperties.end())
     {
-        sal_Int32 nTrans = itr->second.get<sal_Int32>();
-        pChart->m_GLRender.SetTransparency(nTrans&0xFF);
+        sal_Int32 nColor = itr->second.get<sal_Int32>();
+        pChart->m_GLRender.SetColor(nColor, nAlpha);
     }
+    else
+        SAL_WARN("chart2.opengl", "missing color");
 
     pChart->m_GLRender.Bubble2DShapePoint(maPosition.X, maPosition.Y,
                                           maSize.Width, maSize.Height);
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index b150df2..a2565a5 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1555,11 +1555,7 @@ void OpenGLRender::SetChartTransparencyGradient(long transparencyGradient)
         m_BackgroundColor[15] = 0.0;
     }
 }
-void OpenGLRender::SetTransparency(sal_uInt32 transparency)
-{
-    m_fAlpha = (float)transparency / 255.0;
-    m_2DColor = glm::vec4(m_2DColor.r, m_2DColor.g, m_2DColor.b, m_fAlpha);
-}
+
 void OpenGLRender::GeneratePieSegment2D(double fInnerRadius, double fOutterRadius, double nAngleStart, double nAngleWidth)
 {
     double nAngleStep = 1;
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 5d6b091..2610804 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -184,7 +184,6 @@ public:
 #endif
 
     void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2, sal_uInt8 nAlpha);
-    void SetTransparency(sal_uInt32 transparency);
 private:
     GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
     int CreateTextureObj(int width, int height);
@@ -287,7 +286,6 @@ private:
     GLuint m_DebugVertexID;
     GLuint m_DebugColorID;
 #endif
-    float m_fAlpha;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 57f2c561ce747ba11ae623935ccc2a5d594945c2
Author: Peilin <peilin at multicorewareinc.com>
Date:   Mon Mar 3 16:15:29 2014 +0800

    add black bubble edge and modify transparence
    
    Change-Id: If18e74c2cec00d29bddaffbbd21991749490493a

diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 88b6ad9..579a8a2 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -453,6 +453,13 @@ void DummyCircle::render()
     else
         SAL_WARN("chart2.opengl", "missing color");
 
+    itr = maProperties.find("FillTransparence");
+    if(itr != maProperties.end())
+    {
+        sal_Int32 nTrans = itr->second.get<sal_Int32>();
+        pChart->m_GLRender.SetTransparency(nTrans&0xFF);
+    }
+
     pChart->m_GLRender.Bubble2DShapePoint(maPosition.X, maPosition.Y,
                                           maSize.Width, maSize.Height);
     pChart->m_GLRender.RenderBubble2FBO(GL_TRUE);
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 35a4b87..b150df2 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1043,6 +1043,7 @@ int OpenGLRender::Bubble2DShapePoint(float x, float y, float directionX, float d
 int OpenGLRender::RenderBubble2FBO(int)
 {
     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++)
     {
@@ -1081,7 +1082,30 @@ int OpenGLRender::RenderBubble2FBO(int)
         glDrawArrays(GL_TRIANGLE_FAN, 0, m_Bubble2DCircle.size() / 2);
         glDisableVertexAttribArray(m_2DVertexID);
         glUseProgram(0);
+        glBindBuffer(GL_ARRAY_BUFFER, 0);
+        //add black edge
+        glLineWidth(3.0);
+        glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+        glBufferData(GL_ARRAY_BUFFER, m_Bubble2DCircle.size() * sizeof(GLfloat) -2 , &m_Bubble2DCircle[2], GL_STATIC_DRAW);
+        glUseProgram(m_CommonProID);
+        glUniform4fv(m_2DColorID, 1, &edgeColor[0]);
+        glUniformMatrix4fv(m_MatrixID, 1, GL_FALSE, &m_MVP[0][0]);
+        glEnableVertexAttribArray(m_2DVertexID);
+        glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
+        glVertexAttribPointer(
+            m_2DVertexID,                  // 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
+            );
+        glDrawArrays(GL_LINE_STRIP, 0, (m_Bubble2DCircle.size() * sizeof(GLfloat) -2) / sizeof(float) / 2);
+        glDisableVertexAttribArray(m_2DVertexID);
+        glUseProgram(0);
+        glBindBuffer(GL_ARRAY_BUFFER, 0);
         m_Bubble2DShapePointList.pop_front();
+        glLineWidth(m_fLineWidth);
     }
     //if use MSAA, we should copy the data to the FBO texture
     GLenum fbResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
@@ -1531,7 +1555,11 @@ void OpenGLRender::SetChartTransparencyGradient(long transparencyGradient)
         m_BackgroundColor[15] = 0.0;
     }
 }
-
+void OpenGLRender::SetTransparency(sal_uInt32 transparency)
+{
+    m_fAlpha = (float)transparency / 255.0;
+    m_2DColor = glm::vec4(m_2DColor.r, m_2DColor.g, m_2DColor.b, m_fAlpha);
+}
 void OpenGLRender::GeneratePieSegment2D(double fInnerRadius, double fOutterRadius, double nAngleStart, double nAngleWidth)
 {
     double nAngleStep = 1;
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index b91d5f3..5d6b091 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -184,7 +184,7 @@ public:
 #endif
 
     void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2, sal_uInt8 nAlpha);
-
+    void SetTransparency(sal_uInt32 transparency);
 private:
     GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
     int CreateTextureObj(int width, int height);
@@ -287,7 +287,7 @@ private:
     GLuint m_DebugVertexID;
     GLuint m_DebugColorID;
 #endif
-
+    float m_fAlpha;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list