forked from organicmaps/organicmaps
[drape] move ScalesProcessor to EngineContext. In reading and geometry processing functions need tileSize
This commit is contained in:
parent
28ef8404c4
commit
5d9210b272
4 changed files with 19 additions and 14 deletions
|
@ -5,11 +5,17 @@
|
|||
|
||||
namespace df
|
||||
{
|
||||
EngineContext::EngineContext(RefPointer<ThreadsCommutator> commutator)
|
||||
EngineContext::EngineContext(RefPointer<ThreadsCommutator> commutator, ScalesProcessor const & processor)
|
||||
: m_commutator(commutator)
|
||||
, m_scalesProcessor(processor)
|
||||
{
|
||||
}
|
||||
|
||||
ScalesProcessor const & EngineContext::GetScalesProcessor() const
|
||||
{
|
||||
return m_scalesProcessor;
|
||||
}
|
||||
|
||||
void EngineContext::BeginReadTile(TileKey const & key)
|
||||
{
|
||||
PostMessage(new TileReadStartMessage(key));
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "../drape/pointers.hpp"
|
||||
|
||||
#include "../map/scales_processor.hpp"
|
||||
|
||||
namespace df
|
||||
{
|
||||
class Message;
|
||||
|
@ -13,7 +15,9 @@ namespace df
|
|||
class EngineContext
|
||||
{
|
||||
public:
|
||||
EngineContext(RefPointer<ThreadsCommutator> commutator);
|
||||
EngineContext(RefPointer<ThreadsCommutator> commutator, ScalesProcessor const & processor);
|
||||
|
||||
ScalesProcessor const & GetScalesProcessor() const;
|
||||
|
||||
void BeginReadTile(TileKey const & key);
|
||||
/// If you call this method, you may forget about shape.
|
||||
|
@ -26,5 +30,6 @@ namespace df
|
|||
|
||||
private:
|
||||
RefPointer<ThreadsCommutator> m_commutator;
|
||||
ScalesProcessor m_scalesProcessor;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -33,13 +33,10 @@ namespace df
|
|||
}
|
||||
}
|
||||
|
||||
ReadManager::ReadManager(double visualScale, int w, int h,
|
||||
EngineContext & context,
|
||||
model::FeaturesFetcher & model)
|
||||
ReadManager::ReadManager(EngineContext & context, model::FeaturesFetcher & model)
|
||||
: m_context(context)
|
||||
, m_model(model)
|
||||
{
|
||||
m_scalesProcessor.SetParams(visualScale, ScalesProcessor::CalculateTileSize(w, h));
|
||||
m_pool.Reset(new threads::ThreadPool(ReadCount(), bind(&ReadManager::OnTaskFinished, this, _1)));
|
||||
}
|
||||
|
||||
|
@ -116,7 +113,7 @@ namespace df
|
|||
{
|
||||
out.clear();
|
||||
|
||||
int const tileScale = m_scalesProcessor.GetTileScaleBase(screen);
|
||||
int const tileScale = m_context.GetScalesProcessor().GetTileScaleBase(screen);
|
||||
// equal for x and y
|
||||
double const range = MercatorBounds::maxX - MercatorBounds::minX;
|
||||
double const rectSize = range / (1 << tileScale);
|
||||
|
@ -145,8 +142,9 @@ namespace df
|
|||
|
||||
bool ReadManager::MustDropAllTiles(ScreenBase const & screen) const
|
||||
{
|
||||
const int oldScale = m_scalesProcessor.GetTileScaleBase(m_currentViewport);
|
||||
const int newScale = m_scalesProcessor.GetTileScaleBase(screen);
|
||||
ScalesProcessor const & sp = m_context.GetScalesProcessor();
|
||||
const int oldScale = sp.GetTileScaleBase(m_currentViewport);
|
||||
const int newScale = sp.GetTileScaleBase(screen);
|
||||
return (oldScale != newScale) || !m_currentViewport.GlobalRect().IsIntersect(screen.GlobalRect());
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,7 @@ namespace df
|
|||
class ReadManager
|
||||
{
|
||||
public:
|
||||
ReadManager(double visualScale, int w, int h,
|
||||
EngineContext & context,
|
||||
model::FeaturesFetcher & model);
|
||||
ReadManager(EngineContext & context, model::FeaturesFetcher & model);
|
||||
|
||||
void UpdateCoverage(ScreenBase const & screen, CoverageUpdateDescriptor & updateDescr);
|
||||
void Resize(m2::RectI const & rect);
|
||||
|
@ -49,13 +47,11 @@ namespace df
|
|||
EngineContext & m_context;
|
||||
|
||||
model::FeaturesFetcher & m_model;
|
||||
ScalesProcessor m_scalesProcessor;
|
||||
|
||||
MasterPointer<threads::ThreadPool> m_pool;
|
||||
|
||||
ScreenBase m_currentViewport;
|
||||
|
||||
|
||||
struct LessByTileKey
|
||||
{
|
||||
bool operator ()(tileinfo_ptr const & l, tileinfo_ptr const & r) const
|
||||
|
|
Loading…
Add table
Reference in a new issue