Chromium Code Reviews| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 | 1028 |
| 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 { |
| 1038 if (id == Layer::INVALID_ID) | |
| 1039 return nullptr; | |
|
jaydasika
2016/06/14 06:12:06
Is this required ? If we had invalid id, we would
ajuma
2016/06/14 12:45:26
Removed.
| |
| 1036 LayerImplMap::const_iterator iter = layer_id_map_.find(id); | 1040 LayerImplMap::const_iterator iter = layer_id_map_.find(id); |
| 1037 return iter != layer_id_map_.end() ? iter->second : NULL; | 1041 return iter != layer_id_map_.end() ? iter->second : nullptr; |
| 1038 } | 1042 } |
| 1039 | 1043 |
| 1040 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) { | 1044 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) { |
| 1041 layers_that_should_push_properties_.insert(layer); | 1045 layers_that_should_push_properties_.insert(layer); |
| 1042 } | 1046 } |
| 1043 | 1047 |
| 1044 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) { | 1048 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) { |
| 1045 layers_that_should_push_properties_.erase(layer); | 1049 layers_that_should_push_properties_.erase(layer); |
| 1046 } | 1050 } |
| 1047 | 1051 |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2069 ->TransformAnimationBoundsForBox(layer->id(), box, bounds); | 2073 ->TransformAnimationBoundsForBox(layer->id(), box, bounds); |
| 2070 } | 2074 } |
| 2071 | 2075 |
| 2072 void LayerTreeImpl::ScrollAnimationAbort(bool needs_completion) { | 2076 void LayerTreeImpl::ScrollAnimationAbort(bool needs_completion) { |
| 2073 layer_tree_host_impl_->animation_host()->ScrollAnimationAbort( | 2077 layer_tree_host_impl_->animation_host()->ScrollAnimationAbort( |
| 2074 needs_completion); | 2078 needs_completion); |
| 2075 } | 2079 } |
| 2076 | 2080 |
| 2077 void LayerTreeImpl::ResetAllChangeTracking() { | 2081 void LayerTreeImpl::ResetAllChangeTracking() { |
| 2078 layers_that_should_push_properties_.clear(); | 2082 layers_that_should_push_properties_.clear(); |
| 2079 for (auto* layer : *this) | 2083 // Iterate over all layers, including masks and replicas. |
| 2084 for (auto& layer : *layers_) | |
| 2080 layer->ResetChangeTracking(); | 2085 layer->ResetChangeTracking(); |
| 2081 property_trees_.ResetAllChangeTracking(); | 2086 property_trees_.ResetAllChangeTracking(); |
| 2082 } | 2087 } |
| 2083 | 2088 |
| 2084 } // namespace cc | 2089 } // namespace cc |
| OLD | NEW |