From 33cc10e8a16a207a77504578832caa61c0e6079d Mon Sep 17 00:00:00 2001 From: rachytski Date: Mon, 13 Jun 2011 00:34:33 +0300 Subject: [PATCH] moved InfoLayer rendering from main thread to render thread. --- base/base_tests/string_utils_test.cpp | 20 ++++++++++++++++++++ base/buffer_vector.hpp | 17 +++++++++++++++++ iphone/Maps/Classes/EAGLView.mm | 3 ++- map/framework.cpp | 4 ++-- map/render_queue_routine.cpp | 10 +++++++--- qt/widgets.cpp | 1 + qt_tstfrm/tstwidgets.cpp | 1 + yg/glyph_layout.cpp | 3 ++- yg/info_layer.cpp | 6 +++--- yg/info_layer.hpp | 2 +- yg/render_state_updater.cpp | 4 ++-- yg/resource_manager.cpp | 1 - yg/text_element.cpp | 10 ++-------- yg/text_element.hpp | 7 +++---- yg/text_renderer.cpp | 2 +- 15 files changed, 64 insertions(+), 27 deletions(-) diff --git a/base/base_tests/string_utils_test.cpp b/base/base_tests/string_utils_test.cpp index 92af81819c..16685b36cd 100644 --- a/base/base_tests/string_utils_test.cpp +++ b/base/base_tests/string_utils_test.cpp @@ -263,3 +263,23 @@ UNIT_TEST(Normalize) strings::Normalize(us); TEST_EQUAL(us, result, ()); } + +UNIT_TEST(UniString_Less) +{ + strings::UniString s0 = strings::MakeUniString("Test"); + TEST(!(s0 < s0), ()); + strings::UniString s1 = strings::MakeUniString("Test1"); + TEST(s0 < s1, ()); + strings::UniString s2 = strings::MakeUniString("Tast"); + TEST(s2 < s1, ()); + strings::UniString s3 = strings::MakeUniString("Tas"); + TEST(s3 < s0, ()); + strings::UniString s4 = strings::MakeUniString("Taste"); + TEST(!(s0 < s4), ()); + strings::UniString s5 = strings::MakeUniString("Tist"); + TEST(s0 < s5, ()); + strings::UniString s6 = strings::MakeUniString("Tis"); + TEST(s0 < s6, ()); + strings::UniString s7 = strings::MakeUniString("Tiste"); + TEST(s0 < s7, ()); +} diff --git a/base/buffer_vector.hpp b/base/buffer_vector.hpp index 70be9015b3..96aceeba7c 100644 --- a/base/buffer_vector.hpp +++ b/base/buffer_vector.hpp @@ -234,6 +234,23 @@ inline bool operator==(buffer_vector const & v1, buffer_vector con return (v1.size() == v2.size() && std::equal(v1.begin(), v1.end(), v2.begin())); } +template +inline bool operator<(buffer_vector const & v1, buffer_vector const & v2) +{ + const int N = v1.size() > v2.size() ? v2.size() : v1.size(); + for (size_t i = 0; i < N; ++i) + { + if (v1[i] == v2[i]) + continue; + return v1[i] < v2[i]; + } + if (v1.size() == v2.size()) + return false; + if (v1.size() == N) + return true; + return false; +} + template inline bool operator!=(buffer_vector const & v1, buffer_vector const & v2) { diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index 2140e746eb..765ad7cc33 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -112,7 +112,8 @@ DrawerYG::params_t p; p.m_resourceManager = resourceManager; p.m_isMultiSampled = false; - p.m_frameBuffer = frameBuffer; + p.m_frameBuffer = frameBuffer; + p.m_glyphCacheID = 1; drawer = shared_ptr(new DrawerYG(GetPlatform().SkinName(), p)); diff --git a/map/framework.cpp b/map/framework.cpp index d150f50193..dc82bd4a46 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -884,9 +884,9 @@ void FrameWork::AddRedrawCommandSure() m_informationDisplay.doDraw(pDrawer); - m_renderQueue.renderState().m_actualInfoLayer->draw( +/* m_renderQueue.renderState().m_actualInfoLayer->draw( pDrawer->screen().get(), - m_renderQueue.renderState().m_actualScreen.PtoGMatrix() * currentScreen.GtoPMatrix()); + m_renderQueue.renderState().m_actualScreen.PtoGMatrix() * currentScreen.GtoPMatrix());*/ m_locationState.DrawMyPosition(*pDrawer, m_navigator.Screen()); diff --git a/map/render_queue_routine.cpp b/map/render_queue_routine.cpp index 859bc560db..5f1888145b 100644 --- a/map/render_queue_routine.cpp +++ b/map/render_queue_routine.cpp @@ -239,7 +239,7 @@ void RenderQueueRoutine::Do() params.m_renderState = m_renderState; params.m_doPeriodicalUpdate = m_doPeriodicalUpdate; params.m_updateInterval = m_updateInterval; - params.m_glyphCacheID = 1; + params.m_glyphCacheID = 0; /* params.m_isDebugging = true; params.m_drawPathes = false; params.m_drawAreas = false; @@ -324,7 +324,7 @@ void RenderQueueRoutine::Do() areas.push_back(curRect); fullRectRepaint = true; m_renderState->m_currentInfoLayer->clear(); - m_renderState->m_actualInfoLayer->clear(); +// m_renderState->m_actualInfoLayer->clear(); m_renderState->m_doRepaintAll = false; } else @@ -358,7 +358,7 @@ void RenderQueueRoutine::Do() else { m_renderState->m_currentInfoLayer->clear(); - m_renderState->m_actualInfoLayer->clear(); +// m_renderState->m_actualInfoLayer->clear(); } } } @@ -423,6 +423,10 @@ void RenderQueueRoutine::Do() /// setting the "whole texture" clip rect to render texts opened by panning. m_threadDrawer->screen()->setClipRect(textureRect); + + /// rendering all collected texts + m_renderState->m_currentInfoLayer->draw(m_threadDrawer->screen().get(), math::Identity()); + m_threadDrawer->endFrame(); } diff --git a/qt/widgets.cpp b/qt/widgets.cpp index 06e4d765bb..eb403f9391 100644 --- a/qt/widgets.cpp +++ b/qt/widgets.cpp @@ -65,6 +65,7 @@ namespace qt p.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(true)); p.m_dynamicPagesCount = 2; p.m_textPagesCount = 2; + p.m_glyphCacheID = 1; m_p = shared_ptr(new DrawerYG(GetPlatform().SkinName(), p)); } diff --git a/qt_tstfrm/tstwidgets.cpp b/qt_tstfrm/tstwidgets.cpp index 2aee740694..2582ed494a 100644 --- a/qt_tstfrm/tstwidgets.cpp +++ b/qt_tstfrm/tstwidgets.cpp @@ -71,6 +71,7 @@ void GLDrawWidget::initializeGL() params.m_resourceManager = m_resourceManager; params.m_isMultiSampled = false; params.m_frameBuffer = m_frameBuffer; + params.m_glyphCacheID = 1; m_p = make_shared_ptr(new yg::gl::Screen(params)); diff --git a/yg/glyph_layout.cpp b/yg/glyph_layout.cpp index 47edb553b9..c7f900e65e 100644 --- a/yg/glyph_layout.cpp +++ b/yg/glyph_layout.cpp @@ -133,7 +133,8 @@ namespace yg double pathOffset, yg::EPosition pos) : m_firstVisible(0), - m_lastVisible(0) + m_lastVisible(0), + m_limitRect(m2::RectD(0, 0, 0, 0)) { TextPath arrPath(pts, ptsCount, fullLength, pathOffset); diff --git a/yg/info_layer.cpp b/yg/info_layer.cpp index 1c8148e4d8..bac538a3fa 100644 --- a/yg/info_layer.cpp +++ b/yg/info_layer.cpp @@ -25,7 +25,7 @@ namespace yg { m_tree.ForEach(bind(&StraightTextElement::draw, _1, r, m)); - list toErase; + list toErase; for (path_text_elements::const_iterator it = m_pathTexts.begin(); it != m_pathTexts.end(); ++it) { @@ -38,7 +38,7 @@ namespace yg toErase.push_back(it->first); } - for (list::const_iterator it = toErase.begin(); it != toErase.end(); ++it) + for (list::const_iterator it = toErase.begin(); it != toErase.end(); ++it) m_pathTexts.erase(*it); } @@ -111,7 +111,7 @@ namespace yg void InfoLayer::addPathText(PathTextElement const & pte) { - list & l = m_pathTexts[pte.utf8Text()]; + list & l = m_pathTexts[pte.logText()]; bool doAppend = true; diff --git a/yg/info_layer.hpp b/yg/info_layer.hpp index f05e4397ae..4edb6b511c 100644 --- a/yg/info_layer.hpp +++ b/yg/info_layer.hpp @@ -28,7 +28,7 @@ namespace yg static bool better_text(StraightTextElement const & r1, StraightTextElement const & r2); m4::Tree m_tree; - typedef map > path_text_elements; + typedef map > path_text_elements; path_text_elements m_pathTexts; void offsetPathTexts(m2::PointD const & offs, m2::RectD const & rect); diff --git a/yg/render_state_updater.cpp b/yg/render_state_updater.cpp index ae32028f44..22e4a1d7d0 100644 --- a/yg/render_state_updater.cpp +++ b/yg/render_state_updater.cpp @@ -55,12 +55,12 @@ namespace yg { threads::MutexGuard guard(*m_renderState->m_mutex.get()); swap(m_renderState->m_actualTarget, m_renderState->m_backBufferLayers.front()); - swap(m_renderState->m_actualInfoLayer, m_renderState->m_currentInfoLayer); +// swap(m_renderState->m_actualInfoLayer, m_renderState->m_currentInfoLayer); m_renderState->m_actualScreen = m_renderState->m_currentScreen; } /// copying info layer - *m_renderState->m_currentInfoLayer.get() = *m_renderState->m_actualInfoLayer.get(); +// *m_renderState->m_currentInfoLayer.get() = *m_renderState->m_actualInfoLayer.get(); /// blitting will be performed through /// non-multisampled framebuffer for the sake of speed diff --git a/yg/resource_manager.cpp b/yg/resource_manager.cpp index b08947015f..1d25333f80 100644 --- a/yg/resource_manager.cpp +++ b/yg/resource_manager.cpp @@ -35,7 +35,6 @@ namespace yg m_useVA(useVA), m_fillSkinAlpha(fillSkinAlpha) { - /// primary cache is for rendering, so it's big m_glyphCaches.push_back(GlyphCache(GlyphCache::Params(blocksFile, whiteListFile, blackListFile, maxGlyphCacheSize))); /// secondary caches is for glyph metrics only, so they are small diff --git a/yg/text_element.cpp b/yg/text_element.cpp index 8d1aab8452..646d2794ee 100644 --- a/yg/text_element.cpp +++ b/yg/text_element.cpp @@ -63,8 +63,7 @@ namespace yg m_fontDesc(p.m_fontDesc), m_logText(p.m_logText), m_log2vis(p.m_log2vis), - m_glyphCache(p.m_glyphCache), - m_utf8Text(p.m_utf8Text) + m_glyphCache(p.m_glyphCache) { if (m_log2vis) m_visText = log2vis(m_logText); @@ -82,11 +81,6 @@ namespace yg return m_visText; } - string const & TextElement::utf8Text() const - { - return m_utf8Text; - } - FontDesc const & TextElement::fontDesc() const { return m_fontDesc; @@ -94,7 +88,7 @@ namespace yg void TextElement::drawTextImpl(GlyphLayout const & layout, gl::TextRenderer * screen, math::Matrix const & m, FontDesc const & fontDesc, double depth) const { - if ((layout.lastVisible() != visText().size()) && (layout.firstVisible() != 0)) + if ((layout.firstVisible() != 0) || (layout.lastVisible() != visText().size())) return; m2::PointD pivot = layout.entries()[0].m_pt; diff --git a/yg/text_element.hpp b/yg/text_element.hpp index fef63bc38e..8052f7e653 100644 --- a/yg/text_element.hpp +++ b/yg/text_element.hpp @@ -76,7 +76,7 @@ namespace yg struct Params : OverlayElement::Params { FontDesc m_fontDesc; - wstring m_logText; + strings::UniString m_logText; bool m_log2vis; GlyphCache * m_glyphCache; }; @@ -88,9 +88,8 @@ namespace yg math::Matrix const & m, FontDesc const & desc, double depth) const; - wstring const & logText() const; - wstring const & visText() const; - string const & utf8Text() const; + strings::UniString const & logText() const; + strings::UniString const & visText() const; FontDesc const & fontDesc() const; }; diff --git a/yg/text_renderer.cpp b/yg/text_renderer.cpp index 71500ac042..cbe7e29c88 100644 --- a/yg/text_renderer.cpp +++ b/yg/text_renderer.cpp @@ -69,7 +69,7 @@ namespace yg params.m_fullLength = fullLength; params.m_pathOffset = pathOffset; params.m_fontDesc = fontDesc; - params.m_logText = strings::FromUtf8(utf8Text); + params.m_logText = strings::MakeUniString(utf8Text); params.m_depth = depth; params.m_log2vis = true; params.m_glyphCache = resourceManager()->glyphCache(m_glyphCacheID);