forked from organicmaps/organicmaps
Route recaching fixed.
This commit is contained in:
parent
b3f50f59e6
commit
baba7b7953
7 changed files with 58 additions and 12 deletions
|
@ -242,19 +242,19 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
|
|||
{
|
||||
ref_ptr<AddRouteMessage> msg = message;
|
||||
m_routeBuilder->Build(msg->GetRoutePolyline(), msg->GetTurns(),
|
||||
msg->GetColor(), msg->GetPattern(), m_texMng);
|
||||
msg->GetColor(), msg->GetPattern(), m_texMng, msg->GetRechacheId());
|
||||
break;
|
||||
}
|
||||
case Message::CacheRouteSign:
|
||||
{
|
||||
ref_ptr<CacheRouteSignMessage> msg = message;
|
||||
m_routeBuilder->BuildSign(msg->GetPosition(), msg->IsStart(), msg->IsValid(), m_texMng);
|
||||
m_routeBuilder->BuildSign(msg->GetPosition(), msg->IsStart(), msg->IsValid(), m_texMng, msg->GetRechacheId());
|
||||
break;
|
||||
}
|
||||
case Message::CacheRouteArrows:
|
||||
{
|
||||
ref_ptr<CacheRouteArrowsMessage> msg = message;
|
||||
m_routeBuilder->BuildArrows(msg->GetRouteIndex(), msg->GetBorders(), m_texMng);
|
||||
m_routeBuilder->BuildArrows(msg->GetRouteIndex(), msg->GetBorders(), m_texMng, msg->GetRechacheId());
|
||||
break;
|
||||
}
|
||||
case Message::RemoveRoute:
|
||||
|
|
|
@ -476,6 +476,10 @@ 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)
|
||||
break;
|
||||
|
||||
m2::PointD const finishPoint = routeData->m_sourcePolyline.Back();
|
||||
m_routeRenderer->SetRouteData(move(routeData), make_ref(m_gpuProgramManager));
|
||||
if (!m_routeRenderer->GetFinishPoint())
|
||||
|
@ -499,6 +503,10 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
|
|||
{
|
||||
ref_ptr<FlushRouteSignMessage> msg = message;
|
||||
drape_ptr<RouteSignData> routeSignData = msg->AcceptRouteSignData();
|
||||
|
||||
if (routeSignData->m_recacheId > 0 && routeSignData->m_recacheId < m_lastRecacheRouteId)
|
||||
break;
|
||||
|
||||
m_routeRenderer->SetRouteSign(move(routeSignData), make_ref(m_gpuProgramManager));
|
||||
break;
|
||||
}
|
||||
|
@ -507,6 +515,10 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
|
|||
{
|
||||
ref_ptr<FlushRouteArrowsMessage> msg = message;
|
||||
drape_ptr<RouteArrowsData> routeArrowsData = msg->AcceptRouteArrowsData();
|
||||
|
||||
if (routeArrowsData->m_recacheId > 0 && routeArrowsData->m_recacheId < m_lastRecacheRouteId)
|
||||
break;
|
||||
|
||||
m_routeRenderer->SetRouteArrows(move(routeArrowsData), make_ref(m_gpuProgramManager));
|
||||
break;
|
||||
}
|
||||
|
@ -515,6 +527,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
|
|||
{
|
||||
ref_ptr<RemoveRouteMessage> msg = message;
|
||||
m_routeRenderer->Clear();
|
||||
++m_lastRecacheRouteId;
|
||||
if (msg->NeedDeactivateFollowing())
|
||||
{
|
||||
m_myPositionController->DeactivateRouting();
|
||||
|
@ -724,13 +737,15 @@ unique_ptr<threads::IRoutine> FrontendRenderer::CreateRoutine()
|
|||
|
||||
void FrontendRenderer::UpdateGLResources()
|
||||
{
|
||||
++m_lastRecacheRouteId;
|
||||
|
||||
// Invalidate route.
|
||||
if (m_routeRenderer->GetStartPoint())
|
||||
{
|
||||
m2::PointD const & position = m_routeRenderer->GetStartPoint()->m_position;
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<CacheRouteSignMessage>(position, true /* isStart */,
|
||||
true /* isValid */),
|
||||
true /* isValid */, m_lastRecacheRouteId),
|
||||
MessagePriority::High);
|
||||
}
|
||||
|
||||
|
@ -739,7 +754,7 @@ void FrontendRenderer::UpdateGLResources()
|
|||
m2::PointD const & position = m_routeRenderer->GetFinishPoint()->m_position;
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
make_unique_dp<CacheRouteSignMessage>(position, false /* isStart */,
|
||||
true /* isValid */),
|
||||
true /* isValid */, m_lastRecacheRouteId),
|
||||
MessagePriority::High);
|
||||
}
|
||||
|
||||
|
@ -749,7 +764,8 @@ void FrontendRenderer::UpdateGLResources()
|
|||
auto recacheRouteMsg = make_unique_dp<AddRouteMessage>(routeData->m_sourcePolyline,
|
||||
routeData->m_sourceTurns,
|
||||
routeData->m_color,
|
||||
routeData->m_pattern);
|
||||
routeData->m_pattern,
|
||||
m_lastRecacheRouteId);
|
||||
m_routeRenderer->ClearGLDependentResources();
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread, move(recacheRouteMsg),
|
||||
MessagePriority::Normal);
|
||||
|
|
|
@ -309,6 +309,8 @@ private:
|
|||
uint64_t m_maxGeneration;
|
||||
int m_mergeBucketsCounter = 0;
|
||||
|
||||
int m_lastRecacheRouteId = 0;
|
||||
|
||||
struct FollowRouteData
|
||||
{
|
||||
FollowRouteData(int preferredZoomLevel,
|
||||
|
|
|
@ -595,10 +595,16 @@ class AddRouteMessage : public Message
|
|||
public:
|
||||
AddRouteMessage(m2::PolylineD const & routePolyline, vector<double> const & turns,
|
||||
df::ColorConstant color, df::RoutePattern const & pattern)
|
||||
: AddRouteMessage(routePolyline, turns, color, pattern, -1 /* invalid recache id */)
|
||||
{}
|
||||
|
||||
AddRouteMessage(m2::PolylineD const & routePolyline, vector<double> const & turns,
|
||||
df::ColorConstant color, df::RoutePattern const & pattern, int recacheId)
|
||||
: m_routePolyline(routePolyline)
|
||||
, m_color(color)
|
||||
, m_turns(turns)
|
||||
, m_pattern(pattern)
|
||||
, m_recacheId(recacheId)
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Message::AddRoute; }
|
||||
|
@ -607,21 +613,28 @@ public:
|
|||
df::ColorConstant GetColor() const { return m_color; }
|
||||
vector<double> const & GetTurns() const { return m_turns; }
|
||||
df::RoutePattern const & GetPattern() const { return m_pattern; }
|
||||
int GetRechacheId() const { return m_recacheId; }
|
||||
|
||||
private:
|
||||
m2::PolylineD m_routePolyline;
|
||||
df::ColorConstant m_color;
|
||||
vector<double> m_turns;
|
||||
df::RoutePattern m_pattern;
|
||||
int const m_recacheId;
|
||||
};
|
||||
|
||||
class CacheRouteSignMessage : public Message
|
||||
{
|
||||
public:
|
||||
CacheRouteSignMessage(m2::PointD const & pos, bool isStart, bool isValid)
|
||||
: CacheRouteSignMessage(pos, isStart, isValid, -1 /* invalid recache id */)
|
||||
{}
|
||||
|
||||
CacheRouteSignMessage(m2::PointD const & pos, bool isStart, bool isValid, int recacheId)
|
||||
: m_position(pos)
|
||||
, m_isStart(isStart)
|
||||
, m_isValid(isValid)
|
||||
, m_recacheId(recacheId)
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Message::CacheRouteSign; }
|
||||
|
@ -629,29 +642,38 @@ public:
|
|||
m2::PointD const & GetPosition() const { return m_position; }
|
||||
bool IsStart() const { return m_isStart; }
|
||||
bool IsValid() const { return m_isValid; }
|
||||
int GetRechacheId() const { return m_recacheId; }
|
||||
|
||||
private:
|
||||
m2::PointD const m_position;
|
||||
bool const m_isStart;
|
||||
bool const m_isValid;
|
||||
int const m_recacheId;
|
||||
};
|
||||
|
||||
class CacheRouteArrowsMessage : public Message
|
||||
{
|
||||
public:
|
||||
CacheRouteArrowsMessage(int routeIndex, vector<ArrowBorders> const & borders)
|
||||
: CacheRouteArrowsMessage(routeIndex, borders, -1 /* invalid recache id */)
|
||||
{}
|
||||
|
||||
CacheRouteArrowsMessage(int routeIndex, vector<ArrowBorders> const & borders, int recacheId)
|
||||
: m_routeIndex(routeIndex)
|
||||
, m_borders(borders)
|
||||
, m_recacheId(recacheId)
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Message::CacheRouteArrows; }
|
||||
|
||||
int GetRouteIndex() const { return m_routeIndex; }
|
||||
vector<ArrowBorders> const & GetBorders() const { return m_borders; }
|
||||
int GetRechacheId() const { return m_recacheId; }
|
||||
|
||||
private:
|
||||
int m_routeIndex;
|
||||
vector<ArrowBorders> m_borders;
|
||||
int const m_recacheId;
|
||||
};
|
||||
|
||||
class RemoveRouteMessage : public Message
|
||||
|
|
|
@ -15,7 +15,7 @@ RouteBuilder::RouteBuilder(TFlushRouteFn const & flushRouteFn,
|
|||
|
||||
void RouteBuilder::Build(m2::PolylineD const & routePolyline, vector<double> const & turns,
|
||||
df::ColorConstant color, df::RoutePattern const & pattern,
|
||||
ref_ptr<dp::TextureManager> textures)
|
||||
ref_ptr<dp::TextureManager> textures, int recacheId)
|
||||
{
|
||||
drape_ptr<RouteData> routeData = make_unique_dp<RouteData>();
|
||||
routeData->m_routeIndex = m_routeIndex++;
|
||||
|
@ -24,6 +24,7 @@ void RouteBuilder::Build(m2::PolylineD const & routePolyline, vector<double> con
|
|||
routeData->m_sourceTurns = turns;
|
||||
routeData->m_pattern = pattern;
|
||||
routeData->m_pivot = routePolyline.GetLimitRect().Center();
|
||||
routeData->m_recacheId = recacheId;
|
||||
RouteShape::CacheRoute(textures, *routeData.get());
|
||||
m_routeCache.insert(make_pair(routeData->m_routeIndex, routePolyline));
|
||||
|
||||
|
@ -40,12 +41,13 @@ void RouteBuilder::ClearRouteCache()
|
|||
}
|
||||
|
||||
void RouteBuilder::BuildSign(m2::PointD const & pos, bool isStart, bool isValid,
|
||||
ref_ptr<dp::TextureManager> textures)
|
||||
ref_ptr<dp::TextureManager> textures, int recacheId)
|
||||
{
|
||||
drape_ptr<RouteSignData> routeSignData = make_unique_dp<RouteSignData>();
|
||||
routeSignData->m_isStart = isStart;
|
||||
routeSignData->m_position = pos;
|
||||
routeSignData->m_isValid = isValid;
|
||||
routeSignData->m_recacheId = recacheId;
|
||||
if (isValid)
|
||||
RouteShape::CacheRouteSign(textures, *routeSignData.get());
|
||||
|
||||
|
@ -57,7 +59,7 @@ void RouteBuilder::BuildSign(m2::PointD const & pos, bool isStart, bool isValid,
|
|||
}
|
||||
|
||||
void RouteBuilder::BuildArrows(int routeIndex, vector<ArrowBorders> const & borders,
|
||||
ref_ptr<dp::TextureManager> textures)
|
||||
ref_ptr<dp::TextureManager> textures, int recacheId)
|
||||
{
|
||||
auto it = m_routeCache.find(routeIndex);
|
||||
if (it == m_routeCache.end())
|
||||
|
@ -65,6 +67,7 @@ void RouteBuilder::BuildArrows(int routeIndex, vector<ArrowBorders> const & bord
|
|||
|
||||
drape_ptr<RouteArrowsData> routeArrowsData = make_unique_dp<RouteArrowsData>();
|
||||
routeArrowsData->m_pivot = it->second.GetLimitRect().Center();
|
||||
routeArrowsData->m_recacheId = recacheId;
|
||||
RouteShape::CacheRouteArrows(textures, it->second, borders, *routeArrowsData.get());
|
||||
|
||||
// Flush route arrows geometry.
|
||||
|
|
|
@ -27,13 +27,13 @@ public:
|
|||
|
||||
void Build(m2::PolylineD const & routePolyline, vector<double> const & turns,
|
||||
df::ColorConstant color, df::RoutePattern const & pattern,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
ref_ptr<dp::TextureManager> textures, int recacheId);
|
||||
|
||||
void BuildArrows(int routeIndex, vector<ArrowBorders> const & borders,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
ref_ptr<dp::TextureManager> textures, int recacheId);
|
||||
|
||||
void BuildSign(m2::PointD const & pos, bool isStart, bool isValid,
|
||||
ref_ptr<dp::TextureManager> textures);
|
||||
ref_ptr<dp::TextureManager> textures, int recacheId);
|
||||
|
||||
void ClearRouteCache();
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ struct RouteData
|
|||
double m_length;
|
||||
RouteRenderProperty m_route;
|
||||
RoutePattern m_pattern;
|
||||
int m_recacheId;
|
||||
};
|
||||
|
||||
struct RouteSignData
|
||||
|
@ -75,12 +76,14 @@ struct RouteSignData
|
|||
bool m_isStart;
|
||||
bool m_isValid;
|
||||
m2::PointD m_position;
|
||||
int m_recacheId;
|
||||
};
|
||||
|
||||
struct RouteArrowsData
|
||||
{
|
||||
RouteRenderProperty m_arrows;
|
||||
m2::PointD m_pivot;
|
||||
int m_recacheId;
|
||||
};
|
||||
|
||||
class RouteShape
|
||||
|
|
Loading…
Add table
Reference in a new issue