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

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: Set up impl-only timelines for ScrollOffset animations Created 5 years, 8 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/trace_event/trace_event_argument.h" 17 #include "base/trace_event/trace_event_argument.h"
18 #include "cc/animation/animation_host.h"
18 #include "cc/animation/animation_id_provider.h" 19 #include "cc/animation/animation_id_provider.h"
19 #include "cc/animation/scroll_offset_animation_curve.h" 20 #include "cc/animation/scroll_offset_animation_curve.h"
20 #include "cc/animation/scrollbar_animation_controller.h" 21 #include "cc/animation/scrollbar_animation_controller.h"
21 #include "cc/animation/timing_function.h" 22 #include "cc/animation/timing_function.h"
22 #include "cc/base/math_util.h" 23 #include "cc/base/math_util.h"
23 #include "cc/base/util.h" 24 #include "cc/base/util.h"
24 #include "cc/debug/benchmark_instrumentation.h" 25 #include "cc/debug/benchmark_instrumentation.h"
25 #include "cc/debug/debug_rect_history.h" 26 #include "cc/debug/debug_rect_history.h"
26 #include "cc/debug/devtools_instrumentation.h" 27 #include "cc/debug/devtools_instrumentation.h"
27 #include "cc/debug/frame_rate_counter.h" 28 #include "cc/debug/frame_rate_counter.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 animation_registrar_(AnimationRegistrar::Create()), 223 animation_registrar_(AnimationRegistrar::Create()),
223 rendering_stats_instrumentation_(rendering_stats_instrumentation), 224 rendering_stats_instrumentation_(rendering_stats_instrumentation),
224 micro_benchmark_controller_(this), 225 micro_benchmark_controller_(this),
225 shared_bitmap_manager_(shared_bitmap_manager), 226 shared_bitmap_manager_(shared_bitmap_manager),
226 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 227 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
227 task_graph_runner_(task_graph_runner), 228 task_graph_runner_(task_graph_runner),
228 id_(id), 229 id_(id),
229 requires_high_res_to_draw_(false), 230 requires_high_res_to_draw_(false),
230 is_likely_to_require_a_draw_(false), 231 is_likely_to_require_a_draw_(false),
231 frame_timing_tracker_(FrameTimingTracker::Create()) { 232 frame_timing_tracker_(FrameTimingTracker::Create()) {
233 if (settings.use_compositor_animation_timelines) {
234 animation_host_ = AnimationHost::Create(true);
235 animation_host_->SetLayerTreeMutatorsClient(this);
236 }
237
232 DCHECK(proxy_->IsImplThread()); 238 DCHECK(proxy_->IsImplThread());
233 DidVisibilityChange(this, visible_); 239 DidVisibilityChange(this, visible_);
234 animation_registrar_->set_supports_scroll_animations( 240 animation_registrar_->set_supports_scroll_animations(
235 proxy_->SupportsImplScrolling()); 241 proxy_->SupportsImplScrolling());
236 242
237 SetDebugState(settings.initial_debug_state); 243 SetDebugState(settings.initial_debug_state);
238 244
239 // LTHI always has an active tree. 245 // LTHI always has an active tree.
240 active_tree_ = 246 active_tree_ =
241 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), 247 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(),
(...skipping 3177 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 new_target.SetToMax(gfx::ScrollOffset()); 3425 new_target.SetToMax(gfx::ScrollOffset());
3420 new_target.SetToMin(layer_impl->MaxScrollOffset()); 3426 new_target.SetToMin(layer_impl->MaxScrollOffset());
3421 3427
3422 curve->UpdateTarget( 3428 curve->UpdateTarget(
3423 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) 3429 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time)
3424 .InSecondsF(), 3430 .InSecondsF(),
3425 new_target); 3431 new_target);
3426 3432
3427 return true; 3433 return true;
3428 } 3434 }
3435
3436 bool LayerTreeHostImpl::IsLayerInActiveTree(int layer_id) const {
3437 return active_tree() ? active_tree()->LayerById(layer_id) != nullptr : false;
3438 }
3439
3440 bool LayerTreeHostImpl::IsLayerInPendingTree(int layer_id) const {
3441 if (pending_tree() && pending_tree()->LayerById(layer_id))
3442 return true;
3443 if (recycle_tree() && recycle_tree()->LayerById(layer_id))
3444 return true;
3445
3446 return false;
3447 }
3448
3449 void LayerTreeHostImpl::SetMutatorsNeedCommit() {
3450 SetNeedsCommit();
3451 }
3452
3453 void LayerTreeHostImpl::SetTreeLayerFilterMutated(
3454 int layer_id,
3455 LayerTreeImpl* tree,
3456 const FilterOperations& filters) {
3457 if (!tree)
3458 return;
3459
3460 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3461 if (layer)
3462 layer->OnFilterAnimated(filters);
3463 }
3464
3465 void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id,
3466 LayerTreeImpl* tree,
3467 float opacity) {
3468 if (!tree)
3469 return;
3470
3471 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3472 if (layer)
3473 layer->OnOpacityAnimated(opacity);
3474 }
3475
3476 void LayerTreeHostImpl::SetTreeLayerTransformMutated(
3477 int layer_id,
3478 LayerTreeImpl* tree,
3479 const gfx::Transform& transform) {
3480 if (!tree)
3481 return;
3482
3483 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3484 if (layer)
3485 layer->OnTransformAnimated(transform);
3486 }
3487
3488 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated(
3489 int layer_id,
3490 LayerTreeImpl* tree,
3491 const gfx::ScrollOffset& scroll_offset) {
3492 if (!tree)
3493 return;
3494
3495 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3496 if (layer)
3497 layer->OnScrollOffsetAnimated(scroll_offset);
3498 }
3499
3500 void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id,
3501 bool affects_active_tree,
3502 const FilterOperations& filters) {
3503 if (affects_active_tree) {
3504 SetTreeLayerFilterMutated(layer_id, active_tree(), filters);
3505 } else {
3506 SetTreeLayerFilterMutated(layer_id, pending_tree(), filters);
3507 SetTreeLayerFilterMutated(layer_id, recycle_tree(), filters);
3508 }
3509 }
3510
3511 void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id,
3512 bool affects_active_tree,
3513 float opacity) {
3514 if (affects_active_tree) {
3515 SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity);
3516 } else {
3517 SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity);
3518 SetTreeLayerOpacityMutated(layer_id, recycle_tree(), opacity);
3519 }
3520 }
3521
3522 void LayerTreeHostImpl::SetLayerTransformMutated(
3523 int layer_id,
3524 bool affects_active_tree,
3525 const gfx::Transform& transform) {
3526 if (affects_active_tree) {
3527 SetTreeLayerTransformMutated(layer_id, active_tree(), transform);
3528 } else {
3529 SetTreeLayerTransformMutated(layer_id, pending_tree(), transform);
3530 SetTreeLayerTransformMutated(layer_id, recycle_tree(), transform);
3531 }
3532 }
3533
3534 void LayerTreeHostImpl::SetLayerScrollOffsetMutated(
3535 int layer_id,
3536 bool affects_active_tree,
3537 const gfx::ScrollOffset& scroll_offset) {
3538 if (affects_active_tree) {
3539 SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset);
3540 } else {
3541 SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset);
3542 SetTreeLayerScrollOffsetMutated(layer_id, recycle_tree(), scroll_offset);
3543 }
3544 }
3545
3429 } // namespace cc 3546 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698