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-10-11 19:34:13 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:45:22 +0300
commit0e4f41bfb531d6b49caa8ee8fc8de7216774108b (patch)
treeb4b2a5ba68c58f2aed1b56c602005c6af1089a4f /anim
parentc4c7570816b3f1888d6a2c3a27922a2d8d4c51b2 (diff)
dividing anim::Task's into visual/non-visual and taking it into account in RenderPolicy::NeedRedraw.
Diffstat (limited to 'anim')
-rw-r--r--anim/controller.cpp53
-rw-r--r--anim/controller.hpp6
-rw-r--r--anim/task.cpp5
-rw-r--r--anim/task.hpp4
4 files changed, 59 insertions, 9 deletions
diff --git a/anim/controller.cpp b/anim/controller.cpp
index 2482a21370..94495666c2 100644
--- a/anim/controller.cpp
+++ b/anim/controller.cpp
@@ -18,11 +18,17 @@ namespace anim
{
}
- void Controller::AddTask(shared_ptr<Task> const & task)
+ void Controller::AddTaskImpl(list<shared_ptr<Task> > & l, shared_ptr<Task> const & task)
{
+ l.push_back(task);
task->SetController(this);
- m_tasks.PushBack(task);
- m_IdleFrames = m_IdleThreshold;
+ if (task->IsVisual())
+ m_IdleFrames = m_IdleThreshold;
+ }
+
+ void Controller::AddTask(shared_ptr<Task> const & task)
+ {
+ m_tasks.ProcessList(bind(&Controller::AddTaskImpl, this, _1, task));
}
void Controller::CopyAndClearTasks(TTasks & from, TTasks & to)
@@ -41,6 +47,28 @@ namespace anim
return !m_tasks.Empty();
}
+ void Controller::HasVisualTasksImpl(list<shared_ptr<Task> > &l, bool *res) const
+ {
+ *res = false;
+ for (list<shared_ptr<Task> >::const_iterator it = l.begin();
+ it != l.end();
+ ++it)
+ {
+ if ((*it)->IsVisual())
+ {
+ *res = true;
+ break;
+ }
+ }
+ }
+
+ bool Controller::HasVisualTasks()
+ {
+ bool res;
+ m_tasks.ProcessList(bind(&Controller::HasVisualTasksImpl, this, _1, &res));
+ return res;
+ }
+
void Controller::Lock()
{
++m_LockCount;
@@ -65,16 +93,25 @@ namespace anim
TTasks l;
- bool hasTasks = !m_tasksList.empty();
+ bool hasVisualTasks = false;
+ for (list<shared_ptr<Task> >::const_iterator it = m_tasksList.begin();
+ it != m_tasksList.end();
+ ++it)
+ if ((*it)->IsVisual())
+ {
+ hasVisualTasks = true;
+ break;
+ }
for (TTasks::const_iterator it = m_tasksList.begin(); it != m_tasksList.end(); ++it)
{
- m_IdleFrames = m_IdleThreshold;
-
shared_ptr<Task> const & task = *it;
task->Lock();
+ if (task->IsVisual())
+ m_IdleFrames = m_IdleThreshold;
+
if (task->IsReady())
{
task->Start();
@@ -96,13 +133,13 @@ namespace anim
task->Unlock();
}
- if (!hasTasks && m_IdleFrames > 0)
+ if (!hasVisualTasks && m_IdleFrames > 0)
m_IdleFrames -= 1;
m_tasks.ProcessList(bind(&Controller::MergeTasks, ref(l), _1));
}
- bool Controller::IsPreWarmed() const
+ bool Controller::IsVisuallyPreWarmed() const
{
return m_IdleFrames > 0;
}
diff --git a/anim/controller.hpp b/anim/controller.hpp
index 398f191a4d..a26f5e2721 100644
--- a/anim/controller.hpp
+++ b/anim/controller.hpp
@@ -25,6 +25,8 @@ namespace anim
int m_IdleThreshold;
int m_IdleFrames;
+ void AddTaskImpl(list<shared_ptr<Task> > & l, shared_ptr<Task> const & task);
+ void HasVisualTasksImpl(list<shared_ptr<Task> > & l, bool * res) const;
static void CopyAndClearTasks(list<shared_ptr<Task> > & from, list<shared_ptr<Task> > & to);
static void MergeTasks(list<shared_ptr<Task> > & from, list<shared_ptr<Task> > & to);
@@ -37,6 +39,8 @@ namespace anim
void AddTask(shared_ptr<Task> const & task);
// Do we have animation tasks, which are currently running?
bool HasTasks();
+ // Do we have visual animation tasks, which are currently running?
+ bool HasVisualTasks();
// Lock/Unlock controller. Locked controller
// is considered to be in "transition" mode from one task to another
// and this situation is taken into account into RenderPolicy when
@@ -53,7 +57,7 @@ namespace anim
// 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;
+ bool IsVisuallyPreWarmed() const;
// Getting current simulation time
double GetCurrentTime() const;
};
diff --git a/anim/task.cpp b/anim/task.cpp
index 92a5c4b04e..72bbdb2cfa 100644
--- a/anim/task.cpp
+++ b/anim/task.cpp
@@ -97,6 +97,11 @@ namespace anim
return State() == EReady;
}
+ bool Task::IsVisual() const
+ {
+ return false;
+ }
+
void Task::AddCallback(EState state, TCallback const & cb)
{
m_Callbacks[state].push_back(cb);
diff --git a/anim/task.hpp b/anim/task.hpp
index 8cea0054dd..470d22b1e9 100644
--- a/anim/task.hpp
+++ b/anim/task.hpp
@@ -69,6 +69,10 @@ namespace anim
void Lock();
void Unlock();
+ /// is this animation task animate something,
+ /// which is directly changing visual appearance.
+ virtual bool IsVisual() const;
+
void AddCallback(EState state, TCallback const & cb);
};
}