diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2012-10-11 19:34:13 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:45:22 +0300 |
commit | 0e4f41bfb531d6b49caa8ee8fc8de7216774108b (patch) | |
tree | b4b2a5ba68c58f2aed1b56c602005c6af1089a4f /anim/controller.cpp | |
parent | c4c7570816b3f1888d6a2c3a27922a2d8d4c51b2 (diff) |
dividing anim::Task's into visual/non-visual and taking it into account in RenderPolicy::NeedRedraw.
Diffstat (limited to 'anim/controller.cpp')
-rw-r--r-- | anim/controller.cpp | 53 |
1 files changed, 45 insertions, 8 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; } |