forked from organicmaps/organicmaps
[drape] use TileKey comparation for m_taskIndex set instead of less<void *>
convert Tiler::RectInfo to TileKey as soon as posible init m_currectViewport by world rect in constructor
This commit is contained in:
parent
459acded9f
commit
4a9ad53ee7
2 changed files with 20 additions and 17 deletions
|
@ -26,16 +26,14 @@ namespace
|
|||
|
||||
struct CoverageCellComparer
|
||||
{
|
||||
bool operator()(df::ReadMWMTask const * task, Tiler::RectInfo const & rectInfo) const
|
||||
bool operator()(df::ReadMWMTask const * task, df::TileKey const & tileKey) const
|
||||
{
|
||||
/// TODO remove RectInfo to TileInfo covertion after rewrite tiler on TileInfo returning
|
||||
return task->GetTileInfo() < df::TileInfo(rectInfo.m_x, rectInfo.m_y, rectInfo.m_tileScale);
|
||||
return task->GetTileInfo().m_key < tileKey;
|
||||
}
|
||||
|
||||
bool operator()(Tiler::RectInfo const & rectInfo, df::ReadMWMTask const * task) const
|
||||
bool operator()(df::TileKey const & tileKey, df::ReadMWMTask const * task) const
|
||||
{
|
||||
/// TODO remove RectInfo to TileInfo covertion after rewrite tiler on TileInfo returning
|
||||
return df::TileInfo(rectInfo.m_x, rectInfo.m_y, rectInfo.m_tileScale) < task->GetTileInfo();
|
||||
return tileKey < task->GetTileInfo().m_key;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -52,6 +50,7 @@ namespace df
|
|||
, m_contextFactory(oglcontextfactory)
|
||||
{
|
||||
m_scaleProcessor.SetParams(visualScale, ScalesProcessor::CalculateTileSize(surfaceWidth, surfaceHeight));
|
||||
m_currentViewport.SetFromRect(m2::AnyRectD(m_scaleProcessor.GetWorldRect()));
|
||||
|
||||
m_commutator->RegisterThread(ThreadsCommutator::ResourceUploadThread, this);
|
||||
|
||||
|
@ -85,13 +84,16 @@ namespace df
|
|||
PostToRenderThreads(MovePointer<Message>(new DropCoverageMessage()));
|
||||
|
||||
for (size_t i = 0; i < tiles.size(); ++i)
|
||||
CreateTask(tiles[i]);
|
||||
{
|
||||
const Tiler::RectInfo & info = tiles[i];
|
||||
CreateTask(TileKey(info.m_x, info.m_y, info.m_tileScale));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
set<Tiler::RectInfo> rectInfoSet;
|
||||
set<TileKey> rectInfoSet;
|
||||
for (size_t i = 0 ; i < tiles.size(); ++i)
|
||||
rectInfoSet.insert(tiles[i]);
|
||||
rectInfoSet.insert(TileKey(tiles[i].m_x, tiles[i].m_y, tiles[i].m_tileScale));
|
||||
|
||||
// Find rects that go out from viewport
|
||||
buffer_vector<ReadMWMTask *, 8> outdatedTasks;
|
||||
|
@ -100,7 +102,7 @@ namespace df
|
|||
back_inserter(outdatedTasks), CoverageCellComparer());
|
||||
|
||||
// Find rects that go in into viewport
|
||||
buffer_vector<Tiler::RectInfo, 8> inputRects;
|
||||
buffer_vector<TileKey, 8> inputRects;
|
||||
set_difference(rectInfoSet.begin(), rectInfoSet.end(),
|
||||
m_taskIndex.begin(), m_taskIndex.end(),
|
||||
back_inserter(inputRects), CoverageCellComparer());
|
||||
|
@ -113,6 +115,8 @@ namespace df
|
|||
for (size_t i = 0; i < inputRects.size(); ++i)
|
||||
CreateTask(inputRects[i]);
|
||||
}
|
||||
|
||||
m_currentViewport = screen;
|
||||
}
|
||||
|
||||
void BackendRendererImpl::FinishTask(threads::IRoutine * routine)
|
||||
|
@ -129,13 +133,12 @@ namespace df
|
|||
void BackendRendererImpl::Resize(m2::RectI const & rect)
|
||||
{
|
||||
m_currentViewport.OnSize(rect);
|
||||
UpdateCoverage(m_currentViewport);
|
||||
}
|
||||
|
||||
void BackendRendererImpl::CreateTask(Tiler::RectInfo const & info)
|
||||
void BackendRendererImpl::CreateTask(TileKey const & info)
|
||||
{
|
||||
ReadMWMTask * task = new ReadMWMTask(TileKey(info.m_x, info.m_y, info.m_tileScale),
|
||||
m_index,
|
||||
m_engineContext);
|
||||
ReadMWMTask * task = new ReadMWMTask(info, m_index, m_engineContext);
|
||||
m_taskIndex.insert(task);
|
||||
m_threadPool->AddTask(task);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "memory_feature_index.hpp"
|
||||
#include "engine_context.hpp"
|
||||
#include "batchers_pool.hpp"
|
||||
#include "read_mwm_task.hpp"
|
||||
|
||||
#include "../drape/pointers.hpp"
|
||||
#include "../drape/oglcontextfactory.hpp"
|
||||
|
@ -22,7 +23,6 @@ namespace df
|
|||
{
|
||||
class Message;
|
||||
class ThreadsCommutator;
|
||||
class ReadMWMTask;
|
||||
|
||||
class BackendRendererImpl : public MessageAcceptor,
|
||||
public threads::IRoutine
|
||||
|
@ -45,13 +45,13 @@ namespace df
|
|||
void ShapeReaded(const TileKey & key, MapShape const * shape);
|
||||
|
||||
private:
|
||||
void CreateTask(Tiler::RectInfo const & info);
|
||||
void CreateTask(const TileKey & info);
|
||||
void CancelTask(ReadMWMTask * task, bool removefromIndex, bool postToRenderer);
|
||||
void RestartExistTasks();
|
||||
|
||||
private:
|
||||
ScreenBase m_currentViewport;
|
||||
set<ReadMWMTask *> m_taskIndex;
|
||||
set<ReadMWMTask *, ReadMWMTaskLess> m_taskIndex;
|
||||
|
||||
/////////////////////////////////////////
|
||||
/// Calculate rect for read from MWM
|
||||
|
|
Loading…
Add table
Reference in a new issue