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

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 (UMA name fix) 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
170 base::LazyInstance<SquareRippleMetricsReporter>::Leaky g_reporter =
171 LAZY_INSTANCE_INITIALIZER;
172
162 } // namespace 173 } // namespace
163 174
164 namespace views { 175 namespace views {
165 176
166 SquareInkDropRipple::SquareInkDropRipple(const gfx::Size& large_size, 177 SquareInkDropRipple::SquareInkDropRipple(const gfx::Size& large_size,
167 int large_corner_radius, 178 int large_corner_radius,
168 const gfx::Size& small_size, 179 const gfx::Size& small_size,
169 int small_corner_radius, 180 int small_corner_radius,
170 const gfx::Point& center_point, 181 const gfx::Point& center_point,
171 SkColor color, 182 SkColor color,
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 gfx::Transform transform; 463 gfx::Transform transform;
453 transform.Translate(target_center_point_.x(), target_center_point_.y()); 464 transform.Translate(target_center_point_.x(), target_center_point_.y());
454 std::unique_ptr<ui::LayerAnimationElement> element = 465 std::unique_ptr<ui::LayerAnimationElement> element =
455 ui::LayerAnimationElement::CreateTransformElement(transform, duration); 466 ui::LayerAnimationElement::CreateTransformElement(transform, duration);
456 ui::LayerAnimationSequence* sequence = 467 ui::LayerAnimationSequence* sequence =
457 new ui::LayerAnimationSequence(std::move(element)); 468 new ui::LayerAnimationSequence(std::move(element));
458 469
459 if (observer) 470 if (observer)
460 sequence->AddObserver(observer); 471 sequence->AddObserver(observer);
461 472
473 sequence->SetAnimationMetricsReporter(g_reporter.Pointer());
462 animator->StartAnimation(sequence); 474 animator->StartAnimation(sequence);
463 } 475 }
464 476
465 void SquareInkDropRipple::AnimateToTransforms( 477 void SquareInkDropRipple::AnimateToTransforms(
466 const InkDropTransforms transforms, 478 const InkDropTransforms transforms,
467 base::TimeDelta duration, 479 base::TimeDelta duration,
468 ui::LayerAnimator::PreemptionStrategy preemption_strategy, 480 ui::LayerAnimator::PreemptionStrategy preemption_strategy,
469 gfx::Tween::Type tween, 481 gfx::Tween::Type tween,
470 ui::LayerAnimationObserver* animation_observer) { 482 ui::LayerAnimationObserver* animation_observer) {
471 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) { 483 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) {
472 ui::LayerAnimator* animator = painted_layers_[i]->GetAnimator(); 484 ui::LayerAnimator* animator = painted_layers_[i]->GetAnimator();
473 ui::ScopedLayerAnimationSettings animation(animator); 485 ui::ScopedLayerAnimationSettings animation(animator);
474 animation.SetPreemptionStrategy(preemption_strategy); 486 animation.SetPreemptionStrategy(preemption_strategy);
475 animation.SetTweenType(tween); 487 animation.SetTweenType(tween);
476 std::unique_ptr<ui::LayerAnimationElement> element = 488 std::unique_ptr<ui::LayerAnimationElement> element =
477 ui::LayerAnimationElement::CreateTransformElement(transforms[i], 489 ui::LayerAnimationElement::CreateTransformElement(transforms[i],
478 duration); 490 duration);
479 ui::LayerAnimationSequence* sequence = 491 ui::LayerAnimationSequence* sequence =
480 new ui::LayerAnimationSequence(std::move(element)); 492 new ui::LayerAnimationSequence(std::move(element));
481 493
482 if (animation_observer) 494 if (animation_observer)
483 sequence->AddObserver(animation_observer); 495 sequence->AddObserver(animation_observer);
484 496
497 sequence->SetAnimationMetricsReporter(g_reporter.Pointer());
485 animator->StartAnimation(sequence); 498 animator->StartAnimation(sequence);
486 } 499 }
487 } 500 }
488 501
489 void SquareInkDropRipple::SetTransforms(const InkDropTransforms transforms) { 502 void SquareInkDropRipple::SetTransforms(const InkDropTransforms transforms) {
490 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) 503 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i)
491 painted_layers_[i]->SetTransform(transforms[i]); 504 painted_layers_[i]->SetTransform(transforms[i]);
492 } 505 }
493 506
494 void SquareInkDropRipple::SetOpacity(float opacity) { 507 void SquareInkDropRipple::SetOpacity(float opacity) {
(...skipping 11 matching lines...) Expand all
506 animation_settings.SetPreemptionStrategy(preemption_strategy); 519 animation_settings.SetPreemptionStrategy(preemption_strategy);
507 animation_settings.SetTweenType(tween); 520 animation_settings.SetTweenType(tween);
508 std::unique_ptr<ui::LayerAnimationElement> animation_element = 521 std::unique_ptr<ui::LayerAnimationElement> animation_element =
509 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration); 522 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration);
510 ui::LayerAnimationSequence* animation_sequence = 523 ui::LayerAnimationSequence* animation_sequence =
511 new ui::LayerAnimationSequence(std::move(animation_element)); 524 new ui::LayerAnimationSequence(std::move(animation_element));
512 525
513 if (animation_observer) 526 if (animation_observer)
514 animation_sequence->AddObserver(animation_observer); 527 animation_sequence->AddObserver(animation_observer);
515 528
529 animation_sequence->SetAnimationMetricsReporter(g_reporter.Pointer());
516 animator->StartAnimation(animation_sequence); 530 animator->StartAnimation(animation_sequence);
517 } 531 }
518 532
519 void SquareInkDropRipple::CalculateCircleTransforms( 533 void SquareInkDropRipple::CalculateCircleTransforms(
520 const gfx::Size& size, 534 const gfx::Size& size,
521 InkDropTransforms* transforms_out) const { 535 InkDropTransforms* transforms_out) const {
522 CalculateRectTransforms(size, std::min(size.width(), size.height()) / 2.0f, 536 CalculateRectTransforms(size, std::min(size.width(), size.height()) / 2.0f,
523 transforms_out); 537 transforms_out);
524 } 538 }
525 539
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 layer->set_delegate(delegate); 653 layer->set_delegate(delegate);
640 layer->SetVisible(true); 654 layer->SetVisible(true);
641 layer->SetOpacity(1.0); 655 layer->SetOpacity(1.0);
642 layer->SetMasksToBounds(false); 656 layer->SetMasksToBounds(false);
643 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape)); 657 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape));
644 658
645 painted_layers_[painted_shape].reset(layer); 659 painted_layers_[painted_shape].reset(layer);
646 } 660 }
647 661
648 } // namespace views 662 } // namespace views
OLDNEW
« ui/compositor/layer_animation_element.cc ('K') | « ui/views/animation/flood_fill_ink_drop_ripple.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698