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

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

Issue 1413153014: Add a flag for enabling compositor property trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( 639 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs(
640 root_layer(), DrawViewportSize(), 640 root_layer(), DrawViewportSize(),
641 layer_tree_host_impl_->DrawTransform(), device_scale_factor(), 641 layer_tree_host_impl_->DrawTransform(), device_scale_factor(),
642 current_page_scale_factor(), PageScaleLayer(), 642 current_page_scale_factor(), PageScaleLayer(),
643 InnerViewportScrollLayer(), OuterViewportScrollLayer(), 643 InnerViewportScrollLayer(), OuterViewportScrollLayer(),
644 elastic_overscroll()->Current(IsActiveTree()), 644 elastic_overscroll()->Current(IsActiveTree()),
645 OverscrollElasticityLayer(), resource_provider()->max_texture_size(), 645 OverscrollElasticityLayer(), resource_provider()->max_texture_size(),
646 settings().can_use_lcd_text, settings().layers_always_allowed_lcd_text, 646 settings().can_use_lcd_text, settings().layers_always_allowed_lcd_text,
647 can_render_to_separate_surface, 647 can_render_to_separate_surface,
648 settings().layer_transforms_should_scale_layer_contents, 648 settings().layer_transforms_should_scale_layer_contents,
649 settings().verify_property_trees, &render_surface_layer_list_, 649 settings().verify_property_trees, settings().use_property_trees,
650 render_surface_layer_list_id_, &property_trees_); 650 &render_surface_layer_list_, render_surface_layer_list_id_,
651 &property_trees_);
651 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 652 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
652 } 653 }
653 654
654 { 655 {
655 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", 656 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion",
656 "IsActive", IsActiveTree(), "SourceFrameNumber", 657 "IsActive", IsActiveTree(), "SourceFrameNumber",
657 source_frame_number_); 658 source_frame_number_);
658 OcclusionTracker occlusion_tracker( 659 OcclusionTracker occlusion_tracker(
659 root_layer()->render_surface()->content_rect()); 660 root_layer()->render_surface()->content_rect());
660 occlusion_tracker.set_minimum_tracking_size( 661 occlusion_tracker.set_minimum_tracking_size(
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 1532
1532 struct FindScrollingLayerFunctor { 1533 struct FindScrollingLayerFunctor {
1533 bool operator()(LayerImpl* layer) const { 1534 bool operator()(LayerImpl* layer) const {
1534 return ScrollsAnyDrawnRenderSurfaceLayerListMember(layer); 1535 return ScrollsAnyDrawnRenderSurfaceLayerListMember(layer);
1535 } 1536 }
1536 }; 1537 };
1537 1538
1538 LayerImpl* LayerTreeImpl::FindFirstScrollingLayerThatIsHitByPoint( 1539 LayerImpl* LayerTreeImpl::FindFirstScrollingLayerThatIsHitByPoint(
1539 const gfx::PointF& screen_space_point) { 1540 const gfx::PointF& screen_space_point) {
1540 FindClosestMatchingLayerDataForRecursion data_for_recursion; 1541 FindClosestMatchingLayerDataForRecursion data_for_recursion;
1542 bool use_property_trees =
1543 settings().use_property_trees || settings().verify_property_trees;
1541 FindClosestMatchingLayer( 1544 FindClosestMatchingLayer(
1542 screen_space_point, root_layer(), FindScrollingLayerFunctor(), 1545 screen_space_point, root_layer(), FindScrollingLayerFunctor(),
1543 property_trees_.transform_tree, settings().verify_property_trees, 1546 property_trees_.transform_tree, use_property_trees, &data_for_recursion);
1544 &data_for_recursion);
1545 return data_for_recursion.closest_match; 1547 return data_for_recursion.closest_match;
1546 } 1548 }
1547 1549
1548 struct HitTestVisibleScrollableOrTouchableFunctor { 1550 struct HitTestVisibleScrollableOrTouchableFunctor {
1549 bool operator()(LayerImpl* layer) const { 1551 bool operator()(LayerImpl* layer) const {
1550 return layer->IsDrawnRenderSurfaceLayerListMember() || 1552 return layer->IsDrawnRenderSurfaceLayerListMember() ||
1551 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || 1553 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) ||
1552 !layer->touch_event_handler_region().IsEmpty() || 1554 !layer->touch_event_handler_region().IsEmpty() ||
1553 layer->have_wheel_event_handlers(); 1555 layer->have_wheel_event_handlers();
1554 } 1556 }
1555 }; 1557 };
1556 1558
1557 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( 1559 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint(
1558 const gfx::PointF& screen_space_point) { 1560 const gfx::PointF& screen_space_point) {
1559 if (!root_layer()) 1561 if (!root_layer())
1560 return NULL; 1562 return NULL;
1561 bool update_lcd_text = false; 1563 bool update_lcd_text = false;
1562 if (!UpdateDrawProperties(update_lcd_text)) 1564 if (!UpdateDrawProperties(update_lcd_text))
1563 return NULL; 1565 return NULL;
1566 bool use_property_trees =
1567 settings().use_property_trees || settings().verify_property_trees;
1564 FindClosestMatchingLayerDataForRecursion data_for_recursion; 1568 FindClosestMatchingLayerDataForRecursion data_for_recursion;
1565 FindClosestMatchingLayer(screen_space_point, root_layer(), 1569 FindClosestMatchingLayer(screen_space_point, root_layer(),
1566 HitTestVisibleScrollableOrTouchableFunctor(), 1570 HitTestVisibleScrollableOrTouchableFunctor(),
1567 property_trees_.transform_tree, 1571 property_trees_.transform_tree, use_property_trees,
1568 settings().verify_property_trees,
1569 &data_for_recursion); 1572 &data_for_recursion);
1570 return data_for_recursion.closest_match; 1573 return data_for_recursion.closest_match;
1571 } 1574 }
1572 1575
1573 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, 1576 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point,
1574 LayerImpl* layer_impl, 1577 LayerImpl* layer_impl,
1575 const TransformTree& transform_tree, 1578 const TransformTree& transform_tree,
1576 const bool use_property_trees) { 1579 const bool use_property_trees) {
1577 if (layer_impl->touch_event_handler_region().IsEmpty()) 1580 if (layer_impl->touch_event_handler_region().IsEmpty())
1578 return false; 1581 return false;
(...skipping 21 matching lines...) Expand all
1600 } 1603 }
1601 }; 1604 };
1602 1605
1603 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( 1606 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint(
1604 const gfx::PointF& screen_space_point) { 1607 const gfx::PointF& screen_space_point) {
1605 if (!root_layer()) 1608 if (!root_layer())
1606 return NULL; 1609 return NULL;
1607 bool update_lcd_text = false; 1610 bool update_lcd_text = false;
1608 if (!UpdateDrawProperties(update_lcd_text)) 1611 if (!UpdateDrawProperties(update_lcd_text))
1609 return NULL; 1612 return NULL;
1613 bool use_property_trees =
1614 settings().use_property_trees || settings().verify_property_trees;
1610 FindWheelEventLayerFunctor func; 1615 FindWheelEventLayerFunctor func;
1611 FindClosestMatchingLayerDataForRecursion data_for_recursion; 1616 FindClosestMatchingLayerDataForRecursion data_for_recursion;
1612 FindClosestMatchingLayer( 1617 FindClosestMatchingLayer(screen_space_point, root_layer(), func,
1613 screen_space_point, root_layer(), func, property_trees_.transform_tree, 1618 property_trees_.transform_tree, use_property_trees,
1614 settings().verify_property_trees, &data_for_recursion); 1619 &data_for_recursion);
1615 return data_for_recursion.closest_match; 1620 return data_for_recursion.closest_match;
1616 } 1621 }
1617 1622
1618 struct FindTouchEventLayerFunctor { 1623 struct FindTouchEventLayerFunctor {
1619 bool operator()(LayerImpl* layer) const { 1624 bool operator()(LayerImpl* layer) const {
1620 return LayerHasTouchEventHandlersAt(screen_space_point, layer, 1625 return LayerHasTouchEventHandlersAt(screen_space_point, layer,
1621 transform_tree, use_property_trees); 1626 transform_tree, use_property_trees);
1622 } 1627 }
1623 const gfx::PointF screen_space_point; 1628 const gfx::PointF screen_space_point;
1624 const TransformTree& transform_tree; 1629 const TransformTree& transform_tree;
1625 const bool use_property_trees; 1630 const bool use_property_trees;
1626 }; 1631 };
1627 1632
1628 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( 1633 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion(
1629 const gfx::PointF& screen_space_point) { 1634 const gfx::PointF& screen_space_point) {
1630 if (!root_layer()) 1635 if (!root_layer())
1631 return NULL; 1636 return NULL;
1632 bool update_lcd_text = false; 1637 bool update_lcd_text = false;
1633 if (!UpdateDrawProperties(update_lcd_text)) 1638 if (!UpdateDrawProperties(update_lcd_text))
1634 return NULL; 1639 return NULL;
1635 FindTouchEventLayerFunctor func = {screen_space_point, 1640 bool use_property_trees =
1636 property_trees_.transform_tree, 1641 settings().use_property_trees || settings().verify_property_trees;
1637 settings().verify_property_trees}; 1642 FindTouchEventLayerFunctor func = {
1643 screen_space_point, property_trees_.transform_tree, use_property_trees};
1638 FindClosestMatchingLayerDataForRecursion data_for_recursion; 1644 FindClosestMatchingLayerDataForRecursion data_for_recursion;
1639 FindClosestMatchingLayer( 1645 FindClosestMatchingLayer(screen_space_point, root_layer(), func,
1640 screen_space_point, root_layer(), func, property_trees_.transform_tree, 1646 property_trees_.transform_tree, use_property_trees,
1641 settings().verify_property_trees, &data_for_recursion); 1647 &data_for_recursion);
1642 return data_for_recursion.closest_match; 1648 return data_for_recursion.closest_match;
1643 } 1649 }
1644 1650
1645 void LayerTreeImpl::RegisterSelection(const LayerSelection& selection) { 1651 void LayerTreeImpl::RegisterSelection(const LayerSelection& selection) {
1646 selection_ = selection; 1652 selection_ = selection;
1647 } 1653 }
1648 1654
1649 static ViewportSelectionBound ComputeViewportSelectionBound( 1655 static ViewportSelectionBound ComputeViewportSelectionBound(
1650 const LayerSelectionBound& layer_bound, 1656 const LayerSelectionBound& layer_bound,
1651 LayerImpl* layer, 1657 LayerImpl* layer,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 viewport_bound.visible = 1704 viewport_bound.visible =
1699 PointHitsLayer(layer, visibility_point, &intersect_distance, 1705 PointHitsLayer(layer, visibility_point, &intersect_distance,
1700 transform_tree, use_property_trees); 1706 transform_tree, use_property_trees);
1701 1707
1702 return viewport_bound; 1708 return viewport_bound;
1703 } 1709 }
1704 1710
1705 void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) { 1711 void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) {
1706 DCHECK(selection); 1712 DCHECK(selection);
1707 1713
1714 bool use_property_trees =
1715 settings().use_property_trees || settings().verify_property_trees;
1708 selection->start = ComputeViewportSelectionBound( 1716 selection->start = ComputeViewportSelectionBound(
1709 selection_.start, 1717 selection_.start,
1710 selection_.start.layer_id ? LayerById(selection_.start.layer_id) : NULL, 1718 selection_.start.layer_id ? LayerById(selection_.start.layer_id) : NULL,
1711 device_scale_factor(), property_trees_.transform_tree, 1719 device_scale_factor(), property_trees_.transform_tree,
1712 settings().verify_property_trees); 1720 use_property_trees);
1713 selection->is_editable = selection_.is_editable; 1721 selection->is_editable = selection_.is_editable;
1714 selection->is_empty_text_form_control = selection_.is_empty_text_form_control; 1722 selection->is_empty_text_form_control = selection_.is_empty_text_form_control;
1715 if (selection->start.type == SELECTION_BOUND_CENTER || 1723 if (selection->start.type == SELECTION_BOUND_CENTER ||
1716 selection->start.type == SELECTION_BOUND_EMPTY) { 1724 selection->start.type == SELECTION_BOUND_EMPTY) {
1717 selection->end = selection->start; 1725 selection->end = selection->start;
1718 } else { 1726 } else {
1719 selection->end = ComputeViewportSelectionBound( 1727 selection->end = ComputeViewportSelectionBound(
1720 selection_.end, 1728 selection_.end,
1721 selection_.end.layer_id ? LayerById(selection_.end.layer_id) : NULL, 1729 selection_.end.layer_id ? LayerById(selection_.end.layer_id) : NULL,
1722 device_scale_factor(), property_trees_.transform_tree, 1730 device_scale_factor(), property_trees_.transform_tree,
1723 settings().verify_property_trees); 1731 use_property_trees);
1724 } 1732 }
1725 } 1733 }
1726 1734
1727 void LayerTreeImpl::InputScrollAnimationFinished() { 1735 void LayerTreeImpl::InputScrollAnimationFinished() {
1728 layer_tree_host_impl_->ScrollEnd(); 1736 layer_tree_host_impl_->ScrollEnd();
1729 } 1737 }
1730 1738
1731 bool LayerTreeImpl::SmoothnessTakesPriority() const { 1739 bool LayerTreeImpl::SmoothnessTakesPriority() const {
1732 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; 1740 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY;
1733 } 1741 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 const gfx::BoxF& box, 1914 const gfx::BoxF& box,
1907 gfx::BoxF* bounds) const { 1915 gfx::BoxF* bounds) const {
1908 *bounds = gfx::BoxF(); 1916 *bounds = gfx::BoxF();
1909 return layer_tree_host_impl_->animation_host() 1917 return layer_tree_host_impl_->animation_host()
1910 ? layer_tree_host_impl_->animation_host() 1918 ? layer_tree_host_impl_->animation_host()
1911 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) 1919 ->TransformAnimationBoundsForBox(layer->id(), box, bounds)
1912 : true; 1920 : true;
1913 } 1921 }
1914 1922
1915 } // namespace cc 1923 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698