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
path: root/anim
diff options
context:
space:
mode:
authorrachytski <siarhei.rachytski@gmail.com>2012-09-28 22:12:14 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:44:25 +0300
commit7ea55eff17c28cb688f314e0904c160cba4c8952 (patch)
treeba4dc3d778f42e52fcbff2dc3473a5ff923d4553 /anim
parentb307e49a76580e8c64cee6c51ea66fb1978ddf23 (diff)
keeping anim::Controller pre-warmed for 5 cycles to allow new animations to start without interrupting rendering process.
Diffstat (limited to 'anim')
-rw-r--r--anim/controller.cpp15
-rw-r--r--anim/controller.hpp9
2 files changed, 24 insertions, 0 deletions
diff --git a/anim/controller.cpp b/anim/controller.cpp
index 9e246da4c2..3f217cf48c 100644
--- a/anim/controller.cpp
+++ b/anim/controller.cpp
@@ -10,6 +10,8 @@ namespace anim
Controller::Controller()
{
m_LockCount = 0;
+ m_IdleThreshold = 5;
+ m_IdleFrames = 0;
}
Controller::~Controller()
@@ -19,6 +21,7 @@ namespace anim
void Controller::AddTask(shared_ptr<Task> const & task)
{
m_tasks.PushBack(task);
+ m_IdleFrames = m_IdleThreshold;
}
void Controller::CopyAndClearTasks(TTasks & from, TTasks & to)
@@ -56,8 +59,12 @@ namespace anim
TTasks l;
+ bool hasTasks = !m_tasksList.empty();
+
for (TTasks::const_iterator it = m_tasksList.begin(); it != m_tasksList.end(); ++it)
{
+ m_IdleFrames = m_IdleThreshold;
+
shared_ptr<Task> const & task = *it;
if (task->State() == Task::EStarted)
task->OnStart(ts);
@@ -75,6 +82,14 @@ namespace anim
}
}
+ if (!hasTasks && m_IdleFrames > 0)
+ m_IdleFrames -= 1;
+
m_tasks.ProcessList(bind(&Controller::CopyAndClearTasks, ref(l), _1));
}
+
+ bool Controller::IsPreWarmed() const
+ {
+ return m_IdleFrames > 0;
+ }
}
diff --git a/anim/controller.hpp b/anim/controller.hpp
index b93b19b71e..ff8a66e863 100644
--- a/anim/controller.hpp
+++ b/anim/controller.hpp
@@ -22,6 +22,8 @@ namespace anim
TTasks m_tasksList;
int m_LockCount;
+ int m_IdleThreshold;
+ int m_IdleFrames;
static void CopyAndClearTasks(list<shared_ptr<Task> > & from, list<shared_ptr<Task> > & to);
@@ -44,5 +46,12 @@ namespace anim
int LockCount();
// Perform single animation step
void PerformStep();
+ // When the last animation is finished, Controller continues
+ // to be considered animating something for some frames to allow
+ // animations that are likely to happen in the next few frames to
+ // catch the Controller up and animate everything smoothly without
+ // interrupting rendering process, which might had happened in these
+ // "frames-in-the-middle".
+ bool IsPreWarmed() const;
};
}