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 #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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 animation_registrar_(AnimationRegistrar::Create()), | 233 animation_registrar_(AnimationRegistrar::Create()), |
233 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 234 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
234 micro_benchmark_controller_(this), | 235 micro_benchmark_controller_(this), |
235 shared_bitmap_manager_(shared_bitmap_manager), | 236 shared_bitmap_manager_(shared_bitmap_manager), |
236 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 237 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
237 task_graph_runner_(task_graph_runner), | 238 task_graph_runner_(task_graph_runner), |
238 id_(id), | 239 id_(id), |
239 requires_high_res_to_draw_(false), | 240 requires_high_res_to_draw_(false), |
240 is_likely_to_require_a_draw_(false), | 241 is_likely_to_require_a_draw_(false), |
241 frame_timing_tracker_(FrameTimingTracker::Create(this)) { | 242 frame_timing_tracker_(FrameTimingTracker::Create(this)) { |
| 243 if (settings.use_compositor_animation_timelines) { |
| 244 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); |
| 245 animation_host_->SetMutatorHostClient(this); |
| 246 } |
| 247 |
242 DCHECK(proxy_->IsImplThread()); | 248 DCHECK(proxy_->IsImplThread()); |
243 DCHECK_IMPLIES(settings.use_one_copy, !settings.use_zero_copy); | 249 DCHECK_IMPLIES(settings.use_one_copy, !settings.use_zero_copy); |
244 DCHECK_IMPLIES(settings.use_zero_copy, !settings.use_one_copy); | 250 DCHECK_IMPLIES(settings.use_zero_copy, !settings.use_one_copy); |
245 DidVisibilityChange(this, visible_); | 251 DidVisibilityChange(this, visible_); |
246 animation_registrar_->set_supports_scroll_animations( | 252 animation_registrar_->set_supports_scroll_animations( |
247 proxy_->SupportsImplScrolling()); | 253 proxy_->SupportsImplScrolling()); |
248 | 254 |
249 SetDebugState(settings.initial_debug_state); | 255 SetDebugState(settings.initial_debug_state); |
250 | 256 |
251 // LTHI always has an active tree. | 257 // LTHI always has an active tree. |
(...skipping 3182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3434 new_target.SetToMax(gfx::ScrollOffset()); | 3440 new_target.SetToMax(gfx::ScrollOffset()); |
3435 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3441 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3436 | 3442 |
3437 curve->UpdateTarget( | 3443 curve->UpdateTarget( |
3438 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3444 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3439 .InSecondsF(), | 3445 .InSecondsF(), |
3440 new_target); | 3446 new_target); |
3441 | 3447 |
3442 return true; | 3448 return true; |
3443 } | 3449 } |
| 3450 |
| 3451 bool LayerTreeHostImpl::IsLayerInTree(int layer_id, |
| 3452 LayerTreeType tree_type) const { |
| 3453 if (tree_type == LayerTreeType::ACTIVE) { |
| 3454 return active_tree() ? active_tree()->LayerById(layer_id) != nullptr |
| 3455 : false; |
| 3456 } else { |
| 3457 if (pending_tree() && pending_tree()->LayerById(layer_id)) |
| 3458 return true; |
| 3459 if (recycle_tree() && recycle_tree()->LayerById(layer_id)) |
| 3460 return true; |
| 3461 |
| 3462 return false; |
| 3463 } |
| 3464 } |
| 3465 |
| 3466 void LayerTreeHostImpl::SetMutatorsNeedCommit() { |
| 3467 SetNeedsCommit(); |
| 3468 } |
| 3469 |
| 3470 void LayerTreeHostImpl::SetTreeLayerFilterMutated( |
| 3471 int layer_id, |
| 3472 LayerTreeImpl* tree, |
| 3473 const FilterOperations& filters) { |
| 3474 if (!tree) |
| 3475 return; |
| 3476 |
| 3477 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3478 if (layer) |
| 3479 layer->OnFilterAnimated(filters); |
| 3480 } |
| 3481 |
| 3482 void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id, |
| 3483 LayerTreeImpl* tree, |
| 3484 float opacity) { |
| 3485 if (!tree) |
| 3486 return; |
| 3487 |
| 3488 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3489 if (layer) |
| 3490 layer->OnOpacityAnimated(opacity); |
| 3491 } |
| 3492 |
| 3493 void LayerTreeHostImpl::SetTreeLayerTransformMutated( |
| 3494 int layer_id, |
| 3495 LayerTreeImpl* tree, |
| 3496 const gfx::Transform& transform) { |
| 3497 if (!tree) |
| 3498 return; |
| 3499 |
| 3500 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3501 if (layer) |
| 3502 layer->OnTransformAnimated(transform); |
| 3503 } |
| 3504 |
| 3505 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( |
| 3506 int layer_id, |
| 3507 LayerTreeImpl* tree, |
| 3508 const gfx::ScrollOffset& scroll_offset) { |
| 3509 if (!tree) |
| 3510 return; |
| 3511 |
| 3512 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3513 if (layer) |
| 3514 layer->OnScrollOffsetAnimated(scroll_offset); |
| 3515 } |
| 3516 |
| 3517 void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id, |
| 3518 LayerTreeType tree_type, |
| 3519 const FilterOperations& filters) { |
| 3520 if (tree_type == LayerTreeType::ACTIVE) { |
| 3521 SetTreeLayerFilterMutated(layer_id, active_tree(), filters); |
| 3522 } else { |
| 3523 SetTreeLayerFilterMutated(layer_id, pending_tree(), filters); |
| 3524 SetTreeLayerFilterMutated(layer_id, recycle_tree(), filters); |
| 3525 } |
| 3526 } |
| 3527 |
| 3528 void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id, |
| 3529 LayerTreeType tree_type, |
| 3530 float opacity) { |
| 3531 if (tree_type == LayerTreeType::ACTIVE) { |
| 3532 SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity); |
| 3533 } else { |
| 3534 SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity); |
| 3535 SetTreeLayerOpacityMutated(layer_id, recycle_tree(), opacity); |
| 3536 } |
| 3537 } |
| 3538 |
| 3539 void LayerTreeHostImpl::SetLayerTransformMutated( |
| 3540 int layer_id, |
| 3541 LayerTreeType tree_type, |
| 3542 const gfx::Transform& transform) { |
| 3543 if (tree_type == LayerTreeType::ACTIVE) { |
| 3544 SetTreeLayerTransformMutated(layer_id, active_tree(), transform); |
| 3545 } else { |
| 3546 SetTreeLayerTransformMutated(layer_id, pending_tree(), transform); |
| 3547 SetTreeLayerTransformMutated(layer_id, recycle_tree(), transform); |
| 3548 } |
| 3549 } |
| 3550 |
| 3551 void LayerTreeHostImpl::SetLayerScrollOffsetMutated( |
| 3552 int layer_id, |
| 3553 LayerTreeType tree_type, |
| 3554 const gfx::ScrollOffset& scroll_offset) { |
| 3555 if (tree_type == LayerTreeType::ACTIVE) { |
| 3556 SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset); |
| 3557 } else { |
| 3558 SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset); |
| 3559 SetTreeLayerScrollOffsetMutated(layer_id, recycle_tree(), scroll_offset); |
| 3560 } |
| 3561 } |
| 3562 |
3444 } // namespace cc | 3563 } // namespace cc |
OLD | NEW |