Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 2080223010: cc: Clean up root_layer code in LTI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase++ Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 namespace cc { 48 namespace cc {
49 49
50 LayerTreeImpl::LayerTreeImpl( 50 LayerTreeImpl::LayerTreeImpl(
51 LayerTreeHostImpl* layer_tree_host_impl, 51 LayerTreeHostImpl* layer_tree_host_impl,
52 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, 52 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor,
53 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, 53 scoped_refptr<SyncedTopControls> top_controls_shown_ratio,
54 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) 54 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll)
55 : layer_tree_host_impl_(layer_tree_host_impl), 55 : layer_tree_host_impl_(layer_tree_host_impl),
56 source_frame_number_(-1), 56 source_frame_number_(-1),
57 is_first_frame_after_commit_tracker_(-1), 57 is_first_frame_after_commit_tracker_(-1),
58 root_layer_(nullptr), 58 root_layer_for_testing_(nullptr),
59 hud_layer_(nullptr), 59 hud_layer_(nullptr),
60 background_color_(0), 60 background_color_(0),
61 has_transparent_background_(false), 61 has_transparent_background_(false),
62 last_scrolled_layer_id_(Layer::INVALID_ID), 62 last_scrolled_layer_id_(Layer::INVALID_ID),
63 overscroll_elasticity_layer_id_(Layer::INVALID_ID), 63 overscroll_elasticity_layer_id_(Layer::INVALID_ID),
64 page_scale_layer_id_(Layer::INVALID_ID), 64 page_scale_layer_id_(Layer::INVALID_ID),
65 inner_viewport_scroll_layer_id_(Layer::INVALID_ID), 65 inner_viewport_scroll_layer_id_(Layer::INVALID_ID),
66 outer_viewport_scroll_layer_id_(Layer::INVALID_ID), 66 outer_viewport_scroll_layer_id_(Layer::INVALID_ID),
67 page_scale_factor_(page_scale_factor), 67 page_scale_factor_(page_scale_factor),
68 min_page_scale_factor_(0), 68 min_page_scale_factor_(0),
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 255
256 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { 256 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const {
257 return layer_list_.empty() ? nullptr : layer_list_[0]->render_surface(); 257 return layer_list_.empty() ? nullptr : layer_list_[0]->render_surface();
258 } 258 }
259 259
260 bool LayerTreeImpl::LayerListIsEmpty() const { 260 bool LayerTreeImpl::LayerListIsEmpty() const {
261 return layer_list_.empty(); 261 return layer_list_.empty();
262 } 262 }
263 263
264 void LayerTreeImpl::SetRootLayer(std::unique_ptr<LayerImpl> layer) { 264 void LayerTreeImpl::SetRootLayerForTesting(std::unique_ptr<LayerImpl> layer) {
265 if (root_layer_ && layer.get() != root_layer_) 265 if (root_layer_for_testing_ && layer.get() != root_layer_for_testing_)
266 RemoveLayer(root_layer_->id()); 266 RemoveLayer(root_layer_for_testing_->id());
267 root_layer_ = layer.get(); 267 root_layer_for_testing_ = layer.get();
268 if (layer) 268 if (layer)
269 AddLayer(std::move(layer)); 269 AddLayer(std::move(layer));
270 BuildLayerListForTesting();
270 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); 271 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
271 } 272 }
272 273
273 void LayerTreeImpl::SetRootLayerFromLayerList() { 274 void LayerTreeImpl::SetRootLayerFromLayerListForTesting() {
274 root_layer_ = layer_list_.empty() ? nullptr : layer_list_[0]; 275 root_layer_for_testing_ = layer_list_.empty() ? nullptr : layer_list_[0];
276 }
277
278 void LayerTreeImpl::OnCanDrawStateChangedForTree() {
275 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); 279 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
276 } 280 }
277 281
278 void LayerTreeImpl::AddToLayerList(LayerImpl* layer) { 282 void LayerTreeImpl::AddToLayerList(LayerImpl* layer) {
279 layer_list_.push_back(layer); 283 layer_list_.push_back(layer);
280 } 284 }
281 285
282 void LayerTreeImpl::ClearLayerList() { 286 void LayerTreeImpl::ClearLayerList() {
283 layer_list_.clear(); 287 layer_list_.clear();
284 } 288 }
285 289
286 void LayerTreeImpl::BuildLayerListForTesting() { 290 void LayerTreeImpl::BuildLayerListForTesting() {
287 ClearLayerList(); 291 ClearLayerList();
288 LayerListIterator<LayerImpl> it(root_layer_); 292 LayerListIterator<LayerImpl> it(root_layer_for_testing_);
289 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) { 293 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) {
290 AddToLayerList(*it); 294 AddToLayerList(*it);
291 } 295 }
292 } 296 }
293 297
294 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const { 298 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const {
295 return layer_list_.empty() ? false : layer_list_[0] == layer; 299 return layer_list_.empty() ? false : layer_list_[0] == layer;
296 } 300 }
297 301
298 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { 302 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const {
(...skipping 22 matching lines...) Expand all
321 if (InnerViewportScrollLayer()) 325 if (InnerViewportScrollLayer())
322 offset += InnerViewportScrollLayer()->MaxScrollOffset(); 326 offset += InnerViewportScrollLayer()->MaxScrollOffset();
323 327
324 if (OuterViewportScrollLayer()) 328 if (OuterViewportScrollLayer())
325 offset += OuterViewportScrollLayer()->MaxScrollOffset(); 329 offset += OuterViewportScrollLayer()->MaxScrollOffset();
326 330
327 return offset; 331 return offset;
328 } 332 }
329 333
330 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { 334 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() {
331 root_layer_ = nullptr; 335 root_layer_for_testing_ = nullptr;
332 layer_list_.clear(); 336 layer_list_.clear();
333 render_surface_layer_list_.clear(); 337 render_surface_layer_list_.clear();
334 set_needs_update_draw_properties(); 338 set_needs_update_draw_properties();
335 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_); 339 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_);
336 layers_.reset(new OwnedLayerImplList); 340 layers_.reset(new OwnedLayerImplList);
337 return ret; 341 return ret;
338 } 342 }
339 343
340 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, 344 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer,
341 ClipTree* clip_tree) { 345 ClipTree* clip_tree) {
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 "layers_updated_count", layers_updated_count); 1008 "layers_updated_count", layers_updated_count);
1005 } 1009 }
1006 1010
1007 DCHECK(!needs_update_draw_properties_) 1011 DCHECK(!needs_update_draw_properties_)
1008 << "CalcDrawProperties should not set_needs_update_draw_properties()"; 1012 << "CalcDrawProperties should not set_needs_update_draw_properties()";
1009 return true; 1013 return true;
1010 } 1014 }
1011 1015
1012 void LayerTreeImpl::BuildLayerListAndPropertyTreesForTesting() { 1016 void LayerTreeImpl::BuildLayerListAndPropertyTreesForTesting() {
1013 BuildLayerListForTesting(); 1017 BuildLayerListForTesting();
1014 PropertyTreeBuilder::PreCalculateMetaInformationForTesting(root_layer_); 1018 PropertyTreeBuilder::PreCalculateMetaInformationForTesting(
1019 root_layer_for_testing_);
1015 property_trees_.transform_tree.set_source_to_parent_updates_allowed(true); 1020 property_trees_.transform_tree.set_source_to_parent_updates_allowed(true);
1016 PropertyTreeBuilder::BuildPropertyTrees( 1021 PropertyTreeBuilder::BuildPropertyTrees(
1017 root_layer_, PageScaleLayer(), InnerViewportScrollLayer(), 1022 root_layer_for_testing_, PageScaleLayer(), InnerViewportScrollLayer(),
1018 OuterViewportScrollLayer(), OverscrollElasticityLayer(), 1023 OuterViewportScrollLayer(), OverscrollElasticityLayer(),
1019 elastic_overscroll()->Current(IsActiveTree()), 1024 elastic_overscroll()->Current(IsActiveTree()),
1020 current_page_scale_factor(), device_scale_factor(), 1025 current_page_scale_factor(), device_scale_factor(),
1021 gfx::Rect(DrawViewportSize()), layer_tree_host_impl_->DrawTransform(), 1026 gfx::Rect(DrawViewportSize()), layer_tree_host_impl_->DrawTransform(),
1022 &property_trees_); 1027 &property_trees_);
1023 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false); 1028 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false);
1024 } 1029 }
1025 1030
1026 const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { 1031 const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const {
1027 // If this assert triggers, then the list is dirty. 1032 // If this assert triggers, then the list is dirty.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 } 1096 }
1092 1097
1093 // These manage ownership of the LayerImpl. 1098 // These manage ownership of the LayerImpl.
1094 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) { 1099 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) {
1095 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); 1100 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end());
1096 layers_->push_back(std::move(layer)); 1101 layers_->push_back(std::move(layer));
1097 set_needs_update_draw_properties(); 1102 set_needs_update_draw_properties();
1098 } 1103 }
1099 1104
1100 std::unique_ptr<LayerImpl> LayerTreeImpl::RemoveLayer(int id) { 1105 std::unique_ptr<LayerImpl> LayerTreeImpl::RemoveLayer(int id) {
1101 if (root_layer_ && root_layer_->id() == id)
1102 root_layer_ = nullptr;
1103 for (auto it = layers_->begin(); it != layers_->end(); ++it) { 1106 for (auto it = layers_->begin(); it != layers_->end(); ++it) {
1104 if ((*it) && (*it)->id() != id) 1107 if ((*it) && (*it)->id() != id)
1105 continue; 1108 continue;
1106 std::unique_ptr<LayerImpl> ret = std::move(*it); 1109 std::unique_ptr<LayerImpl> ret = std::move(*it);
1107 set_needs_update_draw_properties(); 1110 set_needs_update_draw_properties();
1108 layers_->erase(it); 1111 layers_->erase(it);
1109 return ret; 1112 return ret;
1110 } 1113 }
1111 return nullptr; 1114 return nullptr;
1112 } 1115 }
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 2090
2088 void LayerTreeImpl::ResetAllChangeTracking() { 2091 void LayerTreeImpl::ResetAllChangeTracking() {
2089 layers_that_should_push_properties_.clear(); 2092 layers_that_should_push_properties_.clear();
2090 // Iterate over all layers, including masks and replicas. 2093 // Iterate over all layers, including masks and replicas.
2091 for (auto& layer : *layers_) 2094 for (auto& layer : *layers_)
2092 layer->ResetChangeTracking(); 2095 layer->ResetChangeTracking();
2093 property_trees_.ResetAllChangeTracking(); 2096 property_trees_.ResetAllChangeTracking();
2094 } 2097 }
2095 2098
2096 } // namespace cc 2099 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698