Skip to content

Commit

Permalink
CC Animation: Erase LayerTreeSettings::accelerated_animation_enabled …
Browse files Browse the repository at this point in the history
…flag.

We use disable-threaded-animation command line switch for
testing purposes.

Now blink knows ahead of time, whether we support threaded animations.

See
RendererBlinkPlatformImpl::isThreadedAnimationEnabled()

BUG=575041
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1798503004

Cr-Commit-Position: refs/heads/master@{#381192}
  • Loading branch information
loyso authored and Commit bot committed Mar 15, 2016
1 parent 93edc00 commit f0099ca
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ void PopulateCommonLayerTreeSettings(cc::LayerTreeSettings* settings) {
settings->layer_transforms_should_scale_layer_contents = true;

settings->main_frame_before_activation_enabled = false;
settings->accelerated_animation_enabled = true;
settings->default_tile_size = gfx::Size(256, 256);
settings->gpu_rasterization_msaa_sample_count = 0;
settings->gpu_rasterization_forced = false;
Expand Down
109 changes: 35 additions & 74 deletions cc/trees/layer_tree_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,8 @@ LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode)
next_surface_sequence_(1u) {
DCHECK(task_graph_runner_);

if (settings_.accelerated_animation_enabled) {
animation_host_ = AnimationHost::Create(ThreadInstance::MAIN);
animation_host_->SetMutatorHostClient(this);
}
animation_host_ = AnimationHost::Create(ThreadInstance::MAIN);
animation_host_->SetMutatorHostClient(this);

rendering_stats_instrumentation_->set_record_rendering_stats(
debug_state_.RecordRenderingStats());
Expand Down Expand Up @@ -285,17 +283,14 @@ void LayerTreeHost::InitializeProxy(

proxy_ = std::move(proxy);
proxy_->Start(std::move(external_begin_frame_source));
if (settings_.accelerated_animation_enabled) {
animation_host_->SetSupportsScrollAnimations(
proxy_->SupportsImplScrolling());
}

animation_host_->SetSupportsScrollAnimations(proxy_->SupportsImplScrolling());
}

LayerTreeHost::~LayerTreeHost() {
TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");

if (animation_host_)
animation_host_->SetMutatorHostClient(nullptr);
animation_host_->SetMutatorHostClient(nullptr);

if (root_layer_.get())
root_layer_->SetLayerTreeHost(NULL);
Expand Down Expand Up @@ -473,11 +468,9 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer());

if (animation_host_) {
TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties");
DCHECK(host_impl->animation_host());
animation_host_->PushPropertiesTo(host_impl->animation_host());
}
TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties");
DCHECK(host_impl->animation_host());
animation_host_->PushPropertiesTo(host_impl->animation_host());
}

// This must happen after synchronizing property trees and after push
Expand Down Expand Up @@ -1048,11 +1041,8 @@ void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints,
}

void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
if (!settings_.accelerated_animation_enabled)
return;
scoped_ptr<AnimationEvents> events = animation_host_->CreateEvents();

scoped_ptr<AnimationEvents> events;
events = animation_host_->CreateEvents();
if (animation_host_->AnimateLayers(monotonic_time))
animation_host_->UpdateAnimationState(true, events.get());

Expand Down Expand Up @@ -1236,15 +1226,13 @@ void LayerTreeHost::RegisterLayer(Layer* layer) {
DCHECK(!LayerById(layer->id()));
DCHECK(!in_paint_layer_contents_);
layer_id_map_[layer->id()] = layer;
if (animation_host_)
animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE);
animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE);
}

void LayerTreeHost::UnregisterLayer(Layer* layer) {
DCHECK(LayerById(layer->id()));
DCHECK(!in_paint_layer_contents_);
if (animation_host_)
animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE);
animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE);
layer_id_map_.erase(layer->id());
}

Expand Down Expand Up @@ -1311,103 +1299,76 @@ gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation(

bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted(
const Layer* layer) const {
return animation_host_
? animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id())
: false;
return animation_host_->ScrollOffsetAnimationWasInterrupted(layer->id());
}

bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const {
return animation_host_
? animation_host_->IsAnimatingFilterProperty(layer->id(),
LayerTreeType::ACTIVE)
: false;
return animation_host_->IsAnimatingFilterProperty(layer->id(),
LayerTreeType::ACTIVE);
}

bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const {
return animation_host_
? animation_host_->IsAnimatingOpacityProperty(
layer->id(), LayerTreeType::ACTIVE)
: false;
return animation_host_->IsAnimatingOpacityProperty(layer->id(),
LayerTreeType::ACTIVE);
}

bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const {
return animation_host_
? animation_host_->IsAnimatingTransformProperty(
layer->id(), LayerTreeType::ACTIVE)
: false;
return animation_host_->IsAnimatingTransformProperty(layer->id(),
LayerTreeType::ACTIVE);
}

bool LayerTreeHost::HasPotentiallyRunningFilterAnimation(
const Layer* layer) const {
return animation_host_
? animation_host_->HasPotentiallyRunningFilterAnimation(
layer->id(), LayerTreeType::ACTIVE)
: false;
return animation_host_->HasPotentiallyRunningFilterAnimation(
layer->id(), LayerTreeType::ACTIVE);
}

bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation(
const Layer* layer) const {
return animation_host_
? animation_host_->HasPotentiallyRunningOpacityAnimation(
layer->id(), LayerTreeType::ACTIVE)
: false;
return animation_host_->HasPotentiallyRunningOpacityAnimation(
layer->id(), LayerTreeType::ACTIVE);
}

