Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2017-05-26 13:13:03 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2017-05-26 15:23:01 +0300
commita5eb151f55d0ae7f266a2b9c4c858301a261b109 (patch)
tree0961fad8dd1c9902d31b3d024b6670bce180f293
parent849121e71f5c227370531b39017a9dc1f0363200 (diff)
Refactored ReadManager and displacement modes
-rw-r--r--drape/constants.hpp14
-rw-r--r--drape/overlay_handle.cpp1
-rw-r--r--drape/overlay_handle.hpp4
-rw-r--r--drape/overlay_tree.cpp11
-rw-r--r--drape/overlay_tree.hpp2
-rw-r--r--drape_frontend/apply_feature_functors.cpp60
-rw-r--r--drape_frontend/apply_feature_functors.hpp8
-rw-r--r--drape_frontend/backend_renderer.cpp13
-rw-r--r--drape_frontend/colored_symbol_shape.cpp7
-rw-r--r--drape_frontend/colored_symbol_shape.hpp5
-rw-r--r--drape_frontend/drape_engine.cpp2
-rw-r--r--drape_frontend/engine_context.cpp13
-rw-r--r--drape_frontend/engine_context.hpp24
-rwxr-xr-xdrape_frontend/frontend_renderer.cpp8
-rw-r--r--drape_frontend/poi_symbol_shape.cpp7
-rw-r--r--drape_frontend/poi_symbol_shape.hpp5
-rwxr-xr-xdrape_frontend/read_manager.cpp116
-rwxr-xr-xdrape_frontend/read_manager.hpp34
-rw-r--r--drape_frontend/rule_drawer.cpp140
-rw-r--r--drape_frontend/rule_drawer.hpp28
-rw-r--r--drape_frontend/text_shape.cpp15
-rw-r--r--drape_frontend/text_shape.hpp12
-rw-r--r--drape_frontend/tile_info.cpp33
-rw-r--r--drape_frontend/tile_info.hpp30
24 files changed, 297 insertions, 295 deletions
diff --git a/drape/constants.hpp b/drape/constants.hpp
index 5cbe4d88db..1d1e463c62 100644
--- a/drape/constants.hpp
+++ b/drape/constants.hpp
@@ -4,23 +4,15 @@
namespace dp
{
-
namespace depth
{
-
float constexpr POSITION_ACCURACY = minDepth + 1.0f;
float constexpr MY_POSITION_MARK = maxDepth - 1.0f;
-
-} // namespace depth
+} // namespace depth
namespace displacement
{
-
int constexpr kDefaultMode = 0x1;
int constexpr kHotelMode = 0x2;
-
-int constexpr kAllModes = kDefaultMode | kHotelMode;
-
-} // namespace displacement
-
-} // namespace dp
+} // namespace displacement
+} // namespace dp
diff --git a/drape/overlay_handle.cpp b/drape/overlay_handle.cpp
index 5fde690748..3dc72915c5 100644
--- a/drape/overlay_handle.cpp
+++ b/drape/overlay_handle.cpp
@@ -34,7 +34,6 @@ OverlayHandle::OverlayHandle(OverlayID const & id, dp::Anchor anchor,
, m_pivotZ(0.0)
, m_isBillboard(isBillboard)
, m_isVisible(false)
- , m_displacementMode(displacement::kAllModes)
, m_enableCaching(false)
, m_extendedShapeDirty(true)
, m_extendedRectDirty(true)
diff --git a/drape/overlay_handle.hpp b/drape/overlay_handle.hpp
index 67b6419714..762f63aeb4 100644
--- a/drape/overlay_handle.hpp
+++ b/drape/overlay_handle.hpp
@@ -141,9 +141,6 @@ public:
void SetCachingEnable(bool enable);
- int GetDisplacementMode() const { return m_displacementMode; }
- void SetDisplacementMode(int mode) { m_displacementMode = mode; }
-
#ifdef DEBUG_OVERLAYS_OUTPUT
virtual string GetOverlayDebugInfo() { return ""; }
#endif
@@ -166,7 +163,6 @@ protected:
private:
bool const m_isBillboard;
bool m_isVisible;
- int m_displacementMode;
dp::IndexStorage m_indexes;
struct LessOffsetNode
diff --git a/drape/overlay_tree.cpp b/drape/overlay_tree.cpp
index 825946a300..5937d32b79 100644
--- a/drape/overlay_tree.cpp
+++ b/drape/overlay_tree.cpp
@@ -65,7 +65,6 @@ OverlayTree::OverlayTree()
: m_frameCounter(kInvalidFrame)
, m_followingMode(false)
, m_isDisplacementEnabled(true)
- , m_displacementMode(displacement::kDefaultMode)
{
for (size_t i = 0; i < m_handles.size(); i++)
m_handles[i].reserve(kAverageHandlesCount[i]);
@@ -118,10 +117,6 @@ void OverlayTree::Add(ref_ptr<OverlayHandle> handle)
handle->SetIsVisible(false);
handle->SetCachingEnable(true);
- // Skip overlays from another displacement mode.
- if ((handle->GetDisplacementMode() & m_displacementMode) == 0)
- return;
-
// Skip duplicates.
if (m_handlesCache.find(handle) != m_handlesCache.end())
return;
@@ -450,12 +445,6 @@ void OverlayTree::SetDisplacementEnabled(bool enabled)
m_frameCounter = kInvalidFrame;
}
-void OverlayTree::SetDisplacementMode(int displacementMode)
-{
- m_displacementMode = displacementMode;
- m_frameCounter = kInvalidFrame;
-}
-
void OverlayTree::SetSelectedFeature(FeatureID const & featureID)
{
m_selectedFeatureID = featureID;
diff --git a/drape/overlay_tree.hpp b/drape/overlay_tree.hpp
index e40bd7e419..30db970360 100644
--- a/drape/overlay_tree.hpp
+++ b/drape/overlay_tree.hpp
@@ -66,7 +66,6 @@ public:
void SetFollowingMode(bool mode);
void SetDisplacementEnabled(bool enabled);
- void SetDisplacementMode(int displacementMode);
void SetSelectedFeature(FeatureID const & featureID);
bool GetSelectedFeatureRect(ScreenBase const & screen, m2::RectD & featureRect);
@@ -102,7 +101,6 @@ private:
bool m_followingMode;
bool m_isDisplacementEnabled;
- int m_displacementMode;
FeatureID m_selectedFeatureID;
diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp
index 5019b68a33..6de6d5d37c 100644
--- a/drape_frontend/apply_feature_functors.cpp
+++ b/drape_frontend/apply_feature_functors.cpp
@@ -392,9 +392,10 @@ void BaseApplyFeature::SetHotelData(HotelData && hotelData)
m_hotelData = move(hotelData);
}
-ApplyPointFeature::ApplyPointFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureID const & id,
- int minVisibleScale, uint8_t rank, CaptionDescription const & captions,
- float posZ)
+ApplyPointFeature::ApplyPointFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape,
+ FeatureID const & id, int minVisibleScale, uint8_t rank,
+ CaptionDescription const & captions, float posZ,
+ int displacementMode)
: TBase(tileKey, insertShape, id, minVisibleScale, rank, captions)
, m_posZ(posZ)
, m_hasPoint(false)
@@ -403,8 +404,8 @@ ApplyPointFeature::ApplyPointFeature(TileKey const & tileKey, TInsertShapeFn con
, m_obsoleteInEditor(false)
, m_symbolDepth(dp::minDepth)
, m_symbolRule(nullptr)
-{
-}
+ , m_displacementMode(displacementMode)
+{}
void ApplyPointFeature::operator()(m2::PointD const & point, bool hasArea)
{
@@ -445,31 +446,30 @@ void ApplyPointFeature::ProcessRule(Stylist::TRuleWrapper const & rule)
params.m_posZ = m_posZ;
params.m_hasArea = m_hasArea;
params.m_createdByEditor = m_createdByEditor;
- if (!params.m_primaryText.empty() || !params.m_secondaryText.empty())
- {
- int displacementMode = dp::displacement::kAllModes;
- // For hotels we set only kDefaultMode, because we have a special shape
- // for kHotelMode and this shape will not be displayed in this case.
- if (m_hotelData.m_isHotel)
- displacementMode = dp::displacement::kDefaultMode;
- m_insertShape(make_unique_dp<TextShape>(m_centerPoint, params, m_tileKey,
- hasPOI, 0 /* textIndex */,
- true /* affectedByZoomPriority */,
- displacementMode));
- }
- if (m_hotelData.m_isHotel && !params.m_primaryText.empty())
+
+ bool specialDisplacementMode = false;
+ uint16_t specialModePriority = 0;
+ if (m_displacementMode == dp::displacement::kHotelMode &&
+ m_hotelData.m_isHotel && !params.m_primaryText.empty())
{
+ specialDisplacementMode = true;
+ specialModePriority = CalculateHotelOverlayPriority(m_hotelData);
+
params.m_primaryOptional = false;
params.m_primaryTextFont.m_size *= 1.2;
params.m_primaryTextFont.m_outlineColor = df::GetColorConstant(df::kPoiHotelTextOutlineColor);
params.m_secondaryTextFont = params.m_primaryTextFont;
params.m_secondaryText = ExtractHotelInfo();
params.m_secondaryOptional = false;
- uint16_t const priority = CalculateHotelOverlayPriority(m_hotelData);
+
+ }
+
+ if (!params.m_primaryText.empty() || !params.m_secondaryText.empty())
+ {
m_insertShape(make_unique_dp<TextShape>(m_centerPoint, params, m_tileKey,
hasPOI, 0 /* textIndex */,
true /* affectedByZoomPriority */,
- dp::displacement::kHotelMode, priority));
+ specialDisplacementMode, specialModePriority));
}
}
}
@@ -505,22 +505,23 @@ void ApplyPointFeature::Finish(CustomSymbolsContextPtr const & customSymbolsCont
params.m_prioritized = prioritized || m_createdByEditor;
params.m_obsoleteInEditor = m_obsoleteInEditor;
- m_insertShape(make_unique_dp<PoiSymbolShape>(m_centerPoint, params, m_tileKey, 0 /* text index */,
- m_hotelData.m_isHotel ? dp::displacement::kDefaultMode :
- dp::displacement::kAllModes));
- if (m_hotelData.m_isHotel)
+ bool specialDisplacementMode = false;
+ uint16_t specialModePriority = 0;
+ if (m_displacementMode == dp::displacement::kHotelMode && m_hotelData.m_isHotel)
{
- uint16_t const priority = CalculateHotelOverlayPriority(m_hotelData);
- m_insertShape(make_unique_dp<PoiSymbolShape>(m_centerPoint, params, m_tileKey, 0 /* text index */,
- dp::displacement::kHotelMode, priority));
+ specialDisplacementMode = true;
+ specialModePriority = CalculateHotelOverlayPriority(m_hotelData);
}
+
+ m_insertShape(make_unique_dp<PoiSymbolShape>(m_centerPoint, params, m_tileKey, 0 /* text index */,
+ specialDisplacementMode, specialModePriority));
}
ApplyAreaFeature::ApplyAreaFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape,
FeatureID const & id, double currentScaleGtoP, bool isBuilding,
bool skipAreaGeometry, float minPosZ, float posZ, int minVisibleScale,
uint8_t rank, CaptionDescription const & captions, bool hatchingArea)
- : TBase(tileKey, insertShape, id, minVisibleScale, rank, captions, posZ)
+ : TBase(tileKey, insertShape, id, minVisibleScale, rank, captions, posZ, dp::displacement::kDefaultMode)
, m_minPosZ(minPosZ)
, m_isBuilding(isBuilding)
, m_skipAreaGeometry(skipAreaGeometry)
@@ -621,7 +622,8 @@ bool ApplyAreaFeature::FindEdge(TEdge const & edge)
return false;
}
-m2::PointD ApplyAreaFeature::CalculateNormal(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3) const
+m2::PointD ApplyAreaFeature::CalculateNormal(m2::PointD const & p1, m2::PointD const & p2,
+ m2::PointD const & p3) const
{
m2::PointD const tangent = (p2 - p1).Normalize();
m2::PointD normal = m2::PointD(-tangent.y, tangent.x);
diff --git a/drape_frontend/apply_feature_functors.hpp b/drape_frontend/apply_feature_functors.hpp
index ecfe345ec0..7d6de97ac7 100644
--- a/drape_frontend/apply_feature_functors.hpp
+++ b/drape_frontend/apply_feature_functors.hpp
@@ -77,9 +77,10 @@ class ApplyPointFeature : public BaseApplyFeature
using TBase = BaseApplyFeature;
public:
- ApplyPointFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureID const & id,
- int minVisibleScale, uint8_t rank, CaptionDescription const & captions,
- float posZ);
+ ApplyPointFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape,
+ FeatureID const & id, int minVisibleScale, uint8_t rank,
+ CaptionDescription const & captions, float posZ,
+ int displacementMode);
void operator()(m2::PointD const & point, bool hasArea);
void ProcessRule(Stylist::TRuleWrapper const & rule);
@@ -96,6 +97,7 @@ private:
double m_symbolDepth;
SymbolRuleProto const * m_symbolRule;
m2::PointF m_centerPoint;
+ int m_displacementMode;
};
class ApplyAreaFeature : public ApplyPointFeature
diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp
index edc94f2874..58aece281c 100644
--- a/drape_frontend/backend_renderer.cpp
+++ b/drape_frontend/backend_renderer.cpp
@@ -456,6 +456,19 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
break;
}
+ case Message::SetDisplacementMode:
+ {
+ ref_ptr<SetDisplacementModeMessage> msg = message;
+ m_readManager->SetDisplacementMode(msg->GetMode());
+ if (m_readManager->IsModeChanged())
+ {
+ m_commutator->PostMessage(ThreadsCommutator::RenderThread,
+ make_unique_dp<SetDisplacementModeMessage>(msg->GetMode()),
+ MessagePriority::Normal);
+ }
+ break;
+ }
+
default:
ASSERT(false, ());
break;
diff --git a/drape_frontend/colored_symbol_shape.cpp b/drape_frontend/colored_symbol_shape.cpp
index b29f6184e6..05ca606c67 100644
--- a/drape_frontend/colored_symbol_shape.cpp
+++ b/drape_frontend/colored_symbol_shape.cpp
@@ -16,13 +16,13 @@ namespace df
ColoredSymbolShape::ColoredSymbolShape(m2::PointD const & mercatorPt, ColoredSymbolViewParams const & params,
TileKey const & tileKey, uint32_t textIndex, bool needOverlay,
- int displacementMode, uint16_t specialModePriority)
+ bool specialDisplacementMode, uint16_t specialModePriority)
: m_point(mercatorPt)
, m_params(params)
, m_tileCoords(tileKey.GetTileCoords())
, m_textIndex(textIndex)
, m_needOverlay(needOverlay)
- , m_displacementMode(displacementMode)
+ , m_specialDisplacementMode(specialDisplacementMode)
, m_specialModePriority(specialModePriority)
{}
@@ -217,10 +217,9 @@ void ColoredSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureM
uint64_t ColoredSymbolShape::GetOverlayPriority() const
{
// Special displacement mode.
- if ((m_displacementMode & dp::displacement::kDefaultMode) == 0)
+ if (m_specialDisplacementMode)
return dp::CalculateSpecialModePriority(m_specialModePriority);
return dp::CalculateOverlayPriority(m_params.m_minVisibleScale, m_params.m_rank, m_params.m_depth);
}
-
} // namespace df
diff --git a/drape_frontend/colored_symbol_shape.hpp b/drape_frontend/colored_symbol_shape.hpp
index 2f93323fe0..ca18049f51 100644
--- a/drape_frontend/colored_symbol_shape.hpp
+++ b/drape_frontend/colored_symbol_shape.hpp
@@ -13,8 +13,7 @@ class ColoredSymbolShape : public MapShape
public:
ColoredSymbolShape(m2::PointD const & mercatorPt, ColoredSymbolViewParams const & params,
TileKey const & tileKey, uint32_t textIndex, bool needOverlay = true,
- int displacementMode = dp::displacement::kAllModes,
- uint16_t specialModePriority = 0xFFFF);
+ bool specialDisplacementMode = false, uint16_t specialModePriority = 0xFFFF);
void Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const override;
MapShapeType GetType() const override { return MapShapeType::OverlayType; }
@@ -26,7 +25,7 @@ private:
m2::PointI const m_tileCoords;
uint32_t const m_textIndex;
bool const m_needOverlay;
- int const m_displacementMode;
+ bool const m_specialDisplacementMode;
uint16_t const m_specialModePriority;
};
diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp
index c95d101565..2faa9eea32 100644
--- a/drape_frontend/drape_engine.cpp
+++ b/drape_frontend/drape_engine.cpp
@@ -551,7 +551,7 @@ void DrapeEngine::SetTimeInBackground(double time)
void DrapeEngine::SetDisplacementMode(int mode)
{
- m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
+ m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
make_unique_dp<SetDisplacementModeMessage>(mode),
MessagePriority::Normal);
}
diff --git a/drape_frontend/engine_context.cpp b/drape_frontend/engine_context.cpp
index 63452369c4..5d3237a3aa 100644
--- a/drape_frontend/engine_context.cpp
+++ b/drape_frontend/engine_context.cpp
@@ -8,11 +8,20 @@
namespace df
{
-EngineContext::EngineContext(TileKey tileKey, ref_ptr<ThreadsCommutator> commutator,
- ref_ptr<dp::TextureManager> texMng)
+EngineContext::EngineContext(TileKey tileKey,
+ ref_ptr<ThreadsCommutator> commutator,
+ ref_ptr<dp::TextureManager> texMng,
+ CustomSymbolsContextWeakPtr customSymbolsContext,
+ bool is3dBuildingsEnabled,
+ bool isTrafficEnabled,
+ int displacementMode)
: m_tileKey(tileKey)
, m_commutator(commutator)
, m_texMng(texMng)
+ , m_customSymbolsContext(customSymbolsContext)
+ , m_3dBuildingsEnabled(is3dBuildingsEnabled)
+ , m_trafficEnabled(isTrafficEnabled)
+ , m_displacementMode(displacementMode)
{}
ref_ptr<dp::TextureManager> EngineContext::GetTextureManager() const
diff --git a/drape_frontend/engine_context.hpp b/drape_frontend/engine_context.hpp
index febfc6189a..262d936e9a 100644
--- a/drape_frontend/engine_context.hpp
+++ b/drape_frontend/engine_context.hpp
@@ -1,10 +1,12 @@
#pragma once
+#include "drape_frontend/custom_symbol.hpp"
#include "drape_frontend/map_shape.hpp"
#include "drape_frontend/tile_utils.hpp"
#include "drape_frontend/threads_commutator.hpp"
#include "drape_frontend/traffic_generator.hpp"
+#include "drape/constants.hpp"
#include "drape/pointers.hpp"
namespace dp
@@ -14,17 +16,24 @@ class TextureManager;
namespace df
{
-
class Message;
class EngineContext
{
public:
- EngineContext(TileKey tileKey, ref_ptr<ThreadsCommutator> commutator,
- ref_ptr<dp::TextureManager> texMng);
+ EngineContext(TileKey tileKey,
+ ref_ptr<ThreadsCommutator> commutator,
+ ref_ptr<dp::TextureManager> texMng,
+ CustomSymbolsContextWeakPtr customSymbolsContext,
+ bool is3dBuildingsEnabled,
+ bool isTrafficEnabled,
+ int displacementMode);
TileKey const & GetTileKey() const { return m_tileKey; }
-
+ bool Is3dBuildingsEnabled() const { return m_3dBuildingsEnabled; }
+ bool IsTrafficEnabled() const { return m_trafficEnabled; }
+ int GetDisplacementMode() const { return m_displacementMode; }
+ CustomSymbolsContextWeakPtr GetCustomSymbolsContext() const { return m_customSymbolsContext; }
ref_ptr<dp::TextureManager> GetTextureManager() const;
void BeginReadTile();
@@ -39,6 +48,9 @@ private:
TileKey m_tileKey;
ref_ptr<ThreadsCommutator> m_commutator;
ref_ptr<dp::TextureManager> m_texMng;
+ CustomSymbolsContextWeakPtr m_customSymbolsContext;
+ bool m_3dBuildingsEnabled;
+ bool m_trafficEnabled;
+ int m_displacementMode;
};
-
-} // namespace df
+} // namespace df
diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp
index fb9c01c920..e3b86aa9f7 100755
--- a/drape_frontend/frontend_renderer.cpp
+++ b/drape_frontend/frontend_renderer.cpp
@@ -697,13 +697,6 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
break;
}
- case Message::SetDisplacementMode:
- {
- ref_ptr<SetDisplacementModeMessage> msg = message;
- m_overlayTree->SetDisplacementMode(msg->GetMode());
- break;
- }
-
case Message::SetVisibleViewport:
{
ref_ptr<SetVisibleViewportMessage> msg = message;
@@ -734,6 +727,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
case Message::RegenerateTraffic:
case Message::SetSimplifiedTrafficColors:
+ case Message::SetDisplacementMode:
{
m_forceUpdateScene = true;
break;
diff --git a/drape_frontend/poi_symbol_shape.cpp b/drape_frontend/poi_symbol_shape.cpp
index d89fa3f741..db146519bc 100644
--- a/drape_frontend/poi_symbol_shape.cpp
+++ b/drape_frontend/poi_symbol_shape.cpp
@@ -95,10 +95,10 @@ namespace df
{
PoiSymbolShape::PoiSymbolShape(m2::PointD const & mercatorPt, PoiSymbolViewParams const & params,
TileKey const & tileKey, uint32_t textIndex,
- int displacementMode, uint16_t specialModePriority)
+ bool specialDisplacementMode, uint16_t specialModePriority)
: m_pt(mercatorPt)
, m_params(params)
- , m_displacementMode(displacementMode)
+ , m_specialDisplacementMode(specialDisplacementMode)
, m_specialModePriority(specialModePriority)
, m_tileCoords(tileKey.GetTileCoords())
, m_textIndex(textIndex)
@@ -121,7 +121,6 @@ void PoiSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManag
true /* isBound */,
m_params.m_symbolName,
true /* isBillboard */);
- handle->SetDisplacementMode(m_displacementMode);
handle->SetPivotZ(m_params.m_posZ);
handle->SetExtendingSize(m_params.m_extendingSize);
@@ -144,7 +143,7 @@ uint64_t PoiSymbolShape::GetOverlayPriority() const
return dp::kPriorityMaskAll;
// Special displacement mode.
- if ((m_displacementMode & dp::displacement::kDefaultMode) == 0)
+ if (m_specialDisplacementMode)
return dp::CalculateSpecialModePriority(m_specialModePriority);
// Set up minimal priority for shapes which belong to areas.
diff --git a/drape_frontend/poi_symbol_shape.hpp b/drape_frontend/poi_symbol_shape.hpp
index ed09476752..cc386de698 100644
--- a/drape_frontend/poi_symbol_shape.hpp
+++ b/drape_frontend/poi_symbol_shape.hpp
@@ -13,8 +13,7 @@ class PoiSymbolShape : public MapShape
public:
PoiSymbolShape(m2::PointD const & mercatorPt, PoiSymbolViewParams const & params,
TileKey const & tileKey, uint32_t textIndex,
- int displacementMode = dp::displacement::kAllModes,
- uint16_t specialModePriority = 0xFFFF);
+ bool specialDisplacementMode = false, uint16_t specialModePriority = 0xFFFF);
void Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const override;
MapShapeType GetType() const override { return MapShapeType::OverlayType; }
@@ -24,7 +23,7 @@ private:
m2::PointD const m_pt;
PoiSymbolViewParams const m_params;
- int const m_displacementMode;
+ bool const m_specialDisplacementMode;
uint16_t const m_specialModePriority;
m2::PointI const m_tileCoords;
uint32_t const m_textIndex;
diff --git a/drape_frontend/read_manager.cpp b/drape_frontend/read_manager.cpp
index 35224da209..aaedb8c6f0 100755
--- a/drape_frontend/read_manager.cpp
+++ b/drape_frontend/read_manager.cpp
@@ -2,50 +2,56 @@
#include "drape_frontend/message_subclasses.hpp"
#include "drape_frontend/visual_params.hpp"
-#include "platform/platform.hpp"
+#include "drape/constants.hpp"
#include "base/buffer_vector.hpp"
#include "base/stl_add.hpp"
-#include "std/algorithm.hpp"
-#include "std/bind.hpp"
-#include "std/iterator.hpp"
+#include <algorithm>
+#include <functional>
namespace df
{
-
namespace
{
-
struct LessCoverageCell
{
- bool operator()(shared_ptr<TileInfo> const & l, TileKey const & r) const
+ bool operator()(std::shared_ptr<TileInfo> const & l,
+ TileKey const & r) const
{
return l->GetTileKey() < r;
}
- bool operator()(TileKey const & l, shared_ptr<TileInfo> const & r) const
+ bool operator()(TileKey const & l,
+ std::shared_ptr<TileInfo> const & r) const
{
return l < r->GetTileKey();
}
- bool operator()(shared_ptr<TileInfo> const & l, shared_ptr<TileInfo> const & r) const
+ bool operator()(std::shared_ptr<TileInfo> const & l,
+ std::shared_ptr<TileInfo> const & r) const
{
return l->GetTileKey() < r->GetTileKey();
}
};
+} // namespace
-} // namespace
+bool ReadManager::LessByTileInfo::operator()(std::shared_ptr<TileInfo> const & l,
+ std::shared_ptr<TileInfo> const & r) const
+{
+ return *l < *r;
+}
ReadManager::ReadManager(ref_ptr<ThreadsCommutator> commutator, MapDataProvider & model,
bool allow3dBuildings, bool trafficEnabled)
: m_commutator(commutator)
, m_model(model)
, m_pool(make_unique_dp<threads::ThreadPool>(kReadingThreadsCount,
- bind(&ReadManager::OnTaskFinished, this, _1)))
+ std::bind(&ReadManager::OnTaskFinished, this, _1)))
, m_have3dBuildings(false)
, m_allow3dBuildings(allow3dBuildings)
, m_trafficEnabled(trafficEnabled)
+ , m_displacementMode(dp::displacement::kDefaultMode)
, m_modeChanged(false)
, myPool(64, ReadMWMTaskFactory(m_model))
, m_counter(0)
@@ -59,7 +65,7 @@ void ReadManager::OnTaskFinished(threads::IRoutine * task)
// finish tiles
{
- lock_guard<mutex> lock(m_finishedTilesMutex);
+ std::lock_guard<std::mutex> lock(m_finishedTilesMutex);
m_activeTiles.erase(t->GetTileKey());
@@ -78,7 +84,7 @@ void ReadManager::OnTaskFinished(threads::IRoutine * task)
TTilesCollection tiles;
tiles.emplace(t->GetTileKey());
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
- make_unique_dp<FinishTileReadMessage>(move(tiles)),
+ make_unique_dp<FinishTileReadMessage>(std::move(tiles)),
MessagePriority::Normal);
}
}
@@ -87,8 +93,10 @@ void ReadManager::OnTaskFinished(threads::IRoutine * task)
myPool.Return(t);
}
-void ReadManager::UpdateCoverage(ScreenBase const & screen, bool have3dBuildings, bool forceUpdate,
- TTilesCollection const & tiles, ref_ptr<dp::TextureManager> texMng)
+void ReadManager::UpdateCoverage(ScreenBase const & screen,
+ bool have3dBuildings, bool forceUpdate,
+ TTilesCollection const & tiles,
+ ref_ptr<dp::TextureManager> texMng)
{
m_modeChanged |= (m_have3dBuildings != have3dBuildings);
m_have3dBuildings = have3dBuildings;
@@ -97,48 +105,43 @@ void ReadManager::UpdateCoverage(ScreenBase const & screen, bool have3dBuildings
{
m_modeChanged = false;
- for_each(m_tileInfos.begin(), m_tileInfos.end(), bind(&ReadManager::CancelTileInfo, this, _1));
+ for (auto const & info : m_tileInfos)
+ CancelTileInfo(info);
m_tileInfos.clear();
IncreaseCounter(static_cast<int>(tiles.size()));
m_generationCounter++;
- for_each(tiles.begin(), tiles.end(), bind(&ReadManager::PushTaskBackForTileKey, this, _1, texMng));
+ for (auto const & tileKey : tiles)
+ PushTaskBackForTileKey(tileKey, texMng);
}
else
{
- // Find rects that go out from viewport
+ // Find rects that go out from viewport.
TTileInfoCollection outdatedTiles;
-#ifdef _MSC_VER
- vs_bug::
-#endif
- set_difference(m_tileInfos.begin(), m_tileInfos.end(),
- tiles.begin(), tiles.end(),
- back_inserter(outdatedTiles), LessCoverageCell());
+ std::set_difference(m_tileInfos.begin(), m_tileInfos.end(),
+ tiles.begin(), tiles.end(),
+ std::back_inserter(outdatedTiles), LessCoverageCell());
- for_each(outdatedTiles.begin(), outdatedTiles.end(), bind(&ReadManager::ClearTileInfo, this, _1));
+ for (auto const & info : outdatedTiles)
+ ClearTileInfo(info);
// Find rects that go in into viewport.
buffer_vector<TileKey, 8> newTiles;
-#ifdef _MSC_VER
- vs_bug::
-#endif
- set_difference(tiles.begin(), tiles.end(),
- m_tileInfos.begin(), m_tileInfos.end(),
- back_inserter(newTiles), LessCoverageCell());
+ std::set_difference(tiles.begin(), tiles.end(),
+ m_tileInfos.begin(), m_tileInfos.end(),
+ std::back_inserter(newTiles), LessCoverageCell());
// Find ready tiles.
TTileInfoCollection readyTiles;
-#ifdef _MSC_VER
- vs_bug::
-#endif
- set_difference(m_tileInfos.begin(), m_tileInfos.end(),
- outdatedTiles.begin(), outdatedTiles.end(),
- back_inserter(readyTiles), LessCoverageCell());
+ std::set_difference(m_tileInfos.begin(), m_tileInfos.end(),
+ outdatedTiles.begin(), outdatedTiles.end(),
+ std::back_inserter(readyTiles), LessCoverageCell());
IncreaseCounter(static_cast<int>(newTiles.size()));
CheckFinishedTiles(readyTiles);
- for_each(newTiles.begin(), newTiles.end(), bind(&ReadManager::PushTaskBackForTileKey, this, _1, texMng));
+ for (auto const & tileKey : newTiles)
+ PushTaskBackForTileKey(tileKey, texMng);
}
m_currentViewport = screen;
@@ -172,7 +175,8 @@ void ReadManager::InvalidateAll()
void ReadManager::Stop()
{
- for_each(m_tileInfos.begin(), m_tileInfos.end(), bind(&ReadManager::CancelTileInfo, this, _1));
+ for (auto const & info : m_tileInfos)
+ CancelTileInfo(info);
m_tileInfos.clear();
m_pool->Stop();
@@ -182,9 +186,10 @@ void ReadManager::Stop()
bool ReadManager::CheckTileKey(TileKey const & tileKey) const
{
for (auto const & tileInfo : m_tileInfos)
+ {
if (tileInfo->GetTileKey() == tileKey)
return !tileInfo->IsCancelled();
-
+ }
return false;
}
@@ -197,16 +202,17 @@ bool ReadManager::MustDropAllTiles(ScreenBase const & screen) const
void ReadManager::PushTaskBackForTileKey(TileKey const & tileKey, ref_ptr<dp::TextureManager> texMng)
{
- shared_ptr<TileInfo> tileInfo(new TileInfo(make_unique_dp<EngineContext>(TileKey(tileKey, m_generationCounter),
- m_commutator, texMng), m_customSymbolsContext));
- tileInfo->Set3dBuildings(m_have3dBuildings && m_allow3dBuildings);
- tileInfo->SetTrafficEnabled(m_trafficEnabled);
+ auto context = make_unique_dp<EngineContext>(TileKey(tileKey, m_generationCounter),
+ m_commutator, texMng, m_customSymbolsContext,
+ m_have3dBuildings && m_allow3dBuildings,
+ m_trafficEnabled, m_displacementMode);
+ std::shared_ptr<TileInfo> tileInfo = std::make_shared<TileInfo>(std::move(context));
m_tileInfos.insert(tileInfo);
ReadMWMTask * task = myPool.Get();
task->Init(tileInfo);
{
- lock_guard<mutex> lock(m_finishedTilesMutex);
+ std::lock_guard<std::mutex> lock(m_finishedTilesMutex);
m_activeTiles.insert(tileKey);
}
m_pool->PushBack(task);
@@ -219,7 +225,7 @@ void ReadManager::CheckFinishedTiles(TTileInfoCollection const & requestedTiles)
TTilesCollection finishedTiles;
- lock_guard<mutex> lock(m_finishedTilesMutex);
+ std::lock_guard<std::mutex> lock(m_finishedTilesMutex);
for (auto const & tile : requestedTiles)
if (m_activeTiles.find(tile->GetTileKey()) == m_activeTiles.end())
@@ -228,17 +234,17 @@ void ReadManager::CheckFinishedTiles(TTileInfoCollection const & requestedTiles)
if (!finishedTiles.empty())
{
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
- make_unique_dp<FinishTileReadMessage>(move(finishedTiles)),
+ make_unique_dp<FinishTileReadMessage>(std::move(finishedTiles)),
MessagePriority::Normal);
}
}
-void ReadManager::CancelTileInfo(shared_ptr<TileInfo> const & tileToCancel)
+void ReadManager::CancelTileInfo(std::shared_ptr<TileInfo> const & tileToCancel)
{
tileToCancel->Cancel();
}
-void ReadManager::ClearTileInfo(shared_ptr<TileInfo> const & tileToClear)
+void ReadManager::ClearTileInfo(std::shared_ptr<TileInfo> const & tileToClear)
{
CancelTileInfo(tileToClear);
m_tileInfos.erase(tileToClear);
@@ -246,7 +252,7 @@ void ReadManager::ClearTileInfo(shared_ptr<TileInfo> const & tileToClear)
void ReadManager::IncreaseCounter(int value)
{
- lock_guard<mutex> lock(m_finishedTilesMutex);
+ std::lock_guard<std::mutex> lock(m_finishedTilesMutex);
m_counter += value;
if (m_counter == 0)
@@ -275,6 +281,15 @@ void ReadManager::SetTrafficEnabled(bool trafficEnabled)
}
}
+void ReadManager::SetDisplacementMode(int displacementMode)
+{
+ if (m_displacementMode != displacementMode)
+ {
+ m_modeChanged = true;
+ m_displacementMode = displacementMode;
+ }
+}
+
void ReadManager::UpdateCustomSymbols(CustomSymbols const & symbols)
{
CustomSymbols currentSymbols = m_customSymbolsContext ? m_customSymbolsContext->m_symbols :
@@ -306,5 +321,4 @@ void ReadManager::RemoveAllCustomSymbols()
{
m_customSymbolsContext = std::make_shared<CustomSymbolsContext>(CustomSymbols());
}
-
} // namespace df
diff --git a/drape_frontend/read_manager.hpp b/drape_frontend/read_manager.hpp
index ed6b6e138b..df58e43f8f 100755
--- a/drape_frontend/read_manager.hpp
+++ b/drape_frontend/read_manager.hpp
@@ -14,15 +14,13 @@
#include "base/thread_pool.hpp"
-#include "std/atomic.hpp"
-#include "std/mutex.hpp"
-#include "std/set.hpp"
-#include "std/shared_ptr.hpp"
-#include "std/target_os.hpp"
+#include <memory>
+#include <mutex>
+#include <set>
+#include <vector>
namespace df
{
-
class MapDataProvider;
class CoverageUpdateDescriptor;
@@ -45,10 +43,14 @@ public:
void SetTrafficEnabled(bool trafficEnabled);
+ void SetDisplacementMode(int displacementMode);
+
void UpdateCustomSymbols(CustomSymbols const & symbols);
void RemoveCustomSymbols(MwmSet::MwmId const & mwmId, std::vector<FeatureID> & leftoverIds);
void RemoveAllCustomSymbols();
+ bool IsModeChanged() const { return m_modeChanged; }
+
private:
void OnTaskFinished(threads::IRoutine * task);
bool MustDropAllTiles(ScreenBase const & screen) const;
@@ -65,34 +67,32 @@ private:
bool m_have3dBuildings;
bool m_allow3dBuildings;
bool m_trafficEnabled;
+ int m_displacementMode;
bool m_modeChanged;
struct LessByTileInfo
{
- bool operator ()(shared_ptr<TileInfo> const & l, shared_ptr<TileInfo> const & r) const
- {
- return *l < *r;
- }
+ bool operator ()(std::shared_ptr<TileInfo> const & l,
+ std::shared_ptr<TileInfo> const & r) const;
};
- using TTileSet = set<shared_ptr<TileInfo>, LessByTileInfo>;
+ using TTileSet = std::set<std::shared_ptr<TileInfo>, LessByTileInfo>;
TTileSet m_tileInfos;
ObjectPool<ReadMWMTask, ReadMWMTaskFactory> myPool;
int m_counter;
- mutex m_finishedTilesMutex;
+ std::mutex m_finishedTilesMutex;
uint64_t m_generationCounter;
- using TTileInfoCollection = buffer_vector<shared_ptr<TileInfo>, 8>;
+ using TTileInfoCollection = buffer_vector<std::shared_ptr<TileInfo>, 8>;
TTilesCollection m_activeTiles;
CustomSymbolsContextPtr m_customSymbolsContext;
- void CancelTileInfo(shared_ptr<TileInfo> const & tileToCancel);
- void ClearTileInfo(shared_ptr<TileInfo> const & tileToClear);
+ void CancelTileInfo(std::shared_ptr<TileInfo> const & tileToCancel);
+ void ClearTileInfo(std::shared_ptr<TileInfo> const & tileToClear);
void IncreaseCounter(int value);
void CheckFinishedTiles(TTileInfoCollection const & requestedTiles);
};
-
-} // namespace df
+} // namespace df
diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp
index f55d4ed922..7dec50d7ac 100644
--- a/drape_frontend/rule_drawer.cpp
+++ b/drape_frontend/rule_drawer.cpp
@@ -18,8 +18,6 @@
#include "base/assert.hpp"
#include "base/logging.hpp"
-#include "std/bind.hpp"
-
#ifdef DRAW_TILE_NET
#include "drape_frontend/line_shape.hpp"
#include "drape_frontend/text_shape.hpp"
@@ -27,22 +25,70 @@
#include "base/string_utils.hpp"
#endif
+#include <vector>
+
namespace
{
// The first zoom level in kAverageSegmentsCount.
int constexpr kFirstZoomInAverageSegments = 10;
-// 10 11 12 13 14 15 16 17 18 19
-vector<size_t> const kAverageSegmentsCount = { 10000, 5000, 10000, 5000, 2500, 5000, 2000, 1000, 500, 500 };
+std::vector<size_t> const kAverageSegmentsCount =
+{
+ // 10 11 12 13 14 15 16 17 18 19
+ 10000, 5000, 10000, 5000, 2500, 5000, 2000, 1000, 500, 500
+};
+
+double GetBuildingHeightInMeters(FeatureType const & f)
+{
+ double constexpr kDefaultHeightInMeters = 3.0;
+ double constexpr kMetersPerLevel = 3.0;
+
+ feature::Metadata const & md = f.GetMetadata();
+ double heightInMeters = kDefaultHeightInMeters;
+
+ std::string value = md.Get(feature::Metadata::FMD_HEIGHT);
+ if (!value.empty())
+ {
+ if (!strings::to_double(value, heightInMeters))
+ heightInMeters = kDefaultHeightInMeters;
+ }
+ else
+ {
+ value = md.Get(feature::Metadata::FMD_BUILDING_LEVELS);
+ if (!value.empty())
+ {
+ if (strings::to_double(value, heightInMeters))
+ heightInMeters *= kMetersPerLevel;
+ }
+ }
+ return heightInMeters;
+}
+
+double GetBuildingMinHeightInMeters(FeatureType const & f)
+{
+ feature::Metadata const & md = f.GetMetadata();
+ std::string value = md.Get(feature::Metadata::FMD_MIN_HEIGHT);
+ if (value.empty())
+ return 0.0;
+
+ double minHeightInMeters;
+ if (!strings::to_double(value, minHeightInMeters))
+ minHeightInMeters = 0.0;
+
+ return minHeightInMeters;
+}
df::BaseApplyFeature::HotelData ExtractHotelData(FeatureType const & f)
{
df::BaseApplyFeature::HotelData result;
if (ftypes::IsBookingChecker::Instance()(f))
{
+ auto const & metadata = f.GetMetadata();
result.m_isHotel = true;
- result.m_rating = f.GetMetadata().Get(feature::Metadata::FMD_RATING);
- strings::to_int(f.GetMetadata().Get(feature::Metadata::FMD_STARS), result.m_stars);
- strings::to_int(f.GetMetadata().Get(feature::Metadata::FMD_PRICE_RATE), result.m_priceCategory);
+ result.m_rating = metadata.Get(feature::Metadata::FMD_RATING);
+ if (!strings::to_int(metadata.Get(feature::Metadata::FMD_STARS), result.m_stars))
+ result.m_stars = 0;
+ if (!strings::to_int(metadata.Get(feature::Metadata::FMD_PRICE_RATE), result.m_priceCategory))
+ result.m_priceCategory = 0;
}
return result;
}
@@ -62,8 +108,8 @@ void ExtractTrafficGeometry(FeatureType const & f, df::RoadClass const & roadCla
if (!oneWay)
twoWayOffset = pixelToGlobalScale * df::TrafficRenderer::GetTwoWayOffset(roadClass, zoomLevel);
- static vector<uint8_t> directions = {traffic::TrafficInfo::RoadSegmentId::kForwardDirection,
- traffic::TrafficInfo::RoadSegmentId::kReverseDirection};
+ static std::vector<uint8_t> directions = {traffic::TrafficInfo::RoadSegmentId::kForwardDirection,
+ traffic::TrafficInfo::RoadSegmentId::kReverseDirection};
auto & segments = geometry[f.GetID().m_mwmId];
int const index = zoomLevel - kFirstZoomInAverageSegments;
@@ -94,14 +140,14 @@ void ExtractTrafficGeometry(FeatureType const & f, df::RoadClass const & roadCla
m2::PointD const tangent = (segment[1] - segment[0]).Normalize();
m2::PointD const normal = isLeftHandTraffic ? m2::PointD(-tangent.y, tangent.x) :
m2::PointD(tangent.y, -tangent.x);
- m2::PolylineD segmentPolyline(vector<m2::PointD>{segment[0] + normal * twoWayOffset,
- segment[1] + normal * twoWayOffset});
- segments.emplace_back(sid, df::TrafficSegmentGeometry(move(segmentPolyline), roadClass));
+ m2::PolylineD segmentPolyline(std::vector<m2::PointD>{segment[0] + normal * twoWayOffset,
+ segment[1] + normal * twoWayOffset});
+ segments.emplace_back(sid, df::TrafficSegmentGeometry(std::move(segmentPolyline), roadClass));
}
else
{
- m2::PolylineD segmentPolyline(vector<m2::PointD>{segment[0], segment[1]});
- segments.emplace_back(sid, df::TrafficSegmentGeometry(move(segmentPolyline), roadClass));
+ m2::PolylineD segmentPolyline(std::vector<m2::PointD>{segment[0], segment[1]});
+ segments.emplace_back(sid, df::TrafficSegmentGeometry(std::move(segmentPolyline), roadClass));
}
}
}
@@ -115,16 +161,12 @@ namespace df
RuleDrawer::RuleDrawer(TDrawerCallback const & drawerFn,
TCheckCancelledCallback const & checkCancelled,
TIsCountryLoadedByNameFn const & isLoadedFn,
- ref_ptr<EngineContext> engineContext,
- CustomSymbolsContextPtr customSymbolsContext,
- bool is3dBuildings, bool trafficEnabled)
+ ref_ptr<EngineContext> engineContext)
: m_callback(drawerFn)
, m_checkCancelled(checkCancelled)
, m_isLoadedFn(isLoadedFn)
, m_context(engineContext)
- , m_customSymbolsContext(customSymbolsContext)
- , m_is3dBuildings(is3dBuildings)
- , m_trafficEnabled(trafficEnabled)
+ , m_customSymbolsContext(engineContext->GetCustomSymbolsContext().lock())
, m_wasCancelled(false)
{
ASSERT(m_callback != nullptr, ());
@@ -163,10 +205,10 @@ RuleDrawer::~RuleDrawer()
{
TMapShapes overlayShapes;
overlayShapes.swap(m_mapShapes[df::OverlayType]);
- m_context->FlushOverlays(move(overlayShapes));
+ m_context->FlushOverlays(std::move(overlayShapes));
}
- m_context->FlushTrafficGeometry(move(m_trafficGeometry));
+ m_context->FlushTrafficGeometry(std::move(m_trafficGeometry));
}
bool RuleDrawer::CheckCancelled()
@@ -214,7 +256,7 @@ void RuleDrawer::operator()(FeatureType const & f)
#ifdef DEBUG
// Validate on feature styles
- if (s.AreaStyleExists() == false)
+ if (!s.AreaStyleExists())
{
int checkFlag = s.PointStyleExists() ? 1 : 0;
checkFlag += s.LineStyleExists() ? 1 : 0;
@@ -229,7 +271,7 @@ void RuleDrawer::operator()(FeatureType const & f)
ASSERT_LESS(index, static_cast<int>(m_mapShapes.size()), ());
shape->SetFeatureMinZoom(minVisibleScale);
- m_mapShapes[index].push_back(move(shape));
+ m_mapShapes[index].push_back(std::move(shape));
};
if (s.AreaStyleExists())
@@ -249,7 +291,7 @@ void RuleDrawer::operator()(FeatureType const & f)
!ftypes::IsTunnelChecker::Instance()(f);
isBuildingOutline = isBuilding && hasParts && !isPart;
- is3dBuilding = m_is3dBuildings && (isBuilding && !isBuildingOutline);
+ is3dBuilding = m_context->Is3dBuildingsEnabled() && (isBuilding && !isBuildingOutline);
}
m2::PointD featureCenter;
@@ -260,32 +302,8 @@ void RuleDrawer::operator()(FeatureType const & f)
float areaMinHeight = 0.0f;
if (is3dBuilding)
{
- feature::Metadata const & md = f.GetMetadata();
-
- constexpr double kDefaultHeightInMeters = 3.0;
- constexpr double kMetersPerLevel = 3.0;
- double heightInMeters = kDefaultHeightInMeters;
-
- string value = md.Get(feature::Metadata::FMD_HEIGHT);
- if (!value.empty())
- {
- strings::to_double(value, heightInMeters);
- }
- else
- {
- value = md.Get(feature::Metadata::FMD_BUILDING_LEVELS);
- if (!value.empty())
- {
- if (strings::to_double(value, heightInMeters))
- heightInMeters *= kMetersPerLevel;
- }
- }
-
- value = md.Get(feature::Metadata::FMD_MIN_HEIGHT);
- double minHeightInMeters = 0.0;
- if (!value.empty())
- strings::to_double(value, minHeightInMeters);
-
+ double const heightInMeters = GetBuildingHeightInMeters(f);
+ double const minHeightInMeters = GetBuildingMinHeightInMeters(f);
featureCenter = feature::GetCenter(f, zoomLevel);
double const lon = MercatorBounds::XToLon(featureCenter.x);
double const lat = MercatorBounds::YToLat(featureCenter.y);
@@ -313,7 +331,8 @@ void RuleDrawer::operator()(FeatureType const & f)
minVisibleScale = feature::GetMinDrawableScale(f);
ApplyAreaFeature apply(m_context->GetTileKey(), insertShape, f.GetID(),
- m_currentScaleGtoP, isBuilding, m_is3dBuildings && isBuildingOutline,
+ m_currentScaleGtoP, isBuilding,
+ m_context->Is3dBuildingsEnabled() && isBuildingOutline,
areaMinHeight, areaHeight, minVisibleScale, f.GetRank(),
s.GetCaptionDescription(), hatchingArea);
f.ForEachTriangle(apply, zoomLevel);
@@ -342,11 +361,11 @@ void RuleDrawer::operator()(FeatureType const & f)
apply.Finish(ftypes::GetRoadShields(f));
- if (m_trafficEnabled && zoomLevel >= kRoadClass0ZoomLevel)
+ if (m_context->IsTrafficEnabled() && zoomLevel >= kRoadClass0ZoomLevel)
{
struct Checker
{
- vector<ftypes::HighwayClass> m_highwayClasses;
+ std::vector<ftypes::HighwayClass> m_highwayClasses;
int m_zoomLevel;
df::RoadClass m_roadClass;
};
@@ -367,7 +386,7 @@ void RuleDrawer::operator()(FeatureType const & f)
if (find(classes.begin(), classes.end(), highwayClass) != classes.end() &&
zoomLevel >= checkers[i].m_zoomLevel)
{
- vector<m2::PointD> points;
+ std::vector<m2::PointD> points;
points.reserve(f.GetPointsCount());
f.ResetGeometry();
f.ForEachPoint([&points](m2::PointD const & p) { points.emplace_back(p); },
@@ -385,7 +404,7 @@ void RuleDrawer::operator()(FeatureType const & f)
minVisibleScale = feature::GetMinDrawableScale(f);
ApplyPointFeature apply(m_context->GetTileKey(), insertShape, f.GetID(), minVisibleScale, f.GetRank(),
- s.GetCaptionDescription(), 0.0f /* posZ */);
+ s.GetCaptionDescription(), 0.0f /* posZ */, m_context->GetDisplacementMode());
apply.SetHotelData(ExtractHotelData(f));
f.ForEachPoint([&apply](m2::PointD const & pt) { apply(pt, false /* hasArea */); }, zoomLevel);
@@ -399,7 +418,7 @@ void RuleDrawer::operator()(FeatureType const & f)
#ifdef DRAW_TILE_NET
TileKey key = m_context->GetTileKey();
m2::RectD r = key.GetGlobalRect();
- vector<m2::PointD> path;
+ std::vector<m2::PointD> path;
path.push_back(r.LeftBottom());
path.push_back(r.LeftTop());
path.push_back(r.RightTop());
@@ -431,7 +450,7 @@ void RuleDrawer::operator()(FeatureType const & f)
drape_ptr<TextShape> textShape =
make_unique_dp<TextShape>(r.Center(), tp, m_context->GetTileKey(), false, 0, false);
textShape->DisableDisplacing();
- insertShape(move(textShape));
+ insertShape(std::move(textShape));
#endif
if (CheckCancelled())
@@ -444,8 +463,7 @@ void RuleDrawer::operator()(FeatureType const & f)
{
TMapShapes geomShapes;
geomShapes.swap(m_mapShapes[df::GeometryType]);
- m_context->Flush(move(geomShapes));
+ m_context->Flush(std::move(geomShapes));
}
}
-
-} // namespace df
+} // namespace df
diff --git a/drape_frontend/rule_drawer.hpp b/drape_frontend/rule_drawer.hpp
index a8870db36a..ec2a60eb54 100644
--- a/drape_frontend/rule_drawer.hpp
+++ b/drape_frontend/rule_drawer.hpp
@@ -10,35 +10,31 @@
#include "geometry/rect2d.hpp"
#include "geometry/screenbase.hpp"
-#include "std/array.hpp"
-#include "std/function.hpp"
-#include "std/set.hpp"
-#include "std/string.hpp"
+#include <array>
+#include <functional>
+#include <string>
class FeatureType;
namespace df
{
-
class EngineContext;
class Stylist;
class RuleDrawer
{
public:
- using TDrawerCallback = function<void (FeatureType const &, Stylist &)>;
- using TCheckCancelledCallback = function<bool ()>;
- using TIsCountryLoadedByNameFn = function<bool (string const &)>;
+ using TDrawerCallback = std::function<void(FeatureType const &, Stylist &)>;
+ using TCheckCancelledCallback = std::function<bool()>;
+ using TIsCountryLoadedByNameFn = std::function<bool(std::string const &)>;
RuleDrawer(TDrawerCallback const & drawerFn,
TCheckCancelledCallback const & checkCancelled,
TIsCountryLoadedByNameFn const & isLoadedFn,
- ref_ptr<EngineContext> engineContext,
- CustomSymbolsContextPtr customSymbolsContext,
- bool is3dBuildings, bool trafficEnabled);
+ ref_ptr<EngineContext> engineContext);
~RuleDrawer();
- void operator() (FeatureType const & f);
+ void operator()(FeatureType const & f);
private:
bool CheckCancelled();
@@ -53,13 +49,9 @@ private:
double m_currentScaleGtoP;
double m_trafficScalePtoG;
- bool const m_is3dBuildings;
-
- bool const m_trafficEnabled;
TrafficSegmentsGeometry m_trafficGeometry;
- array<TMapShapes, df::MapShapeTypeCount> m_mapShapes;
+ std::array<TMapShapes, df::MapShapeTypeCount> m_mapShapes;
bool m_wasCancelled;
};
-
-} // namespace dfo
+} // namespace df
diff --git a/drape_frontend/text_shape.cpp b/drape_frontend/text_shape.cpp
index cbb539c11c..12d3c1516f 100644
--- a/drape_frontend/text_shape.cpp
+++ b/drape_frontend/text_shape.cpp
@@ -16,10 +16,8 @@
namespace df
{
-
namespace
{
-
class StraightTextHandle : public TextHandle
{
using TBase = TextHandle;
@@ -121,19 +119,19 @@ private:
bool m_affectedByZoomPriority;
};
-} // namespace
+} // namespace
TextShape::TextShape(m2::PointD const & basePoint, TextViewParams const & params,
TileKey const & tileKey, bool hasPOI,
uint32_t textIndex, bool affectedByZoomPriority,
- int displacementMode, uint16_t specialModePriority)
+ bool specialDisplacementMode, uint16_t specialModePriority)
: m_basePoint(basePoint)
, m_params(params)
, m_tileCoords(tileKey.GetTileCoords())
, m_hasPOI(hasPOI)
, m_affectedByZoomPriority(affectedByZoomPriority)
, m_textIndex(textIndex)
- , m_displacementMode(displacementMode)
+ , m_specialDisplacementMode(specialDisplacementMode)
, m_specialModePriority(specialModePriority)
{}
@@ -243,7 +241,6 @@ void TextShape::DrawSubStringPlain(StraightTextLayout const & layout, dp::FontDe
m_affectedByZoomPriority,
move(dynamicBuffer),
true);
- handle->SetDisplacementMode(m_displacementMode);
handle->SetPivotZ(m_params.m_posZ);
handle->SetOverlayRank(m_hasPOI ? (isPrimary ? dp::OverlayRank1 : dp::OverlayRank2) : dp::OverlayRank0);
handle->SetExtendingSize(m_params.m_extendingSize);
@@ -293,7 +290,6 @@ void TextShape::DrawSubStringOutlined(StraightTextLayout const & layout, dp::Fon
m_affectedByZoomPriority,
move(dynamicBuffer),
true);
- handle->SetDisplacementMode(m_displacementMode);
handle->SetPivotZ(m_params.m_posZ);
handle->SetOverlayRank(m_hasPOI ? (isPrimary ? dp::OverlayRank1 : dp::OverlayRank2) : dp::OverlayRank0);
handle->SetExtendingSize(m_params.m_extendingSize);
@@ -312,7 +308,7 @@ uint64_t TextShape::GetOverlayPriority() const
return dp::kPriorityMaskAll;
// Special displacement mode.
- if ((m_displacementMode & dp::displacement::kDefaultMode) == 0)
+ if (m_specialDisplacementMode)
return dp::CalculateSpecialModePriority(m_specialModePriority);
// Set up minimal priority for shapes which belong to areas
@@ -330,5 +326,4 @@ uint64_t TextShape::GetOverlayPriority() const
return priority;
}
-
-} //end of df namespace
+} // namespace df
diff --git a/drape_frontend/text_shape.hpp b/drape_frontend/text_shape.hpp
index 6e71fd3bb1..e135cbd127 100644
--- a/drape_frontend/text_shape.hpp
+++ b/drape_frontend/text_shape.hpp
@@ -10,7 +10,6 @@
namespace df
{
-
class StraightTextLayout;
class TextShape : public MapShape
@@ -19,8 +18,7 @@ public:
TextShape(m2::PointD const & basePoint, TextViewParams const & params,
TileKey const & tileKey, bool hasPOI,
uint32_t textIndex, bool affectedByZoomPriority,
- int displacementMode = dp::displacement::kAllModes,
- uint16_t specialModePriority = 0xFFFF);
+ bool specialDisplacementMode = false, uint16_t specialModePriority = 0xFFFF);
void Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const override;
MapShapeType GetType() const override { return MapShapeType::OverlayType; }
@@ -49,9 +47,9 @@ private:
bool m_affectedByZoomPriority;
uint32_t m_textIndex;
- bool m_disableDisplacing = false;
- int m_displacementMode;
+ bool m_specialDisplacementMode;
uint16_t m_specialModePriority;
-};
-} // namespace df
+ bool m_disableDisplacing = false;
+};
+} // namespace df
diff --git a/drape_frontend/tile_info.cpp b/drape_frontend/tile_info.cpp
index 5392c2c7d6..c027318507 100644
--- a/drape_frontend/tile_info.cpp
+++ b/drape_frontend/tile_info.cpp
@@ -1,9 +1,9 @@
+#include "drape_frontend/tile_info.hpp"
#include "drape_frontend/drape_measurer.hpp"
#include "drape_frontend/engine_context.hpp"
#include "drape_frontend/map_data_provider.hpp"
#include "drape_frontend/rule_drawer.hpp"
#include "drape_frontend/stylist.hpp"
-#include "drape_frontend/tile_info.hpp"
#include "indexer/scales.hpp"
@@ -12,17 +12,13 @@
#include "base/scope_guard.hpp"
#include "base/logging.hpp"
-#include "std/bind.hpp"
+#include <functional>
+#include <set>
namespace df
{
-
-TileInfo::TileInfo(drape_ptr<EngineContext> && engineContext,
- CustomSymbolsContextWeakPtr customSymbolsContext)
- : m_context(move(engineContext))
- , m_customSymbolsContext(customSymbolsContext)
- , m_is3dBuildings(false)
- , m_trafficEnabled(false)
+TileInfo::TileInfo(drape_ptr<EngineContext> && engineContext)
+ : m_context(std::move(engineContext))
, m_isCanceled(false)
{}
@@ -41,7 +37,7 @@ void TileInfo::ReadFeatureIndex(MapDataProvider const & model)
m_featureInfo.reserve(kAverageFeaturesCount);
#ifdef DEBUG
- set<MwmSet::MwmId> existing;
+ std::set<MwmSet::MwmId> existing;
MwmSet::MwmId lastMwm;
model.ReadFeaturesID([this, &existing, &lastMwm](FeatureID const & id)
{
@@ -67,7 +63,7 @@ void TileInfo::ReadFeatures(MapDataProvider const & model)
m_context->BeginReadTile();
// Reading can be interrupted by exception throwing
- MY_SCOPE_GUARD(ReleaseReadTile, bind(&EngineContext::EndReadTile, m_context.get()));
+ MY_SCOPE_GUARD(ReleaseReadTile, std::bind(&EngineContext::EndReadTile, m_context.get()));
ReadFeatureIndex(model);
CheckCanceled();
@@ -75,12 +71,11 @@ void TileInfo::ReadFeatures(MapDataProvider const & model)
if (!m_featureInfo.empty())
{
auto const deviceLang = StringUtf8Multilang::GetLangIndex(languages::GetCurrentNorm());
- RuleDrawer drawer(bind(&TileInfo::InitStylist, this, deviceLang, _1, _2),
- bind(&TileInfo::IsCancelled, this),
+ RuleDrawer drawer(std::bind(&TileInfo::InitStylist, this, deviceLang, _1, _2),
+ std::bind(&TileInfo::IsCancelled, this),
model.m_isCountryLoadedByName,
- make_ref(m_context), m_customSymbolsContext.lock(),
- m_is3dBuildings, m_trafficEnabled);
- model.ReadFeatures(bind<void>(ref(drawer), _1), m_featureInfo);
+ make_ref(m_context));
+ model.ReadFeatures(std::bind<void>(std::ref(drawer), _1), m_featureInfo);
}
#if defined(DRAPE_MEASURER) && defined(TILES_STATISTIC)
DrapeMeasurer::Instance().EndTileReading();
@@ -100,7 +95,8 @@ bool TileInfo::IsCancelled() const
void TileInfo::InitStylist(int8_t deviceLang, FeatureType const & f, Stylist & s)
{
CheckCanceled();
- df::InitStylist(f, deviceLang, m_context->GetTileKey().m_zoomLevel, m_is3dBuildings, s);
+ df::InitStylist(f, deviceLang, m_context->GetTileKey().m_zoomLevel,
+ m_context->Is3dBuildingsEnabled(), s);
}
bool TileInfo::DoNeedReadIndex() const
@@ -118,5 +114,4 @@ int TileInfo::GetZoomLevel() const
{
return ClipTileZoomByMaxDataZoom(m_context->GetTileKey().m_zoomLevel);
}
-
-} // namespace df
+} // namespace df
diff --git a/drape_frontend/tile_info.hpp b/drape_frontend/tile_info.hpp
index 7a60134c56..0ba44a1cfc 100644
--- a/drape_frontend/tile_info.hpp
+++ b/drape_frontend/tile_info.hpp
@@ -7,38 +7,29 @@
#include "indexer/feature_decl.hpp"
#include "base/exception.hpp"
+#include "base/macros.hpp"
-#include "std/atomic.hpp"
-#include "std/mutex.hpp"
-#include "std/noncopyable.hpp"
-#include "std/vector.hpp"
+#include <atomic>
+#include <vector>
class FeatureType;
namespace df
{
-
class MapDataProvider;
class Stylist;
-class TileInfo : private noncopyable
+class TileInfo
{
public:
DECLARE_EXCEPTION(ReadCanceledException, RootException);
- TileInfo(drape_ptr<EngineContext> && engineContext,
- CustomSymbolsContextWeakPtr customSymbolsContext);
+ TileInfo(drape_ptr<EngineContext> && engineContext);
void ReadFeatures(MapDataProvider const & model);
void Cancel();
bool IsCancelled() const;
- void Set3dBuildings(bool buildings3d) { m_is3dBuildings = buildings3d; }
- bool Get3dBuildings() const { return m_is3dBuildings; }
-
- void SetTrafficEnabled(bool trafficEnabled) { m_trafficEnabled = trafficEnabled; }
- bool GetTrafficEnabled() const { return m_trafficEnabled; }
-
m2::RectD GetGlobalRect() const;
TileKey const & GetTileKey() const { return m_context->GetTileKey(); }
bool operator <(TileInfo const & other) const { return GetTileKey() < other.GetTileKey(); }
@@ -53,12 +44,9 @@ private:
private:
drape_ptr<EngineContext> m_context;
- CustomSymbolsContextWeakPtr m_customSymbolsContext;
- vector<FeatureID> m_featureInfo;
- bool m_is3dBuildings;
- bool m_trafficEnabled;
+ std::vector<FeatureID> m_featureInfo;
+ std::atomic<bool> m_isCanceled;
- atomic<bool> m_isCanceled;
+ DISALLOW_COPY_AND_MOVE(TileInfo);
};
-
-} // namespace df
+} // namespace df