Commit 9e32c196 authored by wutao's avatar wutao Committed by Commit Bot

cros: Use transform animation for Launcher state transition.

Currently Launcher state transition animation is using layer animation
element of BoundsElement, which will SetBoundsFromAnimation on each
OnProgress. This will generate additional overhead with a whole commit
every frame. This cl converts it to use ThreadedTransformTransition,
which will let compositor optimize and accelerate the animation.

Bug:786209
Test:On Cyan and EVE
Average Smoothness Improved:
Cyan:
1x slow-down-compositing-scale-factor: 88% -> 100%
10x slow-down-compositing-scale-factor: 63% -> 73%

1x slow-down-compositing-scale-factor: 93% -> 99%
5x slow-down-compositing-scale-factor: 46% -> 59%

EVE: 
Change-Id: I960421d89762ff7fcb7c4e230d98137cd3e61170
Reviewed-on: https://chromium-review.googlesource.com/776195
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517525}
parent 1d26ab1e
......@@ -1249,6 +1249,7 @@ void AppListView::StartAnimationForState(AppListViewState target_state) {
}
gfx::Rect target_bounds = fullscreen_widget_->GetNativeView()->bounds();
const int original_state_y = target_bounds.origin().y();
target_bounds.set_y(target_state_y);
int animation_duration;
......@@ -1264,21 +1265,26 @@ void AppListView::StartAnimationForState(AppListViewState target_state) {
animation_duration = kAppListAnimationDurationMs;
}
std::unique_ptr<ui::LayerAnimationElement> bounds_animation_element =
ui::LayerAnimationElement::CreateBoundsElement(
target_bounds, base::TimeDelta::FromMilliseconds(animation_duration));
bounds_animation_element->set_tween_type(gfx::Tween::EASE_OUT);
ui::LayerAnimator* animator = fullscreen_widget_->GetLayer()->GetAnimator();
animator->set_preemption_strategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
animator->StopAnimating();
ui::LayerAnimationSequence* animation_sequence =
new ui::LayerAnimationSequence(std::move(bounds_animation_element));
animation_sequence->SetAnimationMetricsReporter(
state_animation_metrics_reporter_.get());
animator->ScheduleAnimation(animation_sequence);
ui::Layer* layer = fullscreen_widget_->GetLayer();
layer->SetBounds(target_bounds);
gfx::Transform transform;
transform.Translate(0, original_state_y - target_state_y);
layer->SetTransform(transform);
{
ui::LayerAnimator* animator = layer->GetAnimator();
animator->StopAnimating();
ui::ScopedLayerAnimationSettings settings(animator);
settings.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(animation_duration));
settings.SetTweenType(gfx::Tween::EASE_OUT);
settings.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
settings.SetAnimationMetricsReporter(
state_animation_metrics_reporter_.get());
layer->SetTransform(gfx::Transform());
}
}
void AppListView::StartCloseAnimation(base::TimeDelta animation_duration) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment