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

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

Issue 2035863003: cc: Add mask and replica layer ids to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 years, 6 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_host_common.h ('k') | cc/trees/layer_tree_host_common_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_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 for (int i = 0; i < proto.scrolls_size(); ++i) { 179 for (int i = 0; i < proto.scrolls_size(); ++i) {
180 scrolls.push_back(LayerTreeHostCommon::ScrollUpdateInfo()); 180 scrolls.push_back(LayerTreeHostCommon::ScrollUpdateInfo());
181 scrolls[i].FromProtobuf(proto.scrolls(i)); 181 scrolls[i].FromProtobuf(proto.scrolls(i));
182 } 182 }
183 page_scale_delta = proto.page_scale_delta(); 183 page_scale_delta = proto.page_scale_delta();
184 elastic_overscroll_delta = ProtoToVector2dF(proto.elastic_overscroll_delta()); 184 elastic_overscroll_delta = ProtoToVector2dF(proto.elastic_overscroll_delta());
185 top_controls_delta = proto.top_controls_delta(); 185 top_controls_delta = proto.top_controls_delta();
186 } 186 }
187 187
188 static inline void SetMaskLayersAreDrawnRenderSurfaceLayerListMembers( 188 static inline void SetMaskLayersAreDrawnRenderSurfaceLayerListMembers(
189 LayerImpl* layer, 189 RenderSurfaceImpl* surface,
190 PropertyTrees* property_trees) { 190 PropertyTrees* property_trees) {
191 if (layer->mask_layer()) { 191 LayerImpl* mask_layer = surface->MaskLayer();
192 layer->mask_layer()->set_is_drawn_render_surface_layer_list_member(true); 192 LayerImpl* replica_mask_layer = surface->ReplicaMaskLayer();
193 draw_property_utils::ComputeMaskDrawProperties(layer->mask_layer(), 193 if (mask_layer) {
194 mask_layer->set_is_drawn_render_surface_layer_list_member(true);
195 draw_property_utils::ComputeMaskDrawProperties(mask_layer, property_trees);
196 }
197 if (replica_mask_layer) {
198 replica_mask_layer->set_is_drawn_render_surface_layer_list_member(true);
199 draw_property_utils::ComputeMaskDrawProperties(replica_mask_layer,
194 property_trees); 200 property_trees);
195 } 201 }
196 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) {
197 layer->replica_layer()
198 ->mask_layer()
199 ->set_is_drawn_render_surface_layer_list_member(true);
200 draw_property_utils::ComputeMaskDrawProperties(
201 layer->replica_layer()->mask_layer(), property_trees);
202 }
203 } 202 }
204 203
205 static inline void ClearLayerIsDrawnRenderSurfaceLayerListMember( 204 static inline void ClearMaskLayersAreDrawnRenderSurfaceLayerListMembers(
206 LayerImpl* layer) { 205 RenderSurfaceImpl* surface) {
207 layer->set_is_drawn_render_surface_layer_list_member(false); 206 LayerImpl* mask_layer = surface->MaskLayer();
208 if (layer->mask_layer()) 207 LayerImpl* replica_mask_layer = surface->ReplicaMaskLayer();
209 layer->mask_layer()->set_is_drawn_render_surface_layer_list_member(false); 208 if (mask_layer)
210 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { 209 mask_layer->set_is_drawn_render_surface_layer_list_member(false);
211 layer->replica_layer() 210 if (replica_mask_layer)
212 ->mask_layer() 211 replica_mask_layer->set_is_drawn_render_surface_layer_list_member(false);
213 ->set_is_drawn_render_surface_layer_list_member(false);
214 }
215 } 212 }
216 213
217 static inline void ClearIsDrawnRenderSurfaceLayerListMember( 214 static inline void ClearIsDrawnRenderSurfaceLayerListMember(
218 LayerImplList* layer_list, 215 LayerImplList* layer_list,
219 ScrollTree* scroll_tree) { 216 ScrollTree* scroll_tree) {
220 for (LayerImpl* layer : *layer_list) { 217 for (LayerImpl* layer : *layer_list) {
221 if (layer->is_drawn_render_surface_layer_list_member()) { 218 if (layer->is_drawn_render_surface_layer_list_member()) {
222 DCHECK_GT(scroll_tree->Node(layer->scroll_tree_index()) 219 DCHECK_GT(scroll_tree->Node(layer->scroll_tree_index())
223 ->data.num_drawn_descendants, 220 ->data.num_drawn_descendants,
224 0); 221 0);
225 scroll_tree->Node(layer->scroll_tree_index()) 222 scroll_tree->Node(layer->scroll_tree_index())
226 ->data.num_drawn_descendants--; 223 ->data.num_drawn_descendants--;
227 } 224 }
228 ClearLayerIsDrawnRenderSurfaceLayerListMember(layer); 225 layer->set_is_drawn_render_surface_layer_list_member(false);
229 } 226 }
230 } 227 }
231 228
232 static bool CdpPerfTracingEnabled() { 229 static bool CdpPerfTracingEnabled() {
233 bool tracing_enabled; 230 bool tracing_enabled;
234 TRACE_EVENT_CATEGORY_GROUP_ENABLED("cdp.perf", &tracing_enabled); 231 TRACE_EVENT_CATEGORY_GROUP_ENABLED("cdp.perf", &tracing_enabled);
235 return tracing_enabled; 232 return tracing_enabled;
236 } 233 }
237 234
238 static float TranslationFromActiveTreeLayerScreenSpaceTransform( 235 static float TranslationFromActiveTreeLayerScreenSpaceTransform(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 LayerImplList* render_surface_layer_list, 320 LayerImplList* render_surface_layer_list,
324 bool can_render_to_separate_surface) { 321 bool can_render_to_separate_surface) {
325 ScrollTree* scroll_tree = &property_trees->scroll_tree; 322 ScrollTree* scroll_tree = &property_trees->scroll_tree;
326 for (int i = 0; i < static_cast<int>(scroll_tree->size()); ++i) 323 for (int i = 0; i < static_cast<int>(scroll_tree->size()); ++i)
327 scroll_tree->Node(i)->data.num_drawn_descendants = 0; 324 scroll_tree->Node(i)->data.num_drawn_descendants = 0;
328 325
329 // Add all non-skipped surfaces to the initial render surface layer list. Add 326 // Add all non-skipped surfaces to the initial render surface layer list. Add
330 // all non-skipped layers to the layer list of their target surface, and 327 // all non-skipped layers to the layer list of their target surface, and
331 // add their content rect to their target surface's accumulated content rect. 328 // add their content rect to their target surface's accumulated content rect.
332 for (LayerImpl* layer : *layer_tree_impl) { 329 for (LayerImpl* layer : *layer_tree_impl) {
333 if (layer->render_surface()) 330 if (layer->render_surface()) {
334 layer->ClearRenderSurfaceLayerList(); 331 layer->ClearRenderSurfaceLayerList();
335 ClearLayerIsDrawnRenderSurfaceLayerListMember(layer); 332 ClearMaskLayersAreDrawnRenderSurfaceLayerListMembers(
333 layer->render_surface());
334 }
335 layer->set_is_drawn_render_surface_layer_list_member(false);
336 336
337 bool layer_is_drawn = 337 bool layer_is_drawn =
338 property_trees->effect_tree.Node(layer->effect_tree_index()) 338 property_trees->effect_tree.Node(layer->effect_tree_index())
339 ->data.is_drawn; 339 ->data.is_drawn;
340 bool is_root = layer_tree_impl->IsRootLayer(layer); 340 bool is_root = layer_tree_impl->IsRootLayer(layer);
341 bool skip_layer = 341 bool skip_layer =
342 !is_root && draw_property_utils::LayerShouldBeSkipped( 342 !is_root && draw_property_utils::LayerShouldBeSkipped(
343 layer, layer_is_drawn, property_trees->transform_tree, 343 layer, layer_is_drawn, property_trees->transform_tree,
344 property_trees->effect_tree); 344 property_trees->effect_tree);
345 if (skip_layer) 345 if (skip_layer)
(...skipping 25 matching lines...) Expand all
371 surface); 371 surface);
372 372
373 // Ignore occlusion from outside the surface when surface contents need to 373 // Ignore occlusion from outside the surface when surface contents need to
374 // be fully drawn. Layers with copy-request need to be complete. We could 374 // be fully drawn. Layers with copy-request need to be complete. We could
375 // be smarter about layers with replica and exclude regions where both 375 // be smarter about layers with replica and exclude regions where both
376 // layer and the replica are occluded, but this seems like overkill. The 376 // layer and the replica are occluded, but this seems like overkill. The
377 // same is true for layers with filters that move pixels. 377 // same is true for layers with filters that move pixels.
378 // TODO(senorblanco): make this smarter for the SkImageFilter case (check 378 // TODO(senorblanco): make this smarter for the SkImageFilter case (check
379 // for pixel-moving filters) 379 // for pixel-moving filters)
380 bool is_occlusion_immune = surface->HasCopyRequest() || 380 bool is_occlusion_immune = surface->HasCopyRequest() ||
381 layer->has_replica() || 381 surface->HasReplica() ||
382 layer->filters().HasReferenceFilter() || 382 layer->filters().HasReferenceFilter() ||
383 layer->filters().HasFilterThatMovesPixels(); 383 layer->filters().HasFilterThatMovesPixels();
384 if (is_occlusion_immune) { 384 if (is_occlusion_immune) {
385 surface->SetNearestOcclusionImmuneAncestor(surface); 385 surface->SetNearestOcclusionImmuneAncestor(surface);
386 } else if (is_root) { 386 } else if (is_root) {
387 surface->SetNearestOcclusionImmuneAncestor(nullptr); 387 surface->SetNearestOcclusionImmuneAncestor(nullptr);
388 } else { 388 } else {
389 surface->SetNearestOcclusionImmuneAncestor( 389 surface->SetNearestOcclusionImmuneAncestor(
390 surface->render_target()->nearest_occlusion_immune_ancestor()); 390 surface->render_target()->nearest_occlusion_immune_ancestor());
391 } 391 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // root surface. 457 // root surface.
458 DCHECK(!target_surface->layer_list().empty() || 458 DCHECK(!target_surface->layer_list().empty() ||
459 target_surface->render_target() == target_surface); 459 target_surface->render_target() == target_surface);
460 } else { 460 } else {
461 // This layer was removed when the target itself was cleared. 461 // This layer was removed when the target itself was cleared.
462 DCHECK(target_surface->layer_list().empty()); 462 DCHECK(target_surface->layer_list().empty());
463 } 463 }
464 } 464 }
465 continue; 465 continue;
466 } 466 }
467 SetMaskLayersAreDrawnRenderSurfaceLayerListMembers(layer, property_trees); 467 SetMaskLayersAreDrawnRenderSurfaceLayerListMembers(surface, property_trees);
468 final_surface_list->push_back(layer); 468 final_surface_list->push_back(layer);
469 } 469 }
470 } 470 }
471 471
472 static void CalculateRenderSurfaceLayerList( 472 static void CalculateRenderSurfaceLayerList(
473 LayerTreeImpl* layer_tree_impl, 473 LayerTreeImpl* layer_tree_impl,
474 PropertyTrees* property_trees, 474 PropertyTrees* property_trees,
475 LayerImplList* render_surface_layer_list, 475 LayerImplList* render_surface_layer_list,
476 const bool can_render_to_separate_surface, 476 const bool can_render_to_separate_surface,
477 const int max_texture_size) { 477 const int max_texture_size) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 684
685 PropertyTrees* GetPropertyTrees(Layer* layer) { 685 PropertyTrees* GetPropertyTrees(Layer* layer) {
686 return layer->layer_tree_host()->property_trees(); 686 return layer->layer_tree_host()->property_trees();
687 } 687 }
688 688
689 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { 689 PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
690 return layer->layer_tree_impl()->property_trees(); 690 return layer->layer_tree_impl()->property_trees();
691 } 691 }
692 692
693 } // namespace cc 693 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698