chart2/opengl/screenTextFragmentShader.glsl    |    6 +--
 chart2/source/view/charttypes/GL3DBarChart.cxx |   49 ++++++++++++++++---------
 chart2/source/view/inc/GL3DBarChart.hxx        |    4 +-
 chart2/source/view/main/GL3DRenderer.cxx       |    6 ++-
 4 files changed, 41 insertions(+), 24 deletions(-)

New commits:
commit 7d833aa8a7e572dd266c1e9f52826cbdbfc95185
Author: xukai <xu...@multicorewareinc.com>
Date:   Mon Sep 22 17:40:30 2014 +0800

    add translucent balck background for history rendering
    
    Change-Id: I9da69bdb29bb780776355e79fab61d5d9bb844a4
    Reviewed-on: https://gerrit.libreoffice.org/11583
    Reviewed-by: Kohei Yoshida <libreoff...@kohei.us>
    Tested-by: Kohei Yoshida <libreoff...@kohei.us>

diff --git a/chart2/opengl/screenTextFragmentShader.glsl 
b/chart2/opengl/screenTextFragmentShader.glsl
index f76abee..f60b54fd 100644
--- a/chart2/opengl/screenTextFragmentShader.glsl
+++ b/chart2/opengl/screenTextFragmentShader.glsl
@@ -13,11 +13,11 @@ in vec2 vTexCoord;
 uniform sampler2D TextTex;
 uniform vec4 textColor;
 out vec4 actualColor;
-
 void main()
 {
-    vec3 color = texture(TextTex, vTexCoord).rgb;
-    actualColor = vec4(textColor.rgb, 1.0 - color.r);
+    vec3 color = texture2D(TextTex, vTexCoord).rgb;
+    actualColor = ((1.0 - color.r) == 0.0) ? vec4(0.0, 0.0, 0.0, textColor.a) :
+                    vec4(textColor.rgb, 1.0);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx 
b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 8215158..5241aa8 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -360,6 +360,9 @@ void RenderBenchMarkThread::MoveToCorner()
 void RenderBenchMarkThread::ProcessScroll()
 {
     //will add other process later
+    mpChart->mpRenderer->EndClick();
+    mnStep = 0;
+    mnStepsTotal = STEPS;
     mpChart->maRenderEvent = EVENT_SHOW_SCROLL;
 }
 
@@ -1019,7 +1022,7 @@ void GL3DBarChart::scroll(long nDelta)
         SharedResourceAccess(maCond1, maCond2);
         osl::MutexGuard aGuard(maMutex);
         if ((maRenderEvent != EVENT_NONE) && (maRenderEvent != 
EVENT_SHOW_SCROLL) &&
-            (maRenderEvent != EVENT_AUTO_FLY) && (maRenderEvent == 
EVENT_SHOW_SELECT))
+            (maRenderEvent != EVENT_AUTO_FLY) && (maRenderEvent != 
EVENT_SHOW_SELECT))
             return;
         glm::vec3 maDir = glm::normalize(maCameraPosition - maCameraDirection);
         maCameraPosition -= (float((nDelta/10)) * maDir);
@@ -1042,17 +1045,18 @@ void GL3DBarChart::contextDestroyed()
     mbValidContext = false;
 }
 
-void GL3DBarChart::addScreenTextShape(OUString &nStr, glm::vec2 
rLeftOrRightTop, float nTextHeight, bool bLeftTopFlag,
-                                            const glm::vec3& rPos, const 
glm::vec4& rColor, sal_uInt32 nEvent)
+float GL3DBarChart::addScreenTextShape(OUString &nStr, glm::vec2 
aLeftOrRightTop, float nTextHeight, bool bLeftTopFlag,
+                                            const glm::vec4& rColor, const 
glm::vec3& rPos, sal_uInt32 nEvent)
 {
     maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), 
*mpTextCache, nStr, rColor, nEvent));
     const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(nStr);
     float nRectWidth = (float)rTextCache.maSize.Width() / 
(float)rTextCache.maSize.Height() * nTextHeight / 2.0f;
     opengl3D::ScreenText* pScreenText = 
static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back());
     if (bLeftTopFlag)
-        pScreenText->setPosition(rLeftOrRightTop, glm::vec2(rLeftOrRightTop.x 
+ nRectWidth, rLeftOrRightTop.y - nTextHeight), rPos);
+        pScreenText->setPosition(aLeftOrRightTop, glm::vec2(aLeftOrRightTop.x 
+ nRectWidth, aLeftOrRightTop.y - nTextHeight), rPos);
     else
