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

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: comments 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
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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 gfx::SizeF content_size = root_scroll_layer->BoundsForScrolling(); 1212 gfx::SizeF content_size = root_scroll_layer->BoundsForScrolling();
1212 content_size.SetToMax(root_container_layer->BoundsForScrolling()); 1213 content_size.SetToMax(root_container_layer->BoundsForScrolling());
1213 return content_size; 1214 return content_size;
1214 } 1215 }
1215 1216
1216 LayerImpl* LayerTreeImpl::LayerById(int id) const { 1217 LayerImpl* LayerTreeImpl::LayerById(int id) const {
1217 LayerImplMap::const_iterator iter = layer_id_map_.find(id); 1218 LayerImplMap::const_iterator iter = layer_id_map_.find(id);
1218 return iter != layer_id_map_.end() ? iter->second : nullptr; 1219 return iter != layer_id_map_.end() ? iter->second : nullptr;
1219 } 1220 }
1220 1221
1222 void LayerTreeImpl::SetSurfaceLayerIds(
1223 const std::vector<SurfaceId>& surface_layer_ids) {
1224 DCHECK(surface_layer_ids_.empty());
1225 surface_layer_ids_ = surface_layer_ids;
1226 needs_surface_ids_sync_ = true;
1227 }
1228
1229 const std::vector<SurfaceId>& LayerTreeImpl::SurfaceLayerIds() const {
1230 return surface_layer_ids_;
1231 }
1232
1233 void LayerTreeImpl::ClearSurfaceLayerIds() {
1234 surface_layer_ids_.clear();
1235 needs_surface_ids_sync_ = true;
1236 }
1237
1221 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) { 1238 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) {
1222 layers_that_should_push_properties_.insert(layer); 1239 layers_that_should_push_properties_.insert(layer);
1223 } 1240 }
1224 1241
1225 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) { 1242 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) {
1226 layers_that_should_push_properties_.erase(layer); 1243 layers_that_should_push_properties_.erase(layer);
1227 } 1244 }
1228 1245
1229 std::unordered_set<LayerImpl*>& 1246 std::unordered_set<LayerImpl*>&
1230 LayerTreeImpl::LayersThatShouldPushProperties() { 1247 LayerTreeImpl::LayersThatShouldPushProperties() {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 layer->set_needs_show_scrollbars(true); 1747 layer->set_needs_show_scrollbars(true);
1731 } 1748 }
1732 1749
1733 void LayerTreeImpl::UnregisterScrollLayer(LayerImpl* layer) { 1750 void LayerTreeImpl::UnregisterScrollLayer(LayerImpl* layer) {
1734 if (layer->scroll_clip_layer_id() == Layer::INVALID_ID) 1751 if (layer->scroll_clip_layer_id() == Layer::INVALID_ID)
1735 return; 1752 return;
1736 1753
1737 clip_scroll_map_.erase(layer->scroll_clip_layer_id()); 1754 clip_scroll_map_.erase(layer->scroll_clip_layer_id());
1738 } 1755 }
1739 1756
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( 1757 static bool PointHitsRect(
1754 const gfx::PointF& screen_space_point, 1758 const gfx::PointF& screen_space_point,
1755 const gfx::Transform& local_space_to_screen_space_transform, 1759 const gfx::Transform& local_space_to_screen_space_transform,
1756 const gfx::Rect& local_space_rect, 1760 const gfx::Rect& local_space_rect,
1757 float* distance_to_camera) { 1761 float* distance_to_camera) {
1758 // If the transform is not invertible, then assume that this point doesn't hit 1762 // If the transform is not invertible, then assume that this point doesn't hit
1759 // this rect. 1763 // this rect.
1760 gfx::Transform inverse_local_space_to_screen_space( 1764 gfx::Transform inverse_local_space_to_screen_space(
1761 gfx::Transform::kSkipInitialization); 1765 gfx::Transform::kSkipInitialization);
1762 if (!local_space_to_screen_space_transform.GetInverse( 1766 if (!local_space_to_screen_space_transform.GetInverse(
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 2121
2118 void LayerTreeImpl::ResetAllChangeTracking() { 2122 void LayerTreeImpl::ResetAllChangeTracking() {
2119 layers_that_should_push_properties_.clear(); 2123 layers_that_should_push_properties_.clear();
2120 // Iterate over all layers, including masks. 2124 // Iterate over all layers, including masks.
2121 for (auto& layer : *layers_) 2125 for (auto& layer : *layers_)
2122 layer->ResetChangeTracking(); 2126 layer->ResetChangeTracking();
2123 property_trees_.ResetAllChangeTracking(); 2127 property_trees_.ResetAllChangeTracking();
2124 } 2128 }
2125 2129
2126 } // namespace cc 2130 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698