forked from organicmaps/organicmaps
fixed race conditions on current graphics::Overlay object.
This commit is contained in:
parent
182f784678
commit
29d56aa987
5 changed files with 55 additions and 15 deletions
|
@ -118,8 +118,6 @@ void BasicTilingRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e, Screen
|
|||
|
||||
if (curCvg)
|
||||
{
|
||||
SetOverlay(curCvg->GetOverlay());
|
||||
|
||||
curCvg->Draw(pDrawer->screen().get(), s);
|
||||
|
||||
m_DrawScale = curCvg->GetDrawScale();
|
||||
|
@ -255,6 +253,21 @@ size_t BasicTilingRenderPolicy::TileSize() const
|
|||
return m_TileSize;
|
||||
}
|
||||
|
||||
void BasicTilingRenderPolicy::FrameLock()
|
||||
{
|
||||
m_CoverageGenerator->Mutex().Lock();
|
||||
}
|
||||
|
||||
void BasicTilingRenderPolicy::FrameUnlock()
|
||||
{
|
||||
m_CoverageGenerator->Mutex().Unlock();
|
||||
}
|
||||
|
||||
shared_ptr<graphics::Overlay> const BasicTilingRenderPolicy::FrameOverlay() const
|
||||
{
|
||||
return m_CoverageGenerator->CurrentCoverage()->GetOverlay();
|
||||
}
|
||||
|
||||
int BasicTilingRenderPolicy::InsertBenchmarkFence()
|
||||
{
|
||||
return m_CoverageGenerator->InsertBenchmarkFence();
|
||||
|
|
|
@ -79,6 +79,10 @@ public:
|
|||
size_t ScaleEtalonSize() const;
|
||||
size_t TileSize() const;
|
||||
|
||||
void FrameLock();
|
||||
void FrameUnlock();
|
||||
shared_ptr<graphics::Overlay> const FrameOverlay() const;
|
||||
|
||||
/// benchmarking protocol
|
||||
int InsertBenchmarkFence();
|
||||
void JoinBenchmarkFence(int fenceID);
|
||||
|
|
|
@ -1411,6 +1411,8 @@ shared_ptr<graphics::OverlayElement> const GetClosestToPivot(list<shared_ptr<gra
|
|||
|
||||
bool Framework::GetVisiblePOI(m2::PointD const & pxPoint, m2::PointD & pxPivot, AddressInfo & info) const
|
||||
{
|
||||
m_renderPolicy->FrameLock();
|
||||
|
||||
m2::PointD const pt = m_navigator.ShiftPoint(pxPoint);
|
||||
double const halfSize = TOUCH_PIXEL_RADIUS * GetVisualScale();
|
||||
|
||||
|
@ -1419,12 +1421,14 @@ bool Framework::GetVisiblePOI(m2::PointD const & pxPoint, m2::PointD & pxPivot,
|
|||
list<shared_ptr<ElementT> > candidates;
|
||||
m2::RectD rect(pt.x - halfSize, pt.y - halfSize,
|
||||
pt.x + halfSize, pt.y + halfSize);
|
||||
m_renderPolicy->GetOverlay()->selectOverlayElements(rect, candidates);
|
||||
m_renderPolicy->FrameOverlay()->selectOverlayElements(rect, candidates);
|
||||
|
||||
shared_ptr<ElementT> res = GetClosestToPivot(candidates, pt);
|
||||
if (res)
|
||||
bool res = false;
|
||||
|
||||
shared_ptr<ElementT> elem = GetClosestToPivot(candidates, pt);
|
||||
if (elem)
|
||||
{
|
||||
ElementT::UserInfo const & ui = res->userInfo();
|
||||
ElementT::UserInfo const & ui = elem->userInfo();
|
||||
if (ui.IsValid())
|
||||
{
|
||||
Index::FeaturesLoaderGuard guard(m_model.GetIndex(), ui.m_mwmID);
|
||||
|
@ -1439,11 +1443,12 @@ bool Framework::GetVisiblePOI(m2::PointD const & pxPoint, m2::PointD & pxPivot,
|
|||
GetAddressInfo(ft, center, info);
|
||||
|
||||
pxPivot = GtoP(center);
|
||||
return true;
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
m_renderPolicy->FrameUnlock();
|
||||
return res;
|
||||
}
|
||||
|
||||
Animator & Framework::GetAnimator()
|
||||
|
|
|
@ -239,14 +239,20 @@ void RenderPolicy::SetAnimController(anim::Controller * controller)
|
|||
m_controller = controller;
|
||||
}
|
||||
|
||||
void RenderPolicy::SetOverlay(shared_ptr<graphics::Overlay> const & overlay)
|
||||
void RenderPolicy::FrameLock()
|
||||
{
|
||||
m_overlay = overlay;
|
||||
LOG(LWARNING, ("unimplemented method called."));
|
||||
}
|
||||
|
||||
shared_ptr<graphics::Overlay> const RenderPolicy::GetOverlay() const
|
||||
void RenderPolicy::FrameUnlock()
|
||||
{
|
||||
return m_overlay;
|
||||
LOG(LWARNING, ("unimplemented method called"));
|
||||
}
|
||||
|
||||
shared_ptr<graphics::Overlay> const RenderPolicy::FrameOverlay() const
|
||||
{
|
||||
LOG(LWARNING, ("unimplemented method called"));
|
||||
return shared_ptr<graphics::Overlay>();
|
||||
}
|
||||
|
||||
graphics::Color const RenderPolicy::GetBgColor() const
|
||||
|
|
|
@ -71,8 +71,6 @@ protected:
|
|||
anim::Controller * m_controller;
|
||||
shared_ptr<graphics::Overlay> m_overlay;
|
||||
|
||||
void SetOverlay(shared_ptr<graphics::Overlay> const & overlay);
|
||||
|
||||
void InitCacheScreen();
|
||||
|
||||
public:
|
||||
|
@ -149,11 +147,25 @@ public:
|
|||
double VisualScale() const;
|
||||
string const & SkinName() const;
|
||||
|
||||
/// This function is used when we need to prevent race
|
||||
/// conditions on some resources, which could be modified
|
||||
/// from another threads.
|
||||
/// One example of such resource is a current graphics::Overlay
|
||||
/// object
|
||||
/// @{
|
||||
virtual void FrameLock();
|
||||
virtual void FrameUnlock();
|
||||
/// @}
|
||||
|
||||
/// Get current graphics::Overlay object.
|
||||
/// Access to this resource should be synchronized using
|
||||
/// FrameLock/FrameUnlock methods
|
||||
virtual shared_ptr<graphics::Overlay> const FrameOverlay() const;
|
||||
|
||||
/// Benchmarking protocol
|
||||
virtual int InsertBenchmarkFence();
|
||||
virtual void JoinBenchmarkFence(int fenceID);
|
||||
|
||||
virtual shared_ptr<graphics::Overlay> const GetOverlay() const;
|
||||
graphics::Color const GetBgColor() const;
|
||||
|
||||
shared_ptr<graphics::Screen> const & GetCacheScreen() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue