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 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/trace_event/trace_event_argument.h" | 16 #include "base/trace_event/trace_event_argument.h" |
17 #include "cc/animation/animation_id_provider.h" | 17 #include "cc/animation/animation_id_provider.h" |
| 18 #include "cc/animation/animation_timeline.h" |
18 #include "cc/animation/scroll_offset_animation_curve.h" | 19 #include "cc/animation/scroll_offset_animation_curve.h" |
19 #include "cc/animation/scrollbar_animation_controller.h" | 20 #include "cc/animation/scrollbar_animation_controller.h" |
20 #include "cc/animation/timing_function.h" | 21 #include "cc/animation/timing_function.h" |
21 #include "cc/base/latency_info_swap_promise_monitor.h" | 22 #include "cc/base/latency_info_swap_promise_monitor.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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 | 920 |
920 void LayerTreeHostImpl::DidAnimateScrollOffset() { | 921 void LayerTreeHostImpl::DidAnimateScrollOffset() { |
921 client_->SetNeedsCommitOnImplThread(); | 922 client_->SetNeedsCommitOnImplThread(); |
922 client_->RenewTreePriority(); | 923 client_->RenewTreePriority(); |
923 } | 924 } |
924 | 925 |
925 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { | 926 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { |
926 viewport_damage_rect_.Union(damage_rect); | 927 viewport_damage_rect_.Union(damage_rect); |
927 } | 928 } |
928 | 929 |
| 930 void LayerTreeHostImpl::SetAnimationTimeline( |
| 931 scoped_refptr<AnimationTimeline> timeline) { |
| 932 if (animation_timeline_.get() == timeline.get()) |
| 933 return; |
| 934 |
| 935 if (animation_timeline_.get()) |
| 936 animation_timeline_->SetLayerTreeMutatorsClient(nullptr); |
| 937 animation_timeline_ = timeline; |
| 938 if (animation_timeline_.get()) |
| 939 animation_timeline_->SetLayerTreeMutatorsClient(this); |
| 940 } |
| 941 |
929 static inline RenderPass* FindRenderPassById( | 942 static inline RenderPass* FindRenderPassById( |
930 RenderPassId render_pass_id, | 943 RenderPassId render_pass_id, |
931 const LayerTreeHostImpl::FrameData& frame) { | 944 const LayerTreeHostImpl::FrameData& frame) { |
932 RenderPassIdHashMap::const_iterator it = | 945 RenderPassIdHashMap::const_iterator it = |
933 frame.render_passes_by_id.find(render_pass_id); | 946 frame.render_passes_by_id.find(render_pass_id); |
934 return it != frame.render_passes_by_id.end() ? it->second : NULL; | 947 return it != frame.render_passes_by_id.end() ? it->second : NULL; |
935 } | 948 } |
936 | 949 |
937 static void RemoveRenderPassesRecursive(RenderPassId remove_render_pass_id, | 950 static void RemoveRenderPassesRecursive(RenderPassId remove_render_pass_id, |
938 LayerTreeHostImpl::FrameData* frame) { | 951 LayerTreeHostImpl::FrameData* frame) { |
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3473 for (; it != swap_promise_monitor_.end(); it++) | 3486 for (; it != swap_promise_monitor_.end(); it++) |
3474 (*it)->OnSetNeedsRedrawOnImpl(); | 3487 (*it)->OnSetNeedsRedrawOnImpl(); |
3475 } | 3488 } |
3476 | 3489 |
3477 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { | 3490 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
3478 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3491 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3479 for (; it != swap_promise_monitor_.end(); it++) | 3492 for (; it != swap_promise_monitor_.end(); it++) |
3480 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); | 3493 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
3481 } | 3494 } |
3482 | 3495 |
| 3496 AnimationRegistrar* LayerTreeHostImpl::GetAnimationRegistrar() const { |
| 3497 return animation_registrar_.get(); |
| 3498 } |
| 3499 |
| 3500 void LayerTreeHostImpl::SetMutatorsNeedCommit() { |
| 3501 SetNeedsCommit(); |
| 3502 } |
| 3503 |
| 3504 void LayerTreeHostImpl::SetTreeLayerFilterMutated( |
| 3505 int layer_id, |
| 3506 LayerTreeImpl* tree, |
| 3507 const FilterOperations& filters) { |
| 3508 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3509 if (layer) |
| 3510 layer->OnFilterAnimated(filters); |
| 3511 } |
| 3512 |
| 3513 void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id, |
| 3514 LayerTreeImpl* tree, |
| 3515 float opacity) { |
| 3516 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3517 if (layer) |
| 3518 layer->OnOpacityAnimated(opacity); |
| 3519 } |
| 3520 |
| 3521 void LayerTreeHostImpl::SetTreeLayerTransformMutated( |
| 3522 int layer_id, |
| 3523 LayerTreeImpl* tree, |
| 3524 const gfx::Transform& transform) { |
| 3525 if (!tree) |
| 3526 return; |
| 3527 |
| 3528 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); |
| 3529 if (layer) |
| 3530 layer->OnTransformAnimated(transform); |
| 3531 } |
| 3532 |
| 3533 void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id, |
| 3534 bool affects_active_tree, |
| 3535 const FilterOperations& filters) { |
| 3536 if (affects_active_tree) { |
| 3537 SetTreeLayerFilterMutated(layer_id, active_tree(), filters); |
| 3538 } else { |
| 3539 SetTreeLayerFilterMutated(layer_id, pending_tree(), filters); |
| 3540 SetTreeLayerFilterMutated(layer_id, recycle_tree(), filters); |
| 3541 } |
| 3542 } |
| 3543 |
| 3544 void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id, |
| 3545 bool affects_active_tree, |
| 3546 float opacity) { |
| 3547 if (affects_active_tree) { |
| 3548 SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity); |
| 3549 } else { |
| 3550 SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity); |
| 3551 SetTreeLayerOpacityMutated(layer_id, recycle_tree(), opacity); |
| 3552 } |
| 3553 } |
| 3554 |
| 3555 void LayerTreeHostImpl::SetLayerTransformMutated( |
| 3556 int layer_id, |
| 3557 bool affects_active_tree, |
| 3558 const gfx::Transform& transform) { |
| 3559 if (affects_active_tree) { |
| 3560 SetTreeLayerTransformMutated(layer_id, active_tree(), transform); |
| 3561 } else { |
| 3562 SetTreeLayerTransformMutated(layer_id, pending_tree(), transform); |
| 3563 SetTreeLayerTransformMutated(layer_id, recycle_tree(), transform); |
| 3564 } |
| 3565 } |
| 3566 |
3483 } // namespace cc | 3567 } // namespace cc |
OLD | NEW |