diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2017-02-20 14:45:05 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2017-02-20 14:56:20 +0300 |
commit | 7e848c132f171617db4f903b50473b1a5f639d8b (patch) | |
tree | 4aa8c491d63fd1377181226e6b9274314854df1b /drape_frontend | |
parent | 325d595022107c965fffa8276276d062a48ea0a2 (diff) |
Added simplified traffic colors
Diffstat (limited to 'drape_frontend')
-rw-r--r-- | drape_frontend/backend_renderer.cpp | 17 | ||||
-rw-r--r-- | drape_frontend/backend_renderer.hpp | 4 | ||||
-rw-r--r-- | drape_frontend/drape_engine.cpp | 9 | ||||
-rw-r--r-- | drape_frontend/drape_engine.hpp | 6 | ||||
-rwxr-xr-x | drape_frontend/frontend_renderer.cpp | 1 | ||||
-rw-r--r-- | drape_frontend/message.hpp | 1 | ||||
-rw-r--r-- | drape_frontend/message_subclasses.hpp | 15 | ||||
-rw-r--r-- | drape_frontend/traffic_generator.cpp | 15 | ||||
-rw-r--r-- | drape_frontend/traffic_generator.hpp | 3 |
9 files changed, 67 insertions, 4 deletions
diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp index 481bc14ebd..ce75b4cd96 100644 --- a/drape_frontend/backend_renderer.cpp +++ b/drape_frontend/backend_renderer.cpp @@ -38,6 +38,8 @@ BackendRenderer::BackendRenderer(Params const & params) m_isTeardowned = false; #endif + TrafficGenerator::SetSimplifiedColorSchemeEnabled(params.m_simplifiedTrafficColors); + ASSERT(m_updateCurrentCountryFn != nullptr, ()); m_routeBuilder = make_unique_dp<RouteBuilder>([this](drape_ptr<RouteData> && routeData) @@ -380,6 +382,7 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message) MessagePriority::Normal); break; } + case Message::ClearTrafficData: { ref_ptr<ClearTrafficDataMessage> msg = message; @@ -391,6 +394,20 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message) MessagePriority::Normal); break; } + + case Message::SetSimplifiedTrafficColors: + { + ref_ptr<SetSimplifiedTrafficColorsMessage> msg = message; + + m_trafficGenerator->SetSimplifiedColorSchemeEnabled(msg->IsSimplified()); + m_trafficGenerator->InvalidateTexturesCache(); + + m_commutator->PostMessage(ThreadsCommutator::RenderThread, + make_unique_dp<SetSimplifiedTrafficColorsMessage>(msg->IsSimplified()), + MessagePriority::Normal); + break; + } + case Message::DrapeApiAddLines: { ref_ptr<DrapeApiAddLinesMessage> msg = message; diff --git a/drape_frontend/backend_renderer.hpp b/drape_frontend/backend_renderer.hpp index 15d138e0a3..b8b1f8a417 100644 --- a/drape_frontend/backend_renderer.hpp +++ b/drape_frontend/backend_renderer.hpp @@ -39,13 +39,14 @@ public: ref_ptr<dp::TextureManager> texMng, MapDataProvider const & model, TUpdateCurrentCountryFn const & updateCurrentCountryFn, ref_ptr<RequestedTiles> requestedTiles, bool allow3dBuildings, - bool trafficEnabled) + bool trafficEnabled, bool simplifiedTrafficColors) : BaseRenderer::Params(commutator, factory, texMng) , m_model(model) , m_updateCurrentCountryFn(updateCurrentCountryFn) , m_requestedTiles(requestedTiles) , m_allow3dBuildings(allow3dBuildings) , m_trafficEnabled(trafficEnabled) + , m_simplifiedTrafficColors(simplifiedTrafficColors) {} MapDataProvider const & m_model; @@ -53,6 +54,7 @@ public: ref_ptr<RequestedTiles> m_requestedTiles; bool m_allow3dBuildings; bool m_trafficEnabled; + bool m_simplifiedTrafficColors; }; BackendRenderer(Params const & params); diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index c81c5f8fa3..d39a1c0851 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -67,7 +67,7 @@ DrapeEngine::DrapeEngine(Params && params) frParams.m_texMng, params.m_model, params.m_model.UpdateCurrentCountryFn(), make_ref(m_requestedTiles), params.m_allow3dBuildings, - params.m_trafficEnabled); + params.m_trafficEnabled, params.m_simplifiedTrafficColors); m_backend = make_unique_dp<BackendRenderer>(brParams); m_widgetsInfo = move(params.m_info); @@ -560,6 +560,13 @@ void DrapeEngine::ClearTrafficCache(MwmSet::MwmId const & mwmId) MessagePriority::Normal); } +void DrapeEngine::SetSimplifiedTrafficColors(bool simplified) +{ + m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, + make_unique_dp<SetSimplifiedTrafficColorsMessage>(simplified), + MessagePriority::Normal); +} + void DrapeEngine::SetFontScaleFactor(double scaleFactor) { double const kMinScaleFactor = 0.5; diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index 76ddb562a7..6d70cedd31 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -54,7 +54,8 @@ public: vector<m2::TriangleD> && boundAreaTriangles, bool firstLaunch, bool isRoutingActive, - bool isAutozoomEnabled) + bool isAutozoomEnabled, + bool simplifiedTrafficColors) : m_factory(factory) , m_stringsBundle(stringBundle) , m_viewport(viewport) @@ -72,6 +73,7 @@ public: , m_isFirstLaunch(firstLaunch) , m_isRoutingActive(isRoutingActive) , m_isAutozoomEnabled(isAutozoomEnabled) + , m_simplifiedTrafficColors(simplifiedTrafficColors) {} ref_ptr<dp::OGLContextFactory> m_factory; @@ -91,6 +93,7 @@ public: bool m_isFirstLaunch; bool m_isRoutingActive; bool m_isAutozoomEnabled; + bool m_simplifiedTrafficColors; }; DrapeEngine(Params && params); @@ -176,6 +179,7 @@ public: void EnableTraffic(bool trafficEnabled); void UpdateTraffic(traffic::TrafficInfo const & info); void ClearTrafficCache(MwmSet::MwmId const & mwmId); + void SetSimplifiedTrafficColors(bool simplified); void SetFontScaleFactor(double scaleFactor); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 2f9a1d1b01..e1b6327c30 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -737,6 +737,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message) } case Message::RegenerateTraffic: + case Message::SetSimplifiedTrafficColors: { m_needRegenerateTraffic = true; break; diff --git a/drape_frontend/message.hpp b/drape_frontend/message.hpp index dfccdf43f7..2b268aab79 100644 --- a/drape_frontend/message.hpp +++ b/drape_frontend/message.hpp @@ -71,6 +71,7 @@ public: UpdateTraffic, FlushTrafficData, ClearTrafficData, + SetSimplifiedTrafficColors, DrapeApiAddLines, DrapeApiRemove, DrapeApiFlush, diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index 2109c8a04d..ec023666e1 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -1085,6 +1085,21 @@ private: MwmSet::MwmId m_mwmId; }; +class SetSimplifiedTrafficColorsMessage : public Message +{ +public: + SetSimplifiedTrafficColorsMessage(bool isSimplified) + : m_isSimplified(isSimplified) + {} + + Type GetType() const override { return Message::SetSimplifiedTrafficColors; } + + bool IsSimplified() const { return m_isSimplified; } + +private: + bool const m_isSimplified; +}; + class DrapeApiAddLinesMessage : public Message { public: diff --git a/drape_frontend/traffic_generator.cpp b/drape_frontend/traffic_generator.cpp index 574e626425..399312cf09 100644 --- a/drape_frontend/traffic_generator.cpp +++ b/drape_frontend/traffic_generator.cpp @@ -103,6 +103,8 @@ void GenerateCapTriangles(glsl::vec3 const & pivot, vector<glsl::vec2> const & n } // namespace +bool TrafficGenerator::m_simplifiedColorScheme = true; + void TrafficGenerator::Init() { int constexpr kBatchersCount = 3; @@ -332,6 +334,12 @@ void TrafficGenerator::GenerateLineSegment(dp::TextureManager::ColorRegion const } // static +void TrafficGenerator::SetSimplifiedColorSchemeEnabled(bool enabled) +{ + m_simplifiedColorScheme = enabled; +} + +// static df::ColorConstant TrafficGenerator::GetColorBySpeedGroup(traffic::SpeedGroup const & speedGroup, bool route) { size_t constexpr kSpeedGroupsCount = static_cast<size_t>(traffic::SpeedGroup::Count); @@ -359,7 +367,12 @@ df::ColorConstant TrafficGenerator::GetColorBySpeedGroup(traffic::SpeedGroup con "TrafficUnknown", }}; - size_t const index = static_cast<size_t>(speedGroup); + traffic::SpeedGroup group = speedGroup; + // In simplified color scheme we reduce amount of speed groups visually. + if (m_simplifiedColorScheme && speedGroup == traffic::SpeedGroup::G4) + group = traffic::SpeedGroup::G3; + + size_t const index = static_cast<size_t>(group); ASSERT_LESS(index, kSpeedGroupsCount, ()); return route ? kColorMapRoute[index] : kColorMap[index]; } diff --git a/drape_frontend/traffic_generator.hpp b/drape_frontend/traffic_generator.hpp index e9c331c8d2..3bc9d4608a 100644 --- a/drape_frontend/traffic_generator.hpp +++ b/drape_frontend/traffic_generator.hpp @@ -147,6 +147,7 @@ public: void ClearCache(MwmSet::MwmId const & mwmId); void InvalidateTexturesCache(); + static void SetSimplifiedColorSchemeEnabled(bool enabled); static df::ColorConstant GetColorBySpeedGroup(traffic::SpeedGroup const & speedGroup, bool route); private: @@ -200,6 +201,8 @@ private: dp::AttributeProvider m_providerTriangles; dp::AttributeProvider m_providerLines; + + static bool m_simplifiedColorScheme; }; } // namespace df |