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

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

Issue 2631333002: [animations] Adds metrics for jank on selected layer animations (Closed)
Patch Set: Adds UMA reporting for ripples and overview mode (query refresh rate) Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « ui/compositor/layer_animation_sequence.h ('k') | ui/compositor/layer_animator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/compositor/layer_animation_sequence.h" 5 #include "ui/compositor/layer_animation_sequence.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "cc/animation/animation_id_provider.h" 11 #include "cc/animation/animation_id_provider.h"
12 #include "ui/compositor/layer_animation_delegate.h" 12 #include "ui/compositor/layer_animation_delegate.h"
13 #include "ui/compositor/layer_animation_element.h" 13 #include "ui/compositor/layer_animation_element.h"
14 #include "ui/compositor/layer_animation_observer.h" 14 #include "ui/compositor/layer_animation_observer.h"
15 15
16 namespace ui { 16 namespace ui {
17 17
18 LayerAnimationSequence::LayerAnimationSequence() 18 LayerAnimationSequence::LayerAnimationSequence()
19 : properties_(LayerAnimationElement::UNKNOWN), 19 : properties_(LayerAnimationElement::UNKNOWN),
20 is_cyclic_(false), 20 is_cyclic_(false),
21 last_element_(0), 21 last_element_(0),
22 waiting_for_group_start_(false), 22 waiting_for_group_start_(false),
23 animation_group_id_(0), 23 animation_group_id_(0),
24 last_progressed_fraction_(0.0), 24 last_progressed_fraction_(0.0),
25 weak_ptr_factory_(this) { 25 animation_metrics_reporter_(nullptr),
26 } 26 weak_ptr_factory_(this) {}
27 27
28 LayerAnimationSequence::LayerAnimationSequence( 28 LayerAnimationSequence::LayerAnimationSequence(
29 std::unique_ptr<LayerAnimationElement> element) 29 std::unique_ptr<LayerAnimationElement> element)
30 : properties_(LayerAnimationElement::UNKNOWN), 30 : properties_(LayerAnimationElement::UNKNOWN),
31 is_cyclic_(false), 31 is_cyclic_(false),
32 last_element_(0), 32 last_element_(0),
33 waiting_for_group_start_(false), 33 waiting_for_group_start_(false),
34 animation_group_id_(0), 34 animation_group_id_(0),
35 last_progressed_fraction_(0.0), 35 last_progressed_fraction_(0.0),
36 animation_metrics_reporter_(nullptr),
36 weak_ptr_factory_(this) { 37 weak_ptr_factory_(this) {
37 AddElement(std::move(element)); 38 AddElement(std::move(element));
38 } 39 }
39 40
40 LayerAnimationSequence::~LayerAnimationSequence() { 41 LayerAnimationSequence::~LayerAnimationSequence() {
41 for (auto& observer : observers_) 42 for (auto& observer : observers_)
42 observer.DetachedFromSequence(this, true); 43 observer.DetachedFromSequence(this, true);
43 } 44 }
44 45
45 void LayerAnimationSequence::Start(LayerAnimationDelegate* delegate) { 46 void LayerAnimationSequence::Start(LayerAnimationDelegate* delegate) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 ++current_index; 180 ++current_index;
180 } 181 }
181 last_element_ = 0; 182 last_element_ = 0;
182 waiting_for_group_start_ = false; 183 waiting_for_group_start_ = false;
183 NotifyAborted(); 184 NotifyAborted();
184 } 185 }
185 186
186 void LayerAnimationSequence::AddElement( 187 void LayerAnimationSequence::AddElement(
187 std::unique_ptr<LayerAnimationElement> element) { 188 std::unique_ptr<LayerAnimationElement> element) {
188 properties_ |= element->properties(); 189 properties_ |= element->properties();
190 element->set_animation_metrics_reporter(animation_metrics_reporter_);
189 elements_.push_back(std::move(element)); 191 elements_.push_back(std::move(element));
190 } 192 }
191 193
192 bool LayerAnimationSequence::HasConflictingProperty( 194 bool LayerAnimationSequence::HasConflictingProperty(
193 LayerAnimationElement::AnimatableProperties other) const { 195 LayerAnimationElement::AnimatableProperties other) const {
194 return (properties_ & other) != LayerAnimationElement::UNKNOWN; 196 return (properties_ & other) != LayerAnimationElement::UNKNOWN;
195 } 197 }
196 198
197 bool LayerAnimationSequence::IsFirstElementThreaded() const { 199 bool LayerAnimationSequence::IsFirstElementThreaded() const {
198 if (!elements_.empty()) 200 if (!elements_.empty())
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 void LayerAnimationSequence::OnAnimatorDestroyed() { 238 void LayerAnimationSequence::OnAnimatorDestroyed() {
237 for (LayerAnimationObserver& observer : observers_) { 239 for (LayerAnimationObserver& observer : observers_) {
238 if (!observer.RequiresNotificationWhenAnimatorDestroyed()) { 240 if (!observer.RequiresNotificationWhenAnimatorDestroyed()) {
239 // Remove the observer, but do not allow notifications to be sent. 241 // Remove the observer, but do not allow notifications to be sent.
240 observers_.RemoveObserver(&observer); 242 observers_.RemoveObserver(&observer);
241 observer.DetachedFromSequence(this, false); 243 observer.DetachedFromSequence(this, false);
242 } 244 }
243 } 245 }
244 } 246 }
245 247
248 void LayerAnimationSequence::SetAnimationMetricsReporter(
249 AnimationMetricsReporter* reporter) {
250 animation_metrics_reporter_ = reporter;
251 for (auto& element : elements_)
252 element->set_animation_metrics_reporter(animation_metrics_reporter_);
253 }
254
246 size_t LayerAnimationSequence::size() const { 255 size_t LayerAnimationSequence::size() const {
247 return elements_.size(); 256 return elements_.size();
248 } 257 }
249 258
250 LayerAnimationElement* LayerAnimationSequence::FirstElement() const { 259 LayerAnimationElement* LayerAnimationSequence::FirstElement() const {
251 if (elements_.empty()) { 260 if (elements_.empty()) {
252 return NULL; 261 return NULL;
253 } 262 }
254 263
255 return elements_[0].get(); 264 return elements_[0].get();
(...skipping 21 matching lines...) Expand all
277 286
278 LayerAnimationElement* LayerAnimationSequence::CurrentElement() const { 287 LayerAnimationElement* LayerAnimationSequence::CurrentElement() const {
279 if (elements_.empty()) 288 if (elements_.empty())
280 return NULL; 289 return NULL;
281 290
282 size_t current_index = last_element_ % elements_.size(); 291 size_t current_index = last_element_ % elements_.size();
283 return elements_[current_index].get(); 292 return elements_[current_index].get();
284 } 293 }
285 294
286 } // namespace ui 295 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animation_sequence.h ('k') | ui/compositor/layer_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698