OLD | NEW |
---|---|
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 animation_registrar_(AnimationRegistrar::Create()), | 221 animation_registrar_(AnimationRegistrar::Create()), |
221 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 222 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
222 micro_benchmark_controller_(this), | 223 micro_benchmark_controller_(this), |
223 shared_bitmap_manager_(shared_bitmap_manager), | 224 shared_bitmap_manager_(shared_bitmap_manager), |
224 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 225 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
225 task_graph_runner_(task_graph_runner), | 226 task_graph_runner_(task_graph_runner), |
226 id_(id), | 227 id_(id), |
227 requires_high_res_to_draw_(false), | 228 requires_high_res_to_draw_(false), |
228 is_likely_to_require_a_draw_(false), | 229 is_likely_to_require_a_draw_(false), |
229 frame_timing_tracker_(FrameTimingTracker::Create()) { | 230 frame_timing_tracker_(FrameTimingTracker::Create()) { |
231 if (settings.use_compositor_animation_timelines) { | |
232 animation_host_ = AnimationHost::Create(true); | |
233 animation_host_->SetLayerTreeMutatorsClient(this); | |
234 } | |
235 | |
230 DCHECK(proxy_->IsImplThread()); | 236 DCHECK(proxy_->IsImplThread()); |
231 DidVisibilityChange(this, visible_); | 237 DidVisibilityChange(this, visible_); |
232 animation_registrar_->set_supports_scroll_animations( | 238 animation_registrar_->set_supports_scroll_animations( |
233 proxy_->SupportsImplScrolling()); | 239 proxy_->SupportsImplScrolling()); |
234 | 240 |
235 SetDebugState(settings.initial_debug_state); | 241 SetDebugState(settings.initial_debug_state); |
236 | 242 |
237 // LTHI always has an active tree. | 243 // LTHI always has an active tree. |
238 active_tree_ = | 244 active_tree_ = |
239 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), | 245 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), |
(...skipping 3131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3371 new_target.SetToMax(gfx::ScrollOffset()); | 3377 new_target.SetToMax(gfx::ScrollOffset()); |
3372 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3378 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3373 | 3379 |
3374 curve->UpdateTarget( | 3380 curve->UpdateTarget( |
3375 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3381 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3376 .InSecondsF(), | 3382 .InSecondsF(), |
3377 new_target); | 3383 new_target); |
3378 | 3384 |
3379 return true; | 3385 return true; |
3380 } | 3386 } |
3387 | |
3388 bool LayerTreeHostImpl::IsLayerInActiveTree(int layer_id) const { | |
3389 return active_tree() ? active_tree()->LayerById(layer_id) != nullptr : false; | |
3390 } | |
3391 | |
3392 bool LayerTreeHostImpl::IsLayerInPendingTree(int layer_id) const { | |
3393 if (pending_tree() && pending_tree()->LayerById(layer_id)) | |
3394 return true; | |
3395 if (recycle_tree() && recycle_tree()->LayerById(layer_id)) | |
3396 return true; | |
3397 | |
3398 return false; | |
3399 } | |
3400 | |
3401 void LayerTreeHostImpl::SetMutatorsNeedCommit() { | |
3402 SetNeedsCommit(); | |
3403 } | |
3404 | |
3405 void LayerTreeHostImpl::SetTreeLayerFilterMutated( | |
3406 int layer_id, | |
3407 LayerTreeImpl* tree, | |
3408 const FilterOperations& filters) { | |
3409 if (!tree) | |
3410 return; | |
3411 | |
3412 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); | |
3413 if (layer) | |
3414 layer->OnFilterAnimated(filters); | |
3415 } | |
3416 | |
3417 void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id, | |
3418 LayerTreeImpl* tree, | |
3419 float opacity) { | |
3420 if (!tree) | |
3421 return; | |
3422 | |
3423 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); | |
3424 if (layer) | |
3425 layer->OnOpacityAnimated(opacity); | |
3426 } | |
3427 | |
3428 void LayerTreeHostImpl::SetTreeLayerTransformMutated( | |
3429 int layer_id, | |
3430 LayerTreeImpl* tree, | |
3431 const gfx::Transform& transform) { | |
3432 if (!tree) | |
3433 return; | |
3434 | |
3435 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); | |
3436 if (layer) | |
3437 layer->OnTransformAnimated(transform); | |
3438 } | |
3439 | |
3440 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( | |
3441 int layer_id, | |
3442 LayerTreeImpl* tree, | |
3443 const gfx::ScrollOffset& scroll_offset) { | |
3444 if (!tree) | |
3445 return; | |
3446 | |
3447 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); | |
3448 if (layer) | |
3449 layer->OnScrollOffsetAnimated(scroll_offset); | |
3450 } | |
3451 | |
3452 void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id, | |
3453 bool affects_active_tree, | |
3454 const FilterOperations& filters) { | |
3455 if (affects_active_tree) { | |
3456 SetTreeLayerFilterMutated(layer_id, active_tree(), filters); | |
3457 } else { | |
3458 SetTreeLayerFilterMutated(layer_id, pending_tree(), filters); | |
3459 SetTreeLayerFilterMutated(layer_id, recycle_tree(), filters); | |
3460 } | |
3461 } | |
3462 | |
3463 void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id, | |
3464 bool affects_active_tree, | |
3465 float opacity) { | |
3466 if (affects_active_tree) { | |
ajuma
2015/04/22 15:47:18
This logic doesn't seem to handle the case where a
loyso (OOO)
2015/04/30 06:40:21
Each cc::AnimationPlayer has up to two AnimationPl
ajuma
2015/04/30 13:17:53
Ah, ok, that makes sense. But I'm not seeing how t
loyso (OOO)
2015/05/01 00:46:55
No worries. That's a key detail.
AnimationPlayer r
ajuma
2015/05/01 14:45:40
Thanks for the explanation. Just to make sure I un
| |
3467 SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity); | |
3468 } else { | |
3469 SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity); | |
3470 SetTreeLayerOpacityMutated(layer_id, recycle_tree(), opacity); | |
3471 } | |
3472 } | |
3473 | |
3474 void LayerTreeHostImpl::SetLayerTransformMutated( | |
3475 int layer_id, | |
3476 bool affects_active_tree, | |
3477 const gfx::Transform& transform) { | |
3478 if (affects_active_tree) { | |
3479 SetTreeLayerTransformMutated(layer_id, active_tree(), transform); | |
3480 } else { | |
3481 SetTreeLayerTransformMutated(layer_id, pending_tree(), transform); | |
3482 SetTreeLayerTransformMutated(layer_id, recycle_tree(), transform); | |
3483 } | |
3484 } | |
3485 | |
3486 void LayerTreeHostImpl::SetLayerScrollOffsetMutated( | |
3487 int layer_id, | |
3488 bool affects_active_tree, | |
3489 const gfx::ScrollOffset& scroll_offset) { | |
3490 if (affects_active_tree) { | |
3491 SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset); | |
3492 } else { | |
3493 SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset); | |
3494 SetTreeLayerScrollOffsetMutated(layer_id, recycle_tree(), scroll_offset); | |
3495 } | |
3496 } | |
3497 | |
3381 } // namespace cc | 3498 } // namespace cc |
OLD | NEW |