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:
authorDaria Volvenkova <d.volvenkova@corp.mail.ru>2016-06-06 10:49:47 +0300
committerDaria Volvenkova <d.volvenkova@corp.mail.ru>2016-06-06 10:49:47 +0300
commitb3d3b3fa406a42676231e06f182c1167af9cc561 (patch)
treef840b899ad292604b79024ca2a9f4a9139945749 /drape_frontend
parent2aa8f994bc66418c0b994807cf70dbbd50f4ff19 (diff)
parent0ae1e5808ada0f418aad7a03d47323c5a8e9f003 (diff)
Merge pull request #3427 from rokuz/added-dashed-routes
Added support of dashes in route visualization
Diffstat (limited to 'drape_frontend')
-rw-r--r--drape_frontend/backend_renderer.cpp3
-rw-r--r--drape_frontend/drape_engine.cpp4
-rw-r--r--drape_frontend/drape_engine.hpp5
-rwxr-xr-xdrape_frontend/frontend_renderer.cpp3
-rw-r--r--drape_frontend/message_subclasses.hpp6
-rw-r--r--drape_frontend/route_builder.cpp4
-rw-r--r--drape_frontend/route_builder.hpp3
-rw-r--r--drape_frontend/route_renderer.cpp12
-rw-r--r--drape_frontend/route_shape.hpp16
9 files changed, 45 insertions, 11 deletions
diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp
index 9ee46fe45b..cf0c5818b2 100644
--- a/drape_frontend/backend_renderer.cpp
+++ b/drape_frontend/backend_renderer.cpp
@@ -217,7 +217,8 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
case Message::AddRoute:
{
ref_ptr<AddRouteMessage> msg = message;
- m_routeBuilder->Build(msg->GetRoutePolyline(), msg->GetTurns(), msg->GetColor(), m_texMng);
+ m_routeBuilder->Build(msg->GetRoutePolyline(), msg->GetTurns(),
+ msg->GetColor(), msg->GetPattern(), m_texMng);
break;
}
case Message::CacheRouteSign:
diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp
index 3a5e767d0f..ecd729ae7a 100644
--- a/drape_frontend/drape_engine.cpp
+++ b/drape_frontend/drape_engine.cpp
@@ -344,10 +344,10 @@ bool DrapeEngine::GetMyPosition(m2::PointD & myPosition)
}
void DrapeEngine::AddRoute(m2::PolylineD const & routePolyline, vector<double> const & turns,
- df::ColorConstant color)
+ df::ColorConstant color, df::RoutePattern pattern)
{
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
- make_unique_dp<AddRouteMessage>(routePolyline, turns, color),
+ make_unique_dp<AddRouteMessage>(routePolyline, turns, color, pattern),
MessagePriority::Normal);
}
diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp
index dad1982e66..8799059452 100644
--- a/drape_frontend/drape_engine.hpp
+++ b/drape_frontend/drape_engine.hpp
@@ -3,8 +3,9 @@
#include "drape_frontend/backend_renderer.hpp"
#include "drape_frontend/color_constants.hpp"
#include "drape_frontend/frontend_renderer.hpp"
-#include "drape_frontend/threads_commutator.hpp"
+#include "drape_frontend/route_shape.hpp"
#include "drape_frontend/selection_shape.hpp"
+#include "drape_frontend/threads_commutator.hpp"
#include "drape/pointers.hpp"
#include "drape/texture_manager.hpp"
@@ -121,7 +122,7 @@ public:
SelectionShape::ESelectedObject GetSelectedObject();
void AddRoute(m2::PolylineD const & routePolyline, vector<double> const & turns,
- df::ColorConstant color);
+ df::ColorConstant color, df::RoutePattern pattern = df::RoutePattern());
void RemoveRoute(bool deactivateFollowing);
void FollowRoute(int preferredZoomLevel, int preferredZoomLevel3d, double rotationAngle, double angleFOV);
void DeactivateRouteFollowing();
diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp
index 783ee969f3..1f1ffa9286 100755
--- a/drape_frontend/frontend_renderer.cpp
+++ b/drape_frontend/frontend_renderer.cpp
@@ -590,7 +590,8 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
{
auto recacheRouteMsg = make_unique_dp<AddRouteMessage>(routeData->m_sourcePolyline,
routeData->m_sourceTurns,
- routeData->m_color);
+ routeData->m_color,
+ routeData->m_pattern);
m_routeRenderer->Clear(true /* keepDistanceFromBegin */);
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, move(recacheRouteMsg),
MessagePriority::Normal);
diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp
index 508e34119d..4122e85397 100644
--- a/drape_frontend/message_subclasses.hpp
+++ b/drape_frontend/message_subclasses.hpp
@@ -544,10 +544,12 @@ private:
class AddRouteMessage : public Message
{
public:
- AddRouteMessage(m2::PolylineD const & routePolyline, vector<double> const & turns, df::ColorConstant color)
+ AddRouteMessage(m2::PolylineD const & routePolyline, vector<double> const & turns,
+ df::ColorConstant color, df::RoutePattern const & pattern)
: m_routePolyline(routePolyline)
, m_color(color)
, m_turns(turns)
+ , m_pattern(pattern)
{}
Type GetType() const override { return Message::AddRoute; }
@@ -555,11 +557,13 @@ public:
m2::PolylineD const & GetRoutePolyline() { return m_routePolyline; }
df::ColorConstant GetColor() const { return m_color; }
vector<double> const & GetTurns() const { return m_turns; }
+ df::RoutePattern const & GetPattern() const { return m_pattern; }
private:
m2::PolylineD m_routePolyline;
df::ColorConstant m_color;
vector<double> m_turns;
+ df::RoutePattern m_pattern;
};
class CacheRouteSignMessage : public Message
diff --git a/drape_frontend/route_builder.cpp b/drape_frontend/route_builder.cpp
index 1051b4ddda..cb49392083 100644
--- a/drape_frontend/route_builder.cpp
+++ b/drape_frontend/route_builder.cpp
@@ -12,7 +12,8 @@ RouteBuilder::RouteBuilder(TFlushRouteFn const & flushRouteFn,
{}
void RouteBuilder::Build(m2::PolylineD const & routePolyline, vector<double> const & turns,
- df::ColorConstant color, ref_ptr<dp::TextureManager> textures)
+ df::ColorConstant color, df::RoutePattern const & pattern,
+ ref_ptr<dp::TextureManager> textures)
{
CommonViewParams params;
params.m_minVisibleScale = 1;
@@ -23,6 +24,7 @@ void RouteBuilder::Build(m2::PolylineD const & routePolyline, vector<double> con
routeData->m_color = color;
routeData->m_sourcePolyline = routePolyline;
routeData->m_sourceTurns = turns;
+ routeData->m_pattern = pattern;
RouteShape(params).Draw(textures, *routeData.get());
// Flush route geometry.
diff --git a/drape_frontend/route_builder.hpp b/drape_frontend/route_builder.hpp
index e6a34dab44..8bcf046af0 100644
--- a/drape_frontend/route_builder.hpp
+++ b/drape_frontend/route_builder.hpp
@@ -23,7 +23,8 @@ public:
TFlushRouteSignFn const & flushRouteSignFn);
void Build(m2::PolylineD const & routePolyline, vector<double> const & turns,
- df::ColorConstant color, ref_ptr<dp::TextureManager> textures);
+ df::ColorConstant color, df::RoutePattern const & pattern,
+ ref_ptr<dp::TextureManager> textures);
void BuildSign(m2::PointD const & pos, bool isStart, bool isValid,
ref_ptr<dp::TextureManager> textures);
diff --git a/drape_frontend/route_renderer.cpp b/drape_frontend/route_renderer.cpp
index 9336876dac..446d89b27a 100644
--- a/drape_frontend/route_renderer.cpp
+++ b/drape_frontend/route_renderer.cpp
@@ -183,10 +183,18 @@ void RouteRenderer::RenderRoute(ScreenBase const & screen, ref_ptr<dp::GpuProgra
glsl::vec4 const color = glsl::ToVec4(df::GetColorConstant(GetStyleReader().GetCurrentStyle(),
m_routeData->m_color));
uniforms.SetFloatValue("u_color", color.r, color.g, color.b, alpha);
- uniforms.SetFloatValue("u_routeParams", halfWidth, halfWidth * screen.GetScale(), m_distanceFromBegin);
+ double const screenScale = screen.GetScale();
+ uniforms.SetFloatValue("u_routeParams", halfWidth, halfWidth * screenScale, m_distanceFromBegin);
+
+ if (m_routeData->m_pattern.m_isDashed)
+ {
+ uniforms.SetFloatValue("u_pattern", halfWidth * m_routeData->m_pattern.m_dashLength * screenScale,
+ halfWidth * m_routeData->m_pattern.m_gapLength * screenScale);
+ }
// set up shaders and apply uniforms
- ref_ptr<dp::GpuProgram> prg = mng->GetProgram(gpu::ROUTE_PROGRAM);
+ ref_ptr<dp::GpuProgram> prg = mng->GetProgram(m_routeData->m_pattern.m_isDashed ?
+ gpu::ROUTE_DASH_PROGRAM : gpu::ROUTE_PROGRAM);
prg->Bind();
dp::ApplyState(state, prg);
dp::ApplyUniforms(uniforms, prg);
diff --git a/drape_frontend/route_shape.hpp b/drape_frontend/route_shape.hpp
index 77f8b598cb..8d0155631e 100644
--- a/drape_frontend/route_shape.hpp
+++ b/drape_frontend/route_shape.hpp
@@ -18,6 +18,21 @@ namespace df
double const kArrowSize = 0.001;
+struct RoutePattern
+{
+ bool m_isDashed = false;
+ double m_dashLength = 0.0;
+ double m_gapLength = 0.0;
+
+ RoutePattern() = default;
+
+ RoutePattern(double dashLength, double gapLength)
+ : m_isDashed(true)
+ , m_dashLength(dashLength)
+ , m_gapLength(gapLength)
+ {}
+};
+
struct RouteJoinBounds
{
double m_start = 0;
@@ -50,6 +65,7 @@ struct RouteData
double m_length;
RouteRenderProperty m_route;
vector<drape_ptr<ArrowRenderProperty>> m_arrows;
+ RoutePattern m_pattern;
};
struct RouteSignData