OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/property_tree_builder.h" | 5 #include "cc/trees/property_tree_builder.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 // affected by the ancestor clip), we cannot clip the surface itself, and | 362 // affected by the ancestor clip), we cannot clip the surface itself, and |
363 // must instead apply clips to the clipped descendants. | 363 // must instead apply clips to the clipped descendants. |
364 if (ancestor_clips_subtree && NumUnclippedDescendants(layer) > 0) { | 364 if (ancestor_clips_subtree && NumUnclippedDescendants(layer) > 0) { |
365 layers_are_clipped = true; | 365 layers_are_clipped = true; |
366 } else if (!ancestor_clips_subtree) { | 366 } else if (!ancestor_clips_subtree) { |
367 // When there are no ancestor clips that need to be applied to a render | 367 // When there are no ancestor clips that need to be applied to a render |
368 // surface, we reset clipping state. The surface might contribute a clip | 368 // surface, we reset clipping state. The surface might contribute a clip |
369 // of its own, but clips from ancestor nodes don't need to be considered | 369 // of its own, but clips from ancestor nodes don't need to be considered |
370 // when computing clip rects or visibility. | 370 // when computing clip rects or visibility. |
371 has_unclipped_surface = true; | 371 has_unclipped_surface = true; |
372 DCHECK(!parent->applies_local_clip); | 372 DCHECK(parent->clip_type != ClipNode::ClipType::APPLIES_LOCAL_CLIP); |
jaydasika
2016/10/21 23:20:58
Nit : You can use DCHECK_NE here.
ajuma
2016/10/21 23:35:30
Done.
| |
373 } | 373 } |
374 // A surface with unclipped descendants cannot be clipped by its ancestor | 374 // A surface with unclipped descendants cannot be clipped by its ancestor |
375 // clip at draw time since the unclipped descendants aren't affected by the | 375 // clip at draw time since the unclipped descendants aren't affected by the |
376 // ancestor clip. | 376 // ancestor clip. |
377 data_for_children->target_is_clipped = | 377 data_for_children->target_is_clipped = |
378 ancestor_clips_subtree && !NumUnclippedDescendants(layer); | 378 ancestor_clips_subtree && !NumUnclippedDescendants(layer); |
379 } else { | 379 } else { |
380 // Without a new render surface, layer clipping state from ancestors needs | 380 // Without a new render surface, layer clipping state from ancestors needs |
381 // to continue to propagate. | 381 // to continue to propagate. |
382 data_for_children->target_is_clipped = data_from_ancestor.target_is_clipped; | 382 data_for_children->target_is_clipped = data_from_ancestor.target_is_clipped; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 // clipping state from ancestors must continue to get propagated. | 422 // clipping state from ancestors must continue to get propagated. |
423 node.layer_clipping_uses_only_local_clip = | 423 node.layer_clipping_uses_only_local_clip = |
424 (created_render_surface && NumUnclippedDescendants(layer) == 0) || | 424 (created_render_surface && NumUnclippedDescendants(layer) == 0) || |
425 !ancestor_clips_subtree; | 425 !ancestor_clips_subtree; |
426 } else { | 426 } else { |
427 // Otherwise, we're either unclipped, or exist only in order to apply our | 427 // Otherwise, we're either unclipped, or exist only in order to apply our |
428 // parent's clips in our space. | 428 // parent's clips in our space. |
429 node.layer_clipping_uses_only_local_clip = false; | 429 node.layer_clipping_uses_only_local_clip = false; |
430 } | 430 } |
431 | 431 |
432 node.applies_local_clip = layer_clips_subtree; | 432 if (layer_clips_subtree) |
433 node.clip_type = ClipNode::ClipType::APPLIES_LOCAL_CLIP; | |
434 else | |
435 node.clip_type = ClipNode::ClipType::NONE; | |
433 node.resets_clip = has_unclipped_surface; | 436 node.resets_clip = has_unclipped_surface; |
434 node.target_is_clipped = data_for_children->target_is_clipped; | 437 node.target_is_clipped = data_for_children->target_is_clipped; |
435 node.layers_are_clipped = layers_are_clipped; | 438 node.layers_are_clipped = layers_are_clipped; |
436 node.layers_are_clipped_when_surfaces_disabled = | 439 node.layers_are_clipped_when_surfaces_disabled = |
437 layers_are_clipped_when_surfaces_disabled; | 440 layers_are_clipped_when_surfaces_disabled; |
438 | 441 |
439 data_for_children->clip_tree_parent = | 442 data_for_children->clip_tree_parent = |
440 data_for_children->property_trees->clip_tree.Insert(node, parent_id); | 443 data_for_children->property_trees->clip_tree.Insert(node, parent_id); |
441 data_for_children->property_trees->clip_id_to_index_map[layer->id()] = | 444 data_for_children->property_trees->clip_id_to_index_map[layer->id()] = |
442 data_for_children->clip_tree_parent; | 445 data_for_children->clip_tree_parent; |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1381 | 1384 |
1382 data_for_recursion.property_trees->clear(); | 1385 data_for_recursion.property_trees->clear(); |
1383 data_for_recursion.compound_transform_since_render_target = gfx::Transform(); | 1386 data_for_recursion.compound_transform_since_render_target = gfx::Transform(); |
1384 data_for_recursion.axis_align_since_render_target = true; | 1387 data_for_recursion.axis_align_since_render_target = true; |
1385 data_for_recursion.property_trees->transform_tree.set_device_scale_factor( | 1388 data_for_recursion.property_trees->transform_tree.set_device_scale_factor( |
1386 device_scale_factor); | 1389 device_scale_factor); |
1387 data_for_recursion.safe_opaque_background_color = color; | 1390 data_for_recursion.safe_opaque_background_color = color; |
1388 | 1391 |
1389 ClipNode root_clip; | 1392 ClipNode root_clip; |
1390 root_clip.resets_clip = true; | 1393 root_clip.resets_clip = true; |
1391 root_clip.applies_local_clip = true; | 1394 root_clip.clip_type = ClipNode::ClipType::APPLIES_LOCAL_CLIP; |
1392 root_clip.clip = gfx::RectF(viewport); | 1395 root_clip.clip = gfx::RectF(viewport); |
1393 root_clip.transform_id = kRootPropertyTreeNodeId; | 1396 root_clip.transform_id = kRootPropertyTreeNodeId; |
1394 data_for_recursion.clip_tree_parent = | 1397 data_for_recursion.clip_tree_parent = |
1395 data_for_recursion.property_trees->clip_tree.Insert( | 1398 data_for_recursion.property_trees->clip_tree.Insert( |
1396 root_clip, kRootPropertyTreeNodeId); | 1399 root_clip, kRootPropertyTreeNodeId); |
1397 | 1400 |
1398 DataForRecursionFromChild<LayerType> data_from_child; | 1401 DataForRecursionFromChild<LayerType> data_from_child; |
1399 BuildPropertyTreesInternal(root_layer, data_for_recursion, &data_from_child); | 1402 BuildPropertyTreesInternal(root_layer, data_for_recursion, &data_from_child); |
1400 property_trees->needs_rebuild = false; | 1403 property_trees->needs_rebuild = false; |
1401 | 1404 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1477 color = SkColorSetA(color, 255); | 1480 color = SkColorSetA(color, 255); |
1478 BuildPropertyTreesTopLevelInternal( | 1481 BuildPropertyTreesTopLevelInternal( |
1479 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1482 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
1480 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1483 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
1481 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1484 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
1482 device_transform, property_trees, color); | 1485 device_transform, property_trees, color); |
1483 property_trees->ResetCachedData(); | 1486 property_trees->ResetCachedData(); |
1484 } | 1487 } |
1485 | 1488 |
1486 } // namespace cc | 1489 } // namespace cc |
OLD | NEW |