-        pScreenText->setPosition(glm::vec2(rLeftOrRightTop.x - nRectWidth, 
rLeftOrRightTop.y), glm::vec2(rLeftOrRightTop.x, rLeftOrRightTop.y - 
nTextHeight), rPos);
+        pScreenText->setPosition(glm::vec2(aLeftOrRightTop.x - nRectWidth, 
aLeftOrRightTop.y), glm::vec2(aLeftOrRightTop.x, aLeftOrRightTop.y - 
nTextHeight), rPos);
+    return nRectWidth;
 }
 
 void GL3DBarChart::updateRenderFPS()
@@ -1069,7 +1073,7 @@ void GL3DBarChart::updateRenderFPS()
     }
     osl_getSystemTime(&maFPSRenderEndTime);
     addScreenTextShape(maFPS, glm::vec2(-0.99f, 0.99f), 0.07f, true,
-                       glm::vec3(0.0f, 0.0f, 0.0f), glm::vec4(1.0f, 0.0f, 
0.0f, 1.0f));
+                       glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 
0.0f, 0.0f));
 }
 
 int GL3DBarChart::calcTimeInterval(TimeValue &startTime, TimeValue &endTime)
@@ -1133,29 +1137,32 @@ void GL3DBarChart::updateClickEvent()
         sal_uInt32 nIdex = 0;
         OUString aTitle;
         OUString aBarValue;
-        float nXCoordStart;
-        float nYCoordStart;
+        float nXCoordStart, nYCoordStart, nTextWidth, nMaxXCoord = 0.0f, 
nMinXCoord = 1.0f, nMaxHight = 0.0f;
         //write title
         if (aList.size() > 1)
         {
             aTitle = OUString("Time      ");
-            addScreenTextShape(aTitle, glm::vec2(0.875f, 0.99f), 0.07f, false);
+            nTextWidth = addScreenTextShape(aTitle, glm::vec2(0.875, 0.99f), 
0.07f, false, glm::vec4(0.0f, 1.0f, 1.0f, 0.5f));
+            nMinXCoord = std::min(nMinXCoord, 0.875f - nTextWidth);
             aTitle = OUString("   Value");
-            addScreenTextShape(aTitle, glm::vec2(0.875f, 0.99f), 0.07f);
+            nTextWidth = addScreenTextShape(aTitle, glm::vec2(0.875f, 0.99f), 
0.07f, true, glm::vec4(0.0f, 1.0f, 1.0f, 0.5f));
+            nMaxXCoord = std::max(nMaxXCoord, 0.875f + nTextWidth);
         }
         if (aList.size() > COLUMNSIZE)
         {
             aTitle = OUString("Time      ");
-            addScreenTextShape(aTitle, glm::vec2(0.55f, 0.99f), 0.07f, false);
+            nTextWidth = addScreenTextShape(aTitle, glm::vec2(0.55f, 0.99f), 
0.07f, false, glm::vec4(0.0f, 1.0f, 1.0f, 0.5f));
+            nMinXCoord = std::min(nMinXCoord, 0.55f - nTextWidth);
             aTitle = OUString("   Value");
-            addScreenTextShape(aTitle, glm::vec2(0.55f, 0.99f), 0.07f);
+            nTextWidth = addScreenTextShape(aTitle, glm::vec2(0.55f, 0.99f), 
0.07f, true, glm::vec4(0.0f, 1.0f, 1.0f, 0.5f));
+            nMaxXCoord = std::max(nMaxXCoord, 0.55f + nTextWidth);
         }
         for (std::list<float>::iterator it = aList.begin();it != 
aList.end();++it)
         {
             if (nIdex + 1 == aList.size())
             {
                 aBarValue = OUString("Value: ") + OUString::number(*it);
-                maScreenTextShapes.push_back(new 
opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 
0.0f, 1.0f, 1.0f), CALC_POS_EVENT_ID));
+                maScreenTextShapes.push_back(new 
opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 
0.0f, 1.0f, 0.0f), CALC_POS_EVENT_ID));
                 const opengl3D::TextCacheItem& rTextCache = 
mpTextCache->getText(aBarValue);
                 float nRectWidth = (float)rTextCache.maSize.Width() / 
(float)rTextCache.maSize.Height() * 0.03;
                 std::map<sal_uInt32, const BarInformation>::const_iterator itr 
= maBarMap.find(mnSelectBarId);
@@ -1173,7 +1180,7 @@ void GL3DBarChart::updateClickEvent()
                 {
                     aTitle = OUString("Most Recent") + aTitle;
                 }
-                if (aList.size() < COLUMNSIZE)
+                if (aList.size() <= COLUMNSIZE)
                 {
                     nXCoordStart = 0.875f;
                     nYCoordStart = (nIdex + 1) * 0.07f;
@@ -1183,12 +1190,20 @@ void GL3DBarChart::updateClickEvent()
                     nXCoordStart = nIdex < COLUMNSIZE ? 0.55f : 0.875f;
                     nYCoordStart = nIdex < COLUMNSIZE ? (nIdex + 1) * 0.07f : 
(nIdex - 24) * 0.07f;
                 }
