Kaydet (Commit) 7d833aa8 authored tarafından xukai's avatar xukai Kaydeden (comit) Kohei Yoshida

add translucent balck background for history rendering

Change-Id: I9da69bdb29bb780776355e79fab61d5d9bb844a4
Reviewed-on: https://gerrit.libreoffice.org/11583Reviewed-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
Tested-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
üst b8c442f2
...@@ -13,11 +13,11 @@ in vec2 vTexCoord; ...@@ -13,11 +13,11 @@ in vec2 vTexCoord;
uniform sampler2D TextTex; uniform sampler2D TextTex;
uniform vec4 textColor; uniform vec4 textColor;
out vec4 actualColor; out vec4 actualColor;
void main() void main()
{ {
vec3 color = texture(TextTex, vTexCoord).rgb; vec3 color = texture2D(TextTex, vTexCoord).rgb;
actualColor = vec4(textColor.rgb, 1.0 - color.r); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -360,6 +360,9 @@ void RenderBenchMarkThread::MoveToCorner() ...@@ -360,6 +360,9 @@ void RenderBenchMarkThread::MoveToCorner()
void RenderBenchMarkThread::ProcessScroll() void RenderBenchMarkThread::ProcessScroll()
{ {
//will add other process later //will add other process later
mpChart->mpRenderer->EndClick();
mnStep = 0;
mnStepsTotal = STEPS;
mpChart->maRenderEvent = EVENT_SHOW_SCROLL; mpChart->maRenderEvent = EVENT_SHOW_SCROLL;
} }
...@@ -1019,7 +1022,7 @@ void GL3DBarChart::scroll(long nDelta) ...@@ -1019,7 +1022,7 @@ void GL3DBarChart::scroll(long nDelta)
SharedResourceAccess(maCond1, maCond2); SharedResourceAccess(maCond1, maCond2);
osl::MutexGuard aGuard(maMutex); osl::MutexGuard aGuard(maMutex);
if ((maRenderEvent != EVENT_NONE) && (maRenderEvent != EVENT_SHOW_SCROLL) && 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; return;
glm::vec3 maDir = glm::normalize(maCameraPosition - maCameraDirection); glm::vec3 maDir = glm::normalize(maCameraPosition - maCameraDirection);
maCameraPosition -= (float((nDelta/10)) * maDir); maCameraPosition -= (float((nDelta/10)) * maDir);
...@@ -1042,17 +1045,18 @@ void GL3DBarChart::contextDestroyed() ...@@ -1042,17 +1045,18 @@ void GL3DBarChart::contextDestroyed()
mbValidContext = false; mbValidContext = false;
} }
void GL3DBarChart::addScreenTextShape(OUString &nStr, glm::vec2 rLeftOrRightTop, float nTextHeight, bool bLeftTopFlag, float GL3DBarChart::addScreenTextShape(OUString &nStr, glm::vec2 aLeftOrRightTop, float nTextHeight, bool bLeftTopFlag,
const glm::vec3& rPos, const glm::vec4& rColor, sal_uInt32 nEvent) const glm::vec4& rColor, const glm::vec3& rPos, sal_uInt32 nEvent)
{ {
maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, nStr, rColor, nEvent)); maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, nStr, rColor, nEvent));
const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(nStr); const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(nStr);
float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * nTextHeight / 2.0f; float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * nTextHeight / 2.0f;
opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back()); opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back());
if (bLeftTopFlag) 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 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() void GL3DBarChart::updateRenderFPS()
...@@ -1069,7 +1073,7 @@ void GL3DBarChart::updateRenderFPS() ...@@ -1069,7 +1073,7 @@ void GL3DBarChart::updateRenderFPS()
} }
osl_getSystemTime(&maFPSRenderEndTime); osl_getSystemTime(&maFPSRenderEndTime);
addScreenTextShape(maFPS, glm::vec2(-0.99f, 0.99f), 0.07f, true, 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) int GL3DBarChart::calcTimeInterval(TimeValue &startTime, TimeValue &endTime)
...@@ -1133,29 +1137,32 @@ void GL3DBarChart::updateClickEvent() ...@@ -1133,29 +1137,32 @@ void GL3DBarChart::updateClickEvent()
sal_uInt32 nIdex = 0; sal_uInt32 nIdex = 0;
OUString aTitle; OUString aTitle;
OUString aBarValue; OUString aBarValue;
float nXCoordStart; float nXCoordStart, nYCoordStart, nTextWidth, nMaxXCoord = 0.0f, nMinXCoord = 1.0f, nMaxHight = 0.0f;
float nYCoordStart;
//write title //write title
if (aList.size() > 1) if (aList.size() > 1)
{ {
aTitle = OUString("Time "); 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"); 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) if (aList.size() > COLUMNSIZE)
{ {
aTitle = OUString("Time "); 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"); 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) for (std::list<float>::iterator it = aList.begin();it != aList.end();++it)
{ {
if (nIdex + 1 == aList.size()) if (nIdex + 1 == aList.size())
{ {
aBarValue = OUString("Value: ") + OUString::number(*it); 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); const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(aBarValue);
float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * 0.03; float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * 0.03;
std::map<sal_uInt32, const BarInformation>::const_iterator itr = maBarMap.find(mnSelectBarId); std::map<sal_uInt32, const BarInformation>::const_iterator itr = maBarMap.find(mnSelectBarId);
...@@ -1173,7 +1180,7 @@ void GL3DBarChart::updateClickEvent() ...@@ -1173,7 +1180,7 @@ void GL3DBarChart::updateClickEvent()
{ {
aTitle = OUString("Most Recent") + aTitle; aTitle = OUString("Most Recent") + aTitle;
} }
if (aList.size() < COLUMNSIZE) if (aList.size() <= COLUMNSIZE)
{ {
nXCoordStart = 0.875f; nXCoordStart = 0.875f;
nYCoordStart = (nIdex + 1) * 0.07f; nYCoordStart = (nIdex + 1) * 0.07f;
...@@ -1183,12 +1190,20 @@ void GL3DBarChart::updateClickEvent() ...@@ -1183,12 +1190,20 @@ void GL3DBarChart::updateClickEvent()
nXCoordStart = nIdex < COLUMNSIZE ? 0.55f : 0.875f; nXCoordStart = nIdex < COLUMNSIZE ? 0.55f : 0.875f;
nYCoordStart = nIdex < COLUMNSIZE ? (nIdex + 1) * 0.07f : (nIdex - 24) * 0.07f; 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); 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++; 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() ...@@ -1312,7 +1327,7 @@ void GL3DBarChart::updateScroll()
for(size_t i = 0; i < aBarInfoList.size(); i++) for(size_t i = 0; i < aBarInfoList.size(); i++)
{ {
OUString aBarValue = OUString("Value: ") + OUString::number(aBarInfoList[i].mnVal); 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); const opengl3D::TextCacheItem& rTextCache = mpTextCache->getText(aBarValue);
float nRectWidth = (float)rTextCache.maSize.Width() / (float)rTextCache.maSize.Height() * 0.03; 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, glm::vec3 aTextPos = glm::vec3(aBarInfoList[i].maPos.x + BAR_SIZE_X / 2.0f,
......
...@@ -102,9 +102,9 @@ private: ...@@ -102,9 +102,9 @@ private:
void updateDataUpdateFPS(); void updateDataUpdateFPS();
DECL_LINK(updateTimer, void*); DECL_LINK(updateTimer, void*);
int calcTimeInterval(TimeValue &startTime, TimeValue &endTime); 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::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); sal_uInt32 nEvent = 0);
void recordBarHistory(sal_uInt32 &nBarID, float &nVal); void recordBarHistory(sal_uInt32 &nBarID, float &nVal);
void updateClickEvent(); void updateClickEvent();
......
...@@ -36,8 +36,8 @@ const int CORNER_DIVION_Z = 20; ...@@ -36,8 +36,8 @@ const int CORNER_DIVION_Z = 20;
GLfloat texCoords[] = { GLfloat texCoords[] = {
1.0f, 0.0f, 1.0f, 0.0f,
1.0f, 1.0f, 1.0f, 0.96f,
0.0f, 1.0f, 0.0f, 0.96f,
0.0f, 0.0f 0.0f, 0.0f
}; };
...@@ -1927,6 +1927,8 @@ void OpenGL3DRenderer::ReleaseScreenTextTexture() ...@@ -1927,6 +1927,8 @@ void OpenGL3DRenderer::ReleaseScreenTextTexture()
void OpenGL3DRenderer::RenderScreenTextShape() void OpenGL3DRenderer::RenderScreenTextShape()
{ {
if (mbPickingMode)
return;
glUseProgram(maResources.m_ScreenTextProID); glUseProgram(maResources.m_ScreenTextProID);
CHECK_GL_ERROR(); CHECK_GL_ERROR();
for (size_t i = 0; i < m_ScreenTextInfoList.size(); i++) for (size_t i = 0; i < m_ScreenTextInfoList.size(); i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment