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

Side by Side Diff: ui/compositor/layer_animation_element.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 (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_element.h" 5 #include "ui/compositor/layer_animation_element.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 : gfx::Transform()), 440 : gfx::Transform()),
441 opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f), 441 opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f),
442 visibility(delegate ? delegate->GetVisibilityForAnimation() : false), 442 visibility(delegate ? delegate->GetVisibilityForAnimation() : false),
443 brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f), 443 brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f),
444 grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f), 444 grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f),
445 color(delegate ? delegate->GetColorForAnimation() : SK_ColorTRANSPARENT) { 445 color(delegate ? delegate->GetColorForAnimation() : SK_ColorTRANSPARENT) {
446 } 446 }
447 447
448 // LayerAnimationElement ------------------------------------------------------- 448 // LayerAnimationElement -------------------------------------------------------
449 449
450 LayerAnimationElement::LayerAnimationElement( 450 LayerAnimationElement::LayerAnimationElement(AnimatableProperties properties,
451 AnimatableProperties properties, base::TimeDelta duration) 451 base::TimeDelta duration)
452 : first_frame_(true), 452 : first_frame_(true),
453 properties_(properties), 453 properties_(properties),
454 duration_(GetEffectiveDuration(duration)), 454 duration_(GetEffectiveDuration(duration)),
455 tween_type_(gfx::Tween::LINEAR), 455 tween_type_(gfx::Tween::LINEAR),
456 animation_id_(cc::AnimationIdProvider::NextAnimationId()), 456 animation_id_(cc::AnimationIdProvider::NextAnimationId()),
457 animation_group_id_(0), 457 animation_group_id_(0),
458 last_progressed_fraction_(0.0), 458 last_progressed_fraction_(0.0),
459 weak_ptr_factory_(this) { 459 animation_metrics_reporter_(nullptr),
460 } 460 start_frame_number_(0),
461 weak_ptr_factory_(this) {}
461 462
462 LayerAnimationElement::LayerAnimationElement( 463 LayerAnimationElement::LayerAnimationElement(
463 const LayerAnimationElement &element) 464 const LayerAnimationElement& element)
464 : first_frame_(element.first_frame_), 465 : first_frame_(element.first_frame_),
465 properties_(element.properties_), 466 properties_(element.properties_),
466 duration_(element.duration_), 467 duration_(element.duration_),
467 tween_type_(element.tween_type_), 468 tween_type_(element.tween_type_),
468 animation_id_(cc::AnimationIdProvider::NextAnimationId()), 469 animation_id_(cc::AnimationIdProvider::NextAnimationId()),
469 animation_group_id_(element.animation_group_id_), 470 animation_group_id_(element.animation_group_id_),
470 last_progressed_fraction_(element.last_progressed_fraction_), 471 last_progressed_fraction_(element.last_progressed_fraction_),
471 weak_ptr_factory_(this) { 472 animation_metrics_reporter_(nullptr),
472 } 473 start_frame_number_(0),
474 weak_ptr_factory_(this) {}
473 475
474 LayerAnimationElement::~LayerAnimationElement() { 476 LayerAnimationElement::~LayerAnimationElement() {
475 } 477 }
476 478
477 void LayerAnimationElement::Start(LayerAnimationDelegate* delegate, 479 void LayerAnimationElement::Start(LayerAnimationDelegate* delegate,
478 int animation_group_id) { 480 int animation_group_id) {
479 DCHECK(requested_start_time_ != base::TimeTicks()); 481 DCHECK(requested_start_time_ != base::TimeTicks());
480 DCHECK(first_frame_); 482 DCHECK(first_frame_);
481 animation_group_id_ = animation_group_id; 483 animation_group_id_ = animation_group_id;
482 last_progressed_fraction_ = 0.0; 484 last_progressed_fraction_ = 0.0;
483 OnStart(delegate); 485 OnStart(delegate);
486 start_frame_number_ = delegate->GetFrameNumber();
484 RequestEffectiveStart(delegate); 487 RequestEffectiveStart(delegate);
485 first_frame_ = false; 488 first_frame_ = false;
486 } 489 }
487 490
488 bool LayerAnimationElement::Progress(base::TimeTicks now, 491 bool LayerAnimationElement::Progress(base::TimeTicks now,
489 LayerAnimationDelegate* delegate) { 492 LayerAnimationDelegate* delegate) {
490 DCHECK(requested_start_time_ != base::TimeTicks()); 493 DCHECK(requested_start_time_ != base::TimeTicks());
491 DCHECK(!first_frame_); 494 DCHECK(!first_frame_);
492 495
493 bool need_draw; 496 bool need_draw;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 530
528 base::TimeDelta elapsed = time - requested_start_time_; 531 base::TimeDelta elapsed = time - requested_start_time_;
529 if (elapsed >= duration_ + queueing_delay) { 532 if (elapsed >= duration_ + queueing_delay) {
530 *total_duration = duration_ + queueing_delay; 533 *total_duration = duration_ + queueing_delay;
531 return true; 534 return true;
532 } 535 }
533 return false; 536 return false;
534 } 537 }
535 538
536 bool LayerAnimationElement::ProgressToEnd(LayerAnimationDelegate* delegate) { 539 bool LayerAnimationElement::ProgressToEnd(LayerAnimationDelegate* delegate) {
537 if (first_frame_) 540 if (first_frame_) {
538 OnStart(delegate); 541 OnStart(delegate);
542 start_frame_number_ = delegate->GetFrameNumber();
543 }
539 base::WeakPtr<LayerAnimationElement> alive(weak_ptr_factory_.GetWeakPtr()); 544 base::WeakPtr<LayerAnimationElement> alive(weak_ptr_factory_.GetWeakPtr());
540 bool need_draw = OnProgress(1.0, delegate); 545 bool need_draw = OnProgress(1.0, delegate);
546
547 int end_frame_number = delegate->GetFrameNumber();
548 if (animation_metrics_reporter_ && end_frame_number > start_frame_number_) {
549 int smoothness = 100;
550 if (!duration_.is_zero()) {
551 smoothness = std::min(
552 100, static_cast<int>(
553 100 * ((1000.f * (end_frame_number - start_frame_number_)) /
554 (60.f * duration_.InMillisecondsF()))));
ajuma 2017/01/18 23:02:51 Looking at how this can get called, it seems possi
varkha 2017/01/20 00:16:47 Is something like that too naive? Looking at the w
ajuma 2017/01/20 14:31:58 My only worry is that the statistics might be misl
varkha 2017/01/20 17:07:58 Isn't that exactly what I am doing here?
ajuma 2017/01/20 18:03:05 Currently, this just uses duration_, which might n
555 }
556 animation_metrics_reporter_->Report(smoothness);
557 }
541 if (!alive) 558 if (!alive)
542 return need_draw; 559 return need_draw;
543 last_progressed_fraction_ = 1.0; 560 last_progressed_fraction_ = 1.0;
544 first_frame_ = true; 561 first_frame_ = true;
545 return need_draw; 562 return need_draw;
546 } 563 }
547 564
548 void LayerAnimationElement::GetTargetValue(TargetValue* target) const { 565 void LayerAnimationElement::GetTargetValue(TargetValue* target) const {
549 OnGetTarget(target); 566 OnGetTarget(target);
550 } 567 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 } 674 }
658 675
659 // static 676 // static
660 std::unique_ptr<LayerAnimationElement> 677 std::unique_ptr<LayerAnimationElement>
661 LayerAnimationElement::CreateColorElement(SkColor color, 678 LayerAnimationElement::CreateColorElement(SkColor color,
662 base::TimeDelta duration) { 679 base::TimeDelta duration) {
663 return base::MakeUnique<ColorTransition>(color, duration); 680 return base::MakeUnique<ColorTransition>(color, duration);
664 } 681 }
665 682
666 } // namespace ui 683 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698