add translucent balck background for history rendering

Change-Id: I9da69bdb29bb780776355e79fab61d5d9bb844a4
Reviewed-on: https://gerrit.libreoffice.org/11583
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Tested-by: Kohei Yoshida <libreoffice@kohei.us>
This commit is contained in:
xukai 2014-09-22 17:40:30 +08:00 committed by Kohei Yoshida
parent b8c442f2b9
commit 7d833aa8a7
4 changed files with 41 additions and 24 deletions

View file

@ -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: */

View file

@ -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,

View file

@ -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();

View file

@ -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++)