diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2017-07-12 14:42:09 +0300 |
---|---|---|
committer | Roman Kuznetsov <r.kuznetsow@gmail.com> | 2017-07-19 11:51:05 +0300 |
commit | 01be5f1c98d7d2c20f42392fdf0425c7d904a4f5 (patch) | |
tree | 8b5e8a171cac61e7204ada88e6c0c479e3aa7781 /drape_frontend | |
parent | 5e5eec4b74b0e34aa4b96366343628d596238927 (diff) |
User marks with overlay and title.
Diffstat (limited to 'drape_frontend')
-rw-r--r-- | drape_frontend/apply_feature_functors.cpp | 28 | ||||
-rw-r--r-- | drape_frontend/colored_symbol_shape.cpp | 4 | ||||
-rw-r--r-- | drape_frontend/drape_engine.cpp | 8 | ||||
-rwxr-xr-x | drape_frontend/frontend_renderer.cpp | 28 | ||||
-rwxr-xr-x | drape_frontend/frontend_renderer.hpp | 44 | ||||
-rw-r--r-- | drape_frontend/path_text_shape.cpp | 4 | ||||
-rw-r--r-- | drape_frontend/poi_symbol_shape.cpp | 7 | ||||
-rw-r--r-- | drape_frontend/shape_view_params.hpp | 11 | ||||
-rw-r--r-- | drape_frontend/text_shape.cpp | 37 | ||||
-rw-r--r-- | drape_frontend/text_shape.hpp | 4 | ||||
-rw-r--r-- | drape_frontend/user_mark_shapes.cpp | 109 | ||||
-rw-r--r-- | drape_frontend/user_mark_shapes.hpp | 6 | ||||
-rw-r--r-- | drape_frontend/user_marks_provider.hpp | 16 |
13 files changed, 210 insertions, 96 deletions
diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp index ff6a0703a0..24f76100e6 100644 --- a/drape_frontend/apply_feature_functors.cpp +++ b/drape_frontend/apply_feature_functors.cpp @@ -599,8 +599,9 @@ void ApplyPointFeature::Finish(ref_ptr<dp::TextureManager> texMng, params.m_hasArea = m_hasArea; params.m_prioritized = prioritized || m_createdByEditor; params.m_obsoleteInEditor = m_obsoleteInEditor; - params.m_specialDisplacementMode = specialDisplacementMode; - params.m_specialModePriority = specialModePriority; + params.m_specialDisplacement = specialDisplacementMode ? SpecialDisplacement::SpecialMode + : SpecialDisplacement::None; + params.m_specialPriority = specialModePriority; m_insertShape(make_unique_dp<PoiSymbolShape>(m_centerPoint, params, m_tileKey, 0 /* text index */)); @@ -611,10 +612,12 @@ void ApplyPointFeature::Finish(ref_ptr<dp::TextureManager> texMng, for (auto textParams : m_textParams) { - textParams.m_specialDisplacementMode = specialDisplacementMode; - textParams.m_specialModePriority = specialModePriority; + textParams.m_specialDisplacement = specialDisplacementMode ? SpecialDisplacement::SpecialMode + : SpecialDisplacement::None; + textParams.m_specialPriority = specialModePriority; m_insertShape(make_unique_dp<TextShape>(m_centerPoint, textParams, m_tileKey, - hasPOI, symbolSize, 0 /* textIndex */)); + hasPOI, symbolSize, + dp::Center /* symbolAnchor */, 0 /* textIndex */)); } } @@ -1080,10 +1083,10 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureMan // Special priority for road shields in navigation style. if (GetStyleReader().IsCarNavigationStyle()) { - textParams.m_specialDisplacementMode = poiParams.m_specialDisplacementMode - = symbolParams.m_specialDisplacementMode = true; - textParams.m_specialModePriority = poiParams.m_specialModePriority - = symbolParams.m_specialModePriority = CalculateNavigationRoadShieldPriority(); + textParams.m_specialDisplacement = poiParams.m_specialDisplacement + = symbolParams.m_specialDisplacement = SpecialDisplacement::SpecialMode; + textParams.m_specialPriority = poiParams.m_specialPriority + = symbolParams.m_specialPriority = CalculateNavigationRoadShieldPriority(); } } @@ -1135,14 +1138,14 @@ void ApplyLineFeatureAdditional::Finish(ref_ptr<dp::TextureManager> texMng, params.m_baseGtoPScale = m_currentScaleGtoP; bool const navigationEnabled = GetStyleReader().IsCarNavigationStyle(); if (navigationEnabled) - params.m_specialDisplacementMode = true; + params.m_specialDisplacement = SpecialDisplacement::SpecialMode; uint32_t textIndex = kPathTextBaseTextIndex; for (auto const & spline : m_clippedSplines) { PathTextViewParams p = params; if (navigationEnabled) - p.m_specialModePriority = CalculateNavigationPathTextPriority(textIndex); + p.m_specialPriority = CalculateNavigationPathTextPriority(textIndex); auto shape = make_unique_dp<PathTextShape>(spline, p, m_tileKey, textIndex); if (!shape->CalculateLayout(texMng)) @@ -1198,7 +1201,8 @@ void ApplyLineFeatureAdditional::Finish(ref_ptr<dp::TextureManager> texMng, continue; m_insertShape(make_unique_dp<TextShape>(shieldPos, textParams, m_tileKey, true /* hasPOI */, - m2::PointF(0.0f, 0.0f) /* symbolSize */, textIndex)); + m2::PointF(0.0f, 0.0f) /* symbolSize */, + dp::Center /* symbolAnchor */, textIndex)); if (IsColoredRoadShield(shield)) m_insertShape(make_unique_dp<ColoredSymbolShape>(shieldPos, symbolParams, m_tileKey, textIndex)); else if (IsSymbolRoadShield(shield)) diff --git a/drape_frontend/colored_symbol_shape.cpp b/drape_frontend/colored_symbol_shape.cpp index 6e491fb75f..9e23d51d2e 100644 --- a/drape_frontend/colored_symbol_shape.cpp +++ b/drape_frontend/colored_symbol_shape.cpp @@ -248,8 +248,8 @@ void ColoredSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, uint64_t ColoredSymbolShape::GetOverlayPriority() const { // Special displacement mode. - if (m_params.m_specialDisplacementMode) - return dp::CalculateSpecialModePriority(m_params.m_specialModePriority); + if (m_params.m_specialDisplacement == SpecialDisplacement::SpecialMode) + return dp::CalculateSpecialModePriority(m_params.m_specialPriority); return dp::CalculateOverlayPriority(m_params.m_minVisibleScale, m_params.m_rank, m_params.m_depth); } diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index 7d35e6a4c6..c06b9f101a 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -222,12 +222,16 @@ void DrapeEngine::UpdateUserMarksLayer(size_t layerId, UserMarksProvider * provi auto renderInfo = make_unique_dp<UserMarkRenderParams>(); renderInfo->m_anchor = mark->GetAnchor(); renderInfo->m_depth = mark->GetDepth(); + renderInfo->m_depthLayer = mark->GetDepthLayer(); + renderInfo->m_minZoom = mark->GetMinZoom(); renderInfo->m_isVisible = mark->IsVisible(); renderInfo->m_pivot = mark->GetPivot(); renderInfo->m_pixelOffset = mark->GetPixelOffset(); 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(); marksRenderCollection->emplace(mark->GetId(), std::move(renderInfo)); mark->AcceptChanges(); @@ -243,13 +247,15 @@ void DrapeEngine::UpdateUserMarksLayer(size_t layerId, UserMarksProvider * provi if (mark->IsDirty()) { auto renderInfo = make_unique_dp<UserLineRenderParams>(); + renderInfo->m_minZoom = mark->GetMinZoom(); + renderInfo->m_depthLayer = mark->GetDepthLayer(); renderInfo->m_spline = m2::SharedSpline(mark->GetPoints()); renderInfo->m_layers.reserve(mark->GetLayerCount()); for (size_t layerIndex = 0, layersCount = mark->GetLayerCount(); layerIndex < layersCount; ++layerIndex) { renderInfo->m_layers.emplace_back(mark->GetColor(layerIndex), mark->GetWidth(layerIndex), - mark->GetLayerDepth(layerIndex)); + mark->GetDepth(layerIndex)); } linesRenderCollection->emplace(mark->GetId(), std::move(renderInfo)); mark->AcceptChanges(); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index b81fe6d85c..77ef951256 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -1136,7 +1136,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView) GLFunctions::glClear(gl_const::GLColorBit | gl_const::GLDepthBit | gl_const::GLStencilBit); Render2dLayer(modelView); - RenderUserLinesLayer(modelView); + RenderUserMarksLayer(modelView, RenderLayer::UserLineID); if (m_buildingsFramebuffer->IsSupported()) { @@ -1186,7 +1186,8 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView) { StencilWriterGuard guard(make_ref(m_postprocessRenderer)); - RenderUserMarksLayer(modelView); + RenderUserMarksLayer(modelView, RenderLayer::UserMarkID); + RenderUserMarksLayer(modelView, RenderLayer::RoutingMarkID); } m_myPositionController->Render(modelView, m_currentZoomLevel, make_ref(m_gpuProgramManager), @@ -1284,9 +1285,9 @@ void FrontendRenderer::RenderTrafficAndRouteLayer(ScreenBase const & modelView) make_ref(m_gpuProgramManager), m_generalUniforms); } -void FrontendRenderer::RenderUserMarksLayer(ScreenBase const & modelView) +void FrontendRenderer::RenderUserMarksLayer(ScreenBase const & modelView, RenderLayer::RenderLayerID layerId) { - auto & renderGroups = m_layers[RenderLayer::UserMarkID].m_renderGroups; + auto & renderGroups = m_layers[layerId].m_renderGroups; if (renderGroups.empty()) return; @@ -1312,7 +1313,8 @@ void FrontendRenderer::RenderUserLinesLayer(ScreenBase const & modelView) void FrontendRenderer::BuildOverlayTree(ScreenBase const & modelView) { static std::vector<RenderLayer::RenderLayerID> layers = {RenderLayer::OverlayID, - RenderLayer::NavigationID}; + RenderLayer::NavigationID, + RenderLayer::RoutingMarkID}; BeginUpdateOverlayTree(modelView); for (auto const & layerId : layers) { @@ -2046,14 +2048,14 @@ void FrontendRenderer::CheckAndRunFirstLaunchAnimation() FrontendRenderer::RenderLayer::RenderLayerID FrontendRenderer::RenderLayer::GetLayerID(dp::GLState const & state) { - if (state.GetDepthLayer() == dp::GLState::OverlayLayer) - return OverlayID; - if (state.GetDepthLayer() == dp::GLState::UserMarkLayer) - return UserMarkID; - if (state.GetDepthLayer() == dp::GLState::UserLineLayer) - return UserLineID; - if (state.GetDepthLayer() == dp::GLState::NavigationLayer) - return NavigationID; + switch (state.GetDepthLayer()) + { + case dp::GLState::OverlayLayer: return OverlayID; + case dp::GLState::UserMarkLayer: return UserMarkID; + case dp::GLState::UserLineLayer: return UserLineID; + case dp::GLState::RoutingMarkLayer: return RoutingMarkID; + case dp::GLState::NavigationLayer: return NavigationID; + } if (state.GetProgram3dIndex() == gpu::AREA_3D_PROGRAM || state.GetProgram3dIndex() == gpu::AREA_3D_OUTLINE_PROGRAM) diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index 4c04e120e0..a7d961ed92 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -145,12 +145,33 @@ private: void RefreshPivotTransform(ScreenBase const & screen); void RefreshBgColor(); + struct RenderLayer + { + enum RenderLayerID + { + Geometry2dID, + UserLineID, + OverlayID, + Geometry3dID, + UserMarkID, + NavigationID, + RoutingMarkID, + LayerCountID + }; + + static RenderLayerID GetLayerID(dp::GLState const & renderGroup); + + std::vector<drape_ptr<RenderGroup>> m_renderGroups; + bool m_isDirty = false; + + void Sort(ref_ptr<dp::OverlayTree> overlayTree); + }; // Render part of scene void Render2dLayer(ScreenBase const & modelView); void Render3dLayer(ScreenBase const & modelView, bool useFramebuffer); void RenderOverlayLayer(ScreenBase const & modelView); void RenderNavigationOverlayLayer(ScreenBase const & modelView); - void RenderUserMarksLayer(ScreenBase const & modelView); + void RenderUserMarksLayer(ScreenBase const & modelView, RenderLayer::RenderLayerID layerId); void RenderUserLinesLayer(ScreenBase const & modelView); void RenderTrafficAndRouteLayer(ScreenBase const & modelView); @@ -235,27 +256,6 @@ private: drape_ptr<dp::GpuProgramManager> m_gpuProgramManager; - struct RenderLayer - { - enum RenderLayerID - { - Geometry2dID, - UserLineID, - OverlayID, - Geometry3dID, - UserMarkID, - NavigationID, - LayerCountID - }; - - static RenderLayerID GetLayerID(dp::GLState const & renderGroup); - - std::vector<drape_ptr<RenderGroup>> m_renderGroups; - bool m_isDirty = false; - - void Sort(ref_ptr<dp::OverlayTree> overlayTree); - }; - std::array<RenderLayer, RenderLayer::LayerCountID> m_layers; drape_ptr<gui::LayerRenderer> m_guiRenderer; diff --git a/drape_frontend/path_text_shape.cpp b/drape_frontend/path_text_shape.cpp index baf1701939..7271484017 100644 --- a/drape_frontend/path_text_shape.cpp +++ b/drape_frontend/path_text_shape.cpp @@ -246,8 +246,8 @@ uint64_t PathTextShape::GetOverlayPriority(uint32_t textIndex, size_t textLength // [6 bytes - standard overlay priority][1 byte - length][1 byte - path text index]. // Special displacement mode. - if (m_params.m_specialDisplacementMode) - return dp::CalculateSpecialModePriority(m_params.m_specialModePriority); + if (m_params.m_specialDisplacement == SpecialDisplacement::SpecialMode) + return dp::CalculateSpecialModePriority(m_params.m_specialPriority); static uint64_t constexpr kMask = ~static_cast<uint64_t>(0xFFFF); uint64_t priority = dp::CalculateOverlayPriority(m_params.m_minVisibleScale, m_params.m_rank, diff --git a/drape_frontend/poi_symbol_shape.cpp b/drape_frontend/poi_symbol_shape.cpp index 7aaee945e2..a292acf5d0 100644 --- a/drape_frontend/poi_symbol_shape.cpp +++ b/drape_frontend/poi_symbol_shape.cpp @@ -165,8 +165,11 @@ uint64_t PoiSymbolShape::GetOverlayPriority() const return dp::kPriorityMaskAll; // Special displacement mode. - if (m_params.m_specialDisplacementMode) - return dp::CalculateSpecialModePriority(m_params.m_specialModePriority); + if (m_params.m_specialDisplacement == SpecialDisplacement::SpecialMode) + return dp::CalculateSpecialModePriority(m_params.m_specialPriority); + + if (m_params.m_specialDisplacement == SpecialDisplacement::UserMark) + return dp::CalculateUserMarkPriority(m_params.m_minVisibleScale, m_params.m_specialPriority); // Set up minimal priority for shapes which belong to areas. if (m_params.m_hasArea) diff --git a/drape_frontend/shape_view_params.hpp b/drape_frontend/shape_view_params.hpp index 4b9b85f364..33aa3df74f 100644 --- a/drape_frontend/shape_view_params.hpp +++ b/drape_frontend/shape_view_params.hpp @@ -26,10 +26,17 @@ struct CommonViewParams m2::PointD m_tileCenter; }; +enum class SpecialDisplacement +{ + None, + SpecialMode, + UserMark +}; + struct CommonOverlayViewParams : public CommonViewParams { - bool m_specialDisplacementMode = false; - uint16_t m_specialModePriority = std::numeric_limits<uint16_t>::max();; + SpecialDisplacement m_specialDisplacement = SpecialDisplacement::None; + uint16_t m_specialPriority = std::numeric_limits<uint16_t>::max(); }; struct PoiSymbolViewParams : CommonOverlayViewParams diff --git a/drape_frontend/text_shape.cpp b/drape_frontend/text_shape.cpp index 030ccfb56f..4856d8f1d7 100644 --- a/drape_frontend/text_shape.cpp +++ b/drape_frontend/text_shape.cpp @@ -110,13 +110,15 @@ private: } // namespace TextShape::TextShape(m2::PointD const & basePoint, TextViewParams const & params, - TileKey const & tileKey, bool hasPOI, m2::PointF const & symbolSize, + TileKey const & tileKey, bool hasPOI, + m2::PointF const & symbolSize, dp::Anchor symbolAnchor, uint32_t textIndex) : m_basePoint(basePoint) , m_params(params) , m_tileCoords(tileKey.GetTileCoords()) , m_hasPOI(hasPOI) , m_symbolSize(symbolSize) + , m_symbolAnchor(symbolAnchor) , m_textIndex(textIndex) {} @@ -199,6 +201,32 @@ void TextShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> t secondaryOffset.x = primaryOffset.x; } + if (m_symbolAnchor & dp::Top) + { + primaryOffset.y += halfSymbolH; + if (secondaryLayout != nullptr) + secondaryOffset.y += halfSymbolH; + } + else if (m_symbolAnchor & dp::Bottom) + { + primaryOffset.y -= halfSymbolH; + if (secondaryLayout != nullptr) + secondaryOffset.y -= halfSymbolH; + } + + if (m_symbolAnchor & dp::Left) + { + primaryOffset.x += halfSymbolW; + if (secondaryLayout != nullptr) + secondaryOffset.x += halfSymbolW; + } + else if (m_symbolAnchor & dp::Right) + { + primaryOffset.x -= halfSymbolW; + if (secondaryLayout != nullptr) + secondaryOffset.x -= halfSymbolW; + } + if (primaryLayout.GetGlyphCount() > 0) { DrawSubString(primaryLayout, titleDecl.m_primaryTextFont, primaryOffset, batcher, @@ -337,8 +365,11 @@ uint64_t TextShape::GetOverlayPriority() const return dp::kPriorityMaskAll; // Special displacement mode. - if (m_params.m_specialDisplacementMode) - return dp::CalculateSpecialModePriority(m_params.m_specialModePriority); + if (m_params.m_specialDisplacement == SpecialDisplacement::SpecialMode) + return dp::CalculateSpecialModePriority(m_params.m_specialPriority); + + if (m_params.m_specialDisplacement == SpecialDisplacement::UserMark) + return dp::CalculateUserMarkPriority(m_params.m_minVisibleScale, m_params.m_specialPriority); // Set up minimal priority for shapes which belong to areas if (m_params.m_hasArea) diff --git a/drape_frontend/text_shape.hpp b/drape_frontend/text_shape.hpp index e5176e5e3d..f520dcd783 100644 --- a/drape_frontend/text_shape.hpp +++ b/drape_frontend/text_shape.hpp @@ -16,7 +16,8 @@ class TextShape : public MapShape { public: TextShape(m2::PointD const & basePoint, TextViewParams const & params, - TileKey const & tileKey, bool hasPOI, m2::PointF const & symbolSize, uint32_t textIndex); + TileKey const & tileKey, bool hasPOI, m2::PointF const & symbolSize, + dp::Anchor symbolAnchor, uint32_t textIndex); void Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const override; MapShapeType GetType() const override { return MapShapeType::OverlayType; } @@ -43,6 +44,7 @@ private: m2::PointI m_tileCoords; bool m_hasPOI; m2::PointF m_symbolSize; + dp::Anchor m_symbolAnchor; uint32_t m_textIndex; bool m_disableDisplacing = false; diff --git a/drape_frontend/user_mark_shapes.cpp b/drape_frontend/user_mark_shapes.cpp index c3df07d4c9..364de5dc73 100644 --- a/drape_frontend/user_mark_shapes.cpp +++ b/drape_frontend/user_mark_shapes.cpp @@ -2,8 +2,10 @@ #include "drape_frontend/line_shape.hpp" #include "drape_frontend/map_shape.hpp" +#include "drape_frontend/poi_symbol_shape.hpp" #include "drape_frontend/shader_def.hpp" #include "drape_frontend/shape_view_params.hpp" +#include "drape_frontend/text_shape.hpp" #include "drape_frontend/tile_utils.hpp" #include "drape_frontend/visual_params.hpp" @@ -11,6 +13,8 @@ #include "drape/attribute_provider.hpp" #include "drape/batcher.hpp" +#include "indexer/feature_decl.hpp" + #include "geometry/clipping.hpp" namespace df @@ -87,9 +91,9 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture using UPV = UserPointVertex; uint32_t const vertexCount = static_cast<uint32_t>(marksId.size()) * dp::Batcher::VertexPerQuad; buffer_vector<UPV, 128> buffer; - buffer.reserve(vertexCount); dp::TextureManager::SymbolRegion region; + dp::GLState::DepthLayer depthLayer = dp::GLState::UserMarkLayer; for (auto const id : marksId) { auto const it = renderParams.find(id); @@ -99,38 +103,83 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture if (!renderInfo.m_isVisible) continue; - textures->GetSymbolRegion(renderInfo.m_symbolName, region); - m2::RectF const & texRect = region.GetTexRect(); - m2::PointF const pxSize = region.GetPixelSize(); - dp::Anchor const anchor = renderInfo.m_anchor; - m2::PointD const pt = MapShape::ConvertToLocal(renderInfo.m_pivot, tileKey.GetGlobalRect().Center(), - kShapeCoordScalar); - glsl::vec3 const pos = glsl::vec3(glsl::ToVec2(pt), renderInfo.m_depth); - bool const runAnim = renderInfo.m_runCreationAnim; - renderInfo.m_runCreationAnim = false; - - glsl::vec2 left, right, up, down; - AlignHorizontal(pxSize.x * 0.5f, anchor, left, right); - AlignVertical(pxSize.y * 0.5f, anchor, up, down); - - m2::PointD const pixelOffset = renderInfo.m_pixelOffset; - glsl::vec2 const offset(pixelOffset.x, pixelOffset.y); - - buffer.emplace_back(pos, left + down + offset, glsl::ToVec2(texRect.LeftTop()), runAnim); - buffer.emplace_back(pos, left + up + offset, glsl::ToVec2(texRect.LeftBottom()), runAnim); - buffer.emplace_back(pos, right + down + offset, glsl::ToVec2(texRect.RightTop()), runAnim); - buffer.emplace_back(pos, right + up + offset, glsl::ToVec2(texRect.RightBottom()), runAnim); + m2::PointD const tileCenter = tileKey.GetGlobalRect().Center(); + depthLayer = renderInfo.m_depthLayer; + + if (renderInfo.m_symbolHasPriority) + { + PoiSymbolViewParams params((FeatureID())); + 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; + PoiSymbolShape(renderInfo.m_pivot, params, tileKey, + 0 /* textIndex */).Draw(&batcher, textures); + } + else + { + buffer.reserve(vertexCount); + + textures->GetSymbolRegion(renderInfo.m_symbolName, region); + m2::RectF const & texRect = region.GetTexRect(); + m2::PointF const pxSize = region.GetPixelSize(); + dp::Anchor const anchor = renderInfo.m_anchor; + m2::PointD const pt = MapShape::ConvertToLocal(renderInfo.m_pivot, tileCenter, + kShapeCoordScalar); + glsl::vec3 const pos = glsl::vec3(glsl::ToVec2(pt), renderInfo.m_depth); + bool const runAnim = renderInfo.m_runCreationAnim; + renderInfo.m_runCreationAnim = false; + + glsl::vec2 left, right, up, down; + AlignHorizontal(pxSize.x * 0.5f, anchor, left, right); + AlignVertical(pxSize.y * 0.5f, anchor, up, down); + + m2::PointD const pixelOffset = renderInfo.m_pixelOffset; + glsl::vec2 const offset(pixelOffset.x, pixelOffset.y); + + buffer.emplace_back(pos, left + down + offset, glsl::ToVec2(texRect.LeftTop()), runAnim); + buffer.emplace_back(pos, left + up + offset, glsl::ToVec2(texRect.LeftBottom()), runAnim); + buffer.emplace_back(pos, right + down + offset, glsl::ToVec2(texRect.RightTop()), runAnim); + buffer.emplace_back(pos, right + up + offset, glsl::ToVec2(texRect.RightBottom()), runAnim); + } + + if (renderInfo.m_titleDecl != nullptr && !renderInfo.m_titleDecl->m_primaryText.empty()) + { + TextViewParams params; + 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) + { + params.m_specialDisplacement = SpecialDisplacement::UserMark; + params.m_specialPriority = renderInfo.m_priority; + } + + dp::TextureManager::SymbolRegion region; + 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); + } } - dp::GLState state(gpu::BOOKMARK_PROGRAM, dp::GLState::UserMarkLayer); - state.SetProgram3dIndex(gpu::BOOKMARK_BILLBOARD_PROGRAM); - state.SetColorTexture(region.GetTexture()); - state.SetTextureFilter(gl_const::GLNearest); + if (!buffer.empty()) + { + dp::GLState state(gpu::BOOKMARK_PROGRAM, depthLayer); + state.SetProgram3dIndex(gpu::BOOKMARK_BILLBOARD_PROGRAM); + state.SetColorTexture(region.GetTexture()); + state.SetTextureFilter(gl_const::GLNearest); - dp::AttributeProvider attribProvider(1, static_cast<uint32_t>(buffer.size())); - attribProvider.InitStream(0, UPV::GetBinding(), make_ref(buffer.data())); + dp::AttributeProvider attribProvider(1, static_cast<uint32_t>(buffer.size())); + attribProvider.InitStream(0, UPV::GetBinding(), make_ref(buffer.data())); - batcher.InsertListOfStrip(state, make_ref(&attribProvider), dp::Batcher::VertexPerQuad); + batcher.InsertListOfStrip(state, make_ref(&attribProvider), dp::Batcher::VertexPerQuad); + } } void CacheUserLines(TileKey const & tileKey, ref_ptr<dp::TextureManager> textures, @@ -188,7 +237,7 @@ void CacheUserLines(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture params.m_join = dp::RoundJoin; params.m_color = layer.m_color; params.m_depth = layer.m_depth; - params.m_depthLayer = dp::GLState::UserLineLayer; + params.m_depthLayer = renderInfo.m_depthLayer; params.m_width = layer.m_width * vs; params.m_minVisibleScale = 1; params.m_rank = 0; diff --git a/drape_frontend/user_mark_shapes.hpp b/drape_frontend/user_mark_shapes.hpp index 92ad10fafc..8001770111 100644 --- a/drape_frontend/user_mark_shapes.hpp +++ b/drape_frontend/user_mark_shapes.hpp @@ -20,8 +20,11 @@ struct UserMarkRenderParams std::string m_symbolName; dp::Anchor m_anchor = dp::Center; drape_ptr<dp::TitleDecl> m_titleDecl; - uint16_t m_priority; + bool m_symbolHasPriority = false; + bool m_titleHasPriority = 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; }; @@ -43,6 +46,7 @@ struct LineLayer struct UserLineRenderParams { int m_minZoom = 1; + dp::GLState::DepthLayer m_depthLayer = dp::GLState::UserLineLayer; std::vector<LineLayer> m_layers; m2::SharedSpline m_spline; }; diff --git a/drape_frontend/user_marks_provider.hpp b/drape_frontend/user_marks_provider.hpp index dd3e5716b5..f5f51a412a 100644 --- a/drape_frontend/user_marks_provider.hpp +++ b/drape_frontend/user_marks_provider.hpp @@ -1,6 +1,7 @@ #pragma once #include "drape/drape_global.hpp" +#include "drape/glstate.hpp" #include "drape/pointers.hpp" #include "geometry/polyline2d.hpp" @@ -29,11 +30,14 @@ public: virtual std::string GetSymbolName() const = 0; virtual dp::Anchor GetAnchor() const = 0; virtual float GetDepth() const = 0; + virtual dp::GLState::DepthLayer GetDepthLayer() const = 0; virtual bool HasCreationAnimation() const = 0; - virtual bool IsVisible() const { return true; } - - virtual drape_ptr<dp::TitleDecl> GetTitleDecl() const { return nullptr; } - virtual uint16_t GetProirity() const { return 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 int GetMinZoom() const = 0; private: uint32_t m_id; @@ -50,10 +54,12 @@ public: virtual uint32_t GetId() const { return m_id; } + virtual int GetMinZoom() const = 0; + virtual dp::GLState::DepthLayer GetDepthLayer() const = 0; virtual size_t GetLayerCount() const = 0; virtual dp::Color const & GetColor(size_t layerIndex) const = 0; virtual float GetWidth(size_t layerIndex) const = 0; - virtual float GetLayerDepth(size_t layerIndex) const = 0; + virtual float GetDepth(size_t layerIndex) const = 0; virtual std::vector<m2::PointD> const & GetPoints() const = 0; private: |