bool LayerTreeHost::HasPotentiallyRunningTransformAnimation(
const Layer* layer) const {
return animation_host_
? animation_host_->HasPotentiallyRunningTransformAnimation(
layer->id(), LayerTreeType::ACTIVE)
: false;
return animation_host_->HasPotentiallyRunningTransformAnimation(
layer->id(), LayerTreeType::ACTIVE);
}

bool LayerTreeHost::HasOnlyTranslationTransforms(const Layer* layer) const {
return animation_host_
? animation_host_->HasOnlyTranslationTransforms(
layer->id(), LayerTreeType::ACTIVE)
: false;
return animation_host_->HasOnlyTranslationTransforms(layer->id(),
LayerTreeType::ACTIVE);
}

bool LayerTreeHost::MaximumTargetScale(const Layer* layer,
float* max_scale) const {
return animation_host_
? animation_host_->MaximumTargetScale(
layer->id(), LayerTreeType::ACTIVE, max_scale)
: false;
return animation_host_->MaximumTargetScale(layer->id(), LayerTreeType::ACTIVE,
max_scale);
}

bool LayerTreeHost::AnimationStartScale(const Layer* layer,
float* start_scale) const {
return animation_host_
? animation_host_->AnimationStartScale(
layer->id(), LayerTreeType::ACTIVE, start_scale)
: false;
return animation_host_->AnimationStartScale(
layer->id(), LayerTreeType::ACTIVE, start_scale);
}

bool LayerTreeHost::HasAnyAnimationTargetingProperty(
const Layer* layer,
TargetProperty::Type property) const {
return animation_host_
? animation_host_->HasAnyAnimationTargetingProperty(layer->id(),
property)
: false;
return animation_host_->HasAnyAnimationTargetingProperty(layer->id(),
property);
}

bool LayerTreeHost::AnimationsPreserveAxisAlignment(const Layer* layer) const {
return animation_host_
? animation_host_->AnimationsPreserveAxisAlignment(layer->id())
: true;
return animation_host_->AnimationsPreserveAxisAlignment(layer->id());
}

bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const {
return animation_host_ ? animation_host_->HasAnyAnimation(layer->id())
: false;
return animation_host_->HasAnyAnimation(layer->id());
}

bool LayerTreeHost::HasActiveAnimationForTesting(const Layer* layer) const {
return animation_host_
? animation_host_->HasActiveAnimationForTesting(layer->id())
: false;
return animation_host_->HasActiveAnimationForTesting(layer->id());
}

bool LayerTreeHost::IsSingleThreaded() const {
Expand Down
37 changes: 9 additions & 28 deletions cc/trees/layer_tree_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ LayerTreeHostImpl::LayerTreeHostImpl(
requires_high_res_to_draw_(false),
is_likely_to_require_a_draw_(false),
frame_timing_tracker_(FrameTimingTracker::Create(this)) {
if (settings.accelerated_animation_enabled) {
animation_host_ = AnimationHost::Create(ThreadInstance::IMPL);
animation_host_->SetMutatorHostClient(this);
animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling());
}
animation_host_ = AnimationHost::Create(ThreadInstance::IMPL);
animation_host_->SetMutatorHostClient(this);
animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling());

DCHECK(task_runner_provider_->IsImplThread());
DidVisibilityChange(this, visible_);
Expand Down Expand Up @@ -289,10 +287,8 @@ LayerTreeHostImpl::~LayerTreeHostImpl() {
pending_tree_ = nullptr;
active_tree_ = nullptr;

if (animation_host_) {
animation_host_->ClearTimelines();
animation_host_->SetMutatorHostClient(nullptr);
}
animation_host_->ClearTimelines();
animation_host_->SetMutatorHostClient(nullptr);

CleanUpTileManagerAndUIResources();
renderer_ = nullptr;
Expand Down Expand Up @@ -3389,12 +3385,7 @@ bool LayerTreeHostImpl::AnimateScrollbars(base::TimeTicks monotonic_time) {
}

bool LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) {
if (!settings_.accelerated_animation_enabled)
return false;

bool animated = false;
if (animation_host_->AnimateLayers(monotonic_time))
animated = true;
const bool animated = animation_host_->AnimateLayers(monotonic_time);

// TODO(crbug.com/551134): Only do this if the animations are on the active
// tree, or if they are on the pending tree waiting for some future time to
Expand All @@ -3411,14 +3402,9 @@ bool LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) {
}

void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
if (!settings_.accelerated_animation_enabled)
return;

bool has_active_animations = false;
scoped_ptr<AnimationEvents> events;
scoped_ptr<AnimationEvents> events = animation_host_->CreateEvents();

events = animation_host_->CreateEvents();
has_active_animations = animation_host_->UpdateAnimationState(
const bool has_active_animations = animation_host_->UpdateAnimationState(
start_ready_animations, events.get());

if (!events->events_.empty())
Expand All @@ -3429,9 +3415,6 @@ void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
}

void LayerTreeHostImpl::ActivateAnimations() {
if (!settings_.accelerated_animation_enabled)
return;

const bool activated = animation_host_->ActivateAnimations();
if (activated) {
// Activating an animation changes layer draw properties, such as
Expand Down Expand Up @@ -3849,9 +3832,7 @@ void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged(

bool LayerTreeHostImpl::AnimationsPreserveAxisAlignment(
const LayerImpl* layer) const {
return animation_host_
? animation_host_->AnimationsPreserveAxisAlignment(layer->id())
: true;
return animation_host_->AnimationsPreserveAxisAlignment(layer->id());
}

void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id,
Expand Down
Loading

0 comments on commit f0099ca

Please sign in to comment.