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

Side by Side Diff: ui/gfx/compositor/layer_animation_sequence.cc

Issue 8362006: Reland r107720 - Enable the new layer animation framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Enable framework for aura Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/compositor/layer_animation_sequence.h" 5 #include "ui/gfx/compositor/layer_animation_sequence.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 11 matching lines...) Expand all
22 : is_cyclic_(false), 22 : is_cyclic_(false),
23 last_element_(0) { 23 last_element_(0) {
24 AddElement(element); 24 AddElement(element);
25 } 25 }
26 26
27 LayerAnimationSequence::~LayerAnimationSequence() { 27 LayerAnimationSequence::~LayerAnimationSequence() {
28 } 28 }
29 29
30 void LayerAnimationSequence::Progress(base::TimeDelta elapsed, 30 void LayerAnimationSequence::Progress(base::TimeDelta elapsed,
31 LayerAnimationDelegate* delegate) { 31 LayerAnimationDelegate* delegate) {
32 TRACE_EVENT0("LayerAnimationSequence", "Progress"); 32 //TRACE_EVENT0("LayerAnimationSequence", "Progress");
33 if (elements_.size() == 0 || duration_ == base::TimeDelta()) 33 if (elements_.size() == 0 || duration_ == base::TimeDelta())
34 return; 34 return;
35 35
36 if (is_cyclic_) { 36 if (is_cyclic_) {
37 // If delta = elapsed - last_start_ is huge, we can skip ahead by complete 37 // If delta = elapsed - last_start_ is huge, we can skip ahead by complete
38 // loops to save time. 38 // loops to save time.
39 base::TimeDelta delta = elapsed - last_start_; 39 base::TimeDelta delta = elapsed - last_start_;
40 int64 k = delta.ToInternalValue() / duration_.ToInternalValue() - 1; 40 int64 k = delta.ToInternalValue() / duration_.ToInternalValue() - 1;
41 if (k > 0) { 41 if (k > 0) {
42 last_start_ += base::TimeDelta::FromInternalValue( 42 last_start_ += base::TimeDelta::FromInternalValue(
(...skipping 19 matching lines...) Expand all
62 } 62 }
63 elements_[current_index]->Progress(t, delegate); 63 elements_[current_index]->Progress(t, delegate);
64 } 64 }
65 65
66 if (!is_cyclic_ && elapsed == duration_) { 66 if (!is_cyclic_ && elapsed == duration_) {
67 last_element_ = 0; 67 last_element_ = 0;
68 last_start_ = base::TimeDelta::FromMilliseconds(0); 68 last_start_ = base::TimeDelta::FromMilliseconds(0);
69 } 69 }
70 } 70 }
71 71
72 void LayerAnimationSequence::GetTargetValue(
73 LayerAnimationElement::TargetValue* target) const {
74 if (is_cyclic_)
75 return;
76
77 for (size_t i = last_element_; i < elements_.size(); ++i)
78 elements_[i]->GetTargetValue(target);
79 }
80
72 void LayerAnimationSequence::Abort() { 81 void LayerAnimationSequence::Abort() {
73 size_t current_index = last_element_ % elements_.size(); 82 size_t current_index = last_element_ % elements_.size();
74 while (current_index < elements_.size()) { 83 while (current_index < elements_.size()) {
75 elements_[current_index]->Abort(); 84 elements_[current_index]->Abort();
76 ++current_index; 85 ++current_index;
77 } 86 }
78 last_element_ = 0; 87 last_element_ = 0;
79 last_start_ = base::TimeDelta::FromMilliseconds(0); 88 last_start_ = base::TimeDelta::FromMilliseconds(0);
80 } 89 }
81 90
(...skipping 10 matching lines...) Expand all
92 LayerAnimationElement::AnimatableProperties intersection; 101 LayerAnimationElement::AnimatableProperties intersection;
93 std::insert_iterator<LayerAnimationElement::AnimatableProperties> ii( 102 std::insert_iterator<LayerAnimationElement::AnimatableProperties> ii(
94 intersection, intersection.begin()); 103 intersection, intersection.begin());
95 std::set_intersection(properties_.begin(), properties_.end(), 104 std::set_intersection(properties_.begin(), properties_.end(),
96 other.begin(), other.end(), 105 other.begin(), other.end(),
97 ii); 106 ii);
98 return intersection.size() > 0; 107 return intersection.size() > 0;
99 } 108 }
100 109
101 } // namespace ui 110 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698