From a98f5b689b378df349f79d7334ccef1f037a1b17 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Thu, 2 Apr 2015 13:50:54 +0300 Subject: [PATCH] Review fixes --- base/internal/message.hpp | 5 +- drape_frontend/backend_renderer.cpp | 2 +- .../drape_frontend_tests/tile_utils_tests.cpp | 2 - drape_frontend/engine_context.cpp | 21 +- drape_frontend/engine_context.hpp | 1 - drape_frontend/frontend_renderer.cpp | 94 ++++---- drape_frontend/frontend_renderer.hpp | 9 +- drape_frontend/message_subclasses.hpp | 3 +- drape_frontend/read_manager.cpp | 20 +- drape_frontend/read_manager.hpp | 3 +- drape_frontend/read_mwm_task.cpp | 21 +- drape_frontend/read_mwm_task.hpp | 6 +- drape_frontend/tile_info.cpp | 3 + drape_frontend/tile_info.hpp | 4 +- drape_frontend/tile_key.hpp | 9 +- drape_frontend/tile_tree.cpp | 227 +++++++++--------- drape_frontend/tile_tree.hpp | 60 +++-- drape_frontend/tile_utils.cpp | 13 +- drape_frontend/tile_utils.hpp | 18 +- 19 files changed, 267 insertions(+), 254 deletions(-) diff --git a/base/internal/message.hpp b/base/internal/message.hpp index 46786135ba..93534cf171 100644 --- a/base/internal/message.hpp +++ b/base/internal/message.hpp @@ -121,7 +121,10 @@ template inline string DebugPrint(T const & t) template inline string DebugPrint(unique_ptr const & v) { ostringstream out; - out << DebugPrint(*v); + if (v.get() != nullptr) + out << DebugPrint(*v); + else + out << DebugPrint("null"); return out.str(); } diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp index 81932fa5c8..2e7b6d9a1b 100644 --- a/drape_frontend/backend_renderer.cpp +++ b/drape_frontend/backend_renderer.cpp @@ -109,7 +109,7 @@ void BackendRenderer::AcceptMessage(dp::RefPointer message) { FinishReadingMessage * msg = df::CastMessage(message); m_commutator->PostMessage(ThreadsCommutator::RenderThread, - dp::MovePointer(new FinishReadingMessage(move(msg->GetTiles()))), + dp::MovePointer(new FinishReadingMessage(move(msg->MoveTiles()))), MessagePriority::Normal); break; } diff --git a/drape_frontend/drape_frontend_tests/tile_utils_tests.cpp b/drape_frontend/drape_frontend_tests/tile_utils_tests.cpp index dfa8feedfd..a116c53988 100644 --- a/drape_frontend/drape_frontend_tests/tile_utils_tests.cpp +++ b/drape_frontend/drape_frontend_tests/tile_utils_tests.cpp @@ -56,7 +56,6 @@ UNIT_TEST(TileUtils_MagnificationTest) df::TileKey(4, 11, 4), df::TileKey(5, 11, 4), df::TileKey(6, 11, 4), df::TileKey(7, 11, 4) }; - TEST_EQUAL(output.size(), 16, ()); TEST_EQUAL(output, expectedResult, ()); df::TileKey key2(-1 /* x */, -2 /* y */, 2 /* zoom level */); @@ -71,7 +70,6 @@ UNIT_TEST(TileUtils_MagnificationTest) df::TileKey(-4, -5, 4), df::TileKey(-3, -5, 4), df::TileKey(-2, -5, 4), df::TileKey(-1, -5, 4) }; - TEST_EQUAL(output2.size(), 16, ()); TEST_EQUAL(output2, expectedResult2, ()); for (df::TileKey const & k : expectedResult) diff --git a/drape_frontend/engine_context.cpp b/drape_frontend/engine_context.cpp index 1ec961c469..aa062f11a7 100644 --- a/drape_frontend/engine_context.cpp +++ b/drape_frontend/engine_context.cpp @@ -33,7 +33,7 @@ void EngineContext::InsertShape(dp::TransferPointer shape) void EngineContext::EndReadTile() { #ifdef DRAW_TILE_NET - m2::RectD r = key.GetGlobalRect(); + m2::RectD r = m_tileKey.GetGlobalRect(); vector path; path.push_back(r.LeftBottom()); path.push_back(r.LeftTop()); @@ -50,28 +50,23 @@ void EngineContext::EndReadTile() p.m_width = 5; p.m_join = dp::RoundJoin; - InsertShape(key, dp::MovePointer(new LineShape(spline, p))); + InsertShape(dp::MovePointer(new LineShape(spline, p))); df::TextViewParams tp; tp.m_anchor = dp::Center; - tp.m_depth = 20000; - tp.m_primaryText = strings::to_string(key.m_x) + " " + - strings::to_string(key.m_y) + " " + - strings::to_string(key.m_zoomLevel); + tp.m_depth = 0; + tp.m_primaryText = strings::to_string(m_tileKey.m_x) + " " + + strings::to_string(m_tileKey.m_y) + " " + + strings::to_string(m_tileKey.m_zoomLevel); - tp.m_primaryTextFont = df::FontDecl(dp::Color::Red(), 30); + tp.m_primaryTextFont = dp::FontDecl(dp::Color::Red(), 30); - InsertShape(key, dp::MovePointer(new TextShape(r.Center(), tp))); + InsertShape(dp::MovePointer(new TextShape(r.Center(), tp))); #endif PostMessage(dp::MovePointer(new TileReadEndMessage(m_tileKey))); } -void EngineContext::FinishReading(TTilesCollection const & finishedTiles) -{ - PostMessage(new FinishReadingMessage(finishedTiles)); -} - void EngineContext::PostMessage(dp::TransferPointer message) { m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, message, diff --git a/drape_frontend/engine_context.hpp b/drape_frontend/engine_context.hpp index df0c4c9e36..f6bb7ade92 100644 --- a/drape_frontend/engine_context.hpp +++ b/drape_frontend/engine_context.hpp @@ -23,7 +23,6 @@ public: /// It will be proccessed and delete later void InsertShape(dp::TransferPointer shape); void EndReadTile(); - void FinishReading(TTilesCollection const & finishedTiles); private: void PostMessage(dp::TransferPointer message); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 060f0de70b..66b43315f7 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -7,6 +7,8 @@ #include "drape/utils/gpu_mem_tracker.hpp" #include "drape/utils/projection.hpp" +#include "indexer/scales.hpp" + #include "geometry/any_rect2d.hpp" #include "base/timer.hpp" @@ -14,6 +16,7 @@ #include "base/logging.hpp" #include "base/stl_add.hpp" +#include "std/algorithm.hpp" #include "std/bind.hpp" #include "std/cmath.hpp" @@ -41,6 +44,7 @@ FrontendRenderer::FrontendRenderer(dp::RefPointer commutator, , m_textureManager(textureManager) , m_gpuProgramManager(new dp::GpuProgramManager()) , m_viewport(viewport) + , m_tileTree(new TileTree()) { #ifdef DRAW_INFO m_tpf = 0,0; @@ -50,17 +54,16 @@ FrontendRenderer::FrontendRenderer(dp::RefPointer commutator, RefreshProjection(); RefreshModelView(); - m_tileTree.SetHandlers(bind(&FrontendRenderer::OnAddRenderGroup, this, _1, _2, _3), - bind(&FrontendRenderer::OnDeferRenderGroup, this, _1, _2, _3), - bind(&FrontendRenderer::OnAddDeferredTile, this, _1, _2), - bind(&FrontendRenderer::OnRemoveTile, this, _1, _2)); + m_tileTree->SetHandlers(bind(&FrontendRenderer::OnAddRenderGroup, this, _1, _2, _3), + bind(&FrontendRenderer::OnDeferRenderGroup, this, _1, _2, _3), + bind(&FrontendRenderer::OnActivateTile, this, _1), + bind(&FrontendRenderer::OnRemoveTile, this, _1)); StartThread(); } FrontendRenderer::~FrontendRenderer() { StopThread(); - m_tileTree.ResetHandlers(); } #ifdef DRAW_INFO @@ -137,12 +140,12 @@ void FrontendRenderer::AcceptMessage(dp::RefPointer message) bucket->GetBuffer()->Build(program); if (!IsUserMarkLayer(key)) { - if (!m_tileTree.ProcessTile(key, df::GetTileScaleBase(m_view), state, bucket)) + if (!m_tileTree->ProcessTile(key, GetCurrentZoomLevel(), state, bucket)) bucket.Destroy(); } else { - auto const & group = FindUserMarkRenderGroup(key, true); + unique_ptr const & group = FindUserMarkRenderGroup(key, true); ASSERT(group.get() != nullptr, ()); group->SetRenderBucket(state, bucket.Move()); } @@ -152,7 +155,7 @@ void FrontendRenderer::AcceptMessage(dp::RefPointer message) case Message::FinishReading: { FinishReadingMessage * msg = df::CastMessage(message); - m_tileTree.FinishTiles(msg->GetTiles(), df::GetTileScaleBase(m_view)); + m_tileTree->FinishTiles(msg->GetTiles(), GetCurrentZoomLevel()); break; } @@ -168,7 +171,7 @@ void FrontendRenderer::AcceptMessage(dp::RefPointer message) ResolveTileKeys(); TTilesCollection tiles; - m_tileTree.GetTilesCollection(tiles, df::GetTileScaleBase(m_view)); + m_tileTree->GetTilesCollection(tiles, GetCurrentZoomLevel()); m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, dp::MovePointer(new ResizeMessage(m_viewport)), @@ -185,15 +188,14 @@ void FrontendRenderer::AcceptMessage(dp::RefPointer message) case Message::InvalidateRect: { - InvalidateRectMessage * m = df::CastMessage(message); + // TODO(@kuznetsov): implement invalidation - TTilesCollection keyStorage; - // TODO: implement invalidation - - Message * msgToBackend = new InvalidateReadManagerRectMessage(keyStorage); - m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, - dp::MovePointer(msgToBackend), - MessagePriority::Normal); + //InvalidateRectMessage * m = df::CastMessage(message); + //TTilesCollection keyStorage; + //Message * msgToBackend = new InvalidateReadManagerRectMessage(keyStorage); + //m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, + // dp::MovePointer(msgToBackend), + // MessagePriority::Normal); break; } @@ -207,8 +209,7 @@ void FrontendRenderer::AcceptMessage(dp::RefPointer message) if (it != m_userMarkRenderGroups.end()) { - unique_ptr & group = *it; - ASSERT(group.get() != nullptr, ()); + ASSERT((*it).get() != nullptr, ()); m_userMarkRenderGroups.erase(it); } @@ -217,7 +218,7 @@ void FrontendRenderer::AcceptMessage(dp::RefPointer message) case Message::ChangeUserMarkLayerVisibility: { ChangeUserMarkLayerVisibilityMessage * m = df::CastMessage(message); - auto const & group = FindUserMarkRenderGroup(m->GetKey(), true); + unique_ptr const & group = FindUserMarkRenderGroup(m->GetKey(), true); ASSERT(group.get() != nullptr, ()); group->SetIsVisible(m->IsVisible()); break; @@ -251,7 +252,7 @@ void FrontendRenderer::AddToRenderGroup(vector> & groups { unique_ptr group(new RenderGroup(state, newTile)); group->AddBucket(renderBucket.Move()); - groups.emplace_back(move(group)); + groups.push_back(move(group)); } void FrontendRenderer::OnAddRenderGroup(TileKey const & tileKey, dp::GLState const & state, @@ -266,37 +267,38 @@ void FrontendRenderer::OnDeferRenderGroup(TileKey const & tileKey, dp::GLState c AddToRenderGroup(m_deferredRenderGroups, state, renderBucket, tileKey); } -void FrontendRenderer::OnAddDeferredTile(TileKey const & tileKey, TileStatus tileStatus) +void FrontendRenderer::OnActivateTile(TileKey const & tileKey) { - ASSERT(tileStatus == TileStatus::Deferred, ()); for(auto it = m_deferredRenderGroups.begin(); it != m_deferredRenderGroups.end();) { if ((*it)->GetTileKey() == tileKey) { - m_renderGroups.emplace_back(move(*it)); + m_renderGroups.push_back(move(*it)); it = m_deferredRenderGroups.erase(it); } else + { ++it; + } } } -void FrontendRenderer::OnRemoveTile(TileKey const & tileKey, TileStatus tileStatus) +void FrontendRenderer::OnRemoveTile(TileKey const & tileKey) { - UNUSED_VALUE(tileStatus); for(auto const & group : m_renderGroups) { if (group->GetTileKey() == tileKey) group->DeleteLater(); } - for(auto it = m_deferredRenderGroups.begin(); it != m_deferredRenderGroups.end();) + auto removePredicate = [&tileKey](unique_ptr const & group) { - if ((*it)->GetTileKey() == tileKey) - it = m_deferredRenderGroups.erase(it); - else - ++it; - } + return group->GetTileKey() == tileKey; + }; + m_deferredRenderGroups.erase(remove_if(m_deferredRenderGroups.begin(), + m_deferredRenderGroups.end(), + removePredicate), + m_deferredRenderGroups.end()); } void FrontendRenderer::RenderScene() @@ -342,7 +344,7 @@ void FrontendRenderer::RenderScene() GLFunctions::glClear(); dp::GLState::DepthLayer prevLayer = dp::GLState::GeometryLayer; - for (auto const & group : m_renderGroups) + for (unique_ptr const & group : m_renderGroups) { dp::GLState const & state = group->GetState(); dp::GLState::DepthLayer layer = state.GetDepthLayer(); @@ -366,7 +368,7 @@ void FrontendRenderer::RenderScene() GLFunctions::glClearDepth(); - for (unique_ptr & group : m_userMarkRenderGroups) + for (unique_ptr const & group : m_userMarkRenderGroups) { ASSERT(group.get() != nullptr, ()); if (group->IsVisible()) @@ -412,14 +414,17 @@ void FrontendRenderer::RefreshModelView() m_generalUniforms.SetMatrix4x4Value("modelView", mv.m_data); } -void FrontendRenderer::ResolveTileKeys() +int FrontendRenderer::GetCurrentZoomLevel() const { - ResolveTileKeys(df::GetTileScaleBase(m_view)); + //TODO(@kuznetsov): revise it + int const upperScale = scales::GetUpperScale(); + int const zoomLevel = GetDrawTileScale(m_view); + return(zoomLevel <= upperScale ? zoomLevel : upperScale); } -void FrontendRenderer::ResolveTileKeys(m2::RectD const & rect) +void FrontendRenderer::ResolveTileKeys() { - ResolveTileKeys(df::GetTileScaleBase(rect)); + ResolveTileKeys(GetCurrentZoomLevel()); } void FrontendRenderer::ResolveTileKeys(int tileScale) @@ -435,21 +440,18 @@ void FrontendRenderer::ResolveTileKeys(int tileScale) int const minTileY = static_cast(floor(clipRect.minY() / rectSize)); int const maxTileY = static_cast(ceil(clipRect.maxY() / rectSize)); - // clip all tiles which are out of viewport - m_tileTree.ClipByRect(clipRect); - // request new tiles - m_tileTree.BeginRequesting(tileScale); + m_tileTree->BeginRequesting(tileScale, clipRect); for (int tileY = minTileY; tileY < maxTileY; ++tileY) { for (int tileX = minTileX; tileX < maxTileX; ++tileX) { TileKey key(tileX, tileY, tileScale); if (clipRect.IsIntersect(key.GetGlobalRect())) - m_tileTree.RequestTile(key); + m_tileTree->RequestTile(key); } } - m_tileTree.EndRequesting(); + m_tileTree->EndRequesting(); } void FrontendRenderer::StartThread() @@ -526,10 +528,10 @@ void FrontendRenderer::ReleaseResources() void FrontendRenderer::DeleteRenderData() { + m_tileTree.reset(); m_renderGroups.clear(); m_deferredRenderGroups.clear(); m_userMarkRenderGroups.clear(); - m_tileTree.Clear(); } void FrontendRenderer::SetModelView(ScreenBase const & screen) @@ -548,7 +550,7 @@ void FrontendRenderer::UpdateScene() ResolveTileKeys(); TTilesCollection tiles; - m_tileTree.GetTilesCollection(tiles, df::GetTileScaleBase(m_view)); + m_tileTree->GetTilesCollection(tiles, GetCurrentZoomLevel()); m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, dp::MovePointer(new UpdateReadManagerMessage(m_view, move(tiles))), diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index ac5b751253..ccf135c83a 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -68,9 +68,10 @@ private: void RefreshModelView(); void ResolveTileKeys(); - void ResolveTileKeys(m2::RectD const & rect); void ResolveTileKeys(int tileScale); + int GetCurrentZoomLevel() const; + //TODO(@kuznetsov): return new ref-pointer here unique_ptr const & FindUserMarkRenderGroup(TileKey const & tileKey, bool createIfNeed); private: @@ -105,8 +106,8 @@ private: void OnDeferRenderGroup(TileKey const & tileKey, dp::GLState const & state, dp::MasterPointer & renderBucket); - void OnAddDeferredTile(TileKey const & tileKey, TileStatus tileStatus); - void OnRemoveTile(TileKey const & tileKey, TileStatus tileStatus); + void OnActivateTile(TileKey const & tileKey); + void OnRemoveTile(TileKey const & tileKey); private: dp::RefPointer m_textureManager; @@ -124,7 +125,7 @@ private: Viewport m_viewport; ScreenBase m_view; - TileTree m_tileTree; + unique_ptr m_tileTree; ScreenBase m_newView; mutex m_modelViewMutex; diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index 73bf28db0f..9b05cd266a 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -63,7 +63,8 @@ public: Type GetType() const override { return Message::FinishReading; } - TTilesCollection & GetTiles() { return m_tiles; } + TTilesCollection const & GetTiles() { return m_tiles; } + TTilesCollection & MoveTiles() { return m_tiles; } private: TTilesCollection m_tiles; diff --git a/drape_frontend/read_manager.cpp b/drape_frontend/read_manager.cpp index f113d0adbc..883d3de533 100755 --- a/drape_frontend/read_manager.cpp +++ b/drape_frontend/read_manager.cpp @@ -1,4 +1,5 @@ #include "drape_frontend/read_manager.hpp" +#include "drape_frontend/message_subclasses.hpp" #include "drape_frontend/visual_params.hpp" #include "platform/platform.hpp" @@ -44,16 +45,21 @@ void ReadManager::OnTaskFinished(threads::IRoutine * task) ASSERT(dynamic_cast(task) != NULL, ()); ReadMWMTask * t = static_cast(task); - // add finished tile to collection + // finish tiles { lock_guard lock(m_finishedTilesMutex); + + // add finished tile to collection m_finishedTiles.emplace(t->GetTileKey()); + // decrement counter ASSERT(m_counter > 0, ()); --m_counter; if (m_counter == 0) { - m_context.FinishReading(m_finishedTiles); + m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, + dp::MovePointer(new FinishReadingMessage(m_finishedTiles)), + MessagePriority::Normal); m_finishedTiles.clear(); } } @@ -69,7 +75,7 @@ void ReadManager::UpdateCoverage(ScreenBase const & screen, TTilesCollection con if (MustDropAllTiles(screen)) { - m_counter += tiles.size(); + IncreaseCounter(static_cast(tiles.size())); for_each(m_tileInfos.begin(), m_tileInfos.end(), bind(&ReadManager::CancelTileInfo, this, _1)); m_tileInfos.clear(); @@ -95,7 +101,7 @@ void ReadManager::UpdateCoverage(ScreenBase const & screen, TTilesCollection con m_tileInfos.begin(), m_tileInfos.end(), back_inserter(inputRects), LessCoverageCell()); - m_counter += (inputRects.size() + (m_tileInfos.size() - outdatedTiles.size())); + IncreaseCounter(static_cast(inputRects.size() + (m_tileInfos.size() - outdatedTiles.size()))); for_each(outdatedTiles.begin(), outdatedTiles.end(), bind(&ReadManager::ClearTileInfo, this, _1)); for_each(m_tileInfos.begin(), m_tileInfos.end(), bind(&ReadManager::PushTaskFront, this, _1)); @@ -164,4 +170,10 @@ void ReadManager::ClearTileInfo(shared_ptr const & tileToClear) m_tileInfos.erase(tileToClear); } +void ReadManager::IncreaseCounter(int value) +{ + lock_guard lock(m_finishedTilesMutex); + m_counter += value; +} + } // namespace df diff --git a/drape_frontend/read_manager.hpp b/drape_frontend/read_manager.hpp index 2d93026868..c7b5ec1b1a 100755 --- a/drape_frontend/read_manager.hpp +++ b/drape_frontend/read_manager.hpp @@ -65,12 +65,13 @@ private: ObjectPool myPool; - atomic m_counter; + int m_counter; set m_finishedTiles; mutex m_finishedTilesMutex; void CancelTileInfo(shared_ptr const & tileToCancel); void ClearTileInfo(shared_ptr const & tileToClear); + void IncreaseCounter(int value); }; } // namespace df diff --git a/drape_frontend/read_mwm_task.cpp b/drape_frontend/read_mwm_task.cpp index 0f84502888..d84accba03 100644 --- a/drape_frontend/read_mwm_task.cpp +++ b/drape_frontend/read_mwm_task.cpp @@ -1,7 +1,5 @@ #include "drape_frontend/read_mwm_task.hpp" -#include "std/shared_ptr.hpp" - namespace df { ReadMWMTask::ReadMWMTask(MemoryFeatureIndex & memIndex, MapDataProvider & model) @@ -13,7 +11,7 @@ ReadMWMTask::ReadMWMTask(MemoryFeatureIndex & memIndex, MapDataProvider & model) #endif } -void ReadMWMTask::Init(weak_ptr const & tileInfo) +void ReadMWMTask::Init(shared_ptr const & tileInfo) { m_tileInfo = tileInfo; #ifdef DEBUG @@ -26,6 +24,7 @@ void ReadMWMTask::Reset() #ifdef DEBUG m_checker = false; #endif + m_tileInfo.reset(); } void ReadMWMTask::Do() @@ -33,16 +32,13 @@ void ReadMWMTask::Do() #ifdef DEBUG ASSERT(m_checker, ()); #endif - shared_ptr tileInfo = m_tileInfo.lock(); - if (tileInfo == NULL) - return; + ASSERT(m_tileInfo != nullptr, ()); try { - tileInfo->ReadFeatureIndex(m_model); - tileInfo->ReadFeatures(m_model, m_memIndex); + m_tileInfo->ReadFeatures(m_model, m_memIndex); } - catch (TileInfo::ReadCanceledException & ex) + catch (TileInfo::ReadCanceledException &) { return; } @@ -50,11 +46,8 @@ void ReadMWMTask::Do() TileKey ReadMWMTask::GetTileKey() const { - shared_ptr tileInfo = m_tileInfo.lock(); - if (tileInfo == NULL) - return TileKey(); - - return tileInfo->GetTileKey(); + ASSERT(m_tileInfo != nullptr, ()); + return m_tileInfo->GetTileKey(); } } // namespace df diff --git a/drape_frontend/read_mwm_task.hpp b/drape_frontend/read_mwm_task.hpp index 9f35a73b90..cef57d6a56 100644 --- a/drape_frontend/read_mwm_task.hpp +++ b/drape_frontend/read_mwm_task.hpp @@ -8,7 +8,7 @@ #include "base/object_tracker.hpp" #endif -#include "std/weak_ptr.hpp" +#include "std/shared_ptr.hpp" namespace df { @@ -23,12 +23,12 @@ public: virtual void Do(); - void Init(weak_ptr const & tileInfo); + void Init(shared_ptr const & tileInfo); void Reset(); TileKey GetTileKey() const; private: - weak_ptr m_tileInfo; + shared_ptr m_tileInfo; MemoryFeatureIndex & m_memIndex; MapDataProvider & m_model; diff --git a/drape_frontend/tile_info.cpp b/drape_frontend/tile_info.cpp index bad057f752..e2916cf78c 100644 --- a/drape_frontend/tile_info.cpp +++ b/drape_frontend/tile_info.cpp @@ -66,6 +66,8 @@ void TileInfo::ReadFeatures(MapDataProvider const & model, // Reading can be interrupted by exception throwing MY_SCOPE_GUARD(ReleaseReadTile, bind(&EngineContext::EndReadTile, &m_context)); + ReadFeatureIndex(model); + CheckCanceled(); vector indexes; RequestFeatures(memIndex, indexes); @@ -96,6 +98,7 @@ void TileInfo::ProcessID(FeatureID const & id) void TileInfo::InitStylist(FeatureType const & f, Stylist & s) { CheckCanceled(); + //TODO(@kuznetsov): m_context.GetTileKey().m_zoomLevel? df::InitStylist(f, GetZoomLevel(), s); } diff --git a/drape_frontend/tile_info.hpp b/drape_frontend/tile_info.hpp index 65be74d15a..fe29d60923 100644 --- a/drape_frontend/tile_info.hpp +++ b/drape_frontend/tile_info.hpp @@ -7,9 +7,9 @@ #include "indexer/feature_decl.hpp" #include "base/exception.hpp" -#include "base/mutex.hpp" #include "std/atomic.hpp" +#include "std/mutex.hpp" #include "std/vector.hpp" class FeatureType; @@ -27,7 +27,6 @@ public: TileInfo(EngineContext const & context); - void ReadFeatureIndex(MapDataProvider const & model); void ReadFeatures(MapDataProvider const & model, MemoryFeatureIndex & memIndex); void Cancel(MemoryFeatureIndex & memIndex); @@ -37,6 +36,7 @@ public: bool operator <(TileInfo const & other) const { return GetTileKey() < other.GetTileKey(); } private: + void ReadFeatureIndex(MapDataProvider const & model); void ProcessID(FeatureID const & id); void InitStylist(FeatureType const & f, Stylist & s); void RequestFeatures(MemoryFeatureIndex & memIndex, vector & featureIndexes); diff --git a/drape_frontend/tile_key.hpp b/drape_frontend/tile_key.hpp index 6871b980a9..24a9e73d47 100755 --- a/drape_frontend/tile_key.hpp +++ b/drape_frontend/tile_key.hpp @@ -7,9 +7,13 @@ namespace df enum class TileStatus { + // tile does not participate in rendering or fake Unknown = 0, + // tile is rendered Rendered, + // tile has been requested to be rendered Requested, + // tile is ready but it was deferred for rendering Deferred }; @@ -17,7 +21,6 @@ struct TileKey { TileKey(); TileKey(int x, int y, int zoomLevel); - TileKey(int x, int y, int zoomLevel, TileStatus status); bool operator < (TileKey const & other) const; bool operator == (TileKey const & other) const; @@ -27,11 +30,9 @@ struct TileKey int m_x; int m_y; int m_zoomLevel; - -private: - friend string DebugPrint(TileKey const & key); }; +string DebugPrint(TileKey const & key); string DebugPrint(TileStatus status); } // namespace df diff --git a/drape_frontend/tile_tree.cpp b/drape_frontend/tile_tree.cpp index 2743b3f457..28c86b86db 100755 --- a/drape_frontend/tile_tree.cpp +++ b/drape_frontend/tile_tree.cpp @@ -13,36 +13,31 @@ TileTree::TileTree() TileTree::~TileTree() { - m_root.reset(); ResetHandlers(); } void TileTree::SetHandlers(TRenderGroupHandler const & addRenderGroup, TRenderGroupHandler const & deferRenderGroup, - TTileHandler const & addDeferredTile, + TTileHandler const & activateTile, TTileHandler const & removeTile) { - m_addRenderGroup = addRenderGroup; - m_deferRenderGroup = deferRenderGroup; - m_addDeferredTile = addDeferredTile; - m_removeTile = removeTile; + m_addRenderGroupHandler = addRenderGroup; + m_deferRenderGroupHandler = deferRenderGroup; + m_activateTileHandler = activateTile; + m_removeTileHandler = removeTile; } void TileTree::ResetHandlers() { - m_addRenderGroup = nullptr; - m_deferRenderGroup = nullptr; - m_addDeferredTile = nullptr; - m_removeTile = nullptr; + m_addRenderGroupHandler = nullptr; + m_deferRenderGroupHandler = nullptr; + m_activateTileHandler = nullptr; + m_removeTileHandler = nullptr; } -void TileTree::Clear() -{ - m_root.reset(new Node()); -} - -void TileTree::BeginRequesting(int const zoomLevel) +void TileTree::BeginRequesting(int const zoomLevel, m2::RectD const & clipRect) { + ClipByRect(clipRect); AbortTiles(m_root, zoomLevel); } @@ -56,7 +51,7 @@ void TileTree::EndRequesting() SimplifyTree(); } -void TileTree::GetTilesCollection(TTilesCollection & tiles, int const zoomLevel) +void TileTree::GetTilesCollection(TTilesCollection & tiles, int const zoomLevel) const { FillTilesCollection(m_root, tiles, zoomLevel); } @@ -73,7 +68,7 @@ bool TileTree::ProcessTile(TileKey const & tileKey, int const zoomLevel, { bool const result = ProcessNode(m_root, tileKey, zoomLevel, state, bucket); if (result) - SimplifyTree(); + SimplifyTree(); return result; } @@ -108,76 +103,94 @@ void TileTree::InsertToNode(TNodePtr const & node, TileKey const & tileKey) { // here zoom level of node's children less than new tile's zoom level // so we are looking for node to insert new tile recursively - - // looking for parent node - auto parentNodeIt = find_if(node->m_children.begin(), node->m_children.end(), [&tileKey](TNodePtr const & n) - { - return IsTileBelow(n->m_tileKey, tileKey); - }); - - // insert to parent node - if (parentNodeIt == node->m_children.end()) - { - TileKey parentTileKey = GetParentTile(tileKey, childrenZoomLevel); - node->m_children.emplace_back(TNodePtr(new Node(parentTileKey, TileStatus::Unknown))); - InsertToNode(node->m_children.back(), tileKey); - } - else - InsertToNode(*parentNodeIt, tileKey); + InsertToNodeBelow(node, tileKey, childrenZoomLevel); } else if (tileKey.m_zoomLevel < childrenZoomLevel) { // here zoom level of node's children more than new tile's zoom level // so we paste new tile and redistribute children of current node // between new tile and his siblings - - list newChildren; - newChildren.emplace_back(new Node(tileKey, TileStatus::Requested)); - for (auto it = node->m_children.begin(); it != node->m_children.end(); ++it) - { - // looking for parent node - TileKey parentTileKey = GetParentTile((*it)->m_tileKey, tileKey.m_zoomLevel); - auto parentNodeIt = find_if(newChildren.begin(), newChildren.end(), [&parentTileKey](TNodePtr const & n) - { - return n->m_tileKey == parentTileKey; - }); - - // insert to parent node - if (parentNodeIt == newChildren.end()) - { - newChildren.emplace_back(TNodePtr(new Node(parentTileKey, TileStatus::Unknown))); - newChildren.back()->m_children.emplace_back(move(*it)); - } - else - (*parentNodeIt)->m_children.emplace_back(move(*it)); - } - node->m_children.swap(newChildren); + InsertToNodeAbove(node, tileKey); } else { // here zoom level of node's children equals to new tile's zoom level // so we insert new tile if we haven't got one + InsertToCurrentNode(node, tileKey); + } +} - auto it = find_if(node->m_children.begin(), node->m_children.end(), [&tileKey](TNodePtr const & n) +void TileTree::InsertToCurrentNode(TNodePtr const & node, TileKey const & tileKey) +{ + auto it = find_if(node->m_children.begin(), node->m_children.end(), [&tileKey](TNodePtr const & n) + { + return n->m_tileKey == tileKey; + }); + if (it != node->m_children.end()) + { + if ((*it)->m_tileStatus == TileStatus::Unknown) { - return n->m_tileKey == tileKey; + (*it)->m_tileStatus = TileStatus::Requested; + (*it)->m_isRemoved = false; + } + } + else + { + node->m_children.emplace_back(TNodePtr(new Node(tileKey, TileStatus::Requested))); + } +} + +void TileTree::InsertToNodeAbove(TNodePtr const & node, TileKey const & tileKey) +{ + list newChildren; + newChildren.emplace_back(TNodePtr(new Node(tileKey, TileStatus::Requested))); + for (auto it = node->m_children.begin(); it != node->m_children.end(); ++it) + { + // looking for parent node + TileKey const parentTileKey = GetParentTile((*it)->m_tileKey, tileKey.m_zoomLevel); + auto parentNodeIt = find_if(newChildren.begin(), newChildren.end(), [&parentTileKey](TNodePtr const & n) + { + return n->m_tileKey == parentTileKey; }); - if (it != node->m_children.end()) + + // insert to parent node + if (parentNodeIt == newChildren.end()) { - if ((*it)->m_tileStatus == TileStatus::Unknown) - { - (*it)->m_tileStatus = TileStatus::Requested; - (*it)->m_isRemoved = false; - } + newChildren.emplace_back(TNodePtr(new Node(parentTileKey, TileStatus::Unknown))); + newChildren.back()->m_children.emplace_back(move(*it)); } else - node->m_children.emplace_back(TNodePtr(new Node(tileKey, TileStatus::Requested))); + { + (*parentNodeIt)->m_children.emplace_back(move(*it)); + } + } + node->m_children.swap(newChildren); +} + +void TileTree::InsertToNodeBelow(TNodePtr const & node, TileKey const & tileKey, int const childrenZoomLevel) +{ + // looking for parent node + auto parentNodeIt = find_if(node->m_children.begin(), node->m_children.end(), [&tileKey](TNodePtr const & n) + { + return IsTileBelow(n->m_tileKey, tileKey); + }); + + // insert to parent node + if (parentNodeIt == node->m_children.end()) + { + TileKey parentTileKey = GetParentTile(tileKey, childrenZoomLevel); + node->m_children.emplace_back(TNodePtr(new Node(parentTileKey, TileStatus::Unknown))); + InsertToNode(node->m_children.back(), tileKey); + } + else + { + InsertToNode(*parentNodeIt, tileKey); } } void TileTree::AbortTiles(TNodePtr const & node, int const zoomLevel) { - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) { if (childNode->m_tileKey.m_zoomLevel != zoomLevel) { @@ -191,9 +204,9 @@ void TileTree::AbortTiles(TNodePtr const & node, int const zoomLevel) } } -void TileTree::FillTilesCollection(TNodePtr const & node, TTilesCollection & tiles, int const zoomLevel) +void TileTree::FillTilesCollection(TNodePtr const & node, TTilesCollection & tiles, int const zoomLevel) const { - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) { if (childNode->m_tileStatus != TileStatus::Unknown && childNode->m_tileKey.m_zoomLevel == zoomLevel) tiles.insert(childNode->m_tileKey); @@ -223,8 +236,8 @@ void TileTree::ClipNode(TNodePtr const & node, m2::RectD const & rect) void TileTree::RemoveTile(TNodePtr const & node) { - if (m_removeTile != nullptr && !node->m_isRemoved) - m_removeTile(node->m_tileKey, node->m_tileStatus); + if (m_removeTileHandler != nullptr && !node->m_isRemoved) + m_removeTileHandler(node->m_tileKey); node->m_isRemoved = true; node->m_tileStatus = TileStatus::Unknown; @@ -233,7 +246,7 @@ void TileTree::RemoveTile(TNodePtr const & node) bool TileTree::ProcessNode(TNodePtr const & node, TileKey const & tileKey, int const zoomLevel, dp::GLState const & state, dp::MasterPointer & bucket) { - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) { if (tileKey == childNode->m_tileKey) { @@ -250,20 +263,20 @@ bool TileTree::ProcessNode(TNodePtr const & node, TileKey const & tileKey, int c if (node->m_tileStatus == TileStatus::Rendered) { childNode->m_tileStatus = TileStatus::Deferred; - if (m_deferRenderGroup != nullptr) - m_deferRenderGroup(childNode->m_tileKey, state, bucket); + if (m_deferRenderGroupHandler != nullptr) + m_deferRenderGroupHandler(childNode->m_tileKey, state, bucket); childNode->m_isRemoved = false; } else { childNode->m_tileStatus = TileStatus::Rendered; - if (m_addRenderGroup != nullptr) - m_addRenderGroup(childNode->m_tileKey, state, bucket); + if (m_addRenderGroupHandler != nullptr) + m_addRenderGroupHandler(childNode->m_tileKey, state, bucket); childNode->m_isRemoved = false; } - // try to remove tiles above - DeleteTilesAbove(node); + // try to remove tile above + TryDeleteTileAbove(node); return true; } @@ -276,7 +289,7 @@ bool TileTree::ProcessNode(TNodePtr const & node, TileKey const & tileKey, int c bool TileTree::FinishNode(TNodePtr const & node, TileKey const & tileKey, int const zoomLevel) { bool changed = false; - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) { if (childNode->m_tileKey == tileKey && childNode->m_tileStatus == TileStatus::Requested) { @@ -284,6 +297,7 @@ bool TileTree::FinishNode(TNodePtr const & node, TileKey const & tileKey, int co // this tile is empty, so we mark this tile as rendered childNode->m_tileStatus = TileStatus::Rendered; childNode->m_isRemoved = false; + if (childNode->m_tileKey.m_zoomLevel >= zoomLevel) DeleteTilesBelow(childNode); @@ -297,7 +311,7 @@ bool TileTree::FinishNode(TNodePtr const & node, TileKey const & tileKey, int co void TileTree::DeleteTilesBelow(TNodePtr const & node) { - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) { RemoveTile(childNode); DeleteTilesBelow(childNode); @@ -305,23 +319,23 @@ void TileTree::DeleteTilesBelow(TNodePtr const & node) node->m_children.clear(); } -void TileTree::DeleteTilesAbove(TNodePtr const & node) +void TileTree::TryDeleteTileAbove(TNodePtr const & node) { if (node->m_tileStatus == TileStatus::Requested || node->m_children.empty()) return; // check if all child tiles are ready - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) if (childNode->m_tileStatus == TileStatus::Requested) return; // add deferred tiles - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) { if (childNode->m_tileStatus == TileStatus::Deferred) { - if (m_addDeferredTile != nullptr) - m_addDeferredTile(childNode->m_tileKey, childNode->m_tileStatus); + if (m_activateTileHandler != nullptr) + m_activateTileHandler(childNode->m_tileKey); childNode->m_tileStatus = TileStatus::Rendered; childNode->m_isRemoved = false; @@ -349,7 +363,7 @@ void TileTree::ClearEmptyLevels(TNodePtr const & node) // move grandchildren to grandfather list newChildren; - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) { RemoveTile(childNode); newChildren.splice(newChildren.begin(), childNode->m_children); @@ -357,7 +371,7 @@ void TileTree::ClearEmptyLevels(TNodePtr const & node) node->m_children.swap(newChildren); } - // remove unkhown nodes without children + // remove unknown nodes without children for (auto it = node->m_children.begin(); it != node->m_children.end();) { if((*it)->m_tileStatus == TileStatus::Unknown && (*it)->m_children.empty()) @@ -369,19 +383,19 @@ void TileTree::ClearEmptyLevels(TNodePtr const & node) ++it; } - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) ClearEmptyLevels(childNode); } bool TileTree::ClearObsoleteTiles(TNodePtr const & node) { bool canClear = true; - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) canClear &= ClearObsoleteTiles(childNode); if (canClear) { - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) RemoveTile(childNode); node->m_children.clear(); @@ -392,7 +406,7 @@ bool TileTree::ClearObsoleteTiles(TNodePtr const & node) bool TileTree::HaveChildrenSameStatus(TNodePtr const & node, TileStatus tileStatus) const { - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) if (childNode->m_tileStatus != tileStatus) return false; @@ -404,41 +418,34 @@ bool TileTree::HaveGrandchildrenSameZoomLevel(TNodePtr const & node) const if (node->m_children.empty()) return true; - // retrieve grandchildren zoon level int zoomLevel = -1; - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) { - if (!childNode->m_children.empty()) - { - zoomLevel = childNode->m_children.front()->m_tileKey.m_zoomLevel; - break; - } + if (childNode->m_children.empty()) + continue; + + int z = childNode->m_children.front()->m_tileKey.m_zoomLevel; + + if (zoomLevel != -1 && zoomLevel != z) + return false; + + zoomLevel = z; } - - // have got grandchildren? - if (zoomLevel == -1) - return true; - - for (TNodePtr & childNode : node->m_children) - for (TNodePtr & grandchildNode : childNode->m_children) - if (zoomLevel != grandchildNode->m_tileKey.m_zoomLevel) - return false; - return true; } void TileTree::CheckDeferredTiles(TNodePtr const & node) { - for (TNodePtr & childNode : node->m_children) + for (TNodePtr const & childNode : node->m_children) { - DeleteTilesAbove(childNode); + TryDeleteTileAbove(childNode); CheckDeferredTiles(childNode); } } void DebugPrintNode(TileTree::TNodePtr const & node, ostringstream & out, string const & offset) { - for (TileTree::TNodePtr & childNode : node->m_children) + for (TileTree::TNodePtr const & childNode : node->m_children) { out << offset << "{ " << DebugPrint(childNode->m_tileKey) << ", " << DebugPrint(childNode->m_tileStatus) << (childNode->m_isRemoved ? ", removed" : "") << "}\n"; diff --git a/drape_frontend/tile_tree.hpp b/drape_frontend/tile_tree.hpp index 3e86cf0d6e..9c59365786 100755 --- a/drape_frontend/tile_tree.hpp +++ b/drape_frontend/tile_tree.hpp @@ -15,58 +15,58 @@ namespace df { -/// this class implements K-d tree of visible tiles +/// This class implements K-d tree of visible tiles. class TileTree { public: TileTree(); ~TileTree(); - using TTileHandler = function; + using TTileHandler = function; using TRenderGroupHandler = function &)>; - /// addRenderGroup is called when render group can be created by a tile and rendered at once - /// deferRenderGroup is called when render group can be created by a tile but has to be deferred - /// addDeferredTile is called when previously deferred tile can be rendered - /// removeTile is called when a tile must be removed from rendering + /// This method sets following handlers: + /// addRenderGroup is called when render group can be created by a tile and rendered at once, + /// deferRenderGroup is called when render group can be created by a tile but has to be deferred, + /// activateTile is called when previously deferred tile can be rendered, + /// removeTile is called when a tile must be removed from rendering. void SetHandlers(TRenderGroupHandler const & addRenderGroup, TRenderGroupHandler const & deferRenderGroup, - TTileHandler const & addDeferredTile, + TTileHandler const & activateTile, TTileHandler const & removeTile); - void ResetHandlers(); - /// this method must be called before requesting bunch of tiles - void BeginRequesting(int const zoomLevel); - /// request a new tile + /// This method must be called before requesting bunch of tiles. + void BeginRequesting(int const zoomLevel, m2::RectD const & clipRect); + /// This method requests a new tile. void RequestTile(TileKey const & tileKey); - /// this method must be called after requesting bunch of tiles + /// This method must be called after requesting bunch of tiles. void EndRequesting(); - /// this method processes received from BR tile + /// This method processes received from BR (backend renderer) tile. bool ProcessTile(TileKey const & tileKey, int const zoomLevel, dp::GLState const & state, dp::MasterPointer & bucket); - /// this method processes a message about finishing reading tiles on BR + /// This method processes a message about finishing reading tiles on BR. void FinishTiles(TTilesCollection const & tiles, int const zoomLevel); - /// this method performs clipping by rectangle - void ClipByRect(m2::RectD const & rect); - - /// clear all entire structure of tree. DO NOT call removeTile handlers, - /// so all external storages of tiles must be cleared manually - void Clear(); - - /// it returns actual tile collection to send to BR - void GetTilesCollection(TTilesCollection & tiles, int const zoomLevel); + /// It returns actual tile collection to send to BR. + void GetTilesCollection(TTilesCollection & tiles, int const zoomLevel) const; private: struct Node; using TNodePtr = unique_ptr; + void ResetHandlers(); + void InsertToNode(TNodePtr const & node, TileKey const & tileKey); + void InsertToCurrentNode(TNodePtr const & node, TileKey const & tileKey); + void InsertToNodeAbove(TNodePtr const & node, TileKey const & tileKey); + void InsertToNodeBelow(TNodePtr const & node, TileKey const & tileKey, int const childrenZoomLevel); void AbortTiles(TNodePtr const & node, int const zoomLevel); - void FillTilesCollection(TNodePtr const & node, TTilesCollection & tiles, int const zoomLevel); + void ClipByRect(m2::RectD const & rect); + + void FillTilesCollection(TNodePtr const & node, TTilesCollection & tiles, int const zoomLevel) const; void ClipNode(TNodePtr const & node, m2::RectD const & rect); void CheckDeferredTiles(TNodePtr const & node); @@ -78,7 +78,7 @@ private: bool FinishNode(TNodePtr const & node, TileKey const & tileKey, int const zoomLevel); void DeleteTilesBelow(TNodePtr const & node); - void DeleteTilesAbove(TNodePtr const & node); + void TryDeleteTileAbove(TNodePtr const & node); void SimplifyTree(); void ClearEmptyLevels(TNodePtr const & node); @@ -87,7 +87,6 @@ private: bool HaveChildrenSameStatus(TNodePtr const & node, TileStatus tileStatus) const; bool HaveGrandchildrenSameZoomLevel(TNodePtr const & node) const; -private: struct Node { TileKey m_tileKey; @@ -102,12 +101,11 @@ private: }; TNodePtr m_root; - TRenderGroupHandler m_addRenderGroup; - TRenderGroupHandler m_deferRenderGroup; - TTileHandler m_addDeferredTile; - TTileHandler m_removeTile; + TRenderGroupHandler m_addRenderGroupHandler; + TRenderGroupHandler m_deferRenderGroupHandler; + TTileHandler m_activateTileHandler; + TTileHandler m_removeTileHandler; -private: friend void DebugPrintNode(TileTree::TNodePtr const & node, ostringstream & out, string const & offset); friend string DebugPrint(TileTree const & tileTree); }; diff --git a/drape_frontend/tile_utils.cpp b/drape_frontend/tile_utils.cpp index a0baa0679e..44df86679d 100755 --- a/drape_frontend/tile_utils.cpp +++ b/drape_frontend/tile_utils.cpp @@ -1,6 +1,7 @@ #include "tile_utils.hpp" #include "../base/assert.hpp" +#include "../base/stl_add.hpp" namespace df { @@ -18,9 +19,12 @@ int Minificate(int coord, int zoom, int targetZoom) // here we iteratively minificate zoom int c = -coord; + ASSERT(c > 0, ()); while (z > 0) { - c = (c >> 1) + ((c % 2) != 0 ? 1 : 0); + // c = c / 2 + 1, if c is odd + // c = c / 2, if c is even + c = (c + 1) >> 1; z--; } return -c; @@ -30,10 +34,7 @@ int Minificate(int coord, int zoom, int targetZoom) void CalcTilesCoverage(TileKey const & tileKey, int targetZoom, TTilesCollection & tiles) { - CalcTilesCoverage(tileKey, targetZoom, [&tiles](TileKey const & tileKey) - { - tiles.emplace(tileKey); - }); + CalcTilesCoverage(tileKey, targetZoom, MakeInsertFunctor(tiles)); } void CalcTilesCoverage(set const & tileKeys, int targetZoom, TTilesCollection & tiles) @@ -42,7 +43,7 @@ void CalcTilesCoverage(set const & tileKeys, int targetZoom, TTilesColl CalcTilesCoverage(tileKey, targetZoom, tiles); } -void CalcTilesCoverage(TileKey const & tileKey, int targetZoom, function processTile) +void CalcTilesCoverage(TileKey const & tileKey, int targetZoom, function const & processTile) { ASSERT(processTile != nullptr, ()); diff --git a/drape_frontend/tile_utils.hpp b/drape_frontend/tile_utils.hpp index ced47c780b..dbde566369 100755 --- a/drape_frontend/tile_utils.hpp +++ b/drape_frontend/tile_utils.hpp @@ -9,25 +9,23 @@ namespace df using TTilesCollection = set; -/// this function determines the coverage of a tile in specified zoom level +/// This function determines the coverage of a tile in specified zoom level. void CalcTilesCoverage(TileKey const & tileKey, int targetZoom, TTilesCollection & tiles); -/// this function determines the coverage of tiles in specified zoom level +/// This function determines the coverage of tiles in specified zoom level. void CalcTilesCoverage(set const & tileKeys, int targetZoom, TTilesCollection & tiles); -/// this function determines the coverage of a tile in specified zoom level. Each new tile can be processed -/// in processTile callback -void CalcTilesCoverage(TileKey const & tileKey, int targetZoom, function processTile); +/// This function determines the coverage of a tile in specified zoom level. Each new tile can be processed. +/// in processTile callback. +void CalcTilesCoverage(TileKey const & tileKey, int targetZoom, function const & processTile); -/// this function checks if targetTileKey is above tileKey +/// This function checks if targetTileKey is above tileKey. bool IsTileAbove(TileKey const & tileKey, TileKey const & targetTileKey); -/// this function checks if targetTileKey is below tileKey +/// This function checks if targetTileKey is below tileKey. bool IsTileBelow(TileKey const & tileKey, TileKey const & targetTileKey); -/// this function returns parent tile on specified zoom level +/// This function returns parent tile on specified zoom level. TileKey GetParentTile(TileKey const & tileKey, int targetZoom); } // namespace df - -