removed duplicate anim::Controller instance.

This commit is contained in:
rachytski 2012-09-25 13:57:10 +03:00 committed by Alex Zolotarev
parent bcce8416b6
commit 6dd8a1af0b
6 changed files with 20 additions and 29 deletions

View file

@ -16,7 +16,9 @@ void Animator::RotateScreen(double startAngle, double endAngle, double duration)
{
bool shouldRotate = false;
if (m_rotateScreenTask && m_rotateScreenTask->IsRunning())
if (m_rotateScreenTask
&& !m_rotateScreenTask->IsCancelled()
&& !m_rotateScreenTask->IsEnded())
{
// if the end angle seriously changed we should re-create rotation task.
if (fabs(ang::GetShortestDistance(m_rotateScreenTask->EndAngle(), endAngle)) > m_rotationThreshold)
@ -45,7 +47,8 @@ void Animator::RotateScreen(double startAngle, double endAngle, double duration)
void Animator::StopRotation()
{
if (m_rotateScreenTask
&& m_rotateScreenTask->IsRunning())
&& !m_rotateScreenTask->IsEnded()
&& !m_rotateScreenTask->IsCancelled())
m_rotateScreenTask->Cancel();
m_rotateScreenTask.reset();

View file

@ -132,34 +132,16 @@ void CompassArrow::StopAnimation()
bool CompassArrow::onTapEnded(m2::PointD const & pt)
{
shared_ptr<anim::Controller> animController = m_framework->GetRenderPolicy()->GetAnimController();
anim::Controller * animController = m_framework->GetAnimController();
animController->Lock();
/// switching off compass follow mode
m_framework->GetInformationDisplay().locationState()->StopCompassFollowing();
if (m_rotateScreenTask
&& !m_rotateScreenTask->IsEnded()
&& !m_rotateScreenTask->IsCancelled())
m_rotateScreenTask->Cancel();
m_rotateScreenTask.reset();
double startAngle = m_framework->GetNavigator().Screen().GetAngle();
double endAngle = 0;
double period = 2 * math::pi;
startAngle -= floor(startAngle / period) * period;
endAngle -= floor(endAngle / period) * period;
if (fabs(startAngle - endAngle) > math::pi)
startAngle -= 2 * math::pi;
m_rotateScreenTask.reset(new RotateScreenTask(m_framework,
startAngle,
endAngle,
2));
animController->AddTask(m_rotateScreenTask);
m_framework->GetAnimator().RotateScreen(startAngle, endAngle, 2);
animController->Unlock();

View file

@ -1135,6 +1135,8 @@ void Framework::SetRenderPolicy(RenderPolicy * renderPolicy)
m_renderPolicy->SetRenderFn(DrawModelFn());
m_renderPolicy->SetAnimController(m_animController.get());
m_navigator.SetSupportRotation(m_renderPolicy->DoSupportRotation());
if (m_width != 0 && m_height != 0)

View file

@ -387,7 +387,7 @@ namespace location
if (!m_framework->GetNavigator().DoSupportRotation())
return;
shared_ptr<anim::Controller> controller = m_framework->GetRenderPolicy()->GetAnimController();
anim::Controller * controller = m_framework->GetAnimController();
controller->Lock();

View file

@ -37,8 +37,7 @@ RenderPolicy::RenderPolicy(Params const & p,
m_doSupportRotation(doSupportRotation),
m_doForceUpdate(false),
m_visualScale(p.m_visualScale),
m_skinName(p.m_skinName),
m_controller(new anim::Controller())
m_skinName(p.m_skinName)
{
LOG(LDEBUG, ("each BaseRule will hold up to", idCacheSize, "cached values"));
drule::rules().ResizeCaches(idCacheSize);
@ -220,9 +219,9 @@ void RenderPolicy::JoinBenchmarkFence(int fenceID)
{
}
shared_ptr<anim::Controller> const & RenderPolicy::GetAnimController() const
void RenderPolicy::SetAnimController(anim::Controller * controller)
{
return m_controller;
m_controller = controller;
}
void RenderPolicy::SetOverlay(shared_ptr<yg::Overlay> const & overlay)

View file

@ -13,6 +13,11 @@ class PaintEvent;
class ScreenBase;
class VideoTimer;
namespace anim
{
class Controller;
}
namespace yg
{
namespace gl
@ -60,7 +65,7 @@ protected:
m2::AnyRectD m_invalidRect;
double m_visualScale;
string m_skinName;
shared_ptr<anim::Controller> m_controller;
anim::Controller * m_controller;
shared_ptr<yg::Overlay> m_overlay;
void SetOverlay(shared_ptr<yg::Overlay> const & overlay);
@ -111,6 +116,7 @@ public:
/// the start point of rendering in renderpolicy.
virtual void SetRenderFn(TRenderFn renderFn);
virtual void SetCountryNameFn(TCountryNameFn countryNameFn);
void SetAnimController(anim::Controller * controller);
bool DoSupportRotation() const;
virtual bool IsTiling() const;
@ -123,7 +129,6 @@ public:
bool DoForceUpdate() const;
void SetForceUpdate(bool flag);
shared_ptr<anim::Controller> const & GetAnimController() const;
bool IsAnimating() const;
void SetInvalidRect(m2::AnyRectD const & glbRect);