| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 active_tree()->elastic_overscroll()); | 2037 active_tree()->elastic_overscroll()); |
| 2038 } | 2038 } |
| 2039 | 2039 |
| 2040 client_->OnCanDrawStateChanged(CanDraw()); | 2040 client_->OnCanDrawStateChanged(CanDraw()); |
| 2041 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 2041 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
| 2042 | 2042 |
| 2043 DCHECK(!pending_tree_duration_timer_); | 2043 DCHECK(!pending_tree_duration_timer_); |
| 2044 pending_tree_duration_timer_.reset(new PendingTreeDurationHistogramTimer()); | 2044 pending_tree_duration_timer_.reset(new PendingTreeDurationHistogramTimer()); |
| 2045 } | 2045 } |
| 2046 | 2046 |
| 2047 void LayerTreeHostImpl::PushScrollbarOpacitiesFromActiveToPending() { |
| 2048 if (!active_tree()) |
| 2049 return; |
| 2050 for (auto& pair : scrollbar_animation_controllers_) { |
| 2051 for (auto* scrollbar : pair.second->Scrollbars()) { |
| 2052 if (const EffectNode* source_effect_node = |
| 2053 active_tree() |
| 2054 ->property_trees() |
| 2055 ->effect_tree.FindNodeFromElementId( |
| 2056 scrollbar->element_id())) { |
| 2057 if (EffectNode* target_effect_node = |
| 2058 pending_tree() |
| 2059 ->property_trees() |
| 2060 ->effect_tree.FindNodeFromElementId( |
| 2061 scrollbar->element_id())) { |
| 2062 DCHECK(target_effect_node); |
| 2063 float source_opacity = source_effect_node->opacity; |
| 2064 float target_opacity = target_effect_node->opacity; |
| 2065 if (source_opacity == target_opacity) |
| 2066 continue; |
| 2067 target_effect_node->opacity = source_opacity; |
| 2068 pending_tree()->property_trees()->effect_tree.set_needs_update(true); |
| 2069 } |
| 2070 } |
| 2071 } |
| 2072 } |
| 2073 } |
| 2074 |
| 2047 void LayerTreeHostImpl::ActivateSyncTree() { | 2075 void LayerTreeHostImpl::ActivateSyncTree() { |
| 2048 if (pending_tree_) { | 2076 if (pending_tree_) { |
| 2049 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 2077 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
| 2050 | 2078 |
| 2051 DCHECK(pending_tree_duration_timer_); | 2079 DCHECK(pending_tree_duration_timer_); |
| 2052 // Reset will call the destructor and log the timer histogram. | 2080 // Reset will call the destructor and log the timer histogram. |
| 2053 pending_tree_duration_timer_.reset(); | 2081 pending_tree_duration_timer_.reset(); |
| 2054 | 2082 |
| 2055 // Process any requests in the UI resource queue. The request queue is | 2083 // Process any requests in the UI resource queue. The request queue is |
| 2056 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place | 2084 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2067 // trees to pending tree property trees or by moving it onto the layers. | 2095 // trees to pending tree property trees or by moving it onto the layers. |
| 2068 if (active_tree_->property_trees()->changed) { | 2096 if (active_tree_->property_trees()->changed) { |
| 2069 if (pending_tree_->property_trees()->sequence_number == | 2097 if (pending_tree_->property_trees()->sequence_number == |
| 2070 active_tree_->property_trees()->sequence_number) | 2098 active_tree_->property_trees()->sequence_number) |
| 2071 active_tree_->property_trees()->PushChangeTrackingTo( | 2099 active_tree_->property_trees()->PushChangeTrackingTo( |
| 2072 pending_tree_->property_trees()); | 2100 pending_tree_->property_trees()); |
| 2073 else | 2101 else |
| 2074 active_tree_->MoveChangeTrackingToLayers(); | 2102 active_tree_->MoveChangeTrackingToLayers(); |
| 2075 } | 2103 } |
| 2076 TreeSynchronizer::PushLayerProperties(pending_tree(), active_tree()); | 2104 TreeSynchronizer::PushLayerProperties(pending_tree(), active_tree()); |
| 2077 active_tree_->property_trees()->PushOpacityIfNeeded( | 2105 |
| 2078 pending_tree_->property_trees()); | 2106 PushScrollbarOpacitiesFromActiveToPending(); |
| 2079 | 2107 |
| 2080 pending_tree_->PushPropertiesTo(active_tree_.get()); | 2108 pending_tree_->PushPropertiesTo(active_tree_.get()); |
| 2081 if (!pending_tree_->LayerListIsEmpty()) | 2109 if (!pending_tree_->LayerListIsEmpty()) |
| 2082 pending_tree_->property_trees()->ResetAllChangeTracking(); | 2110 pending_tree_->property_trees()->ResetAllChangeTracking(); |
| 2083 | 2111 |
| 2084 // Now that we've synced everything from the pending tree to the active | 2112 // Now that we've synced everything from the pending tree to the active |
| 2085 // tree, rename the pending tree the recycle tree so we can reuse it on the | 2113 // tree, rename the pending tree the recycle tree so we can reuse it on the |
| 2086 // next sync. | 2114 // next sync. |
| 2087 DCHECK(!recycle_tree_); | 2115 DCHECK(!recycle_tree_); |
| 2088 pending_tree_.swap(recycle_tree_); | 2116 pending_tree_.swap(recycle_tree_); |
| (...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3686 if (active_tree_->root_layer_for_testing()) { | 3714 if (active_tree_->root_layer_for_testing()) { |
| 3687 std::unique_ptr<base::Value> json( | 3715 std::unique_ptr<base::Value> json( |
| 3688 active_tree_->root_layer_for_testing()->LayerTreeAsJson()); | 3716 active_tree_->root_layer_for_testing()->LayerTreeAsJson()); |
| 3689 base::JSONWriter::WriteWithOptions( | 3717 base::JSONWriter::WriteWithOptions( |
| 3690 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); | 3718 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); |
| 3691 } | 3719 } |
| 3692 return str; | 3720 return str; |
| 3693 } | 3721 } |
| 3694 | 3722 |
| 3695 void LayerTreeHostImpl::RegisterScrollbarAnimationController( | 3723 void LayerTreeHostImpl::RegisterScrollbarAnimationController( |
| 3696 ElementId scroll_element_id) { | 3724 ElementId scroll_element_id, |
| 3725 float scrollbar_opacity) { |
| 3697 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) | 3726 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) |
| 3698 return; | 3727 return; |
| 3699 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) | 3728 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) |
| 3700 return; | 3729 return; |
| 3701 | 3730 |
| 3702 scrollbar_animation_controllers_[scroll_element_id] = | 3731 scrollbar_animation_controllers_[scroll_element_id] = |
| 3703 active_tree_->CreateScrollbarAnimationController(scroll_element_id); | 3732 active_tree_->CreateScrollbarAnimationController(scroll_element_id, |
| 3733 scrollbar_opacity); |
| 3704 } | 3734 } |
| 3705 | 3735 |
| 3706 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( | 3736 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( |
| 3707 ElementId scroll_element_id) { | 3737 ElementId scroll_element_id) { |
| 3708 scrollbar_animation_controllers_.erase(scroll_element_id); | 3738 scrollbar_animation_controllers_.erase(scroll_element_id); |
| 3709 } | 3739 } |
| 3710 | 3740 |
| 3711 ScrollbarAnimationController* | 3741 ScrollbarAnimationController* |
| 3712 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( | 3742 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( |
| 3713 ElementId scroll_element_id) const { | 3743 ElementId scroll_element_id) const { |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4303 | 4333 |
| 4304 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { | 4334 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { |
| 4305 if (!element_id) | 4335 if (!element_id) |
| 4306 return; | 4336 return; |
| 4307 if (ScrollbarAnimationController* animation_controller = | 4337 if (ScrollbarAnimationController* animation_controller = |
| 4308 ScrollbarAnimationControllerForElementId(element_id)) | 4338 ScrollbarAnimationControllerForElementId(element_id)) |
| 4309 animation_controller->DidScrollUpdate(); | 4339 animation_controller->DidScrollUpdate(); |
| 4310 } | 4340 } |
| 4311 | 4341 |
| 4312 } // namespace cc | 4342 } // namespace cc |
| OLD | NEW |