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>2015-06-09 16:59:36 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2015-11-30 16:08:35 +0300
commitaf730363bda56116403fe6e1d1d75dc06eeb115b (patch)
treec84241f8b80e555bf2ec6e1e48c889225cb0f03a
parentcd0dc231ad79c089b254038ffe0f8141cf0989b0 (diff)
Review fixes
-rw-r--r--drape/shaders/route_fragment_shader.fsh3
-rw-r--r--drape_frontend/backend_renderer.cpp1
-rw-r--r--drape_frontend/drape_engine.cpp12
-rw-r--r--drape_frontend/drape_engine.hpp4
-rwxr-xr-xdrape_frontend/frontend_renderer.cpp14
-rw-r--r--drape_frontend/message.hpp1
-rw-r--r--drape_frontend/message_subclasses.hpp17
-rw-r--r--drape_frontend/my_position_controller.cpp8
-rw-r--r--drape_frontend/route_renderer.cpp28
-rw-r--r--drape_frontend/route_renderer.hpp8
-rw-r--r--map/framework.cpp14
-rw-r--r--map/framework.hpp4
-rw-r--r--platform/location.hpp19
-rw-r--r--routing/route.hpp2
14 files changed, 63 insertions, 72 deletions
diff --git a/drape/shaders/route_fragment_shader.fsh b/drape/shaders/route_fragment_shader.fsh
index 4417577093..94e5b07f9c 100644
--- a/drape/shaders/route_fragment_shader.fsh
+++ b/drape/shaders/route_fragment_shader.fsh
@@ -1,12 +1,11 @@
varying float v_length;
-uniform vec2 u_halfWidth;
uniform vec4 u_color;
uniform float u_clipLength;
void main(void)
{
- if (u_color.a < 0.1 || v_length < u_clipLength)
+ if (v_length < u_clipLength)
discard;
gl_FragColor = u_color;
diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp
index ab2b923be4..42e68e1fdd 100644
--- a/drape_frontend/backend_renderer.cpp
+++ b/drape_frontend/backend_renderer.cpp
@@ -209,6 +209,7 @@ void BackendRenderer::ReleaseResources()
m_readManager.reset();
m_batchersPool.reset();
+ m_routeBuilder.reset();
m_texMng->Release();
}
diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp
index 020245d440..1f53804206 100644
--- a/drape_frontend/drape_engine.cpp
+++ b/drape_frontend/drape_engine.cpp
@@ -221,11 +221,10 @@ void DrapeEngine::SetCompassInfo(location::CompassInfo const & info)
MessagePriority::High);
}
-void DrapeEngine::SetGpsInfo(location::GpsInfo const & info, bool isNavigable, const location::RouteMatchingInfo & routeInfo,
- bool hasDistanceFromBegin, double distanceFromBegin)
+void DrapeEngine::SetGpsInfo(location::GpsInfo const & info, bool isNavigable, const location::RouteMatchingInfo & routeInfo)
{
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
- make_unique_dp<GpsInfoMessage>(info, isNavigable, routeInfo, hasDistanceFromBegin, distanceFromBegin),
+ make_unique_dp<GpsInfoMessage>(info, isNavigable, routeInfo),
MessagePriority::High);
}
@@ -324,11 +323,4 @@ void DrapeEngine::RemoveRoute(bool deactivateFollowing)
MessagePriority::Normal);
}
-void DrapeEngine::FollowRoute()
-{
- m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
- make_unique_dp<FollowRouteMessage>(),
- MessagePriority::Normal);
-}
-
} // namespace df
diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp
index 5814e2ff6d..640c54d7b0 100644
--- a/drape_frontend/drape_engine.hpp
+++ b/drape_frontend/drape_engine.hpp
@@ -78,8 +78,7 @@ public:
void SetCountryInfo(gui::CountryInfo const & info, bool isCurrentCountry, bool isCountryLoaded);
void SetCompassInfo(location::CompassInfo const & info);
- void SetGpsInfo(location::GpsInfo const & info, bool isNavigable, location::RouteMatchingInfo const & routeInfo,
- bool hasDistanceFromBegin, double distanceFromBegin);
+ void SetGpsInfo(location::GpsInfo const & info, bool isNavigable, location::RouteMatchingInfo const & routeInfo);
void MyPositionNextMode();
void CancelMyPosition();
void StopLocationFollow();
@@ -98,7 +97,6 @@ public:
void AddRoute(m2::PolylineD const & routePolyline, dp::Color const & color);
void RemoveRoute(bool deactivateFollowing);
- void FollowRoute();
private:
void AddUserEvent(UserEvent const & e);
diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp
index edf4bf0ceb..d1528a1f5f 100755
--- a/drape_frontend/frontend_renderer.cpp
+++ b/drape_frontend/frontend_renderer.cpp
@@ -237,8 +237,9 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
ref_ptr<GpsInfoMessage> msg = message;
m_myPositionController->OnLocationUpdate(msg->GetInfo(), msg->IsNavigable());
- if (msg->HasDistanceFromBegin())
- m_routeRenderer->UpdateDistanceFromBegin(msg->GetDistanceFromBegin());
+ location::RouteMatchingInfo const & info = msg->GetRouteInfo();
+ if (info.HasDistanceFromBegin())
+ m_routeRenderer->UpdateDistanceFromBegin(info.GetDistanceFromBegin());
break;
}
@@ -280,23 +281,18 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
ref_ptr<FlushRouteMessage> msg = message;
dp::GLState const & state = msg->GetState();
drape_ptr<dp::RenderBucket> bucket = msg->AcceptBuffer();
- m_routeRenderer->AddRoute(state, move(bucket), msg->GetColor(), make_ref(m_gpuProgramManager));
+ m_routeRenderer->AddRouteRenderBucket(state, move(bucket), msg->GetColor(), make_ref(m_gpuProgramManager));
m_myPositionController->ActivateRouting();
break;
}
case Message::RemoveRoute:
{
ref_ptr<RemoveRouteMessage> msg = message;
- m_routeRenderer->RemoveAllRoutes();
+ m_routeRenderer->Clear();
if (msg->NeedDeactivateFollowing())
m_myPositionController->DeactivateRouting();
break;
}
- case Message::FollowRoute:
- {
- m_myPositionController->NextMode();
- break;
- }
default:
ASSERT(false, ());
}
diff --git a/drape_frontend/message.hpp b/drape_frontend/message.hpp
index dcfbc2cc2a..7366e06e45 100644
--- a/drape_frontend/message.hpp
+++ b/drape_frontend/message.hpp
@@ -34,7 +34,6 @@ public:
GetMyPosition,
AddRoute,
RemoveRoute,
- FollowRoute,
FlushRoute
};
diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp
index d0bd8555ef..53c34f61d3 100644
--- a/drape_frontend/message_subclasses.hpp
+++ b/drape_frontend/message_subclasses.hpp
@@ -339,28 +339,21 @@ class GpsInfoMessage : public Message
{
public:
GpsInfoMessage(location::GpsInfo const & info, bool isNavigable,
- location::RouteMatchingInfo const & routeInfo,
- bool hasDistanceFromBegin, double distanceFromBegin)
+ location::RouteMatchingInfo const & routeInfo)
: m_info(info)
, m_isNavigable(isNavigable)
, m_routeInfo(routeInfo)
- , m_hasDistanceFromBegin(hasDistanceFromBegin)
- , m_distanceFromBegin(distanceFromBegin)
{}
Type GetType() const override { return Message::GpsInfo; }
location::GpsInfo const & GetInfo() const { return m_info; }
bool IsNavigable() const { return m_isNavigable; }
location::RouteMatchingInfo const & GetRouteInfo() const { return m_routeInfo; }
- bool HasDistanceFromBegin() const { return m_hasDistanceFromBegin; }
- double GetDistanceFromBegin() const { return m_distanceFromBegin; }
private:
location::GpsInfo const m_info;
bool const m_isNavigable;
location::RouteMatchingInfo const m_routeInfo;
- bool const m_hasDistanceFromBegin;
- double const m_distanceFromBegin;
};
class BaseBlockingMessage : public Message
@@ -509,14 +502,6 @@ private:
bool m_deactivateFollowing;
};
-class FollowRouteMessage : public Message
-{
-public:
- FollowRouteMessage(){}
-
- Type GetType() const override { return Message::FollowRoute; }
-};
-
class FlushRouteMessage : public Message
{
public:
diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp
index 935044cb26..646182eaa5 100644
--- a/drape_frontend/my_position_controller.cpp
+++ b/drape_frontend/my_position_controller.cpp
@@ -443,7 +443,15 @@ void MyPositionController::ActivateRouting()
void MyPositionController::DeactivateRouting()
{
if (IsInRouting())
+ {
SetModeInfo(ResetModeBit(m_modeInfo, RoutingSessionBit));
+
+ location::EMyPositionMode currentMode = GetMode();
+ if (currentMode == location::MODE_ROTATE_AND_FOLLOW)
+ SetModeInfo(ChangeMode(m_modeInfo, location::MODE_FOLLOW));
+
+ ChangeModelView(0.0);
+ }
}
}
diff --git a/drape_frontend/route_renderer.cpp b/drape_frontend/route_renderer.cpp
index f9d78131be..ebdb782245 100644
--- a/drape_frontend/route_renderer.cpp
+++ b/drape_frontend/route_renderer.cpp
@@ -41,36 +41,38 @@ void RouteRenderer::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramMana
// half width calculation
float halfWidth = 0.0;
double const zoomLevel = my::clamp(fabs(log(screen.GetScale()) / log(2.0)), 1.0, scales::UPPER_STYLE_SCALE);
- int const index = static_cast<int>(zoomLevel) - 1;
- float const lerpCoef = static_cast<float>(zoomLevel - static_cast<int>(zoomLevel));
+ double const truncedZoom = trunc(zoomLevel);
+ int const index = truncedZoom - 1.0;
+ float const lerpCoef = zoomLevel - truncedZoom;
+
if (index < scales::UPPER_STYLE_SCALE - 1)
halfWidth = halfWidthInPixel[index] + lerpCoef * (halfWidthInPixel[index + 1] - halfWidthInPixel[index]);
else
halfWidth = halfWidthInPixel[index];
- for (RouteGraphics & route : m_routes)
+ for (RouteGraphics & graphics : m_routeGraphics)
{
dp::UniformValuesStorage uniformStorage;
- glsl::vec4 color = glsl::ToVec4(route.m_color);
+ glsl::vec4 color = glsl::ToVec4(graphics.m_color);
uniformStorage.SetFloatValue("u_color", color.r, color.g, color.b, color.a);
uniformStorage.SetFloatValue("u_halfWidth", halfWidth, halfWidth * screen.GetScale());
uniformStorage.SetFloatValue("u_clipLength", m_distanceFromBegin);
- ref_ptr<dp::GpuProgram> prg = mng->GetProgram(route.m_state.GetProgramIndex());
+ ref_ptr<dp::GpuProgram> prg = mng->GetProgram(graphics.m_state.GetProgramIndex());
prg->Bind();
- dp::ApplyState(route.m_state, prg);
+ dp::ApplyState(graphics.m_state, prg);
dp::ApplyUniforms(commonUniforms, prg);
dp::ApplyUniforms(uniformStorage, prg);
- route.m_buffer->Render();
+ graphics.m_buffer->Render();
}
}
-void RouteRenderer::AddRoute(dp::GLState const & state, drape_ptr<dp::RenderBucket> && bucket,
- dp::Color const & color, ref_ptr<dp::GpuProgramManager> mng)
+void RouteRenderer::AddRouteRenderBucket(dp::GLState const & state, drape_ptr<dp::RenderBucket> && bucket,
+ dp::Color const & color, ref_ptr<dp::GpuProgramManager> mng)
{
- m_routes.push_back(RouteGraphics());
- RouteGraphics & route = m_routes.back();
+ m_routeGraphics.push_back(RouteGraphics());
+ RouteGraphics & route = m_routeGraphics.back();
route.m_state = state;
route.m_color = color;
@@ -78,9 +80,9 @@ void RouteRenderer::AddRoute(dp::GLState const & state, drape_ptr<dp::RenderBuck
route.m_buffer->Build(mng->GetProgram(route.m_state.GetProgramIndex()));
}
-void RouteRenderer::RemoveAllRoutes()
+void RouteRenderer::Clear()
{
- m_routes.clear();
+ m_routeGraphics.clear();
}
void RouteRenderer::UpdateDistanceFromBegin(double distanceFromBegin)
diff --git a/drape_frontend/route_renderer.hpp b/drape_frontend/route_renderer.hpp
index 033e00682c..3f830418c8 100644
--- a/drape_frontend/route_renderer.hpp
+++ b/drape_frontend/route_renderer.hpp
@@ -31,15 +31,15 @@ public:
void Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng,
dp::UniformValuesStorage const & commonUniforms);
- void AddRoute(dp::GLState const & state, drape_ptr<dp::RenderBucket> && bucket,
- dp::Color const & color, ref_ptr<dp::GpuProgramManager> mng);
+ void AddRouteRenderBucket(dp::GLState const & state, drape_ptr<dp::RenderBucket> && bucket,
+ dp::Color const & color, ref_ptr<dp::GpuProgramManager> mng);
- void RemoveAllRoutes();
+ void Clear();
void UpdateDistanceFromBegin(double distanceFromBegin);
private:
- vector<RouteGraphics> m_routes;
+ vector<RouteGraphics> m_routeGraphics;
double m_distanceFromBegin;
};
diff --git a/map/framework.cpp b/map/framework.cpp
index 93a2f361f7..90bff7cdcf 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -128,13 +128,10 @@ void Framework::OnLocationUpdate(GpsInfo const & info)
location::RouteMatchingInfo routeMatchingInfo;
CheckLocationForRouting(rInfo);
- bool hasDistanceFromBegin = false;
- double distanceFromBegin = 0.0;
- MatchLocationToRoute(rInfo, routeMatchingInfo, hasDistanceFromBegin, distanceFromBegin);
+ MatchLocationToRoute(rInfo, routeMatchingInfo);
CallDrapeFunction(bind(&df::DrapeEngine::SetGpsInfo, _1, rInfo,
- m_routingSession.IsNavigable(), routeMatchingInfo,
- hasDistanceFromBegin, distanceFromBegin));
+ m_routingSession.IsNavigable(), routeMatchingInfo));
}
void Framework::OnCompassUpdate(CompassInfo const & info)
@@ -1868,7 +1865,7 @@ void Framework::BuildRoute(m2::PointD const & start, m2::PointD const & finish,
void Framework::FollowRoute()
{
ASSERT(m_drapeEngine != nullptr, ());
- m_drapeEngine->FollowRoute();
+ m_drapeEngine->MyPositionNextMode();
m2::PointD const & position = m_routingSession.GetUserCurrentPosition();
m_drapeEngine->SetModelViewCenter(position, scales::GetNavigationScale(), true);
@@ -2013,13 +2010,12 @@ void Framework::CheckLocationForRouting(GpsInfo const & info)
}
}
-void Framework::MatchLocationToRoute(location::GpsInfo & location, location::RouteMatchingInfo & routeMatchingInfo,
- bool & hasDistanceFromBegin, double & distanceFromBegin) const
+void Framework::MatchLocationToRoute(location::GpsInfo & location, location::RouteMatchingInfo & routeMatchingInfo) const
{
if (!IsRoutingActive())
return;
+
m_routingSession.MatchLocationToRoute(location, routeMatchingInfo);
- hasDistanceFromBegin = m_routingSession.GetMercatorDistanceFromBegin(distanceFromBegin);
}
void Framework::CallRouteBuilded(IRouter::ResultCode code, vector<storage::TIndex> const & absentCountries, vector<storage::TIndex> const & absentRoutingFiles)
diff --git a/map/framework.hpp b/map/framework.hpp
index e7335c9817..2fef96f2af 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -504,9 +504,7 @@ private:
void CallRouteBuilded(routing::IRouter::ResultCode code,
vector<storage::TIndex> const & absentCountries,
vector<storage::TIndex> const & absentRoutingFiles);
- void MatchLocationToRoute(location::GpsInfo & info, location::RouteMatchingInfo & routeMatchingInfo,
- bool & hasDistanceFromBegin, double & distanceFromBegin) const;
-
+ void MatchLocationToRoute(location::GpsInfo & info, location::RouteMatchingInfo & routeMatchingInfo) const;
string GetRoutingErrorMessage(routing::IRouter::ResultCode code);
TRouteBuildingCallback m_routingCallback;
diff --git a/platform/location.hpp b/platform/location.hpp
index ba640a60cb..c9a0c6ff69 100644
--- a/platform/location.hpp
+++ b/platform/location.hpp
@@ -178,19 +178,34 @@ namespace location
m2::PointD m_matchedPosition;
size_t m_indexInRoute;
bool m_isPositionMatched;
+ bool m_hasDistanceFromBegin;
+ double m_distanceFromBegin;
public:
- RouteMatchingInfo() : m_matchedPosition(0., 0.), m_indexInRoute(0), m_isPositionMatched(false) {}
- void Set(m2::PointD const & matchedPosition, size_t indexInRoute)
+ RouteMatchingInfo()
+ : m_matchedPosition(0., 0.)
+ , m_indexInRoute(0)
+ , m_isPositionMatched(false)
+ , m_hasDistanceFromBegin(false)
+ , m_distanceFromBegin(0.0)
+ {}
+
+ void Set(m2::PointD const & matchedPosition, size_t indexInRoute, double distanceFromBegin)
{
m_matchedPosition = matchedPosition;
m_indexInRoute = indexInRoute;
m_isPositionMatched = true;
+
+ m_distanceFromBegin = distanceFromBegin;
+ m_hasDistanceFromBegin = true;
}
+
void Reset() { m_isPositionMatched = false; }
bool IsMatched() const { return m_isPositionMatched; }
size_t GetIndexInRoute() const { return m_indexInRoute; }
m2::PointD GetPosition() const { return m_matchedPosition; }
+ bool HasDistanceFromBegin() const { return m_hasDistanceFromBegin; }
+ double GetDistanceFromBegin() const { return m_distanceFromBegin; }
};
// Do not change the order and values
diff --git a/routing/route.hpp b/routing/route.hpp
index 45bbe66caa..bfb2764930 100644
--- a/routing/route.hpp
+++ b/routing/route.hpp
@@ -116,6 +116,8 @@ private:
double GetPolySegAngle(size_t ind) const;
TTurns::const_iterator GetCurrentTurn() const;
+ double GetMercatorDistanceFromBegin() const;
+
private:
friend string DebugPrint(Route const & r);