added clipping elements in InfoLayer to the specified rectangle bounds.

This commit is contained in:
rachytski 2012-01-08 15:25:27 +04:00 committed by Alex Zolotarev
parent 19095c8b24
commit 9322e2e74f
3 changed files with 50 additions and 0 deletions

View file

@ -177,6 +177,10 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
if (!env.isCancelled())
drawer->screen()->resetInfoLayer();
/// filter out the overlay elements that are out of the bound rect for the tile
if (!env.isCancelled())
tileInfoLayer->clip(renderRect);
yg::gl::PacketsQueue * glQueue = threadData.m_drawerParams.m_renderQueue;
if (!env.isCancelled())

View file

@ -255,5 +255,49 @@ namespace yg
v[pos]->setIsNeedRedraw(false);
}
}
void InfoLayer::clip(m2::RectI const & r)
{
vector<shared_ptr<OverlayElement> > v;
m_tree.ForEach(MakeBackInsertFunctor(v));
m_tree.Clear();
int clippedCnt = 0;
int elemCnt = v.size();
m2::RectD rd(r);
m2::AnyRectD ard(rd);
for (unsigned i = 0; i < v.size(); ++i)
{
shared_ptr<OverlayElement> const & e = v[i];
if (!e->isVisible())
{
clippedCnt++;
continue;
}
if (!e->roughBoundRect().IsIntersect(rd))
clippedCnt++;
else
{
bool hasIntersection = false;
for (unsigned j = 0; j < e->boundRects().size(); ++j)
{
if (ard.IsIntersect(e->boundRects()[j]))
{
hasIntersection = true;
break;
}
}
if (hasIntersection)
processOverlayElement(e);
}
}
LOG(LINFO, ("clipped out", clippedCnt, "elements,", elemCnt, "elements total"));
}
}

View file

@ -51,5 +51,7 @@ namespace yg
void setCouldOverlap(bool flag);
void merge(InfoLayer const & infoLayer, math::Matrix<double, 3, 3> const & m);
void clip(m2::RectI const & r);
};
}