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

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

Issue 2451273003: cc : Snap texture layers to pixel boundary (Closed)
Patch Set: Created 4 years, 1 month 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 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 LayerType* layer, 486 LayerType* layer,
487 bool created_render_surface, 487 bool created_render_surface,
488 DataForRecursion<LayerType>* data_for_children) { 488 DataForRecursion<LayerType>* data_for_children) {
489 const bool is_root = !Parent(layer); 489 const bool is_root = !Parent(layer);
490 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; 490 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer;
491 const bool is_overscroll_elasticity_layer = 491 const bool is_overscroll_elasticity_layer =
492 layer == data_from_ancestor.overscroll_elasticity_layer; 492 layer == data_from_ancestor.overscroll_elasticity_layer;
493 const bool is_scrollable = layer->scrollable(); 493 const bool is_scrollable = layer->scrollable();
494 const bool is_fixed = PositionConstraint(layer).is_fixed_position(); 494 const bool is_fixed = PositionConstraint(layer).is_fixed_position();
495 const bool is_sticky = StickyPositionConstraint(layer).is_sticky; 495 const bool is_sticky = StickyPositionConstraint(layer).is_sticky;
496 const bool is_snapped = layer->IsSnapped();
496 497
497 const bool has_significant_transform = 498 const bool has_significant_transform =
498 !Transform(layer).IsIdentityOr2DTranslation(); 499 !Transform(layer).IsIdentityOr2DTranslation();
499 500
500 const bool has_potentially_animated_transform = 501 const bool has_potentially_animated_transform =
501 HasPotentiallyRunningTransformAnimation(layer); 502 HasPotentiallyRunningTransformAnimation(layer);
502 503
503 // A transform node is needed even for a finished animation, since differences 504 // A transform node is needed even for a finished animation, since differences
504 // in the timing of animation state updates can mean that an animation that's 505 // in the timing of animation state updates can mean that an animation that's
505 // in the Finished state at tree-building time on the main thread is still in 506 // in the Finished state at tree-building time on the main thread is still in
(...skipping 10 matching lines...) Expand all
516 // a scroll child's render target is different from the scroll parent's render 517 // a scroll child's render target is different from the scroll parent's render
517 // target. 518 // target.
518 const bool scroll_child_has_different_target = 519 const bool scroll_child_has_different_target =
519 ScrollParent(layer) && 520 ScrollParent(layer) &&
520 Parent(layer)->effect_tree_index() != 521 Parent(layer)->effect_tree_index() !=
521 ScrollParent(layer)->effect_tree_index(); 522 ScrollParent(layer)->effect_tree_index();
522 523
523 const bool is_at_boundary_of_3d_rendering_context = 524 const bool is_at_boundary_of_3d_rendering_context =
524 IsAtBoundaryOf3dRenderingContext(layer); 525 IsAtBoundaryOf3dRenderingContext(layer);
525 526
526 bool requires_node = is_root || is_scrollable || has_significant_transform || 527 DCHECK(!is_scrollable || is_snapped);
enne (OOO) 2016/10/26 20:32:33 I wish we had DCHECK_IMPLIES. :C
jaydasika 2016/10/26 21:49:14 I wish that too. Just in this CL, I have 3 DCHECK(
528 bool requires_node = is_root || is_snapped || has_significant_transform ||
527 has_any_transform_animation || has_surface || is_fixed || 529 has_any_transform_animation || has_surface || is_fixed ||
528 is_page_scale_layer || is_overscroll_elasticity_layer || 530 is_page_scale_layer || is_overscroll_elasticity_layer ||
529 has_proxied_transform_related_property || 531 has_proxied_transform_related_property ||
530 scroll_child_has_different_target || is_sticky || 532 scroll_child_has_different_target || is_sticky ||
531 is_at_boundary_of_3d_rendering_context; 533 is_at_boundary_of_3d_rendering_context;
532 534
533 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); 535 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer);
534 DCHECK(is_root || transform_parent); 536 DCHECK(is_root || transform_parent);
535 537
536 int parent_index = kRootPropertyTreeNodeId; 538 int parent_index = kRootPropertyTreeNodeId;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 data_for_children->property_trees->transform_tree.Insert(TransformNode(), 594 data_for_children->property_trees->transform_tree.Insert(TransformNode(),
593 parent_index); 595 parent_index);
594 596
595 TransformNode* node = 597 TransformNode* node =
596 data_for_children->property_trees->transform_tree.back(); 598 data_for_children->property_trees->transform_tree.back();
597 layer->SetTransformTreeIndex(node->id); 599 layer->SetTransformTreeIndex(node->id);
598 data_for_children->property_trees->transform_id_to_index_map[layer->id()] = 600 data_for_children->property_trees->transform_id_to_index_map[layer->id()] =
599 node->id; 601 node->id;
600 602
601 node->scrolls = is_scrollable; 603 node->scrolls = is_scrollable;
604 node->should_be_snapped = is_snapped;
602 node->flattens_inherited_transform = data_for_children->should_flatten; 605 node->flattens_inherited_transform = data_for_children->should_flatten;
603 606
604 node->sorting_context_id = layer->sorting_context_id(); 607 node->sorting_context_id = layer->sorting_context_id();
605 608
606 if (layer == data_from_ancestor.page_scale_layer) 609 if (layer == data_from_ancestor.page_scale_layer)
607 data_for_children->in_subtree_of_page_scale_layer = true; 610 data_for_children->in_subtree_of_page_scale_layer = true;
608 node->in_subtree_of_page_scale_layer = 611 node->in_subtree_of_page_scale_layer =
609 data_for_children->in_subtree_of_page_scale_layer; 612 data_for_children->in_subtree_of_page_scale_layer;
610 613
611 // Surfaces inherently flatten transforms. 614 // Surfaces inherently flatten transforms.
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 color = SkColorSetA(color, 255); 1489 color = SkColorSetA(color, 255);
1487 BuildPropertyTreesTopLevelInternal( 1490 BuildPropertyTreesTopLevelInternal(
1488 root_layer, page_scale_layer, inner_viewport_scroll_layer, 1491 root_layer, page_scale_layer, inner_viewport_scroll_layer,
1489 outer_viewport_scroll_layer, overscroll_elasticity_layer, 1492 outer_viewport_scroll_layer, overscroll_elasticity_layer,
1490 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, 1493 elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
1491 device_transform, property_trees, color); 1494 device_transform, property_trees, color);
1492 property_trees->ResetCachedData(); 1495 property_trees->ResetCachedData();
1493 } 1496 }
1494 1497
1495 } // namespace cc 1498 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698