forked from organicmaps/organicmaps
Fixed route disappearing on map style switch (#6846)
Fixed route disappearing on map style switch
This commit is contained in:
parent
6c87c2a9ae
commit
fb3404937c
10 changed files with 55 additions and 30 deletions
|
@ -469,11 +469,11 @@ void DrapeEngine::DeselectObject()
|
|||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
dp::DrapeID DrapeEngine::AddSubroute(drape_ptr<Subroute> && subroute)
|
||||
dp::DrapeID DrapeEngine::AddSubroute(SubrouteConstPtr subroute)
|
||||
{
|
||||
dp::DrapeID const id = GenerateDrapeID();
|
||||
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<AddSubrouteMessage>(id, std::move(subroute)),
|
||||
make_unique_dp<AddSubrouteMessage>(id, subroute),
|
||||
MessagePriority::Normal);
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
FeatureID const & featureID, bool isAnim);
|
||||
void DeselectObject();
|
||||
|
||||
dp::DrapeID AddSubroute(drape_ptr<Subroute> &&segment);
|
||||
dp::DrapeID AddSubroute(SubrouteConstPtr subroute);
|
||||
void RemoveSubroute(dp::DrapeID subrouteId, bool deactivateFollowing);
|
||||
void FollowRoute(int preferredZoomLevel, int preferredZoomLevel3d, bool enableAutoZoom);
|
||||
void DeactivateRouteFollowing();
|
||||
|
|
|
@ -432,9 +432,15 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
|
|||
{
|
||||
ref_ptr<FlushRouteMessage> msg = message;
|
||||
drape_ptr<RouteData> routeData = msg->AcceptRouteData();
|
||||
|
||||
if (routeData->m_recacheId < 0)
|
||||
routeData->m_recacheId = m_lastRecacheRouteId;
|
||||
|
||||
if (!CheckRouteRecaching(make_ref(routeData)))
|
||||
break;
|
||||
|
||||
m_routeRenderer->ClearObsoleteRouteData(m_lastRecacheRouteId);
|
||||
|
||||
m_routeRenderer->AddRouteData(std::move(routeData), make_ref(m_gpuProgramManager));
|
||||
|
||||
// Here we have to recache route arrows.
|
||||
|
@ -821,12 +827,11 @@ void FrontendRenderer::UpdateGLResources()
|
|||
for (auto const & routeData : m_routeRenderer->GetRouteData())
|
||||
{
|
||||
auto msg = make_unique_dp<AddSubrouteMessage>(routeData->m_subrouteId,
|
||||
std::move(routeData->m_subroute),
|
||||
routeData->m_subroute,
|
||||
m_lastRecacheRouteId);
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, std::move(msg),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
m_routeRenderer->ClearRouteData();
|
||||
|
||||
m_trafficRenderer->ClearGLDependentResources();
|
||||
|
||||
|
@ -858,9 +863,6 @@ void FrontendRenderer::FollowRoute(int preferredZoomLevel, int preferredZoomLeve
|
|||
|
||||
bool FrontendRenderer::CheckRouteRecaching(ref_ptr<BaseRouteData> routeData)
|
||||
{
|
||||
if (routeData->m_recacheId < 0)
|
||||
return true;
|
||||
|
||||
return routeData->m_recacheId >= m_lastRecacheRouteId;
|
||||
}
|
||||
|
||||
|
@ -2017,7 +2019,7 @@ void FrontendRenderer::EmitModelViewChanged(ScreenBase const & modelView) const
|
|||
void FrontendRenderer::OnCacheRouteArrows(int routeIndex, std::vector<ArrowBorders> const & borders)
|
||||
{
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<CacheRouteArrowsMessage>(routeIndex, borders),
|
||||
make_unique_dp<CacheRouteArrowsMessage>(routeIndex, borders, m_lastRecacheRouteId),
|
||||
MessagePriority::Normal);
|
||||
}
|
||||
|
||||
|
|
|
@ -547,35 +547,31 @@ private:
|
|||
class AddSubrouteMessage : public Message
|
||||
{
|
||||
public:
|
||||
AddSubrouteMessage(dp::DrapeID subrouteId, drape_ptr<Subroute> && subroute)
|
||||
: AddSubrouteMessage(subrouteId, std::move(subroute), -1 /* invalid recache id */)
|
||||
AddSubrouteMessage(dp::DrapeID subrouteId, SubrouteConstPtr subroute)
|
||||
: AddSubrouteMessage(subrouteId, subroute, -1 /* invalid recache id */)
|
||||
{}
|
||||
|
||||
AddSubrouteMessage(dp::DrapeID subrouteId, drape_ptr<Subroute> && subroute, int recacheId)
|
||||
AddSubrouteMessage(dp::DrapeID subrouteId, SubrouteConstPtr subroute, int recacheId)
|
||||
: m_subrouteId(subrouteId)
|
||||
, m_subroute(std::move(subroute))
|
||||
, m_subroute(subroute)
|
||||
, m_recacheId(recacheId)
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Message::AddSubroute; }
|
||||
|
||||
dp::DrapeID GetSubrouteId() const { return m_subrouteId; };
|
||||
drape_ptr<Subroute> && GetSubroute() { return std::move(m_subroute); }
|
||||
SubrouteConstPtr GetSubroute() const { return m_subroute; }
|
||||
int GetRecacheId() const { return m_recacheId; }
|
||||
|
||||
private:
|
||||
dp::DrapeID m_subrouteId;
|
||||
drape_ptr<Subroute> m_subroute;
|
||||
SubrouteConstPtr m_subroute;
|
||||
int const m_recacheId;
|
||||
};
|
||||
|
||||
class CacheRouteArrowsMessage : public Message
|
||||
{
|
||||
public:
|
||||
CacheRouteArrowsMessage(dp::DrapeID subrouteId, std::vector<ArrowBorders> const & borders)
|
||||
: CacheRouteArrowsMessage(subrouteId, borders, -1 /* invalid recache id */)
|
||||
{}
|
||||
|
||||
CacheRouteArrowsMessage(dp::DrapeID subrouteId, std::vector<ArrowBorders> const & borders,
|
||||
int recacheId)
|
||||
: m_subrouteId(subrouteId)
|
||||
|
|
|
@ -10,12 +10,12 @@ RouteBuilder::RouteBuilder(TFlushRouteFn const & flushRouteFn,
|
|||
, m_flushRouteArrowsFn(flushRouteArrowsFn)
|
||||
{}
|
||||
|
||||
void RouteBuilder::Build(dp::DrapeID subrouteId, drape_ptr<Subroute> && subroute,
|
||||
void RouteBuilder::Build(dp::DrapeID subrouteId, SubrouteConstPtr subroute,
|
||||
ref_ptr<dp::TextureManager> textures, int recacheId)
|
||||
{
|
||||
drape_ptr<RouteData> routeData = make_unique_dp<RouteData>();
|
||||
routeData->m_subrouteId = subrouteId;
|
||||
routeData->m_subroute = std::move(subroute);
|
||||
routeData->m_subroute = subroute;
|
||||
routeData->m_pivot = routeData->m_subroute->m_polyline.GetLimitRect().Center();
|
||||
routeData->m_recacheId = recacheId;
|
||||
RouteShape::CacheRoute(textures, *routeData.get());
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
RouteBuilder(TFlushRouteFn const & flushRouteFn,
|
||||
TFlushRouteArrowsFn const & flushRouteArrowsFn);
|
||||
|
||||
void Build(dp::DrapeID subrouteId, drape_ptr<Subroute> && subroute,
|
||||
void Build(dp::DrapeID subrouteId, SubrouteConstPtr subroute,
|
||||
ref_ptr<dp::TextureManager> textures, int recacheId);
|
||||
|
||||
void BuildArrows(dp::DrapeID subrouteId, std::vector<ArrowBorders> const & borders,
|
||||
|
|
|
@ -61,7 +61,7 @@ uint32_t const kPreviewPointsCount = 512;
|
|||
|
||||
double const kInvalidDistance = -1.0;
|
||||
|
||||
void InterpolateByZoom(drape_ptr<Subroute> const & subroute, ScreenBase const & screen,
|
||||
void InterpolateByZoom(SubrouteConstPtr const & subroute, ScreenBase const & screen,
|
||||
float & halfWidth, double & zoom)
|
||||
{
|
||||
int index = 0;
|
||||
|
@ -88,9 +88,9 @@ float CalculateRadius(ScreenBase const & screen)
|
|||
|
||||
void ClipBorders(std::vector<ArrowBorders> & borders)
|
||||
{
|
||||
auto invalidBorders = [](ArrowBorders const & borders)
|
||||
auto invalidBorders = [](ArrowBorders const & arrowBorders)
|
||||
{
|
||||
return borders.m_groupIndex == kInvalidGroup;
|
||||
return arrowBorders.m_groupIndex == kInvalidGroup;
|
||||
};
|
||||
borders.erase(std::remove_if(borders.begin(), borders.end(), invalidBorders), borders.end());
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ void BuildBuckets(RouteRenderProperty const & renderProperty, ref_ptr<dp::GpuPro
|
|||
bucket->GetBuffer()->Build(mng->GetProgram(renderProperty.m_state.GetProgramIndex()));
|
||||
}
|
||||
|
||||
dp::Color GetOutlineColor(drape_ptr<Subroute> const & subroute)
|
||||
dp::Color GetOutlineColor(SubrouteConstPtr const & subroute)
|
||||
{
|
||||
if (subroute->m_routeType == RouteType::Car || subroute->m_routeType == RouteType::Taxi)
|
||||
return df::GetColorConstant(kRouteOutlineColor);
|
||||
|
@ -377,9 +377,9 @@ dp::Color RouteRenderer::GetMaskColor(RouteType routeType, double baseDistance,
|
|||
{
|
||||
if (routeType == RouteType::Car)
|
||||
return GetColorConstant(arrows ? kRouteArrowsMaskCar : kRouteMaskCar);
|
||||
else if (routeType == RouteType::Bicycle)
|
||||
if (routeType == RouteType::Bicycle)
|
||||
return GetColorConstant(arrows ? kRouteArrowsMaskBicycle : kRouteMaskBicycle);
|
||||
else if (routeType == RouteType::Pedestrian)
|
||||
if (routeType == RouteType::Pedestrian)
|
||||
return GetColorConstant(kRouteMaskPedestrian);
|
||||
}
|
||||
return {0, 0, 0, 0};
|
||||
|
@ -591,6 +591,29 @@ void RouteRenderer::ClearRouteData()
|
|||
m_hiddenSubroutes.clear();
|
||||
}
|
||||
|
||||
void RouteRenderer::ClearObsoleteRouteData(int currentRecacheId)
|
||||
{
|
||||
std::vector<dp::DrapeID> deletedSubroutes;
|
||||
deletedSubroutes.reserve(m_routeData.size());
|
||||
auto const functor = [&deletedSubroutes, ¤tRecacheId](drape_ptr<RouteData> const & data)
|
||||
{
|
||||
if (data->m_recacheId < currentRecacheId)
|
||||
{
|
||||
deletedSubroutes.push_back(data->m_subrouteId);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
m_routeData.erase(std::remove_if(m_routeData.begin(), m_routeData.end(), functor),
|
||||
m_routeData.end());
|
||||
|
||||
for (auto const & subrouteId : deletedSubroutes)
|
||||
{
|
||||
m_routeAdditional[subrouteId].m_arrowsData.reset();
|
||||
m_routeAdditional[subrouteId].m_arrowBorders.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void RouteRenderer::Clear()
|
||||
{
|
||||
ClearRouteData();
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
|
||||
void Clear();
|
||||
void ClearRouteData();
|
||||
void ClearObsoleteRouteData(int currentRecacheId);
|
||||
void ClearGLDependentResources();
|
||||
|
||||
void UpdateDistanceFromBegin(double distanceFromBegin);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "geometry/polyline2d.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace df
|
||||
|
@ -68,6 +69,8 @@ struct Subroute
|
|||
df::RoutePattern m_pattern;
|
||||
};
|
||||
|
||||
using SubrouteConstPtr = std::shared_ptr<Subroute const>;
|
||||
|
||||
struct RouteRenderProperty
|
||||
{
|
||||
dp::GLState m_state;
|
||||
|
@ -87,7 +90,7 @@ struct BaseRouteData
|
|||
|
||||
struct RouteData : public BaseRouteData
|
||||
{
|
||||
drape_ptr<Subroute> m_subroute;
|
||||
SubrouteConstPtr m_subroute;
|
||||
double m_length = 0.0;
|
||||
};
|
||||
|
||||
|
|
|
@ -485,7 +485,7 @@ void RoutingManager::InsertRoute(Route const & route)
|
|||
default: ASSERT(false, ("Unknown router type"));
|
||||
}
|
||||
|
||||
auto const subrouteId = m_drapeEngine->AddSubroute(std::move(subroute));
|
||||
auto const subrouteId = m_drapeEngine->AddSubroute(df::SubrouteConstPtr(subroute.release()));
|
||||
m_drapeSubroutes.push_back(subrouteId);
|
||||
|
||||
// TODO: we will send subrouteId to routing subsystem when we can partly update route.
|
||||
|
|
Loading…
Add table
Reference in a new issue