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/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/trace_event/trace_event_argument.h" | 19 #include "base/trace_event/trace_event_argument.h" |
| 20 #include "cc/animation/animation_host.h" |
20 #include "cc/animation/animation_id_provider.h" | 21 #include "cc/animation/animation_id_provider.h" |
21 #include "cc/animation/scroll_offset_animation_curve.h" | 22 #include "cc/animation/scroll_offset_animation_curve.h" |
22 #include "cc/animation/scrollbar_animation_controller.h" | 23 #include "cc/animation/scrollbar_animation_controller.h" |
23 #include "cc/animation/timing_function.h" | 24 #include "cc/animation/timing_function.h" |
24 #include "cc/base/math_util.h" | 25 #include "cc/base/math_util.h" |
25 #include "cc/base/util.h" | 26 #include "cc/base/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" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3365 new_target.SetToMax(gfx::ScrollOffset()); | 3371 new_target.SetToMax(gfx::ScrollOffset()); |
3366 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 3372 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
3367 | 3373 |
3368 curve->UpdateTarget( | 3374 curve->UpdateTarget( |
3369 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | 3375 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) |
3370 .InSecondsF(), | 3376 .InSecondsF(), |
3371 new_target); | 3377 new_target); |
3372 | 3378 |
3373 return true; | 3379 return true; |
3374 } | 3380 } |
| 3381 |
| 3382 bool LayerTreeHostImpl::IsLayerInActiveTree(int layer_id) const { |
| 3383 return active_tree() ? active_tree()->LayerById(layer_id) != nullptr : false; |
| 3384 } |
| 3385 |
| 3386 bool LayerTreeHostImpl::IsLayerInPendingTree(int layer_id) const { |
| 3387 if (pending_tree() && pending_tree()->LayerById(layer_id)) |
| 3388 return true; |
| 3389 if (recycle_tree() && recycle_tree()->LayerById(layer_id)) |
| 3390 return true; |
| 3391 |
| 3392 return false; |
| 3393 } |
| 3394 |
| 3395 void LayerTreeHostImpl::SetMutatorsNeedCommit() { |
| 3396 SetNeedsCommit(); |
| 3397 } |
| 3398 |
| 3399 void LayerTreeHostImpl::SetTreeLayerFilterMutated( |
| 3400 int layer_id, |
| 3401 LayerTreeImpl* tree, |
| 3402 const FilterOperations& filters) { |
| 3403 if (!tree) |
| 3404 return; |
| 3405 |
| 3406 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3407 if (layer) |
| 3408 layer->OnFilterAnimated(filters); |
| 3409 } |
| 3410 |
| 3411 void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id, |
| 3412 LayerTreeImpl* tree, |
| 3413 float opacity) { |
| 3414 if (!tree) |
| 3415 return; |
| 3416 |
| 3417 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3418 if (layer) |
| 3419 layer->OnOpacityAnimated(opacity); |
| 3420 } |
| 3421 |
| 3422 void LayerTreeHostImpl::SetTreeLayerTransformMutated( |
| 3423 int layer_id, |
| 3424 LayerTreeImpl* tree, |
| 3425 const gfx::Transform& transform) { |
| 3426 if (!tree) |
| 3427 return; |
| 3428 |
| 3429 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3430 if (layer) |
| 3431 layer->OnTransformAnimated(transform); |
| 3432 } |
| 3433 |
| 3434 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( |
| 3435 int layer_id, |
| 3436 LayerTreeImpl* tree, |
| 3437 const gfx::ScrollOffset& scroll_offset) { |
| 3438 if (!tree) |
| 3439 return; |
| 3440 |
| 3441 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3442 if (layer) |
| 3443 layer->OnScrollOffsetAnimated(scroll_offset); |
| 3444 } |
| 3445 |
| 3446 void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id, |
| 3447 bool affects_active_tree, |
| 3448 const FilterOperations& filters) { |
| 3449 if (affects_active_tree) { |
| 3450 SetTreeLayerFilterMutated(layer_id, active_tree(), filters); |
| 3451 } else { |
| 3452 SetTreeLayerFilterMutated(layer_id, pending_tree(), filters); |
| 3453 SetTreeLayerFilterMutated(layer_id, recycle_tree(), filters); |
| 3454 } |
| 3455 } |
| 3456 |
| 3457 void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id, |
| 3458 bool affects_active_tree, |
| 3459 float opacity) { |
| 3460 if (affects_active_tree) { |
| 3461 SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity); |
| 3462 } else { |
| 3463 SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity); |
| 3464 SetTreeLayerOpacityMutated(layer_id, recycle_tree(), opacity); |
| 3465 } |
| 3466 } |
| 3467 |
| 3468 void LayerTreeHostImpl::SetLayerTransformMutated( |
| 3469 int layer_id, |
| 3470 bool affects_active_tree, |
| 3471 const gfx::Transform& transform) { |
| 3472 if (affects_active_tree) { |
| 3473 SetTreeLayerTransformMutated(layer_id, active_tree(), transform); |
| 3474 } else { |
| 3475 SetTreeLayerTransformMutated(layer_id, pending_tree(), transform); |
| 3476 SetTreeLayerTransformMutated(layer_id, recycle_tree(), transform); |
| 3477 } |
| 3478 } |
| 3479 |
| 3480 void LayerTreeHostImpl::SetLayerScrollOffsetMutated( |
| 3481 int layer_id, |
| 3482 bool affects_active_tree, |
| 3483 const gfx::ScrollOffset& scroll_offset) { |
| 3484 if (affects_active_tree) { |
| 3485 SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset); |
| 3486 } else { |
| 3487 SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset); |
| 3488 SetTreeLayerScrollOffsetMutated(layer_id, recycle_tree(), scroll_offset); |
| 3489 } |
| 3490 } |
| 3491 |
3375 } // namespace cc | 3492 } // namespace cc |
OLD | NEW |