forked from organicmaps/organicmaps
doesn't cancel already rendering first tile in new coverage.
This commit is contained in:
parent
6b06509cc8
commit
63fbe9f8a8
5 changed files with 62 additions and 2 deletions
|
@ -244,8 +244,10 @@ void ScreenCoverage::SetScreen(ScreenBase const & screen)
|
|||
m_tileRenderer->ClearCommands();
|
||||
/// setting new sequenceID
|
||||
m_tileRenderer->SetSequenceID(m_tiler.sequenceID());
|
||||
/// cancelling commands in progress
|
||||
m_tileRenderer->CancelCommands();
|
||||
|
||||
/// checking, whether we should cancel tile that is currently rendering
|
||||
m_tileRenderer->CheckCurrentTiles(newRects);
|
||||
|
||||
/// adding commands for tiles which aren't in cache
|
||||
for (size_t i = 0; i < newRects.size(); ++i)
|
||||
m_tileRenderer->AddCommand(newRects[i], m_tiler.sequenceID(),
|
||||
|
|
|
@ -145,6 +145,8 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
|
|||
if (m_resourceManager->renderTargetTextures()->IsCancelled())
|
||||
return;
|
||||
|
||||
StartTile(rectInfo);
|
||||
|
||||
drawer->screen()->setRenderTarget(tileTarget);
|
||||
|
||||
shared_ptr<yg::InfoLayer> tileInfoLayer(new yg::InfoLayer());
|
||||
|
@ -212,6 +214,8 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
|
|||
}
|
||||
}
|
||||
|
||||
FinishTile(rectInfo);
|
||||
|
||||
double duration = timer.ElapsedSeconds();
|
||||
|
||||
if (env.isCancelled())
|
||||
|
@ -285,4 +289,38 @@ void TileRenderer::AddTile(Tiler::RectInfo const & rectInfo, Tile const & tile)
|
|||
m_tileCache.writeUnlock();
|
||||
}
|
||||
|
||||
void TileRenderer::StartTile(Tiler::RectInfo const & rectInfo)
|
||||
{
|
||||
threads::MutexGuard g(m_tilesInProgressMutex);
|
||||
m_tilesInProgress.insert(rectInfo);
|
||||
}
|
||||
|
||||
void TileRenderer::FinishTile(Tiler::RectInfo const & rectInfo)
|
||||
{
|
||||
threads::MutexGuard g(m_tilesInProgressMutex);
|
||||
m_tilesInProgress.erase(rectInfo);
|
||||
}
|
||||
|
||||
void TileRenderer::CheckCurrentTiles(vector<Tiler::RectInfo> & v)
|
||||
{
|
||||
bool shouldCancel = true;
|
||||
|
||||
{
|
||||
threads::MutexGuard g(m_tilesInProgressMutex);
|
||||
|
||||
for (set<Tiler::RectInfo>::const_iterator it = m_tilesInProgress.begin();
|
||||
it != m_tilesInProgress.end();
|
||||
++it)
|
||||
{
|
||||
/// if the first non-drawn tile in new coverage is
|
||||
/// already rendering do not cancell it.
|
||||
if (!v.empty() && v[0] == *it)
|
||||
shouldCancel = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldCancel)
|
||||
CancelCommands();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,6 +57,9 @@ protected:
|
|||
int m_sequenceID;
|
||||
bool m_isExiting;
|
||||
|
||||
threads::Mutex m_tilesInProgressMutex;
|
||||
set<Tiler::RectInfo> m_tilesInProgress;
|
||||
|
||||
void InitializeThreadGL(core::CommandsQueue::Environment const & env);
|
||||
void FinalizeThreadGL(core::CommandsQueue::Environment const & env);
|
||||
void CancelThread(core::CommandsQueue::Environment const & env);
|
||||
|
@ -98,4 +101,11 @@ public:
|
|||
|
||||
bool HasTile(Tiler::RectInfo const & rectInfo);
|
||||
void AddTile(Tiler::RectInfo const & rectInfo, Tile const & tile);
|
||||
|
||||
void StartTile(Tiler::RectInfo const & rectInfo);
|
||||
void FinishTile(Tiler::RectInfo const & rectInfo);
|
||||
|
||||
/// checking, whether we should cancell currently rendering tiles,
|
||||
/// or continue with theirs rendering.
|
||||
void CheckCurrentTiles(vector<Tiler::RectInfo> & v);
|
||||
};
|
||||
|
|
|
@ -50,6 +50,15 @@ bool operator<(Tiler::RectInfo const & l, Tiler::RectInfo const & r)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool operator==(Tiler::RectInfo const & l, Tiler::RectInfo const & r)
|
||||
{
|
||||
return (l.m_y == r.m_y)
|
||||
&& (l.m_x == r.m_x)
|
||||
&& (l.m_drawScale == r.m_drawScale)
|
||||
&& (l.m_tileScale == r.m_tileScale);
|
||||
}
|
||||
|
||||
|
||||
int Tiler::drawScale(ScreenBase const & s) const
|
||||
{
|
||||
ScreenBase tmpS = s;
|
||||
|
|
|
@ -60,3 +60,4 @@ struct LessByDistance
|
|||
};
|
||||
|
||||
bool operator<(Tiler::RectInfo const & l, Tiler::RectInfo const & r);
|
||||
bool operator==(Tiler::RectInfo const & l, Tiler::RectInfo const & r);
|
||||
|
|
Loading…
Add table
Reference in a new issue