Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrachytski <siarhei.rachytski@gmail.com>2012-09-28 22:10:57 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:44:24 +0300
commitb307e49a76580e8c64cee6c51ea66fb1978ddf23 (patch)
tree8e521ad6d59bc6e338f259adb75f89cc2544cc9c /map/animator.cpp
parent4f04b39a7aec4a09eb697c0227dfa4a558972dcc (diff)
[android] using anim::Task::Lock/Unlock methods for correct inter-thread synchronization. [ios] using one degree threshold for animation tasks recreation for smooth animation performance.
Diffstat (limited to 'map/animator.cpp')
-rw-r--r--map/animator.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/map/animator.cpp b/map/animator.cpp
index 414fdea659..3d3e688657 100644
--- a/map/animator.cpp
+++ b/map/animator.cpp
@@ -8,40 +8,40 @@
Animator::Animator(Framework * framework)
: m_framework(framework)
-{
- m_rotationThreshold = ang::DegreeToRad(10);
-}
+{}
void Animator::RotateScreen(double startAngle, double endAngle, double duration)
{
- bool shouldRotate = false;
+ if (m_rotateScreenTask)
+ m_rotateScreenTask->Lock();
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)
- shouldRotate = true;
- }
+ && !m_rotateScreenTask->IsCancelled()
+ && !m_rotateScreenTask->IsEnded())
+ m_rotateScreenTask->SetEndAngle(endAngle);
else
{
- // if there are no current rotate screen task or the task is finished already
- // we check for the distance between current screen angle and headingAngle
- if (fabs(ang::GetShortestDistance(startAngle, endAngle)) > m_rotationThreshold)
- shouldRotate = true;
+ if (floor(ang::RadToDegree(fabs(ang::GetShortestDistance(startAngle, endAngle)))) > 0)
+ {
+ if (m_rotateScreenTask)
+ {
+ m_rotateScreenTask->Unlock();
+ m_rotateScreenTask->Cancel();
+ m_rotateScreenTask.reset();
+ }
+
+ m_rotateScreenTask.reset(new RotateScreenTask(m_framework,
+ startAngle,
+ endAngle,
+ duration));
+
+ m_framework->GetAnimController()->AddTask(m_rotateScreenTask);
+ return;
+ }
}
- if (shouldRotate)
- {
- StopRotation();
- m_rotateScreenTask.reset(new RotateScreenTask(m_framework,
- startAngle,
- endAngle,
- duration));
-
- m_framework->GetAnimController()->AddTask(m_rotateScreenTask);
- }
+ if (m_rotateScreenTask)
+ m_rotateScreenTask->Unlock();
}
void Animator::StopRotation()