forked from organicmaps/organicmaps
proper support for DoForceUpdate and InvalidRect in TilingRenderPolicyST
This commit is contained in:
parent
f7204f9ae5
commit
f3f3ec907d
6 changed files with 81 additions and 12 deletions
|
@ -73,6 +73,40 @@ void CoverageGenerator::Cancel()
|
|||
m_queue.Cancel();
|
||||
}
|
||||
|
||||
void CoverageGenerator::InvalidateTilesImpl(m2::AnyRectD const & r, int startScale)
|
||||
{
|
||||
{
|
||||
threads::MutexGuard g(m_mutex);
|
||||
m_currentCoverage->RemoveTiles(r, startScale);
|
||||
}
|
||||
|
||||
TileCache & tileCache = m_tileRenderer->GetTileCache();
|
||||
|
||||
set<Tiler::RectInfo> k = tileCache.keys();
|
||||
|
||||
for (set<Tiler::RectInfo>::const_iterator it = k.begin(); it != k.end(); ++it)
|
||||
{
|
||||
Tiler::RectInfo ri = *it;
|
||||
if ((ri.m_tileScale >= startScale) && r.IsIntersect(m2::AnyRectD(ri.m_rect)))
|
||||
{
|
||||
ASSERT(tileCache.lockCount(ri) == 0, ());
|
||||
tileCache.remove(ri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CoverageGenerator::InvalidateTiles(m2::AnyRectD const & r, int startScale)
|
||||
{
|
||||
m_queue.Clear();
|
||||
m_sequenceID++;
|
||||
m_queue.CancelCommands();
|
||||
m_queue.Join();
|
||||
|
||||
m_queue.AddCommand(bind(&CoverageGenerator::InvalidateTilesImpl, this, r, startScale), true);
|
||||
|
||||
m_queue.Join();
|
||||
}
|
||||
|
||||
void CoverageGenerator::AddCoverScreenTask(ScreenBase const & screen, bool doForce)
|
||||
{
|
||||
if ((screen == m_currentScreen) && (!doForce))
|
||||
|
|
|
@ -58,6 +58,9 @@ public:
|
|||
void InitializeThreadGL();
|
||||
void FinalizeThreadGL();
|
||||
|
||||
void InvalidateTiles(m2::AnyRectD const & rect, int startScale);
|
||||
void InvalidateTilesImpl(m2::AnyRectD const & rect, int startScale);
|
||||
|
||||
void AddCoverScreenTask(ScreenBase const & screen, bool doForce);
|
||||
void AddMergeTileTask(Tiler::RectInfo const & rectInfo, int sequenceID);
|
||||
|
||||
|
|
|
@ -387,6 +387,31 @@ int ScreenCoverage::GetSequenceID() const
|
|||
{
|
||||
return m_sequenceID;
|
||||
}
|
||||
|
||||
void ScreenCoverage::RemoveTiles(m2::AnyRectD const & r, int startScale)
|
||||
{
|
||||
list<Tile const*> toRemove;
|
||||
|
||||
for (TileSet::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it)
|
||||
{
|
||||
Tiler::RectInfo ri = (*it)->m_rectInfo;
|
||||
|
||||
if (r.IsIntersect(m2::AnyRectD(ri.m_rect)) && (ri.m_tileScale >= startScale))
|
||||
toRemove.push_back(*it);
|
||||
}
|
||||
|
||||
TileCache * tileCache = &m_tileRenderer->GetTileCache();
|
||||
|
||||
for (list<Tile const *>::const_iterator it = toRemove.begin(); it != toRemove.end(); ++it)
|
||||
{
|
||||
tileCache->unlockTile((*it)->m_rectInfo);
|
||||
m_tiles.erase(*it);
|
||||
m_tileRects.erase((*it)->m_rectInfo);
|
||||
}
|
||||
|
||||
MergeInfoLayer();
|
||||
}
|
||||
|
||||
void ScreenCoverage::MergeInfoLayer()
|
||||
{
|
||||
m_infoLayer->clear();
|
||||
|
|
|
@ -105,4 +105,7 @@ public:
|
|||
/// as there could be tiles from lower and higher level in the
|
||||
/// coverage to provide a smooth scale transition experience
|
||||
int GetDrawScale() const;
|
||||
/// Unlock and remove tiles which intersect the specified rect
|
||||
/// and deeper or equal than specified scale
|
||||
void RemoveTiles(m2::AnyRectD const & r, int startScale);
|
||||
};
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
#include "drawer_yg.hpp"
|
||||
#include "window_handle.hpp"
|
||||
#include "events.hpp"
|
||||
#include "screen_coverage.hpp"
|
||||
|
||||
#include "../indexer/scales.hpp"
|
||||
|
||||
#include "../yg/framebuffer.hpp"
|
||||
#include "../yg/renderbuffer.hpp"
|
||||
|
@ -24,11 +27,6 @@
|
|||
#include "../yg/base_texture.hpp"
|
||||
#include "../yg/internal/opengl.hpp"
|
||||
|
||||
#include "drawer_yg.hpp"
|
||||
#include "events.hpp"
|
||||
#include "tiling_render_policy_mt.hpp"
|
||||
#include "window_handle.hpp"
|
||||
#include "screen_coverage.hpp"
|
||||
|
||||
TilingRenderPolicyST::TilingRenderPolicyST(VideoTimer * videoTimer,
|
||||
bool useDefaultFB,
|
||||
|
@ -37,7 +35,7 @@ TilingRenderPolicyST::TilingRenderPolicyST(VideoTimer * videoTimer,
|
|||
: QueuedRenderPolicy(GetPlatform().CpuCores() + 1, primaryRC, false, GetPlatform().CpuCores()),
|
||||
m_drawScale(0),
|
||||
m_isEmptyModel(false),
|
||||
m_doForce(false)
|
||||
m_doRecreateCoverage(false)
|
||||
{
|
||||
yg::ResourceManager::Params rmp = rmParams;
|
||||
|
||||
|
@ -263,8 +261,14 @@ void TilingRenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBas
|
|||
|
||||
pDrawer->screen()->clear(m_bgColor);
|
||||
|
||||
m_coverageGenerator->AddCoverScreenTask(currentScreen, m_doForce);
|
||||
m_doForce = false;
|
||||
if (DoForceUpdate())
|
||||
m_coverageGenerator->InvalidateTiles(GetInvalidRect(), scales::GetUpperWorldScale() + 1);
|
||||
|
||||
m_coverageGenerator->AddCoverScreenTask(currentScreen,
|
||||
m_doRecreateCoverage || (DoForceUpdate() && GetInvalidRect().IsIntersect(currentScreen.GlobalRect())));
|
||||
|
||||
SetForceUpdate(false);
|
||||
m_doRecreateCoverage = false;
|
||||
|
||||
m_coverageGenerator->Mutex().Lock();
|
||||
|
||||
|
@ -305,7 +309,7 @@ void TilingRenderPolicyST::StopScale()
|
|||
{
|
||||
m_isScaling = false;
|
||||
m_tileRenderer->SetIsPaused(false);
|
||||
m_doForce = true;
|
||||
m_doRecreateCoverage = true;
|
||||
RenderPolicy::StopScale();
|
||||
}
|
||||
|
||||
|
@ -318,7 +322,7 @@ void TilingRenderPolicyST::StartDrag()
|
|||
void TilingRenderPolicyST::StopDrag()
|
||||
{
|
||||
m_tileRenderer->SetIsPaused(false);
|
||||
m_doForce = true;
|
||||
m_doRecreateCoverage = true;
|
||||
RenderPolicy::StopDrag();
|
||||
}
|
||||
|
||||
|
@ -331,7 +335,7 @@ void TilingRenderPolicyST::StartRotate(double a, double timeInSec)
|
|||
void TilingRenderPolicyST::StopRotate(double a, double timeInSec)
|
||||
{
|
||||
m_tileRenderer->SetIsPaused(false);
|
||||
m_doForce = true;
|
||||
m_doRecreateCoverage = true;
|
||||
RenderPolicy::StopRotate(a, timeInSec);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ private:
|
|||
int m_drawScale;
|
||||
bool m_isEmptyModel;
|
||||
|
||||
bool m_doForce;
|
||||
bool m_doRecreateCoverage;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue