redrawing screen upon finishing download or deleting the map. closes #408.

This commit is contained in:
rachytski 2011-11-21 19:47:36 +04:00 committed by Alex Zolotarev
parent 18228caef2
commit 9add6182c7
6 changed files with 41 additions and 13 deletions

View file

@ -81,6 +81,7 @@ void Framework::OnCompassUpdate(location::CompassInfo const & info)
Framework::Framework()
: m_hasPendingInvalidate(false),
m_doForceUpdate(false),
m_metresMinWidth(10),
m_metresMaxWidth(1000000),
#if defined(OMIM_OS_MAC) || defined(OMIM_OS_WINDOWS) || defined(OMIM_OS_LINUX)
@ -127,7 +128,7 @@ Framework::Framework()
m_storage.Init(bind(&Framework::AddMap, this, _1),
bind(&Framework::RemoveMap, this, _1),
bind(&Framework::InvalidateRect, this, _1));
bind(&Framework::InvalidateRect, this, _1, true));
LOG(LDEBUG, ("Storage initialized"));
// set language priorities
@ -177,15 +178,23 @@ bool Framework::NeedRedraw() const
void Framework::SetNeedRedraw(bool flag)
{
m_renderPolicy->GetWindowHandle()->setNeedRedraw(false);
m_renderPolicy->GetWindowHandle()->setNeedRedraw(flag);
if (!flag)
m_doForceUpdate = false;
}
void Framework::Invalidate()
void Framework::Invalidate(bool doForceUpdate)
{
if (m_renderPolicy)
{
m_renderPolicy->SetForceUpdate(doForceUpdate);
m_renderPolicy->GetWindowHandle()->invalidate();
}
else
{
m_hasPendingInvalidate = true;
m_doForceUpdate = doForceUpdate;
}
}
void Framework::SaveState()
@ -391,10 +400,10 @@ void Framework::ShowAll()
Invalidate();
}
void Framework::InvalidateRect(m2::RectD const & rect)
void Framework::InvalidateRect(m2::RectD const & rect, bool doForceUpdate)
{
if (m_navigator.Screen().GlobalRect().IsIntersect(m2::AnyRectD(rect)))
Invalidate();
Invalidate(doForceUpdate);
}
/// @name Drag implementation.
@ -625,6 +634,7 @@ void Framework::SetRenderPolicy(RenderPolicy * renderPolicy)
if (m_hasPendingInvalidate)
{
m_renderPolicy->SetForceUpdate(m_doForceUpdate);
m_renderPolicy->GetWindowHandle()->invalidate();
m_hasPendingInvalidate = false;
}

View file

@ -67,6 +67,7 @@ protected:
scoped_ptr<RenderPolicy> m_renderPolicy;
bool m_hasPendingInvalidate;
bool m_doForceUpdate;
InformationDisplay m_informationDisplay;
@ -147,8 +148,8 @@ public:
void SetMaxWorldRect();
void Invalidate();
void InvalidateRect(m2::RectD const & rect);
void Invalidate(bool doForceUpdate = false);
void InvalidateRect(m2::RectD const & rect, bool doForceUpdate = false);
void SaveState();
bool LoadState();

View file

@ -166,8 +166,6 @@ PartialRenderPolicy::~PartialRenderPolicy()
void PartialRenderPolicy::ProcessRenderQueue(list<yg::gl::Renderer::Packet> & renderQueue)
{
threads::ConditionGuard g(m_glCondition);
if (renderQueue.empty())
{
m_hasPacket = false;

View file

@ -24,7 +24,8 @@ RenderPolicy::~RenderPolicy()
RenderPolicy::RenderPolicy(shared_ptr<yg::gl::RenderContext> const & primaryRC, bool doSupportRotation)
: m_bgColor(0xEE, 0xEE, 0xDD, 0xFF),
m_primaryRC(primaryRC),
m_doSupportRotation(doSupportRotation)
m_doSupportRotation(doSupportRotation),
m_doForceUpdate(false)
{}
m2::RectI const RenderPolicy::OnSize(int w, int h)
@ -114,6 +115,16 @@ void RenderPolicy::SetRenderFn(TRenderFn renderFn)
m_renderFn = renderFn;
}
bool RenderPolicy::DoForceUpdate() const
{
return m_doForceUpdate;
}
void RenderPolicy::SetForceUpdate(bool flag)
{
m_doForceUpdate = flag;
}
RenderPolicy * CreateRenderPolicy(VideoTimer * videoTimer,
DrawerYG::Params const & params,
yg::ResourceManager::Params const & rmParams,

View file

@ -44,6 +44,7 @@ protected:
shared_ptr<DrawerYG> m_drawer;
TRenderFn m_renderFn;
bool m_doSupportRotation;
bool m_doForceUpdate;
public:
@ -82,6 +83,9 @@ public:
bool NeedRedraw() const;
bool DoForceUpdate() const;
void SetForceUpdate(bool flag);
shared_ptr<DrawerYG> const & GetDrawer() const;
shared_ptr<WindowHandle> const & GetWindowHandle() const;

View file

@ -164,15 +164,19 @@ void RenderPolicyMT::DrawFrame(shared_ptr<PaintEvent> const & e,
{
m_resourceManager->mergeFreeResources();
if (m_DoAddCommand && (s != m_renderQueue->renderState().m_actualScreen))
m_renderQueue->renderState().m_mutex->Lock();
m_renderQueue->renderStatePtr()->m_doRepaintAll = DoForceUpdate();
if (m_DoAddCommand && (DoForceUpdate() || (s != m_renderQueue->renderState().m_actualScreen)))
m_renderQueue->AddCommand(m_renderFn, s);
SetForceUpdate(false);
DrawerYG * pDrawer = e->drawer();
e->drawer()->screen()->clear(m_bgColor);
m_renderQueue->renderState().m_mutex->Lock();
if (m_renderQueue->renderState().m_actualTarget.get() != 0)
{
m2::PointD const ptShift = m_renderQueue->renderState().coordSystemShift(false);