| 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_impl.h" | 5 #include "cc/trees/layer_tree_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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 property_trees()->is_main_thread = false; | 84 property_trees()->is_main_thread = false; |
| 85 } | 85 } |
| 86 | 86 |
| 87 LayerTreeImpl::~LayerTreeImpl() { | 87 LayerTreeImpl::~LayerTreeImpl() { |
| 88 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS | 88 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS |
| 89 : SwapPromise::ACTIVATION_FAILS); | 89 : SwapPromise::ACTIVATION_FAILS); |
| 90 | 90 |
| 91 // Need to explicitly clear the tree prior to destroying this so that | 91 // Need to explicitly clear the tree prior to destroying this so that |
| 92 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. | 92 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. |
| 93 DCHECK(!root_layer_); | 93 DCHECK(!root_layer_); |
| 94 DCHECK(layers_->empty()); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void LayerTreeImpl::Shutdown() { | 97 void LayerTreeImpl::Shutdown() { |
| 97 DetachLayers(); | 98 DetachLayers(); |
| 98 DCHECK(!root_layer_); | 99 DCHECK(!root_layer_); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void LayerTreeImpl::ReleaseResources() { | 102 void LayerTreeImpl::ReleaseResources() { |
| 102 if (root_layer_) { | 103 if (root_layer_) { |
| 103 LayerTreeHostCommon::CallFunctionForEveryLayer( | 104 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 if (it.represents_contributing_render_surface()) { | 917 if (it.represents_contributing_render_surface()) { |
| 917 // Surfaces aren't used by the tile raster code, so they can have | 918 // Surfaces aren't used by the tile raster code, so they can have |
| 918 // occlusion regardless of replicas. | 919 // occlusion regardless of replicas. |
| 919 Occlusion occlusion = | 920 Occlusion occlusion = |
| 920 occlusion_tracker.GetCurrentOcclusionForContributingSurface( | 921 occlusion_tracker.GetCurrentOcclusionForContributingSurface( |
| 921 it->render_surface()->draw_transform()); | 922 it->render_surface()->draw_transform()); |
| 922 it->render_surface()->set_occlusion_in_content_space(occlusion); | 923 it->render_surface()->set_occlusion_in_content_space(occlusion); |
| 923 // Masks are used to draw the contributing surface, so should have | 924 // Masks are used to draw the contributing surface, so should have |
| 924 // the same occlusion as the surface (nothing inside the surface | 925 // the same occlusion as the surface (nothing inside the surface |
| 925 // occludes them). | 926 // occludes them). |
| 926 if (LayerImpl* mask = it->mask_layer()) { | 927 if (LayerImpl* mask = it->render_surface()->MaskLayer()) { |
| 927 Occlusion mask_occlusion = | 928 Occlusion mask_occlusion = |
| 928 inside_replica | 929 inside_replica |
| 929 ? Occlusion() | 930 ? Occlusion() |
| 930 : occlusion_tracker.GetCurrentOcclusionForContributingSurface( | 931 : occlusion_tracker.GetCurrentOcclusionForContributingSurface( |
| 931 it->render_surface()->draw_transform() * | 932 it->render_surface()->draw_transform() * |
| 932 it->DrawTransform()); | 933 it->DrawTransform()); |
| 933 mask->draw_properties().occlusion_in_content_space = mask_occlusion; | 934 mask->draw_properties().occlusion_in_content_space = mask_occlusion; |
| 934 } | 935 } |
| 935 if (LayerImpl* replica = it->replica_layer()) { | 936 if (LayerImpl* replica_mask = |
| 936 if (LayerImpl* mask = replica->mask_layer()) | 937 it->render_surface()->ReplicaMaskLayer()) { |
| 937 mask->draw_properties().occlusion_in_content_space = Occlusion(); | 938 replica_mask->draw_properties().occlusion_in_content_space = |
| 939 Occlusion(); |
| 938 } | 940 } |
| 939 } | 941 } |
| 940 | 942 |
| 941 occlusion_tracker.LeaveLayer(it); | 943 occlusion_tracker.LeaveLayer(it); |
| 942 } | 944 } |
| 943 | 945 |
| 944 unoccluded_screen_space_region_ = | 946 unoccluded_screen_space_region_ = |
| 945 occlusion_tracker.ComputeVisibleRegionInScreen(this); | 947 occlusion_tracker.ComputeVisibleRegionInScreen(this); |
| 946 } | 948 } |
| 947 | 949 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 gfx::SizeF content_size = root_scroll_layer->BoundsForScrolling(); | 1029 gfx::SizeF content_size = root_scroll_layer->BoundsForScrolling(); |
| 1028 gfx::SizeF viewport_size = | 1030 gfx::SizeF viewport_size = |
| 1029 root_scroll_layer->scroll_clip_layer()->BoundsForScrolling(); | 1031 root_scroll_layer->scroll_clip_layer()->BoundsForScrolling(); |
| 1030 | 1032 |
| 1031 content_size.SetToMax(viewport_size); | 1033 content_size.SetToMax(viewport_size); |
| 1032 return content_size; | 1034 return content_size; |
| 1033 } | 1035 } |
| 1034 | 1036 |
| 1035 LayerImpl* LayerTreeImpl::LayerById(int id) const { | 1037 LayerImpl* LayerTreeImpl::LayerById(int id) const { |
| 1036 LayerImplMap::const_iterator iter = layer_id_map_.find(id); | 1038 LayerImplMap::const_iterator iter = layer_id_map_.find(id); |
| 1037 return iter != layer_id_map_.end() ? iter->second : NULL; | 1039 return iter != layer_id_map_.end() ? iter->second : nullptr; |
| 1038 } | 1040 } |
| 1039 | 1041 |
| 1040 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) { | 1042 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) { |
| 1041 layers_that_should_push_properties_.insert(layer); | 1043 layers_that_should_push_properties_.insert(layer); |
| 1042 } | 1044 } |
| 1043 | 1045 |
| 1044 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) { | 1046 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) { |
| 1045 layers_that_should_push_properties_.erase(layer); | 1047 layers_that_should_push_properties_.erase(layer); |
| 1046 } | 1048 } |
| 1047 | 1049 |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 ->TransformAnimationBoundsForBox(layer->id(), box, bounds); | 2071 ->TransformAnimationBoundsForBox(layer->id(), box, bounds); |
| 2070 } | 2072 } |
| 2071 | 2073 |
| 2072 void LayerTreeImpl::ScrollAnimationAbort(bool needs_completion) { | 2074 void LayerTreeImpl::ScrollAnimationAbort(bool needs_completion) { |
| 2073 layer_tree_host_impl_->animation_host()->ScrollAnimationAbort( | 2075 layer_tree_host_impl_->animation_host()->ScrollAnimationAbort( |
| 2074 needs_completion); | 2076 needs_completion); |
| 2075 } | 2077 } |
| 2076 | 2078 |
| 2077 void LayerTreeImpl::ResetAllChangeTracking() { | 2079 void LayerTreeImpl::ResetAllChangeTracking() { |
| 2078 layers_that_should_push_properties_.clear(); | 2080 layers_that_should_push_properties_.clear(); |
| 2079 for (auto* layer : *this) | 2081 // Iterate over all layers, including masks and replicas. |
| 2082 for (auto& layer : *layers_) |
| 2080 layer->ResetChangeTracking(); | 2083 layer->ResetChangeTracking(); |
| 2081 property_trees_.ResetAllChangeTracking(); | 2084 property_trees_.ResetAllChangeTracking(); |
| 2082 } | 2085 } |
| 2083 | 2086 |
| 2084 } // namespace cc | 2087 } // namespace cc |
| OLD | NEW |