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

Side by Side Diff: ui/views/animation/square_ink_drop_ripple.cc

Issue 2631333002: [animations] Adds metrics for jank on selected layer animations (Closed)
Patch Set: Adds UMA reporting for ripples and overview mode (committed frames) Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/views/animation/square_ink_drop_ripple.h" 5 #include "ui/views/animation/square_ink_drop_ripple.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/lazy_instance.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram_macros.h"
10 #include "ui/compositor/layer.h" 12 #include "ui/compositor/layer.h"
11 #include "ui/compositor/layer_animation_sequence.h" 13 #include "ui/compositor/layer_animation_sequence.h"
12 #include "ui/compositor/scoped_layer_animation_settings.h" 14 #include "ui/compositor/scoped_layer_animation_settings.h"
13 #include "ui/gfx/geometry/point3_f.h" 15 #include "ui/gfx/geometry/point3_f.h"
14 #include "ui/gfx/geometry/point_conversions.h" 16 #include "ui/gfx/geometry/point_conversions.h"
15 #include "ui/gfx/geometry/point_f.h" 17 #include "ui/gfx/geometry/point_f.h"
16 #include "ui/gfx/geometry/vector3d_f.h" 18 #include "ui/gfx/geometry/vector3d_f.h"
17 #include "ui/gfx/transform_util.h" 19 #include "ui/gfx/transform_util.h"
18 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" 20 #include "ui/views/animation/ink_drop_painted_layer_delegates.h"
19 #include "ui/views/view.h" 21 #include "ui/views/view.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // factors. 154 // factors.
153 gfx::Transform CalculateRectTransform(const gfx::Vector2dF& center_offset, 155 gfx::Transform CalculateRectTransform(const gfx::Vector2dF& center_offset,
154 float x_scale, 156 float x_scale,
155 float y_scale) { 157 float y_scale) {
156 gfx::Transform transform; 158 gfx::Transform transform;
157 transform.Scale(x_scale, y_scale); 159 transform.Scale(x_scale, y_scale);
158 transform.Translate(-center_offset.x(), -center_offset.y()); 160 transform.Translate(-center_offset.x(), -center_offset.y());
159 return transform; 161 return transform;
160 } 162 }
161 163
164 class SquareRippleMetricsReporter : public ui::AnimationMetricsReporter {
165 void Report(int value) override {
166 UMA_HISTOGRAM_PERCENTAGE("Views.AnimationSmoothness.SquareRipple", value);
167 }
168 };
169 base::LazyInstance<SquareRippleMetricsReporter>::Leaky g_reporter =
170 LAZY_INSTANCE_INITIALIZER;
171
162 } // namespace 172 } // namespace
163 173
164 namespace views { 174 namespace views {
165 175
166 SquareInkDropRipple::SquareInkDropRipple(const gfx::Size& large_size, 176 SquareInkDropRipple::SquareInkDropRipple(const gfx::Size& large_size,
167 int large_corner_radius, 177 int large_corner_radius,
168 const gfx::Size& small_size, 178 const gfx::Size& small_size,
169 int small_corner_radius, 179 int small_corner_radius,
170 const gfx::Point& center_point, 180 const gfx::Point& center_point,
171 SkColor color, 181 SkColor color,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 gfx::Transform transform; 467 gfx::Transform transform;
458 transform.Translate(target_center_point_.x(), target_center_point_.y()); 468 transform.Translate(target_center_point_.x(), target_center_point_.y());
459 std::unique_ptr<ui::LayerAnimationElement> element = 469 std::unique_ptr<ui::LayerAnimationElement> element =
460 ui::LayerAnimationElement::CreateTransformElement(transform, duration); 470 ui::LayerAnimationElement::CreateTransformElement(transform, duration);
461 ui::LayerAnimationSequence* sequence = 471 ui::LayerAnimationSequence* sequence =
462 new ui::LayerAnimationSequence(std::move(element)); 472 new ui::LayerAnimationSequence(std::move(element));
463 473
464 if (observer) 474 if (observer)
465 sequence->AddObserver(observer); 475 sequence->AddObserver(observer);
466 476
477 sequence->SetAnimationMetricsReporter(g_reporter.Pointer());
467 animator->StartAnimation(sequence); 478 animator->StartAnimation(sequence);
468 } 479 }
469 480
470 void SquareInkDropRipple::AnimateToTransforms( 481 void SquareInkDropRipple::AnimateToTransforms(
471 const InkDropTransforms transforms, 482 const InkDropTransforms transforms,
472 base::TimeDelta duration, 483 base::TimeDelta duration,
473 ui::LayerAnimator::PreemptionStrategy preemption_strategy, 484 ui::LayerAnimator::PreemptionStrategy preemption_strategy,
474 gfx::Tween::Type tween, 485 gfx::Tween::Type tween,
475 ui::LayerAnimationObserver* animation_observer) { 486 ui::LayerAnimationObserver* animation_observer) {
476 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) { 487 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) {
477 ui::LayerAnimator* animator = painted_layers_[i]->GetAnimator(); 488 ui::LayerAnimator* animator = painted_layers_[i]->GetAnimator();
478 ui::ScopedLayerAnimationSettings animation(animator); 489 ui::ScopedLayerAnimationSettings animation(animator);
479 animation.SetPreemptionStrategy(preemption_strategy); 490 animation.SetPreemptionStrategy(preemption_strategy);
480 animation.SetTweenType(tween); 491 animation.SetTweenType(tween);
481 std::unique_ptr<ui::LayerAnimationElement> element = 492 std::unique_ptr<ui::LayerAnimationElement> element =
482 ui::LayerAnimationElement::CreateTransformElement(transforms[i], 493 ui::LayerAnimationElement::CreateTransformElement(transforms[i],
483 duration); 494 duration);
484 ui::LayerAnimationSequence* sequence = 495 ui::LayerAnimationSequence* sequence =
485 new ui::LayerAnimationSequence(std::move(element)); 496 new ui::LayerAnimationSequence(std::move(element));
486 497
487 if (animation_observer) 498 if (animation_observer)
488 sequence->AddObserver(animation_observer); 499 sequence->AddObserver(animation_observer);
489 500
501 sequence->SetAnimationMetricsReporter(g_reporter.Pointer());
490 animator->StartAnimation(sequence); 502 animator->StartAnimation(sequence);
491 } 503 }
492 } 504 }
493 505
494 void SquareInkDropRipple::SetTransforms(const InkDropTransforms transforms) { 506 void SquareInkDropRipple::SetTransforms(const InkDropTransforms transforms) {
495 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) 507 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i)
496 painted_layers_[i]->SetTransform(transforms[i]); 508 painted_layers_[i]->SetTransform(transforms[i]);
497 } 509 }
498 510
499 void SquareInkDropRipple::SetOpacity(float opacity) { 511 void SquareInkDropRipple::SetOpacity(float opacity) {
(...skipping 11 matching lines...) Expand all
511 animation_settings.SetPreemptionStrategy(preemption_strategy); 523 animation_settings.SetPreemptionStrategy(preemption_strategy);
512 animation_settings.SetTweenType(tween); 524 animation_settings.SetTweenType(tween);
513 std::unique_ptr<ui::LayerAnimationElement> animation_element = 525 std::unique_ptr<ui::LayerAnimationElement> animation_element =
514 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration); 526 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration);
515 ui::LayerAnimationSequence* animation_sequence = 527 ui::LayerAnimationSequence* animation_sequence =
516 new ui::LayerAnimationSequence(std::move(animation_element)); 528 new ui::LayerAnimationSequence(std::move(animation_element));
517 529
518 if (animation_observer) 530 if (animation_observer)
519 animation_sequence->AddObserver(animation_observer); 531 animation_sequence->AddObserver(animation_observer);
520 532
533 animation_sequence->SetAnimationMetricsReporter(g_reporter.Pointer());
521 animator->StartAnimation(animation_sequence); 534 animator->StartAnimation(animation_sequence);
522 } 535 }
523 536
524 void SquareInkDropRipple::CalculateCircleTransforms( 537 void SquareInkDropRipple::CalculateCircleTransforms(
525 const gfx::Size& size, 538 const gfx::Size& size,
526 InkDropTransforms* transforms_out) const { 539 InkDropTransforms* transforms_out) const {
527 CalculateRectTransforms(size, std::min(size.width(), size.height()) / 2.0f, 540 CalculateRectTransforms(size, std::min(size.width(), size.height()) / 2.0f,
528 transforms_out); 541 transforms_out);
529 } 542 }
530 543
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 layer->set_delegate(delegate); 657 layer->set_delegate(delegate);
645 layer->SetVisible(true); 658 layer->SetVisible(true);
646 layer->SetOpacity(1.0); 659 layer->SetOpacity(1.0);
647 layer->SetMasksToBounds(false); 660 layer->SetMasksToBounds(false);
648 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape)); 661 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape));
649 662
650 painted_layers_[painted_shape].reset(layer); 663 painted_layers_[painted_shape].reset(layer);
651 } 664 }
652 665
653 } // namespace views 666 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698