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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 947033002: CC Animations: Establish AnimationHost, AnimationTimeline and AnimationPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move MutatorHostClient back to cc/trees/ Created 5 years, 5 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/containers/small_map.h" 14 #include "base/containers/small_map.h"
15 #include "base/json/json_writer.h" 15 #include "base/json/json_writer.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/numerics/safe_conversions.h" 17 #include "base/numerics/safe_conversions.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/trace_event/trace_event_argument.h" 20 #include "base/trace_event/trace_event_argument.h"
21 #include "cc/animation/animation_host.h"
21 #include "cc/animation/animation_id_provider.h" 22 #include "cc/animation/animation_id_provider.h"
22 #include "cc/animation/scroll_offset_animation_curve.h" 23 #include "cc/animation/scroll_offset_animation_curve.h"
23 #include "cc/animation/scrollbar_animation_controller.h" 24 #include "cc/animation/scrollbar_animation_controller.h"
24 #include "cc/animation/timing_function.h" 25 #include "cc/animation/timing_function.h"
25 #include "cc/base/math_util.h" 26 #include "cc/base/math_util.h"
26 #include "cc/debug/benchmark_instrumentation.h" 27 #include "cc/debug/benchmark_instrumentation.h"
27 #include "cc/debug/debug_rect_history.h" 28 #include "cc/debug/debug_rect_history.h"
28 #include "cc/debug/devtools_instrumentation.h" 29 #include "cc/debug/devtools_instrumentation.h"
29 #include "cc/debug/frame_rate_counter.h" 30 #include "cc/debug/frame_rate_counter.h"
30 #include "cc/debug/frame_viewer_instrumentation.h" 31 #include "cc/debug/frame_viewer_instrumentation.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 animation_registrar_(AnimationRegistrar::Create()), 226 animation_registrar_(AnimationRegistrar::Create()),
226 rendering_stats_instrumentation_(rendering_stats_instrumentation), 227 rendering_stats_instrumentation_(rendering_stats_instrumentation),
227 micro_benchmark_controller_(this), 228 micro_benchmark_controller_(this),
228 shared_bitmap_manager_(shared_bitmap_manager), 229 shared_bitmap_manager_(shared_bitmap_manager),
229 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 230 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
230 task_graph_runner_(task_graph_runner), 231 task_graph_runner_(task_graph_runner),
231 id_(id), 232 id_(id),
232 requires_high_res_to_draw_(false), 233 requires_high_res_to_draw_(false),
233 is_likely_to_require_a_draw_(false), 234 is_likely_to_require_a_draw_(false),
234 frame_timing_tracker_(FrameTimingTracker::Create(this)) { 235 frame_timing_tracker_(FrameTimingTracker::Create(this)) {
236 if (settings.use_compositor_animation_timelines) {
237 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL);
238 animation_host_->SetMutatorHostClient(this);
239 }
240
235 DCHECK(proxy_->IsImplThread()); 241 DCHECK(proxy_->IsImplThread());
236 DidVisibilityChange(this, visible_); 242 DidVisibilityChange(this, visible_);
237 animation_registrar_->set_supports_scroll_animations( 243 animation_registrar_->set_supports_scroll_animations(
238 proxy_->SupportsImplScrolling()); 244 proxy_->SupportsImplScrolling());
239 245
240 SetDebugState(settings.initial_debug_state); 246 SetDebugState(settings.initial_debug_state);
241 247
242 // LTHI always has an active tree. 248 // LTHI always has an active tree.
243 active_tree_ = 249 active_tree_ =
244 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), 250 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(),
(...skipping 3257 matching lines...) Expand 10 before | Expand all | Expand 10 after
3502 new_target.SetToMax(gfx::ScrollOffset()); 3508 new_target.SetToMax(gfx::ScrollOffset());
3503 new_target.SetToMin(layer_impl->MaxScrollOffset()); 3509 new_target.SetToMin(layer_impl->MaxScrollOffset());
3504 3510
3505 curve->UpdateTarget( 3511 curve->UpdateTarget(
3506 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) 3512 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time)
3507 .InSecondsF(), 3513 .InSecondsF(),
3508 new_target); 3514 new_target);
3509 3515
3510 return true; 3516 return true;
3511 } 3517 }
3518
3519 bool LayerTreeHostImpl::IsLayerInTree(int layer_id,
3520 LayerTreeType tree_type) const {
3521 if (tree_type == LayerTreeType::ACTIVE) {
3522 return active_tree() ? active_tree()->LayerById(layer_id) != nullptr
3523 : false;
3524 } else {
3525 if (pending_tree() && pending_tree()->LayerById(layer_id))
3526 return true;
3527 if (recycle_tree() && recycle_tree()->LayerById(layer_id))
3528 return true;
3529
3530 return false;
3531 }
3532 }
3533
3534 void LayerTreeHostImpl::SetMutatorsNeedCommit() {
3535 SetNeedsCommit();
3536 }
3537
3538 void LayerTreeHostImpl::SetTreeLayerFilterMutated(
3539 int layer_id,
3540 LayerTreeImpl* tree,
3541 const FilterOperations& filters) {
3542 if (!tree)
3543 return;
3544
3545 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3546 if (layer)
3547 layer->OnFilterAnimated(filters);
3548 }
3549
3550 void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id,
3551 LayerTreeImpl* tree,
3552 float opacity) {
3553 if (!tree)
3554 return;
3555
3556 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3557 if (layer)
3558 layer->OnOpacityAnimated(opacity);
3559 }
3560
3561 void LayerTreeHostImpl::SetTreeLayerTransformMutated(
3562 int layer_id,
3563 LayerTreeImpl* tree,
3564 const gfx::Transform& transform) {
3565 if (!tree)
3566 return;
3567
3568 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3569 if (layer)
3570 layer->OnTransformAnimated(transform);
3571 }
3572
3573 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated(
3574 int layer_id,
3575 LayerTreeImpl* tree,
3576 const gfx::ScrollOffset& scroll_offset) {
3577 if (!tree)
3578 return;
3579
3580 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3581 if (layer)
3582 layer->OnScrollOffsetAnimated(scroll_offset);
3583 }
3584
3585 void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id,
3586 LayerTreeType tree_type,
3587 const FilterOperations& filters) {
3588 if (tree_type == LayerTreeType::ACTIVE) {
3589 SetTreeLayerFilterMutated(layer_id, active_tree(), filters);
3590 } else {
3591 SetTreeLayerFilterMutated(layer_id, pending_tree(), filters);
3592 SetTreeLayerFilterMutated(layer_id, recycle_tree(), filters);
3593 }
3594 }
3595
3596 void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id,
3597 LayerTreeType tree_type,
3598 float opacity) {
3599 if (tree_type == LayerTreeType::ACTIVE) {
3600 SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity);
3601 } else {
3602 SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity);
3603 SetTreeLayerOpacityMutated(layer_id, recycle_tree(), opacity);
3604 }
3605 }
3606
3607 void LayerTreeHostImpl::SetLayerTransformMutated(
3608 int layer_id,
3609 LayerTreeType tree_type,
3610 const gfx::Transform& transform) {
3611 if (tree_type == LayerTreeType::ACTIVE) {
3612 SetTreeLayerTransformMutated(layer_id, active_tree(), transform);
3613 } else {
3614 SetTreeLayerTransformMutated(layer_id, pending_tree(), transform);
3615 SetTreeLayerTransformMutated(layer_id, recycle_tree(), transform);
3616 }
3617 }
3618
3619 void LayerTreeHostImpl::SetLayerScrollOffsetMutated(
3620 int layer_id,
3621 LayerTreeType tree_type,
3622 const gfx::ScrollOffset& scroll_offset) {
3623 if (tree_type == LayerTreeType::ACTIVE) {
3624 SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset);
3625 } else {
3626 SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset);
3627 SetTreeLayerScrollOffsetMutated(layer_id, recycle_tree(), scroll_offset);
3628 }
3629 }
3630
3512 } // namespace cc 3631 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698