-                addScreenTextShape(aTitle, glm::vec2(nXCoordStart, 0.99f - 
nYCoordStart), 0.07f, false);
+                nMaxHight = std::max(nMaxHight, nYCoordStart + 0.07f);
+                nTextWidth = addScreenTextShape(aTitle, 
glm::vec2(nXCoordStart, 0.99f - nYCoordStart), 0.07f, false, glm::vec4(0.0f, 
1.0f, 1.0f, 0.5f));
+                nMinXCoord = std::min(nMinXCoord, nXCoordStart - nTextWidth);
                 aBarValue = OUString::number(*it);
-                addScreenTextShape(aBarValue, glm::vec2(nXCoordStart, 0.99f - 
nYCoordStart), 0.07f);
+                nTextWidth = addScreenTextShape(aBarValue, 
glm::vec2(nXCoordStart, 0.99f - nYCoordStart), 0.07f, true, glm::vec4(0.0f, 
1.0f, 1.0f, 0.5f));
+                nMaxXCoord = std::max(nMaxXCoord, nXCoordStart + nTextWidth);
             }
             nIdex++;
         }
+        //add translucent back ground
+        aTitle = OUString(" ");
+        maScreenTextShapes.push_back(new 
opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aTitle, glm::vec4(0.0f, 
0.0f, 0.0f, 0.5f), 0));
+        opengl3D::ScreenText* pScreenText = 
static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back());
+        pScreenText->setPosition(glm::vec2(nMinXCoord, 0.99f), 
glm::vec2(nMaxXCoord, 0.99f - nMaxHight));
     }
 }
 
@@ -1312,7 +1327,7 @@ void GL3DBarChart::updateScroll()
             for(size_t i = 0; i < aBarInfoList.size(); i++)
             {
                 OUString aBarValue = OUString("Value: ") + 
OUString::number(aBarInfoList[i].mnVal);
-                maScreenTextShapes.push_back(new 
opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 
0.0f, 1.0f, 1.0f), CALC_POS_EVENT_ID));
+                maScreenTextShapes.push_back(new 
opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, aBarValue, glm::vec4(0.0f, 
0.0f, 1.0f, 0.0f), CALC_POS_EVENT_ID));
                 const opengl3D::TextCacheItem& rTextCache = 
mpTextCache->getText(aBarValue);
                 float nRectWidth = (float)rTextCache.maSize.Width() / 
(float)rTextCache.maSize.Height() * 0.03;
                 glm::vec3 aTextPos = glm::vec3(aBarInfoList[i].maPos.x + 
BAR_SIZE_X / 2.0f,
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx 
b/chart2/source/view/inc/GL3DBarChart.hxx
index b4fd709..7affc4b 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -102,9 +102,9 @@ private:
     void updateDataUpdateFPS();
     DECL_LINK(updateTimer, void*);
     int calcTimeInterval(TimeValue &startTime, TimeValue &endTime);
-    void addScreenTextShape(OUString &nStr, glm::vec2 rLeftOrRightTop, float 
nTextHeight, bool bLeftTopFlag = true,
+    float addScreenTextShape(OUString &nStr, glm::vec2 aLeftOrRightTop, float 
nTextHeight, bool bLeftTopFlag = true,
+                                  const glm::vec4& rColor = glm::vec4(0.0f, 
1.0f, 1.0f, 0.0f),
                                   const glm::vec3& rPos = glm::vec3(0.0f, 
0.0f, 0.0f),
-                                  const glm::vec4& rColor = glm::vec4(0.0f, 
1.0f, 1.0f, 1.0f),
                                   sal_uInt32 nEvent = 0);
     void recordBarHistory(sal_uInt32 &nBarID, float &nVal);
     void updateClickEvent();
diff --git a/chart2/source/view/main/GL3DRenderer.cxx 
b/chart2/source/view/main/GL3DRenderer.cxx
index 9d34ea7..5991a3f 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -36,8 +36,8 @@ const int CORNER_DIVION_Z = 20;
 
 GLfloat texCoords[] = {
     1.0f, 0.0f,
-    1.0f, 1.0f,
-    0.0f, 1.0f,
+    1.0f, 0.96f,
+    0.0f, 0.96f,
     0.0f, 0.0f
 };
 
@@ -1927,6 +1927,8 @@ void OpenGL3DRenderer::ReleaseScreenTextTexture()
 
 void OpenGL3DRenderer::RenderScreenTextShape()
 {
+    if (mbPickingMode)
+        return;
     glUseProgram(maResources.m_ScreenTextProID);
     CHECK_GL_ERROR();
     for (size_t i = 0; i < m_ScreenTextInfoList.size(); i++)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to