forked from organicmaps/organicmaps-tmp
[drape] review fixes
This commit is contained in:
parent
d00cf30a69
commit
f702a3820a
5 changed files with 130 additions and 124 deletions
|
@ -105,6 +105,7 @@ bool GLState::operator==(const GLState & other) const
|
|||
m_depthLayer == other.m_depthLayer &&
|
||||
m_gpuProgramIndex == other.m_gpuProgramIndex &&
|
||||
m_textureSet == other.m_textureSet &&
|
||||
m_blending == other.m_blending &&
|
||||
m_color == other.m_color;
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ namespace df
|
|||
double const range = MercatorBounds::maxX - MercatorBounds::minX;
|
||||
double const rectSize = range / (1 << tileScale);
|
||||
|
||||
m2::RectD const & clipRect = m_view.ClipRect();
|
||||
m2::RectD const & clipRect = m_view.ClipRect();
|
||||
|
||||
int const minTileX = static_cast<int>(floor(clipRect.minX() / rectSize));
|
||||
int const maxTileX = static_cast<int>(ceil(clipRect.maxX() / rectSize));
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace df
|
|||
class UpdateReadManagerMessage : public UpdateModelViewMessage
|
||||
{
|
||||
public:
|
||||
UpdateReadManagerMessage(ScreenBase const & screen, shared_ptr<set<TileKey> > tiles)
|
||||
UpdateReadManagerMessage(ScreenBase const & screen, shared_ptr<set<TileKey> > const & tiles)
|
||||
: UpdateModelViewMessage(screen)
|
||||
, m_tiles(tiles)
|
||||
{
|
||||
|
|
|
@ -6,94 +6,97 @@
|
|||
|
||||
namespace df
|
||||
{
|
||||
namespace
|
||||
{
|
||||
RenderBucket * NonConstGetter(MasterPointer<RenderBucket> & p)
|
||||
{
|
||||
return p.GetRaw();
|
||||
}
|
||||
}
|
||||
namespace
|
||||
{
|
||||
|
||||
RenderGroup::RenderGroup(GLState const & state, df::TileKey const & tileKey)
|
||||
: m_state(state)
|
||||
, m_tileKey(tileKey)
|
||||
, m_pendingOnDelete(false)
|
||||
{
|
||||
}
|
||||
|
||||
RenderGroup::~RenderGroup()
|
||||
{
|
||||
(void)GetRangeDeletor(m_renderBuckets, MasterPointerDeleter())();
|
||||
}
|
||||
|
||||
void RenderGroup::CollectOverlay(RefPointer<OverlayTree> tree)
|
||||
{
|
||||
for_each(m_renderBuckets.begin(), m_renderBuckets.end(), bind(&RenderBucket::CollectOverlayHandles,
|
||||
bind(&NonConstGetter, _1),
|
||||
tree));
|
||||
}
|
||||
|
||||
void RenderGroup::Render()
|
||||
{
|
||||
ASSERT(m_pendingOnDelete == false, ());
|
||||
for_each(m_renderBuckets.begin(), m_renderBuckets.end(), bind(&RenderBucket::Render,
|
||||
bind(&NonConstGetter, _1)));
|
||||
}
|
||||
|
||||
void RenderGroup::PrepareForAdd(size_t countForAdd)
|
||||
{
|
||||
m_renderBuckets.reserve(m_renderBuckets.size() + countForAdd);
|
||||
}
|
||||
|
||||
void RenderGroup::AddBucket(TransferPointer<RenderBucket> bucket)
|
||||
{
|
||||
m_renderBuckets.push_back(MasterPointer<RenderBucket>(bucket));
|
||||
}
|
||||
|
||||
bool RenderGroup::IsLess(RenderGroup const & other) const
|
||||
{
|
||||
return m_state < other.m_state;
|
||||
}
|
||||
|
||||
RenderBucketComparator::RenderBucketComparator(set<TileKey> const & activeTiles)
|
||||
: m_activeTiles(activeTiles)
|
||||
, m_needGroupMergeOperation(false)
|
||||
, m_needBucketsMergeOperation(false)
|
||||
{
|
||||
}
|
||||
|
||||
void RenderBucketComparator::ResetInternalState()
|
||||
{
|
||||
m_needBucketsMergeOperation = false;
|
||||
m_needGroupMergeOperation = false;
|
||||
}
|
||||
|
||||
bool RenderBucketComparator::operator()(RenderGroup const * l, RenderGroup const * r)
|
||||
{
|
||||
GLState const & lState = l->GetState();
|
||||
GLState const & rState = r->GetState();
|
||||
|
||||
TileKey const & lKey = l->GetTileKey();
|
||||
TileKey const & rKey = r->GetTileKey();
|
||||
|
||||
if (!l->IsPendingOnDelete() && (l->IsEmpty() || m_activeTiles.find(lKey) == m_activeTiles.end()))
|
||||
l->DeleteLater();
|
||||
|
||||
if (!r->IsPendingOnDelete() && (r->IsEmpty() || m_activeTiles.find(rKey) == m_activeTiles.end()))
|
||||
r->DeleteLater();
|
||||
|
||||
bool lPendingOnDelete = l->IsPendingOnDelete();
|
||||
bool rPendingOnDelete = r->IsPendingOnDelete();
|
||||
|
||||
if (lState == rState && lKey == rKey && !lPendingOnDelete)
|
||||
m_needGroupMergeOperation = true;
|
||||
|
||||
if (rPendingOnDelete == lPendingOnDelete)
|
||||
return lState < rState;
|
||||
|
||||
if (rPendingOnDelete)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
RenderBucket * NonConstGetter(MasterPointer<RenderBucket> & p)
|
||||
{
|
||||
return p.GetRaw();
|
||||
}
|
||||
|
||||
} /// namespace
|
||||
|
||||
RenderGroup::RenderGroup(GLState const & state, df::TileKey const & tileKey)
|
||||
: m_state(state)
|
||||
, m_tileKey(tileKey)
|
||||
, m_pendingOnDelete(false)
|
||||
{
|
||||
}
|
||||
|
||||
RenderGroup::~RenderGroup()
|
||||
{
|
||||
(void)GetRangeDeletor(m_renderBuckets, MasterPointerDeleter())();
|
||||
}
|
||||
|
||||
void RenderGroup::CollectOverlay(RefPointer<OverlayTree> tree)
|
||||
{
|
||||
for_each(m_renderBuckets.begin(), m_renderBuckets.end(), bind(&RenderBucket::CollectOverlayHandles,
|
||||
bind(&NonConstGetter, _1),
|
||||
tree));
|
||||
}
|
||||
|
||||
void RenderGroup::Render()
|
||||
{
|
||||
ASSERT(m_pendingOnDelete == false, ());
|
||||
for_each(m_renderBuckets.begin(), m_renderBuckets.end(), bind(&RenderBucket::Render,
|
||||
bind(&NonConstGetter, _1)));
|
||||
}
|
||||
|
||||
void RenderGroup::PrepareForAdd(size_t countForAdd)
|
||||
{
|
||||
m_renderBuckets.reserve(m_renderBuckets.size() + countForAdd);
|
||||
}
|
||||
|
||||
void RenderGroup::AddBucket(TransferPointer<RenderBucket> bucket)
|
||||
{
|
||||
m_renderBuckets.push_back(MasterPointer<RenderBucket>(bucket));
|
||||
}
|
||||
|
||||
bool RenderGroup::IsLess(RenderGroup const & other) const
|
||||
{
|
||||
return m_state < other.m_state;
|
||||
}
|
||||
|
||||
RenderBucketComparator::RenderBucketComparator(set<TileKey> const & activeTiles)
|
||||
: m_activeTiles(activeTiles)
|
||||
, m_needGroupMergeOperation(false)
|
||||
, m_needBucketsMergeOperation(false)
|
||||
{
|
||||
}
|
||||
|
||||
void RenderBucketComparator::ResetInternalState()
|
||||
{
|
||||
m_needBucketsMergeOperation = false;
|
||||
m_needGroupMergeOperation = false;
|
||||
}
|
||||
|
||||
bool RenderBucketComparator::operator()(RenderGroup const * l, RenderGroup const * r)
|
||||
{
|
||||
GLState const & lState = l->GetState();
|
||||
GLState const & rState = r->GetState();
|
||||
|
||||
TileKey const & lKey = l->GetTileKey();
|
||||
TileKey const & rKey = r->GetTileKey();
|
||||
|
||||
if (!l->IsPendingOnDelete() && (l->IsEmpty() || m_activeTiles.find(lKey) == m_activeTiles.end()))
|
||||
l->DeleteLater();
|
||||
|
||||
if (!r->IsPendingOnDelete() && (r->IsEmpty() || m_activeTiles.find(rKey) == m_activeTiles.end()))
|
||||
r->DeleteLater();
|
||||
|
||||
bool lPendingOnDelete = l->IsPendingOnDelete();
|
||||
bool rPendingOnDelete = r->IsPendingOnDelete();
|
||||
|
||||
if (lState == rState && lKey == rKey && !lPendingOnDelete)
|
||||
m_needGroupMergeOperation = true;
|
||||
|
||||
if (rPendingOnDelete == lPendingOnDelete)
|
||||
return lState < rState;
|
||||
|
||||
if (rPendingOnDelete)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
|
|
|
@ -13,47 +13,49 @@ class OverlayTree;
|
|||
|
||||
namespace df
|
||||
{
|
||||
class RenderGroup
|
||||
{
|
||||
public:
|
||||
RenderGroup(GLState const & state, TileKey const & tileKey);
|
||||
~RenderGroup();
|
||||
|
||||
void CollectOverlay(RefPointer<OverlayTree> tree);
|
||||
void Render();
|
||||
class RenderGroup
|
||||
{
|
||||
public:
|
||||
RenderGroup(GLState const & state, TileKey const & tileKey);
|
||||
~RenderGroup();
|
||||
|
||||
void PrepareForAdd(size_t countForAdd);
|
||||
void AddBucket(TransferPointer<RenderBucket> bucket);
|
||||
void CollectOverlay(RefPointer<OverlayTree> tree);
|
||||
void Render();
|
||||
|
||||
GLState const & GetState() const { return m_state; }
|
||||
TileKey const & GetTileKey() const { return m_tileKey; }
|
||||
void PrepareForAdd(size_t countForAdd);
|
||||
void AddBucket(TransferPointer<RenderBucket> bucket);
|
||||
|
||||
bool IsEmpty() const { return m_renderBuckets.empty(); }
|
||||
void DeleteLater() const { m_pendingOnDelete = true; }
|
||||
bool IsPendingOnDelete() const { return m_pendingOnDelete; }
|
||||
GLState const & GetState() const { return m_state; }
|
||||
TileKey const & GetTileKey() const { return m_tileKey; }
|
||||
|
||||
bool IsLess(RenderGroup const & other) const;
|
||||
bool IsEmpty() const { return m_renderBuckets.empty(); }
|
||||
void DeleteLater() const { m_pendingOnDelete = true; }
|
||||
bool IsPendingOnDelete() const { return m_pendingOnDelete; }
|
||||
|
||||
private:
|
||||
GLState m_state;
|
||||
TileKey m_tileKey;
|
||||
vector<MasterPointer<RenderBucket> > m_renderBuckets;
|
||||
bool IsLess(RenderGroup const & other) const;
|
||||
|
||||
mutable bool m_pendingOnDelete;
|
||||
};
|
||||
private:
|
||||
GLState m_state;
|
||||
TileKey m_tileKey;
|
||||
vector<MasterPointer<RenderBucket> > m_renderBuckets;
|
||||
|
||||
class RenderBucketComparator
|
||||
{
|
||||
public:
|
||||
RenderBucketComparator(set<TileKey> const & activeTiles);
|
||||
mutable bool m_pendingOnDelete;
|
||||
};
|
||||
|
||||
void ResetInternalState();
|
||||
class RenderBucketComparator
|
||||
{
|
||||
public:
|
||||
RenderBucketComparator(set<TileKey> const & activeTiles);
|
||||
|
||||
bool operator()(RenderGroup const * l, RenderGroup const * r);
|
||||
void ResetInternalState();
|
||||
|
||||
private:
|
||||
set<TileKey> const & m_activeTiles;
|
||||
bool m_needGroupMergeOperation;
|
||||
bool m_needBucketsMergeOperation;
|
||||
};
|
||||
}
|
||||
bool operator()(RenderGroup const * l, RenderGroup const * r);
|
||||
|
||||
private:
|
||||
set<TileKey> const & m_activeTiles;
|
||||
bool m_needGroupMergeOperation;
|
||||
bool m_needBucketsMergeOperation;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
|
Loading…
Add table
Reference in a new issue