Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: ui/compositor/layer_animation_sequence.cc

Issue 11896017: Thread ui opacity animations (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Correctly deal with sequences meant to start together Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/compositor/layer_animation_sequence.cc
diff --git a/ui/compositor/layer_animation_sequence.cc b/ui/compositor/layer_animation_sequence.cc
index a997c385a3f49ce1cc696aff829679af5056d60b..bac3040098d30a6bd99a55092ed2f347b1b349d9 100644
--- a/ui/compositor/layer_animation_sequence.cc
+++ b/ui/compositor/layer_animation_sequence.cc
@@ -16,12 +16,14 @@ namespace ui {
LayerAnimationSequence::LayerAnimationSequence()
: is_cyclic_(false),
- last_element_(0) {
+ last_element_(0),
+ waiting_for_group_start_(false) {
}
LayerAnimationSequence::LayerAnimationSequence(LayerAnimationElement* element)
: is_cyclic_(false),
- last_element_(0) {
+ last_element_(0),
+ waiting_for_group_start_(false) {
AddElement(element);
}
@@ -31,6 +33,14 @@ LayerAnimationSequence::~LayerAnimationSequence() {
DetachedFromSequence(this, true));
}
+void LayerAnimationSequence::ProgressToEffectiveStart(
+ LayerAnimationDelegate* delegate) {
+ if (elements_.empty())
+ return;
+
+ elements_[0]->ProgressToEffectiveStart(delegate);
+}
+
void LayerAnimationSequence::Progress(base::TimeTicks now,
LayerAnimationDelegate* delegate) {
bool redraw_required = false;
@@ -44,7 +54,8 @@ void LayerAnimationSequence::Progress(base::TimeTicks now,
size_t current_index = last_element_ % elements_.size();
base::TimeDelta element_duration;
while (is_cyclic_ || last_element_ < elements_.size()) {
- elements_[current_index]->set_start_time(last_start_);
+ elements_[current_index]->set_requested_start_time(last_start_);
+ elements_[current_index]->set_animation_group_id(animation_group_id_);
if (!elements_[current_index]->IsFinished(now, &element_duration))
break;
@@ -68,6 +79,7 @@ void LayerAnimationSequence::Progress(base::TimeTicks now,
if (!is_cyclic_ && last_element_ == elements_.size()) {
last_element_ = 0;
+ waiting_for_group_start_ = false;
NotifyEnded();
}
}
@@ -86,7 +98,7 @@ bool LayerAnimationSequence::IsFinished(base::TimeTicks time) {
size_t current_index = last_element_;
base::TimeDelta element_duration;
while (current_index < elements_.size()) {
- elements_[current_index]->set_start_time(current_start);
+ elements_[current_index]->set_requested_start_time(current_start);
if (!elements_[current_index]->IsFinished(time, &element_duration))
break;
@@ -116,6 +128,7 @@ void LayerAnimationSequence::ProgressToEnd(LayerAnimationDelegate* delegate) {
if (!is_cyclic_) {
last_element_ = 0;
+ waiting_for_group_start_ = false;
NotifyEnded();
}
}
@@ -129,13 +142,14 @@ void LayerAnimationSequence::GetTargetValue(
elements_[i]->GetTargetValue(target);
}
-void LayerAnimationSequence::Abort() {
+void LayerAnimationSequence::Abort(LayerAnimationDelegate* delegate) {
size_t current_index = last_element_ % elements_.size();
while (current_index < elements_.size()) {
- elements_[current_index]->Abort();
+ elements_[current_index]->Abort(delegate);
++current_index;
}
last_element_ = 0;
+ waiting_for_group_start_ = false;
NotifyAborted();
}
@@ -156,6 +170,13 @@ bool LayerAnimationSequence::HasCommonProperty(
return intersection.size() > 0;
}
+bool LayerAnimationSequence::IsFirstElementThreaded() const {
+ if (!elements_.empty())
+ return elements_[0]->IsThreaded();
+
+ return false;
+}
+
void LayerAnimationSequence::AddObserver(LayerAnimationObserver* observer) {
if (!observers_.HasObserver(observer)) {
observers_.AddObserver(observer);
@@ -168,6 +189,23 @@ void LayerAnimationSequence::RemoveObserver(LayerAnimationObserver* observer) {
observer->DetachedFromSequence(this, true);
}
+void LayerAnimationSequence::OnThreadedAnimationStarted(
+ const cc::AnimationEvent& event) {
+ if (elements_.empty() || event.groupId != animation_group_id_)
+ return;
Ian Vollick 2013/01/25 15:11:47 Can you add some DCHECKs that we do find the thing
ajuma 2013/01/29 18:31:23 DCHECK added.
+
+ size_t current_index = last_element_ % elements_.size();
+ const LayerAnimationElement::AnimatableProperties& element_properties =
+ elements_[current_index]->properties();
+ LayerAnimationElement::AnimatableProperty event_property =
+ LayerAnimationElement::ToAnimatableProperty(event.targetProperty);
+ if (element_properties.find(event_property) != element_properties.end()) {
+ elements_[current_index]->set_effective_start_time(
+ base::TimeTicks::FromInternalValue(
+ event.monotonicTime * base::Time::kMicrosecondsPerSecond));
+ }
+}
+
void LayerAnimationSequence::OnScheduled() {
NotifyScheduled();
}

Powered by Google App Engine
This is Rietveld 408576698