diff options
author | weigao <weigao@multicorewareinc.com> | 2014-08-09 14:30:36 +0800 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-08-13 06:21:34 +0200 |
commit | 7a91a493b24dd4a90dc375c71d23b5035169502c (patch) | |
tree | 5033e906b6bd18bd87bd8ec443ac3850c4506786 /chart2 | |
parent | 76fa54819b0445c9e6b85db2729540a07b4601ce (diff) |
add data update text rendering
Change-Id: I022bb00b3704fd3e6bc00a625016716cc7092a99
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/charttypes/GL3DBarChart.cxx | 48 | ||||
-rw-r--r-- | chart2/source/view/inc/GL3DBarChart.hxx | 11 |
2 files changed, 46 insertions, 13 deletions
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx index 70417c29011c..cd95848916d9 100644 --- a/chart2/source/view/charttypes/GL3DBarChart.cxx +++ b/chart2/source/view/charttypes/GL3DBarChart.cxx @@ -404,9 +404,11 @@ GL3DBarChart::GL3DBarChart( mSelectBarId(0), miScrollRate(0), miFrameCount(0), + miDataUpdateCounter(0), mbScrollFlg(false), mbScreenTextNewRender(false), - maFPS(OUString("Render FPS: 0")) + maFPS(OUString("Render FPS: 0")), + maDataUpdateFPS(OUString("Data Update FPS: 0")) { if (BENCH_MARK_MODE) { @@ -423,8 +425,10 @@ GL3DBarChart::GL3DBarChart( maTimer.SetTimeout(DATA_UPDATE_TIME); maTimer.SetTimeoutHdl(LINK(this, GL3DBarChart, updateTimer)); maTimer.Start(); - osl_getSystemTime(&mafpsRenderStartTime); - osl_getSystemTime(&mafpsRenderEndTime); + osl_getSystemTime(&maFPSRenderStartTime); + osl_getSystemTime(&maFPSRenderEndTime); + osl_getSystemTime(&maDataUpdateStartTime); + osl_getSystemTime(&maDataUpdateEndTime); } Size aSize = mrWindow.GetSizePixel(); mpRenderer->SetSize(aSize); @@ -665,6 +669,7 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer mrWindow.getContext().resetCurrent(); mpRenderThread->launch(); } + miDataUpdateCounter++; mbNeedsNewRender = true; } @@ -912,9 +917,9 @@ void GL3DBarChart::contextDestroyed() mbValidContext = false; } -void GL3DBarChart::addScreenTextShape(OUString &nStr, glm::vec2 rLeftTop, float nTextHeight, glm::vec3 rPos) +void GL3DBarChart::addScreenTextShape(OUString &nStr, glm::vec2 rLeftTop, float nTextHeight, glm::vec3 rPos, sal_uInt32 nEvent) { - maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, nStr, 0)); + maScreenTextShapes.push_back(new opengl3D::ScreenText(mpRenderer.get(), *mpTextCache, nStr, nEvent)); opengl3D::TextCacheItem tmpTextCache = mpTextCache->getText(nStr); float rectWidth = (float)tmpTextCache.maSize.Width() / (float)tmpTextCache.maSize.Height() * 0.05; opengl3D::ScreenText* pScreenText = static_cast<opengl3D::ScreenText*>(&maScreenTextShapes.back()); @@ -923,17 +928,17 @@ void GL3DBarChart::addScreenTextShape(OUString &nStr, glm::vec2 rLeftTop, float void GL3DBarChart::updateRenderFPS() { - int aDeltaMs = calcTimeInterval(mafpsRenderStartTime, mafpsRenderEndTime); + int aDeltaMs = calcTimeInterval(maFPSRenderStartTime, maFPSRenderEndTime); if(aDeltaMs >= 500) { - osl_getSystemTime(&mafpsRenderEndTime); - aDeltaMs = calcTimeInterval(mafpsRenderStartTime, mafpsRenderEndTime); + osl_getSystemTime(&maFPSRenderEndTime); + aDeltaMs = calcTimeInterval(maFPSRenderStartTime, maFPSRenderEndTime); int iFPS = miFrameCount * 1000 / aDeltaMs; maFPS = OUString("Render FPS: ") + OUString::number(iFPS); miFrameCount = 0; - osl_getSystemTime(&mafpsRenderStartTime); + osl_getSystemTime(&maFPSRenderStartTime); } - osl_getSystemTime(&mafpsRenderEndTime); + osl_getSystemTime(&maFPSRenderEndTime); addScreenTextShape(maFPS, glm::vec2(-0.99f, 0.99f), 0.1f, glm::vec3(0.0, 0.0, 0.0)); } @@ -953,9 +958,32 @@ void GL3DBarChart::updateScreenText() maScreenTextShapes.clear(); mpRenderer->ReleaseScreenTextShapes(); updateRenderFPS(); + updateDataUpdateFPS(); mbScreenTextNewRender = true; } +void GL3DBarChart::updateDataUpdateFPS() +{ + int aDeltaMs = calcTimeInterval(maDataUpdateStartTime, maDataUpdateEndTime); + if(aDeltaMs >= 500) + { + int iFPS = miDataUpdateCounter * 1000 / aDeltaMs; + if (iFPS) + { + maDataUpdateFPS = OUString("Data Update FPS: ") + OUString::number(iFPS); + } + else + { + float fFPS = (float)miDataUpdateCounter * 1000 / (float)aDeltaMs; + maDataUpdateFPS = OUString("Data Update FPS: ") + OUString::number(fFPS); + } + miDataUpdateCounter = 0; + osl_getSystemTime(&maDataUpdateStartTime); + } + osl_getSystemTime(&maDataUpdateEndTime); + addScreenTextShape(maDataUpdateFPS, glm::vec2(-0.69f, 0.99f), 0.1f, glm::vec3(0.0, 0.0, 0.0)); +} + IMPL_LINK_NOARG(GL3DBarChart, updateTimer) { maTimer.Stop(); diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx index 88de9e0cc5ac..e0cdddd928de 100644 --- a/chart2/source/view/inc/GL3DBarChart.hxx +++ b/chart2/source/view/inc/GL3DBarChart.hxx @@ -88,9 +88,10 @@ private: void updateTimer(); void updateScreenText(); void updateRenderFPS(); + void updateDataUpdateFPS(); DECL_LINK(updateTimer, void*); int calcTimeInterval(TimeValue &startTime, TimeValue &endTime); - void addScreenTextShape(OUString &nStr, glm::vec2 rLeftTop, float nTextHeight, glm::vec3 rPos); + void addScreenTextShape(OUString &nStr, glm::vec2 rLeftTop, float nTextHeight, glm::vec3 rPos, sal_uInt32 nEvent = 0); css::uno::Reference<css::chart2::XChartType> mxChartType; boost::ptr_vector<opengl3D::Renderable3DObject> maShapes; @@ -148,9 +149,13 @@ private: bool mbScreenTextNewRender; boost::ptr_vector<opengl3D::Renderable3DObject> maScreenTextShapes; OUString maFPS; + OUString maDataUpdateFPS; sal_uInt32 miFrameCount; - TimeValue mafpsRenderStartTime; - TimeValue mafpsRenderEndTime; + sal_uInt32 miDataUpdateCounter; + TimeValue maFPSRenderStartTime; + TimeValue maFPSRenderEndTime; + TimeValue maDataUpdateStartTime; + TimeValue maDataUpdateEndTime; }; } |