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

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

Issue 2905533002: cc : Store surface layer ids on LayerTreeHost and push them at commit (Closed)
Patch Set: initialize Created 3 years, 7 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') | no next file » | 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 min_page_scale_factor_(0), 83 min_page_scale_factor_(0),
84 max_page_scale_factor_(0), 84 max_page_scale_factor_(0),
85 device_scale_factor_(1.f), 85 device_scale_factor_(1.f),
86 painted_device_scale_factor_(1.f), 86 painted_device_scale_factor_(1.f),
87 content_source_id_(0), 87 content_source_id_(0),
88 elastic_overscroll_(elastic_overscroll), 88 elastic_overscroll_(elastic_overscroll),
89 layers_(new OwnedLayerImplList), 89 layers_(new OwnedLayerImplList),
90 viewport_size_invalid_(false), 90 viewport_size_invalid_(false),
91 needs_update_draw_properties_(true), 91 needs_update_draw_properties_(true),
92 needs_full_tree_sync_(true), 92 needs_full_tree_sync_(true),
93 needs_surface_ids_sync_(false),
93 next_activation_forces_redraw_(false), 94 next_activation_forces_redraw_(false),
94 has_ever_been_drawn_(false), 95 has_ever_been_drawn_(false),
95 handle_visibility_changed_(false), 96 handle_visibility_changed_(false),
96 have_scroll_event_handlers_(false), 97 have_scroll_event_handlers_(false),
97 event_listener_properties_(), 98 event_listener_properties_(),
98 browser_controls_shrink_blink_size_(false), 99 browser_controls_shrink_blink_size_(false),
99 top_controls_height_(0), 100 top_controls_height_(0),
100 bottom_controls_height_(0), 101 bottom_controls_height_(0),
101 top_controls_shown_ratio_(top_controls_shown_ratio) { 102 top_controls_shown_ratio_(top_controls_shown_ratio) {
102 property_trees()->is_main_thread = false; 103 property_trees()->is_main_thread = false;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 target_tree->SetPropertyTrees(&property_trees_); 415 target_tree->SetPropertyTrees(&property_trees_);
415 416
416 ScrollNode* scrolling_node = nullptr; 417 ScrollNode* scrolling_node = nullptr;
417 if (scrolling_element_id) { 418 if (scrolling_element_id) {
418 auto& scroll_tree = target_tree->property_trees()->scroll_tree; 419 auto& scroll_tree = target_tree->property_trees()->scroll_tree;
419 scrolling_node = scroll_tree.FindNodeFromElementId(scrolling_element_id); 420 scrolling_node = scroll_tree.FindNodeFromElementId(scrolling_element_id);
420 } 421 }
421 target_tree->SetCurrentlyScrollingNode(scrolling_node); 422 target_tree->SetCurrentlyScrollingNode(scrolling_node);
422 } 423 }
423 424
425 void LayerTreeImpl::PushSurfaceIdsTo(LayerTreeImpl* target_tree) {
426 if (needs_surface_ids_sync()) {
427 target_tree->ClearSurfaceLayerIds();
428 target_tree->SetSurfaceLayerIds(SurfaceLayerIds());
429 // Reset for next update
430 set_needs_surface_ids_sync(false);
431 }
432 }
433
424 void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { 434 void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) {
425 // The request queue should have been processed and does not require a push. 435 // The request queue should have been processed and does not require a push.
426 DCHECK_EQ(ui_resource_request_queue_.size(), 0u); 436 DCHECK_EQ(ui_resource_request_queue_.size(), 0u);
427 437
438 PushSurfaceIdsTo(target_tree);
428 target_tree->property_trees()->scroll_tree.PushScrollUpdatesFromPendingTree( 439 target_tree->property_trees()->scroll_tree.PushScrollUpdatesFromPendingTree(
429 &property_trees_, target_tree); 440 &property_trees_, target_tree);
430 441
431 if (next_activation_forces_redraw_) { 442 if (next_activation_forces_redraw_) {
432 target_tree->ForceRedrawNextActivation(); 443 target_tree->ForceRedrawNextActivation();
433 next_activation_forces_redraw_ = false; 444 next_activation_forces_redraw_ = false;
434 } 445 }
435 446
436 target_tree->PassSwapPromises(std::move(swap_promise_list_)); 447 target_tree->PassSwapPromises(std::move(swap_promise_list_));
437 swap_promise_list_.clear(); 448 swap_promise_list_.clear();
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 gfx::SizeF content_size = root_scroll_layer->BoundsForScrolling(); 1222 gfx::SizeF content_size = root_scroll_layer->BoundsForScrolling();
1212 content_size.SetToMax(root_container_layer->BoundsForScrolling()); 1223 content_size.SetToMax(root_container_layer->BoundsForScrolling());
1213 return content_size; 1224 return content_size;
1214 } 1225 }
1215 1226
1216 LayerImpl* LayerTreeImpl::LayerById(int id) const { 1227 LayerImpl* LayerTreeImpl::LayerById(int id) const {
1217 LayerImplMap::const_iterator iter = layer_id_map_.find(id); 1228 LayerImplMap::const_iterator iter = layer_id_map_.find(id);
1218 return iter != layer_id_map_.end() ? iter->second : nullptr; 1229 return iter != layer_id_map_.end() ? iter->second : nullptr;
1219 } 1230 }
1220 1231
1232 void LayerTreeImpl::SetSurfaceLayerIds(
1233 const base::flat_set<SurfaceId>& surface_layer_ids) {
1234 DCHECK(surface_layer_ids_.empty());
1235 surface_layer_ids_ = surface_layer_ids;
1236 needs_surface_ids_sync_ = true;
1237 }
1238
1239 const base::flat_set<SurfaceId>& LayerTreeImpl::SurfaceLayerIds() const {
1240 return surface_layer_ids_;
1241 }
1242
1243 void LayerTreeImpl::ClearSurfaceLayerIds() {
1244 surface_layer_ids_.clear();
1245 needs_surface_ids_sync_ = true;
1246 }
1247
1221 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) { 1248 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) {
1222 layers_that_should_push_properties_.insert(layer); 1249 layers_that_should_push_properties_.insert(layer);
1223 } 1250 }
1224 1251
1225 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) { 1252 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) {
1226 layers_that_should_push_properties_.erase(layer); 1253 layers_that_should_push_properties_.erase(layer);
1227 } 1254 }
1228 1255
1229 std::unordered_set<LayerImpl*>& 1256 std::unordered_set<LayerImpl*>&
1230 LayerTreeImpl::LayersThatShouldPushProperties() { 1257 LayerTreeImpl::LayersThatShouldPushProperties() {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 layer->set_needs_show_scrollbars(true); 1757 layer->set_needs_show_scrollbars(true);
1731 } 1758 }
1732 1759
1733 void LayerTreeImpl::UnregisterScrollLayer(LayerImpl* layer) { 1760 void LayerTreeImpl::UnregisterScrollLayer(LayerImpl* layer) {
1734 if (layer->scroll_clip_layer_id() == Layer::INVALID_ID) 1761 if (layer->scroll_clip_layer_id() == Layer::INVALID_ID)
1735 return; 1762 return;
1736 1763
1737 clip_scroll_map_.erase(layer->scroll_clip_layer_id()); 1764 clip_scroll_map_.erase(layer->scroll_clip_layer_id());
1738 } 1765 }
1739 1766
1740 void LayerTreeImpl::AddSurfaceLayer(LayerImpl* layer) {
1741 DCHECK(std::find(surface_layers_.begin(), surface_layers_.end(), layer) ==
1742 surface_layers_.end());
1743 surface_layers_.push_back(layer);
1744 }
1745
1746 void LayerTreeImpl::RemoveSurfaceLayer(LayerImpl* layer) {
1747 LayerImplList::iterator it =
1748 std::find(surface_layers_.begin(), surface_layers_.end(), layer);
1749 DCHECK(it != surface_layers_.end());
1750 surface_layers_.erase(it);
1751 }
1752
1753 static bool PointHitsRect( 1767 static bool PointHitsRect(
1754 const gfx::PointF& screen_space_point, 1768 const gfx::PointF& screen_space_point,
1755 const gfx::Transform& local_space_to_screen_space_transform, 1769 const gfx::Transform& local_space_to_screen_space_transform,
1756 const gfx::Rect& local_space_rect, 1770 const gfx::Rect& local_space_rect,
1757 float* distance_to_camera) { 1771 float* distance_to_camera) {
1758 // If the transform is not invertible, then assume that this point doesn't hit 1772 // If the transform is not invertible, then assume that this point doesn't hit
1759 // this rect. 1773 // this rect.
1760 gfx::Transform inverse_local_space_to_screen_space( 1774 gfx::Transform inverse_local_space_to_screen_space(
1761 gfx::Transform::kSkipInitialization); 1775 gfx::Transform::kSkipInitialization);
1762 if (!local_space_to_screen_space_transform.GetInverse( 1776 if (!local_space_to_screen_space_transform.GetInverse(
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 2131
2118 void LayerTreeImpl::ResetAllChangeTracking() { 2132 void LayerTreeImpl::ResetAllChangeTracking() {
2119 layers_that_should_push_properties_.clear(); 2133 layers_that_should_push_properties_.clear();
2120 // Iterate over all layers, including masks. 2134 // Iterate over all layers, including masks.
2121 for (auto& layer : *layers_) 2135 for (auto& layer : *layers_)
2122 layer->ResetChangeTracking(); 2136 layer->ResetChangeTracking();
2123 property_trees_.ResetAllChangeTracking(); 2137 property_trees_.ResetAllChangeTracking();
2124 } 2138 }
2125 2139
2126 } // namespace cc 2140 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698