diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2017-07-14 09:49:28 +0300 |
---|---|---|
committer | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2017-07-26 13:13:57 +0300 |
commit | 85f0ffaff1d39088cbd105c102df9cb4e3bad62c (patch) | |
tree | 29107cd27beaa1ba4d0730e395b70b0a8349f810 /drape_frontend | |
parent | 8a5c4bc7ceeed3f0f6ed0cf2a69f8a63fb5134cb (diff) |
Added new local ads rendering
Diffstat (limited to 'drape_frontend')
25 files changed, 182 insertions, 172 deletions
diff --git a/drape_frontend/CMakeLists.txt b/drape_frontend/CMakeLists.txt index e57debecff..3fd99afa8f 100644 --- a/drape_frontend/CMakeLists.txt +++ b/drape_frontend/CMakeLists.txt @@ -72,7 +72,7 @@ set( color_constants.hpp colored_symbol_shape.cpp colored_symbol_shape.hpp - custom_symbol.hpp + custom_features_context.hpp drape_api.cpp drape_api.hpp drape_api_builder.cpp diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp index 24f76100e6..3139c311ba 100644 --- a/drape_frontend/apply_feature_functors.cpp +++ b/drape_frontend/apply_feature_functors.cpp @@ -63,6 +63,7 @@ int const kLineSimplifyLevelEnd = 12; uint32_t const kPathTextBaseTextIndex = 128; uint32_t const kShieldBaseTextIndex = 0; +int const kShieldMinVisibleZoomLevel = 10; #ifdef CALC_FILTERED_POINTS class LinesStat @@ -552,8 +553,7 @@ void ApplyPointFeature::ProcessPointRule(Stylist::TRuleWrapper const & rule) } } -void ApplyPointFeature::Finish(ref_ptr<dp::TextureManager> texMng, - CustomSymbolsContextPtr const & customSymbolsContext) +void ApplyPointFeature::Finish(ref_ptr<dp::TextureManager> texMng) { m2::PointF symbolSize(0.0f, 0.0f); @@ -580,24 +580,12 @@ void ApplyPointFeature::Finish(ref_ptr<dp::TextureManager> texMng, params.m_depthLayer = m_depthLayer; params.m_minVisibleScale = m_minVisibleScale; params.m_rank = m_rank; - params.m_symbolName = m_symbolRule->name(); - bool prioritized = false; - if (customSymbolsContext) - { - auto customSymbolIt = customSymbolsContext->m_symbols.find(m_id); - if (customSymbolIt != customSymbolsContext->m_symbols.end()) - { - params.m_symbolName = customSymbolIt->second.m_symbolName; - prioritized = customSymbolIt->second.m_prioritized; - } - } - double const mainScale = df::VisualParams::Instance().GetVisualScale(); params.m_extendingSize = static_cast<uint32_t>(mainScale * m_symbolRule->min_distance()); params.m_posZ = m_posZ; params.m_hasArea = m_hasArea; - params.m_prioritized = prioritized || m_createdByEditor; + params.m_prioritized = m_createdByEditor; params.m_obsoleteInEditor = m_obsoleteInEditor; params.m_specialDisplacement = specialDisplacementMode ? SpecialDisplacement::SpecialMode : SpecialDisplacement::None; @@ -991,7 +979,7 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureMan textParams.m_tileCenter = m_tileRect.Center(); textParams.m_depth = m_depth; textParams.m_depthLayer = dp::GLState::OverlayLayer; - textParams.m_minVisibleScale = m_minVisibleScale; + textParams.m_minVisibleScale = kShieldMinVisibleZoomLevel; textParams.m_rank = m_rank; textParams.m_featureID = m_id; textParams.m_titleDecl.m_anchor = anchor; @@ -1020,7 +1008,7 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureMan symbolParams.m_tileCenter = m_tileRect.Center(); symbolParams.m_depth = m_depth; symbolParams.m_depthLayer = dp::GLState::OverlayLayer; - symbolParams.m_minVisibleScale = m_minVisibleScale; + symbolParams.m_minVisibleScale = kShieldMinVisibleZoomLevel; symbolParams.m_rank = m_rank; symbolParams.m_anchor = anchor; symbolParams.m_offset = shieldOffset; @@ -1047,7 +1035,7 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureMan poiParams.m_tileCenter = m_tileRect.Center(); poiParams.m_depth = m_depth; poiParams.m_depthLayer = dp::GLState::OverlayLayer; - poiParams.m_minVisibleScale = m_minVisibleScale; + poiParams.m_minVisibleScale = kShieldMinVisibleZoomLevel; poiParams.m_rank = m_rank; poiParams.m_symbolName = symbolName; poiParams.m_extendingSize = 0; diff --git a/drape_frontend/apply_feature_functors.hpp b/drape_frontend/apply_feature_functors.hpp index fd18255833..1cabe5a8ca 100644 --- a/drape_frontend/apply_feature_functors.hpp +++ b/drape_frontend/apply_feature_functors.hpp @@ -1,6 +1,5 @@ #pragma once -#include "drape_frontend/custom_symbol.hpp" #include "drape_frontend/stylist.hpp" #include "drape_frontend/tile_key.hpp" #include "drape_frontend/shape_view_params.hpp" @@ -86,8 +85,7 @@ public: void operator()(m2::PointD const & point, bool hasArea); void ProcessPointRule(Stylist::TRuleWrapper const & rule); - void Finish(ref_ptr<dp::TextureManager> texMng, - CustomSymbolsContextPtr const & customSymbolsContext); + void Finish(ref_ptr<dp::TextureManager> texMng); protected: float const m_posZ; diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp index cea24828bf..d885bbe8e9 100644 --- a/drape_frontend/backend_renderer.cpp +++ b/drape_frontend/backend_renderer.cpp @@ -442,31 +442,35 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message) break; } - case Message::AddCustomSymbols: - { - ref_ptr<AddCustomSymbolsMessage> msg = message; - CustomSymbols customSymbols = msg->AcceptSymbols(); - std::vector<FeatureID> features; - for (auto const & symbol : customSymbols) - features.push_back(symbol.first); - m_readManager->UpdateCustomSymbols(std::move(customSymbols)); - m_commutator->PostMessage(ThreadsCommutator::RenderThread, - make_unique_dp<UpdateCustomSymbolsMessage>(std::move(features)), - MessagePriority::Normal); + case Message::SetCustomFeatures: + { + ref_ptr<SetCustomFeaturesMessage> msg = message; + if (m_readManager->SetCustomFeatures(msg->AcceptFeatures())) + { + m_commutator->PostMessage(ThreadsCommutator::RenderThread, + make_unique_dp<UpdateCustomFeaturesMessage>( + m_readManager->GetCustomFeaturesArray()), + MessagePriority::Normal); + } break; } - case Message::RemoveCustomSymbols: + case Message::RemoveCustomFeatures: { - ref_ptr<RemoveCustomSymbolsMessage> msg = message; - std::vector<FeatureID> leftoverIds; + ref_ptr<RemoveCustomFeaturesMessage> msg = message; + bool changed = false; if (msg->NeedRemoveAll()) - m_readManager->RemoveAllCustomSymbols(); + changed = m_readManager->RemoveAllCustomFeatures(); else - m_readManager->RemoveCustomSymbols(msg->GetMwmId(), leftoverIds); - m_commutator->PostMessage(ThreadsCommutator::RenderThread, - make_unique_dp<UpdateCustomSymbolsMessage>(std::move(leftoverIds)), - MessagePriority::Normal); + changed = m_readManager->RemoveCustomFeatures(msg->GetMwmId()); + + if (changed) + { + m_commutator->PostMessage(ThreadsCommutator::RenderThread, + make_unique_dp<UpdateCustomFeaturesMessage>( + m_readManager->GetCustomFeaturesArray()), + MessagePriority::Normal); + } break; } diff --git a/drape_frontend/custom_features_context.hpp b/drape_frontend/custom_features_context.hpp new file mode 100644 index 0000000000..3d250e912f --- /dev/null +++ b/drape_frontend/custom_features_context.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "indexer/feature_decl.hpp" + +#include <memory> +#include <set> +#include <utility> + +namespace df +{ +struct CustomFeaturesContext +{ + std::set<FeatureID> const m_features; + + explicit CustomFeaturesContext(std::set<FeatureID> && features) + : m_features(std::move(features)) + {} + + bool Contains(FeatureID const & id) const + { + return m_features.find(id) != m_features.cend(); + } +}; + +using CustomFeaturesContextPtr = std::shared_ptr<CustomFeaturesContext>; +using CustomFeaturesContextWeakPtr = std::weak_ptr<CustomFeaturesContext>; +} // namespace df diff --git a/drape_frontend/custom_symbol.hpp b/drape_frontend/custom_symbol.hpp deleted file mode 100644 index 9344eba715..0000000000 --- a/drape_frontend/custom_symbol.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "indexer/feature_decl.hpp" - -#include <map> -#include <memory> -#include <string> - -namespace df -{ -struct CustomSymbol -{ - std::string m_symbolName; - bool m_prioritized = false; - - CustomSymbol() = default; - CustomSymbol(std::string const & name, bool prioritized) - : m_symbolName(name), m_prioritized(prioritized) - {} -}; - -using CustomSymbols = std::map<FeatureID, CustomSymbol>; - -struct CustomSymbolsContext -{ - CustomSymbols m_symbols; - - explicit CustomSymbolsContext(CustomSymbols && symbols) - : m_symbols(std::move(symbols)) - {} -}; - -using CustomSymbolsContextPtr = std::shared_ptr<CustomSymbolsContext>; -using CustomSymbolsContextWeakPtr = std::weak_ptr<CustomSymbolsContext>; -} // namespace df diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index aafea5c9e0..c94652ad8b 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -230,9 +230,10 @@ void DrapeEngine::UpdateUserMarksLayer(size_t layerId, UserMarksProvider * provi renderInfo->m_runCreationAnim = mark->HasCreationAnimation(); renderInfo->m_symbolName = mark->GetSymbolName(); renderInfo->m_titleDecl = mark->GetTitleDecl(); - renderInfo->m_symbolHasPriority = mark->SymbolHasPriority(); - renderInfo->m_titleHasPriority = mark->TitleHasPriority(); - renderInfo->m_priority = mark->GetProirity(); + renderInfo->m_hasSymbolPriority = mark->HasSymbolPriority(); + renderInfo->m_hasTitlePriority = mark->HasTitlePriority(); + renderInfo->m_priority = mark->GetPriority(); + renderInfo->m_featureId = mark->GetFeatureID(); marksRenderCollection->emplace(mark->GetId(), std::move(renderInfo)); mark->AcceptChanges(); } @@ -674,24 +675,24 @@ void DrapeEngine::RunScenario(ScenarioManager::ScenarioData && scenarioData, manager->RunScenario(std::move(scenarioData), onStartFn, onFinishFn); } -void DrapeEngine::AddCustomSymbols(CustomSymbols && symbols) +void DrapeEngine::SetCustomFeatures(std::set<FeatureID> && ids) { m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, - make_unique_dp<AddCustomSymbolsMessage>(std::move(symbols)), + make_unique_dp<SetCustomFeaturesMessage>(std::move(ids)), MessagePriority::Normal); } -void DrapeEngine::RemoveCustomSymbols(MwmSet::MwmId const & mwmId) +void DrapeEngine::RemoveCustomFeatures(MwmSet::MwmId const & mwmId) { m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, - make_unique_dp<RemoveCustomSymbolsMessage>(mwmId), + make_unique_dp<RemoveCustomFeaturesMessage>(mwmId), MessagePriority::Normal); } -void DrapeEngine::RemoveAllCustomSymbols() +void DrapeEngine::RemoveAllCustomFeatures() { m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, - make_unique_dp<RemoveCustomSymbolsMessage>(), + make_unique_dp<RemoveCustomFeaturesMessage>(), MessagePriority::Normal); } diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index c04dea981c..a02d201b6e 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -2,7 +2,6 @@ #include "drape_frontend/backend_renderer.hpp" #include "drape_frontend/color_constants.hpp" -#include "drape_frontend/custom_symbol.hpp" #include "drape_frontend/drape_hints.hpp" #include "drape_frontend/frontend_renderer.hpp" #include "drape_frontend/route_shape.hpp" @@ -202,9 +201,11 @@ public: ScenarioManager::ScenarioCallback const & onStartFn, ScenarioManager::ScenarioCallback const & onFinishFn); - void AddCustomSymbols(CustomSymbols && symbols); - void RemoveCustomSymbols(MwmSet::MwmId const & mwmId); - void RemoveAllCustomSymbols(); + // Custom features are features which we do not render usual way. + // All these features will be skipped in process of geometry generation. + void SetCustomFeatures(std::set<FeatureID> && ids); + void RemoveCustomFeatures(MwmSet::MwmId const & mwmId); + void RemoveAllCustomFeatures(); void SetPosteffectEnabled(PostprocessRenderer::Effect effect, bool enabled); diff --git a/drape_frontend/drape_frontend.pro b/drape_frontend/drape_frontend.pro index 9323e38ffa..92fd09af9f 100755 --- a/drape_frontend/drape_frontend.pro +++ b/drape_frontend/drape_frontend.pro @@ -155,7 +155,7 @@ HEADERS += \ circles_pack_shape.hpp \ color_constants.hpp \ colored_symbol_shape.hpp \ - custom_symbol.hpp \ + custom_features_context.hpp \ drape_api.hpp \ drape_api_builder.hpp \ drape_api_renderer.hpp \ diff --git a/drape_frontend/engine_context.cpp b/drape_frontend/engine_context.cpp index 2c2419e1b2..72b3bc21b0 100644 --- a/drape_frontend/engine_context.cpp +++ b/drape_frontend/engine_context.cpp @@ -12,7 +12,7 @@ EngineContext::EngineContext(TileKey tileKey, ref_ptr<ThreadsCommutator> commutator, ref_ptr<dp::TextureManager> texMng, ref_ptr<MetalineManager> metalineMng, - CustomSymbolsContextWeakPtr customSymbolsContext, + CustomFeaturesContextWeakPtr customFeaturesContext, bool is3dBuildingsEnabled, bool isTrafficEnabled, int displacementMode) @@ -20,7 +20,7 @@ EngineContext::EngineContext(TileKey tileKey, , m_commutator(commutator) , m_texMng(texMng) , m_metalineMng(metalineMng) - , m_customSymbolsContext(customSymbolsContext) + , m_customFeaturesContext(customFeaturesContext) , m_3dBuildingsEnabled(is3dBuildingsEnabled) , m_trafficEnabled(isTrafficEnabled) , m_displacementMode(displacementMode) diff --git a/drape_frontend/engine_context.hpp b/drape_frontend/engine_context.hpp index 948b78d6a1..71a3af3ca9 100644 --- a/drape_frontend/engine_context.hpp +++ b/drape_frontend/engine_context.hpp @@ -1,6 +1,6 @@ #pragma once -#include "drape_frontend/custom_symbol.hpp" +#include "drape_frontend/custom_features_context.hpp" #include "drape_frontend/map_shape.hpp" #include "drape_frontend/tile_utils.hpp" #include "drape_frontend/threads_commutator.hpp" @@ -26,7 +26,7 @@ public: ref_ptr<ThreadsCommutator> commutator, ref_ptr<dp::TextureManager> texMng, ref_ptr<MetalineManager> metalineMng, - CustomSymbolsContextWeakPtr customSymbolsContext, + CustomFeaturesContextWeakPtr customFeaturesContext, bool is3dBuildingsEnabled, bool isTrafficEnabled, int displacementMode); @@ -35,7 +35,7 @@ public: bool Is3dBuildingsEnabled() const { return m_3dBuildingsEnabled; } bool IsTrafficEnabled() const { return m_trafficEnabled; } int GetDisplacementMode() const { return m_displacementMode; } - CustomSymbolsContextWeakPtr GetCustomSymbolsContext() const { return m_customSymbolsContext; } + CustomFeaturesContextWeakPtr GetCustomFeaturesContext() const { return m_customFeaturesContext; } ref_ptr<dp::TextureManager> GetTextureManager() const; ref_ptr<MetalineManager> GetMetalineManager() const; @@ -52,7 +52,7 @@ private: ref_ptr<ThreadsCommutator> m_commutator; ref_ptr<dp::TextureManager> m_texMng; ref_ptr<MetalineManager> m_metalineMng; - CustomSymbolsContextWeakPtr m_customSymbolsContext; + CustomFeaturesContextWeakPtr m_customFeaturesContext; bool m_3dBuildingsEnabled; bool m_trafficEnabled; int m_displacementMode; diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 7cfd064c73..5011095674 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -732,14 +732,10 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message) } case Message::InvalidateUserMarks: { - auto removePredicate = [](drape_ptr<RenderGroup> const & group) + RemoveRenderGroupsLater([](drape_ptr<RenderGroup> const & group) { - RenderLayer::RenderLayerID id = RenderLayer::GetLayerID(group->GetState()); - return id == RenderLayer::UserLineID || - id == RenderLayer::UserMarkID || - id == RenderLayer::RoutingMarkID; - }; - RemoveRenderGroupsLater(removePredicate); + return group->IsUserMark(); + }); m_forceUpdateUserMarks = true; break; } @@ -776,10 +772,10 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message) break; } - case Message::UpdateCustomSymbols: + case Message::UpdateCustomFeatures: { - ref_ptr<UpdateCustomSymbolsMessage> msg = message; - m_overlaysTracker->SetTrackedOverlaysFeatures(msg->AcceptSymbolsFeatures()); + ref_ptr<UpdateCustomFeaturesMessage> msg = message; + m_overlaysTracker->SetTrackedOverlaysFeatures(msg->AcceptFeatures()); m_forceUpdateScene = true; break; } @@ -1164,6 +1160,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView) { StencilWriterGuard guard(make_ref(m_postprocessRenderer)); RenderOverlayLayer(modelView); + RenderUserMarksLayer(modelView, RenderLayer::LocalAdsMarkID); } m_gpsTrackRenderer->RenderTrack(modelView, m_currentZoomLevel, make_ref(m_gpuProgramManager), @@ -1312,6 +1309,7 @@ void FrontendRenderer::RenderUserLinesLayer(ScreenBase const & modelView) void FrontendRenderer::BuildOverlayTree(ScreenBase const & modelView) { static std::vector<RenderLayer::RenderLayerID> layers = {RenderLayer::OverlayID, + RenderLayer::LocalAdsMarkID, RenderLayer::NavigationID, RenderLayer::RoutingMarkID}; BeginUpdateOverlayTree(modelView); @@ -2059,6 +2057,8 @@ FrontendRenderer::RenderLayer::RenderLayerID FrontendRenderer::RenderLayer::GetL case dp::GLState::UserLineLayer: return UserLineID; case dp::GLState::RoutingMarkLayer: return RoutingMarkID; case dp::GLState::NavigationLayer: return NavigationID; + case dp::GLState::LocalAdsMarkLayer: return LocalAdsMarkID; + default: break; } if (state.GetProgram3dIndex() == gpu::AREA_3D_PROGRAM || diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index fe90dbbc9c..ea86495283 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -152,6 +152,7 @@ private: Geometry2dID, UserLineID, OverlayID, + LocalAdsMarkID, Geometry3dID, UserMarkID, NavigationID, diff --git a/drape_frontend/message.hpp b/drape_frontend/message.hpp index 51c1ac0149..911739e7bd 100644 --- a/drape_frontend/message.hpp +++ b/drape_frontend/message.hpp @@ -74,9 +74,9 @@ public: DrapeApiAddLines, DrapeApiRemove, DrapeApiFlush, - AddCustomSymbols, - RemoveCustomSymbols, - UpdateCustomSymbols, + SetCustomFeatures, + RemoveCustomFeatures, + UpdateCustomFeatures, SetPostprocessStaticTextures, SetPosteffectEnabled, RunFirstLaunchAnimation, diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index 950afa949d..7acdf7972f 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -2,7 +2,6 @@ #include "drape_frontend/circles_pack_shape.hpp" #include "drape_frontend/color_constants.hpp" -#include "drape_frontend/custom_symbol.hpp" #include "drape_frontend/drape_api.hpp" #include "drape_frontend/drape_api_builder.hpp" #include "drape_frontend/gps_track_point.hpp" @@ -1110,30 +1109,30 @@ private: TProperties m_properties; }; -class AddCustomSymbolsMessage : public Message +class SetCustomFeaturesMessage : public Message { public: - explicit AddCustomSymbolsMessage(CustomSymbols && symbols) - : m_symbols(std::move(symbols)) + explicit SetCustomFeaturesMessage(std::set<FeatureID> && ids) + : m_features(std::move(ids)) {} - Type GetType() const override { return Message::AddCustomSymbols; } + Type GetType() const override { return Message::SetCustomFeatures; } - CustomSymbols && AcceptSymbols() { return std::move(m_symbols); } + std::set<FeatureID> && AcceptFeatures() { return std::move(m_features); } private: - CustomSymbols m_symbols; + std::set<FeatureID> m_features; }; -class RemoveCustomSymbolsMessage : public Message +class RemoveCustomFeaturesMessage : public Message { public: - RemoveCustomSymbolsMessage() = default; - explicit RemoveCustomSymbolsMessage(MwmSet::MwmId const & mwmId) + RemoveCustomFeaturesMessage() = default; + explicit RemoveCustomFeaturesMessage(MwmSet::MwmId const & mwmId) : m_mwmId(mwmId), m_removeAll(false) {} - Type GetType() const override { return Message::RemoveCustomSymbols; } + Type GetType() const override { return Message::RemoveCustomFeatures; } bool NeedRemoveAll() const { return m_removeAll; } MwmSet::MwmId const & GetMwmId() const { return m_mwmId; } @@ -1142,19 +1141,19 @@ private: bool m_removeAll = true; }; -class UpdateCustomSymbolsMessage : public Message +class UpdateCustomFeaturesMessage : public Message { public: - explicit UpdateCustomSymbolsMessage(std::vector<FeatureID> && symbolsFeatures) - : m_symbolsFeatures(std::move(symbolsFeatures)) + explicit UpdateCustomFeaturesMessage(std::vector<FeatureID> && features) + : m_features(std::move(features)) {} - Type GetType() const override { return Message::UpdateCustomSymbols; } + Type GetType() const override { return Message::UpdateCustomFeatures; } - std::vector<FeatureID> && AcceptSymbolsFeatures() { return std::move(m_symbolsFeatures); } + std::vector<FeatureID> && AcceptFeatures() { return std::move(m_features); } private: - std::vector<FeatureID> m_symbolsFeatures; + std::vector<FeatureID> m_features; }; class SetPostprocessStaticTexturesMessage : public Message diff --git a/drape_frontend/read_manager.cpp b/drape_frontend/read_manager.cpp index 9ed42af240..3b374da994 100755 --- a/drape_frontend/read_manager.cpp +++ b/drape_frontend/read_manager.cpp @@ -221,7 +221,7 @@ void ReadManager::PushTaskBackForTileKey(TileKey const & tileKey, ASSERT(m_pool != nullptr, ()); auto context = make_unique_dp<EngineContext>(TileKey(tileKey, m_generationCounter, m_userMarksGenerationCounter), m_commutator, texMng, metalineMng, - m_customSymbolsContext, + m_customFeaturesContext, m_have3dBuildings && m_allow3dBuildings, m_trafficEnabled, m_displacementMode); std::shared_ptr<TileInfo> tileInfo = std::make_shared<TileInfo>(std::move(context)); @@ -315,35 +315,49 @@ void ReadManager::SetDisplacementMode(int displacementMode) } } -void ReadManager::UpdateCustomSymbols(CustomSymbols const & symbols) +bool ReadManager::SetCustomFeatures(std::set<FeatureID> && ids) { - CustomSymbols currentSymbols = m_customSymbolsContext ? m_customSymbolsContext->m_symbols : - CustomSymbols(); - for (auto const & s : symbols) - currentSymbols[s.first] = s.second; - m_customSymbolsContext = std::make_shared<CustomSymbolsContext>(std::move(currentSymbols)); + size_t const sz = m_customFeaturesContext ? m_customFeaturesContext->m_features.size() : 0; + m_customFeaturesContext = std::make_shared<CustomFeaturesContext>(std::move(ids)); + + return sz != m_customFeaturesContext->m_features.size(); } -void ReadManager::RemoveCustomSymbols(MwmSet::MwmId const & mwmId, std::vector<FeatureID> & leftoverIds) +std::vector<FeatureID> ReadManager::GetCustomFeaturesArray() const { - if (!m_customSymbolsContext) - return; + if (!m_customFeaturesContext) + return {}; + std::vector<FeatureID> features; + features.reserve(m_customFeaturesContext->m_features.size()); + for (auto const & s : m_customFeaturesContext->m_features) + features.push_back(s); + return features; +} + +bool ReadManager::RemoveCustomFeatures(MwmSet::MwmId const & mwmId) +{ + if (!m_customFeaturesContext) + return false; - CustomSymbols currentSymbols; - leftoverIds.reserve(m_customSymbolsContext->m_symbols.size()); - for (auto const & s : m_customSymbolsContext->m_symbols) + std::set<FeatureID> features; + for (auto const & s : m_customFeaturesContext->m_features) { - if (s.first.m_mwmId != mwmId) - { - currentSymbols.insert(std::make_pair(s.first, s.second)); - leftoverIds.push_back(s.first); - } + if (s.m_mwmId != mwmId) + features.insert(s); } - m_customSymbolsContext = std::make_shared<CustomSymbolsContext>(std::move(currentSymbols)); + if (features.size() == m_customFeaturesContext->m_features.size()) + return false; + + m_customFeaturesContext = std::make_shared<CustomFeaturesContext>(std::move(features)); + return true; } -void ReadManager::RemoveAllCustomSymbols() +bool ReadManager::RemoveAllCustomFeatures() { - m_customSymbolsContext = std::make_shared<CustomSymbolsContext>(CustomSymbols()); + if (!m_customFeaturesContext || m_customFeaturesContext->m_features.empty()) + return false; + + m_customFeaturesContext = std::make_shared<CustomFeaturesContext>(std::set<FeatureID>()); + return true; } } // namespace df diff --git a/drape_frontend/read_manager.hpp b/drape_frontend/read_manager.hpp index 759b2a0ece..5cf839a923 100755 --- a/drape_frontend/read_manager.hpp +++ b/drape_frontend/read_manager.hpp @@ -1,6 +1,5 @@ #pragma once -#include "drape_frontend/custom_symbol.hpp" #include "drape_frontend/engine_context.hpp" #include "drape_frontend/read_mwm_task.hpp" #include "drape_frontend/tile_info.hpp" @@ -54,9 +53,10 @@ public: void SetDisplacementMode(int displacementMode); - void UpdateCustomSymbols(CustomSymbols const & symbols); - void RemoveCustomSymbols(MwmSet::MwmId const & mwmId, std::vector<FeatureID> & leftoverIds); - void RemoveAllCustomSymbols(); + bool SetCustomFeatures(std::set<FeatureID> && ids); + std::vector<FeatureID> GetCustomFeaturesArray() const; + bool RemoveCustomFeatures(MwmSet::MwmId const & mwmId); + bool RemoveAllCustomFeatures(); bool IsModeChanged() const { return m_modeChanged; } @@ -99,7 +99,7 @@ private: using TTileInfoCollection = buffer_vector<std::shared_ptr<TileInfo>, 8>; TTilesCollection m_activeTiles; - CustomSymbolsContextPtr m_customSymbolsContext; + CustomFeaturesContextPtr m_customFeaturesContext; void CancelTileInfo(std::shared_ptr<TileInfo> const & tileToCancel); void ClearTileInfo(std::shared_ptr<TileInfo> const & tileToClear); diff --git a/drape_frontend/render_group.cpp b/drape_frontend/render_group.cpp index ed89d6ee55..1e0b32b683 100755 --- a/drape_frontend/render_group.cpp +++ b/drape_frontend/render_group.cpp @@ -161,8 +161,9 @@ bool RenderGroup::IsOverlay() const bool RenderGroup::IsUserMark() const { return m_state.GetDepthLayer() == dp::GLState::UserLineLayer || - m_state.GetDepthLayer() == dp::GLState::UserMarkLayer || - m_state.GetDepthLayer() == dp::GLState::RoutingMarkLayer; + m_state.GetDepthLayer() == dp::GLState::UserMarkLayer || + m_state.GetDepthLayer() == dp::GLState::RoutingMarkLayer || + m_state.GetDepthLayer() == dp::GLState::LocalAdsMarkLayer; } bool RenderGroup::UpdateCanBeDeletedStatus(bool canBeDeleted, int currentZoom, ref_ptr<dp::OverlayTree> tree) diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp index 5555678459..ff22dec0c1 100644 --- a/drape_frontend/rule_drawer.cpp +++ b/drape_frontend/rule_drawer.cpp @@ -173,7 +173,7 @@ RuleDrawer::RuleDrawer(TDrawerCallback const & drawerFn, , m_checkCancelled(checkCancelled) , m_isLoadedFn(isLoadedFn) , m_context(engineContext) - , m_customSymbolsContext(engineContext->GetCustomSymbolsContext().lock()) + , m_customFeaturesContext(engineContext->GetCustomFeaturesContext().lock()) , m_wasCancelled(false) { ASSERT(m_callback != nullptr, ()); @@ -322,7 +322,9 @@ void RuleDrawer::ProcessAreaStyle(FeatureType const & f, Stylist const & s, return; s.ForEachRule(std::bind(&ApplyAreaFeature::ProcessAreaRule, &apply, _1)); - apply.Finish(m_context->GetTextureManager(), m_customSymbolsContext); + + if (!m_customFeaturesContext || !m_customFeaturesContext->Contains(f.GetID())) + apply.Finish(m_context->GetTextureManager()); } void RuleDrawer::ProcessLineStyle(FeatureType const & f, Stylist const & s, @@ -417,6 +419,9 @@ void RuleDrawer::ProcessLineStyle(FeatureType const & f, Stylist const & s, void RuleDrawer::ProcessPointStyle(FeatureType const & f, Stylist const & s, TInsertShapeFn const & insertShape, int & minVisibleScale) { + if (m_customFeaturesContext && m_customFeaturesContext->Contains(f.GetID())) + return; + int const zoomLevel = m_context->GetTileKey().m_zoomLevel; bool const isSpeedCamera = ftypes::IsSpeedCamChecker::Instance()(f); if (isSpeedCamera && !GetStyleReader().IsCarNavigationStyle()) @@ -437,7 +442,7 @@ void RuleDrawer::ProcessPointStyle(FeatureType const & f, Stylist const & s, TIn return; s.ForEachRule(bind(&ApplyPointFeature::ProcessPointRule, &apply, _1)); - apply.Finish(m_context->GetTextureManager(), m_customSymbolsContext); + apply.Finish(m_context->GetTextureManager()); } void RuleDrawer::operator()(FeatureType const & f) diff --git a/drape_frontend/rule_drawer.hpp b/drape_frontend/rule_drawer.hpp index 674540b6bf..7fed3f8284 100644 --- a/drape_frontend/rule_drawer.hpp +++ b/drape_frontend/rule_drawer.hpp @@ -1,6 +1,6 @@ #pragma once -#include "drape_frontend/custom_symbol.hpp" +#include "drape_frontend/custom_features_context.hpp" #include "drape_frontend/map_shape.hpp" #include "drape_frontend/metaline_manager.hpp" #include "drape_frontend/tile_key.hpp" @@ -63,7 +63,7 @@ private: TIsCountryLoadedByNameFn m_isLoadedFn; ref_ptr<EngineContext> m_context; - CustomSymbolsContextPtr m_customSymbolsContext; + CustomFeaturesContextPtr m_customFeaturesContext; std::unordered_set<m2::Spline const *> m_usedMetalines; m2::RectD m_globalRect; diff --git a/drape_frontend/shape_view_params.hpp b/drape_frontend/shape_view_params.hpp index 33aa3df74f..25e6ae09b5 100644 --- a/drape_frontend/shape_view_params.hpp +++ b/drape_frontend/shape_view_params.hpp @@ -45,7 +45,7 @@ struct PoiSymbolViewParams : CommonOverlayViewParams FeatureID m_id; std::string m_symbolName; - uint32_t m_extendingSize; + uint32_t m_extendingSize = 0; float m_posZ = 0.0f; bool m_hasArea = false; bool m_prioritized = false; diff --git a/drape_frontend/tile_info.hpp b/drape_frontend/tile_info.hpp index 2cab45c011..43f245cbc8 100644 --- a/drape_frontend/tile_info.hpp +++ b/drape_frontend/tile_info.hpp @@ -1,6 +1,6 @@ #pragma once -#include "drape_frontend/custom_symbol.hpp" +#include "drape_frontend/custom_features_context.hpp" #include "drape_frontend/engine_context.hpp" #include "drape_frontend/tile_key.hpp" diff --git a/drape_frontend/user_mark_shapes.cpp b/drape_frontend/user_mark_shapes.cpp index 002677f2af..eddb131328 100644 --- a/drape_frontend/user_mark_shapes.cpp +++ b/drape_frontend/user_mark_shapes.cpp @@ -106,14 +106,16 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture m2::PointD const tileCenter = tileKey.GetGlobalRect().Center(); depthLayer = renderInfo.m_depthLayer; - if (renderInfo.m_symbolHasPriority) + if (renderInfo.m_hasSymbolPriority) { - PoiSymbolViewParams params((FeatureID())); + PoiSymbolViewParams params(renderInfo.m_featureId); + params.m_tileCenter = tileCenter; params.m_depth = renderInfo.m_depth; params.m_depthLayer = renderInfo.m_depthLayer; params.m_minVisibleScale = renderInfo.m_minZoom; params.m_specialDisplacement = SpecialDisplacement::UserMark; params.m_specialPriority = renderInfo.m_priority; + params.m_symbolName = renderInfo.m_symbolName; PoiSymbolShape(renderInfo.m_pivot, params, tileKey, 0 /* textIndex */).Draw(&batcher, textures); } @@ -147,12 +149,13 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture if (renderInfo.m_titleDecl != nullptr && !renderInfo.m_titleDecl->m_primaryText.empty()) { TextViewParams params; + params.m_featureID = renderInfo.m_featureId; params.m_tileCenter = tileCenter; params.m_titleDecl = *renderInfo.m_titleDecl; params.m_depth = renderInfo.m_depth; params.m_depthLayer = renderInfo.m_depthLayer; params.m_minVisibleScale = renderInfo.m_minZoom; - if (renderInfo.m_titleHasPriority) + if (renderInfo.m_hasTitlePriority) { params.m_specialDisplacement = SpecialDisplacement::UserMark; params.m_specialPriority = renderInfo.m_priority; @@ -162,9 +165,8 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture textures->GetSymbolRegion(renderInfo.m_symbolName, region); m2::PointF const symbolSize = region.GetPixelSize(); - TextShape(renderInfo.m_pivot, params, tileKey, false /* hasPOI */, - symbolSize, renderInfo.m_anchor, - 0 /* textIndex */).Draw(&batcher, textures); + TextShape(renderInfo.m_pivot, params, tileKey, renderInfo.m_hasSymbolPriority /* hasPOI */, + symbolSize, renderInfo.m_anchor, 0 /* textIndex */).Draw(&batcher, textures); } } diff --git a/drape_frontend/user_mark_shapes.hpp b/drape_frontend/user_mark_shapes.hpp index 8001770111..f1721a88a9 100644 --- a/drape_frontend/user_mark_shapes.hpp +++ b/drape_frontend/user_mark_shapes.hpp @@ -20,13 +20,14 @@ struct UserMarkRenderParams std::string m_symbolName; dp::Anchor m_anchor = dp::Center; drape_ptr<dp::TitleDecl> m_titleDecl; - bool m_symbolHasPriority = false; - bool m_titleHasPriority = false; + bool m_hasSymbolPriority = false; + bool m_hasTitlePriority = false; uint16_t m_priority = 0; float m_depth = 0.0; dp::GLState::DepthLayer m_depthLayer = dp::GLState::UserMarkLayer; bool m_runCreationAnim = false; bool m_isVisible = true; + FeatureID m_featureId; }; struct LineLayer diff --git a/drape_frontend/user_marks_provider.hpp b/drape_frontend/user_marks_provider.hpp index f5f51a412a..6f4105f10e 100644 --- a/drape_frontend/user_marks_provider.hpp +++ b/drape_frontend/user_marks_provider.hpp @@ -4,6 +4,8 @@ #include "drape/glstate.hpp" #include "drape/pointers.hpp" +#include "indexer/feature_decl.hpp" + #include "geometry/polyline2d.hpp" #include "base/mutex.hpp" @@ -34,10 +36,11 @@ public: virtual bool HasCreationAnimation() const = 0; virtual bool IsVisible() const = 0; virtual drape_ptr<dp::TitleDecl> GetTitleDecl() const = 0; - virtual uint16_t GetProirity() const = 0; - virtual bool SymbolHasPriority() const = 0; - virtual bool TitleHasPriority() const = 0; + virtual uint16_t GetPriority() const = 0; + virtual bool HasSymbolPriority() const = 0; + virtual bool HasTitlePriority() const = 0; virtual int GetMinZoom() const = 0; + virtual FeatureID GetFeatureID() const = 0; private: uint32_t m_id; |