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

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

Issue 1551333003: cc:: Use clip tree instead of layer tree during hit testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | cc/trees/layer_tree_impl_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_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 22 matching lines...) Expand all
33 #include "cc/layers/scrollbar_layer_impl_base.h" 33 #include "cc/layers/scrollbar_layer_impl_base.h"
34 #include "cc/resources/ui_resource_request.h" 34 #include "cc/resources/ui_resource_request.h"
35 #include "cc/trees/draw_property_utils.h" 35 #include "cc/trees/draw_property_utils.h"
36 #include "cc/trees/layer_tree_host_common.h" 36 #include "cc/trees/layer_tree_host_common.h"
37 #include "cc/trees/layer_tree_host_impl.h" 37 #include "cc/trees/layer_tree_host_impl.h"
38 #include "cc/trees/occlusion_tracker.h" 38 #include "cc/trees/occlusion_tracker.h"
39 #include "cc/trees/property_tree.h" 39 #include "cc/trees/property_tree.h"
40 #include "cc/trees/property_tree_builder.h" 40 #include "cc/trees/property_tree_builder.h"
41 #include "ui/gfx/geometry/box_f.h" 41 #include "ui/gfx/geometry/box_f.h"
42 #include "ui/gfx/geometry/point_conversions.h" 42 #include "ui/gfx/geometry/point_conversions.h"
43 #include "ui/gfx/geometry/rect_conversions.h"
43 #include "ui/gfx/geometry/size_conversions.h" 44 #include "ui/gfx/geometry/size_conversions.h"
44 #include "ui/gfx/geometry/vector2d_conversions.h" 45 #include "ui/gfx/geometry/vector2d_conversions.h"
45 46
46 namespace cc { 47 namespace cc {
47 48
48 LayerTreeImpl::LayerTreeImpl( 49 LayerTreeImpl::LayerTreeImpl(
49 LayerTreeHostImpl* layer_tree_host_impl, 50 LayerTreeHostImpl* layer_tree_host_impl,
50 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, 51 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor,
51 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, 52 scoped_refptr<SyncedTopControls> top_controls_shown_ratio,
52 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) 53 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll)
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 const bool use_property_trees) { 1428 const bool use_property_trees) {
1428 DCHECK(layer->render_surface()); 1429 DCHECK(layer->render_surface());
1429 if (!use_property_trees) 1430 if (!use_property_trees)
1430 return layer->render_surface()->screen_space_transform(); 1431 return layer->render_surface()->screen_space_transform();
1431 return layer->IsDrawnRenderSurfaceLayerListMember() 1432 return layer->IsDrawnRenderSurfaceLayerListMember()
1432 ? layer->render_surface()->screen_space_transform() 1433 ? layer->render_surface()->screen_space_transform()
1433 : SurfaceScreenSpaceTransformFromPropertyTrees( 1434 : SurfaceScreenSpaceTransformFromPropertyTrees(
1434 layer->render_surface(), transform_tree); 1435 layer->render_surface(), transform_tree);
1435 } 1436 }
1436 1437
1438 static bool PointIsClippedByAncestorClipNode(
1439 const gfx::PointF& screen_space_point,
1440 const LayerImpl* layer,
1441 const ClipTree& clip_tree,
1442 const TransformTree& transform_tree) {
1443 // We need to visit all ancestor clip nodes that apply local clip to check
1444 // this. Checking with just the combined clip stored at a clip node is not
1445 // enough because parent combined clip can sometimes be smaller than current
1446 // combined clip. This can happen when we have transforms like rotation that
1447 // inflate the combined clip's bounds.
1448
1449 // We first check if the point is clipped by viewport.
1450 const ClipNode* clip_node = clip_tree.Node(1);
1451 gfx::Rect combined_clip_in_target_space =
1452 gfx::ToEnclosingRect(clip_node->data.combined_clip_in_target_space);
1453 if (!PointHitsRect(screen_space_point, gfx::Transform(),
1454 combined_clip_in_target_space, NULL))
1455 return true;
1456
1457 for (const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index());
1458 clip_node->id > 1; clip_node = clip_tree.parent(clip_node)) {
ajuma 2016/01/05 18:55:11 Should this be >= 1? (We're probably missing test
jaydasika 2016/01/05 19:00:01 Clip node 1(viewport) is already there at line 145
1459 if (!clip_node->data.applies_local_clip)
1460 continue;
1461 const TransformNode* transform_node =
1462 transform_tree.Node(clip_node->data.transform_id);
1463 gfx::Rect combined_clip_in_target_space =
1464 gfx::ToEnclosingRect(clip_node->data.combined_clip_in_target_space);
1465
1466 if (!PointHitsRect(screen_space_point, transform_node->data.to_screen,
1467 combined_clip_in_target_space, NULL))
1468 return true;
1469 }
1470 return false;
1471 }
1472
1437 static bool PointIsClippedBySurfaceOrClipRect( 1473 static bool PointIsClippedBySurfaceOrClipRect(
1438 const gfx::PointF& screen_space_point, 1474 const gfx::PointF& screen_space_point,
1439 const LayerImpl* layer, 1475 const LayerImpl* layer,
1440 const TransformTree& transform_tree, 1476 const TransformTree& transform_tree,
1477 const ClipTree& clip_tree,
1441 const bool use_property_trees) { 1478 const bool use_property_trees) {
1442 // Walk up the layer tree and hit-test any render_surfaces and any layer 1479 // Walk up the layer tree and hit-test any render_surfaces and any layer
1443 // clip rects that are active. 1480 // clip rects that are active.
1481 if (use_property_trees) {
1482 return PointIsClippedByAncestorClipNode(screen_space_point, layer,
1483 clip_tree, transform_tree);
1484 }
1485
1444 for (; layer; layer = GetNextClippingLayer(layer)) { 1486 for (; layer; layer = GetNextClippingLayer(layer)) {
1445 if (layer->render_surface() && 1487 if (layer->render_surface() &&
1446 !PointHitsRect(screen_space_point, 1488 !PointHitsRect(screen_space_point,
1447 SurfaceScreenSpaceTransform(layer, transform_tree, 1489 SurfaceScreenSpaceTransform(layer, transform_tree,
1448 use_property_trees), 1490 use_property_trees),
1449 layer->render_surface()->content_rect(), NULL)) 1491 layer->render_surface()->content_rect(), NULL)) {
1450 return true; 1492 return true;
1493 }
1451 1494
1452 if (LayerClipsSubtree(layer) && 1495 if (LayerClipsSubtree(layer) &&
1453 !PointHitsRect(screen_space_point, layer->ScreenSpaceTransform(), 1496 !PointHitsRect(screen_space_point, layer->ScreenSpaceTransform(),
1454 gfx::Rect(layer->bounds()), NULL)) 1497 gfx::Rect(layer->bounds()), NULL)) {
1455 return true; 1498 return true;
1499 }
1456 } 1500 }
1457 1501
1458 // If we have finished walking all ancestors without having already exited, 1502 // If we have finished walking all ancestors without having already exited,
1459 // then the point is not clipped by any ancestors. 1503 // then the point is not clipped by any ancestors.
1460 return false; 1504 return false;
1461 } 1505 }
1462 1506
1463 static bool PointHitsLayer(const LayerImpl* layer, 1507 static bool PointHitsLayer(const LayerImpl* layer,
1464 const gfx::PointF& screen_space_point, 1508 const gfx::PointF& screen_space_point,
1465 float* distance_to_intersection, 1509 float* distance_to_intersection,
1466 const TransformTree& transform_tree, 1510 const TransformTree& transform_tree,
1511 const ClipTree& clip_tree,
1467 const bool use_property_trees) { 1512 const bool use_property_trees) {
1468 gfx::Rect content_rect(layer->bounds()); 1513 gfx::Rect content_rect(layer->bounds());
1469 if (!PointHitsRect(screen_space_point, layer->ScreenSpaceTransform(), 1514 if (!PointHitsRect(screen_space_point, layer->ScreenSpaceTransform(),
1470 content_rect, distance_to_intersection)) 1515 content_rect, distance_to_intersection))
1471 return false; 1516 return false;
1472 1517
1473 // At this point, we think the point does hit the layer, but we need to walk 1518 // At this point, we think the point does hit the layer, but we need to walk
1474 // up the parents to ensure that the layer was not clipped in such a way 1519 // up the parents to ensure that the layer was not clipped in such a way
1475 // that the hit point actually should not hit the layer. 1520 // that the hit point actually should not hit the layer.
1476 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer, 1521 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer,
1477 transform_tree, use_property_trees)) 1522 transform_tree, clip_tree,
1523 use_property_trees))
1478 return false; 1524 return false;
1479 1525
1480 // Skip the HUD layer. 1526 // Skip the HUD layer.
1481 if (layer == layer->layer_tree_impl()->hud_layer()) 1527 if (layer == layer->layer_tree_impl()->hud_layer())
1482 return false; 1528 return false;
1483 1529
1484 return true; 1530 return true;
1485 } 1531 }
1486 1532
1487 struct FindClosestMatchingLayerDataForRecursion { 1533 struct FindClosestMatchingLayerDataForRecursion {
1488 FindClosestMatchingLayerDataForRecursion() 1534 FindClosestMatchingLayerDataForRecursion()
1489 : closest_match(NULL), 1535 : closest_match(NULL),
1490 closest_distance(-std::numeric_limits<float>::infinity()) {} 1536 closest_distance(-std::numeric_limits<float>::infinity()) {}
1491 LayerImpl* closest_match; 1537 LayerImpl* closest_match;
1492 // Note that the positive z-axis points towards the camera, so bigger means 1538 // Note that the positive z-axis points towards the camera, so bigger means
1493 // closer in this case, counterintuitively. 1539 // closer in this case, counterintuitively.
1494 float closest_distance; 1540 float closest_distance;
1495 }; 1541 };
1496 1542
1497 template <typename Functor> 1543 template <typename Functor>
1498 static void FindClosestMatchingLayer( 1544 static void FindClosestMatchingLayer(
1499 const gfx::PointF& screen_space_point, 1545 const gfx::PointF& screen_space_point,
1500 LayerImpl* layer, 1546 LayerImpl* layer,
1501 const Functor& func, 1547 const Functor& func,
1502 const TransformTree& transform_tree, 1548 const TransformTree& transform_tree,
1549 const ClipTree& clip_tree,
1503 const bool use_property_trees, 1550 const bool use_property_trees,
1504 FindClosestMatchingLayerDataForRecursion* data_for_recursion) { 1551 FindClosestMatchingLayerDataForRecursion* data_for_recursion) {
1505 size_t children_size = layer->children().size(); 1552 size_t children_size = layer->children().size();
1506 for (size_t i = 0; i < children_size; ++i) { 1553 for (size_t i = 0; i < children_size; ++i) {
1507 size_t index = children_size - 1 - i; 1554 size_t index = children_size - 1 - i;
1508 FindClosestMatchingLayer(screen_space_point, layer->children()[index].get(), 1555 FindClosestMatchingLayer(screen_space_point, layer->children()[index].get(),
1509 func, transform_tree, use_property_trees, 1556 func, transform_tree, clip_tree,
1510 data_for_recursion); 1557 use_property_trees, data_for_recursion);
1511 } 1558 }
1512 1559
1513 if (!func(layer)) 1560 if (!func(layer))
1514 return; 1561 return;
1515 1562
1516 float distance_to_intersection = 0.f; 1563 float distance_to_intersection = 0.f;
1517 bool hit = false; 1564 bool hit = false;
1518 if (layer->Is3dSorted()) 1565 if (layer->Is3dSorted())
1519 hit = PointHitsLayer(layer, screen_space_point, &distance_to_intersection, 1566 hit = PointHitsLayer(layer, screen_space_point, &distance_to_intersection,
1520 transform_tree, use_property_trees); 1567 transform_tree, clip_tree, use_property_trees);
1521 else 1568 else
1522 hit = PointHitsLayer(layer, screen_space_point, nullptr, transform_tree, 1569 hit = PointHitsLayer(layer, screen_space_point, nullptr, transform_tree,
1523 use_property_trees); 1570 clip_tree, use_property_trees);
1524 1571
1525 if (!hit) 1572 if (!hit)
1526 return; 1573 return;
1527 1574
1528 bool in_front_of_previous_candidate = 1575 bool in_front_of_previous_candidate =
1529 data_for_recursion->closest_match && 1576 data_for_recursion->closest_match &&
1530 layer->sorting_context_id() == 1577 layer->sorting_context_id() ==
1531 data_for_recursion->closest_match->sorting_context_id() && 1578 data_for_recursion->closest_match->sorting_context_id() &&
1532 distance_to_intersection > data_for_recursion->closest_distance + 1579 distance_to_intersection > data_for_recursion->closest_distance +
1533 std::numeric_limits<float>::epsilon(); 1580 std::numeric_limits<float>::epsilon();
(...skipping 28 matching lines...) Expand all
1562 } 1609 }
1563 }; 1610 };
1564 1611
1565 LayerImpl* LayerTreeImpl::FindFirstScrollingLayerThatIsHitByPoint( 1612 LayerImpl* LayerTreeImpl::FindFirstScrollingLayerThatIsHitByPoint(
1566 const gfx::PointF& screen_space_point) { 1613 const gfx::PointF& screen_space_point) {
1567 FindClosestMatchingLayerDataForRecursion data_for_recursion; 1614 FindClosestMatchingLayerDataForRecursion data_for_recursion;
1568 bool use_property_trees = 1615 bool use_property_trees =
1569 settings().use_property_trees || settings().verify_property_trees; 1616 settings().use_property_trees || settings().verify_property_trees;
1570 FindClosestMatchingLayer( 1617 FindClosestMatchingLayer(
1571 screen_space_point, root_layer(), FindScrollingLayerFunctor(), 1618 screen_space_point, root_layer(), FindScrollingLayerFunctor(),
1572 property_trees_.transform_tree, use_property_trees, &data_for_recursion); 1619 property_trees_.transform_tree, property_trees_.clip_tree,
1620 use_property_trees, &data_for_recursion);
1573 return data_for_recursion.closest_match; 1621 return data_for_recursion.closest_match;
1574 } 1622 }
1575 1623
1576 struct HitTestVisibleScrollableOrTouchableFunctor { 1624 struct HitTestVisibleScrollableOrTouchableFunctor {
1577 bool operator()(LayerImpl* layer) const { 1625 bool operator()(LayerImpl* layer) const {
1578 return layer->IsDrawnRenderSurfaceLayerListMember() || 1626 return layer->IsDrawnRenderSurfaceLayerListMember() ||
1579 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || 1627 ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) ||
1580 !layer->touch_event_handler_region().IsEmpty() || 1628 !layer->touch_event_handler_region().IsEmpty() ||
1581 layer->have_wheel_event_handlers(); 1629 layer->have_wheel_event_handlers();
1582 } 1630 }
1583 }; 1631 };
1584 1632
1585 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( 1633 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint(
1586 const gfx::PointF& screen_space_point) { 1634 const gfx::PointF& screen_space_point) {
1587 if (!root_layer()) 1635 if (!root_layer())
1588 return NULL; 1636 return NULL;
1589 bool update_lcd_text = false; 1637 bool update_lcd_text = false;
1590 if (!UpdateDrawProperties(update_lcd_text)) 1638 if (!UpdateDrawProperties(update_lcd_text))
1591 return NULL; 1639 return NULL;
1592 bool use_property_trees = 1640 bool use_property_trees =
1593 settings().use_property_trees || settings().verify_property_trees; 1641 settings().use_property_trees || settings().verify_property_trees;
1594 FindClosestMatchingLayerDataForRecursion data_for_recursion; 1642 FindClosestMatchingLayerDataForRecursion data_for_recursion;
1595 FindClosestMatchingLayer(screen_space_point, root_layer(), 1643 FindClosestMatchingLayer(screen_space_point, root_layer(),
1596 HitTestVisibleScrollableOrTouchableFunctor(), 1644 HitTestVisibleScrollableOrTouchableFunctor(),
1597 property_trees_.transform_tree, use_property_trees, 1645 property_trees_.transform_tree,
1646 property_trees_.clip_tree, use_property_trees,
1598 &data_for_recursion); 1647 &data_for_recursion);
1599 return data_for_recursion.closest_match; 1648 return data_for_recursion.closest_match;
1600 } 1649 }
1601 1650
1602 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, 1651 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point,
1603 LayerImpl* layer_impl, 1652 LayerImpl* layer_impl,
1604 const TransformTree& transform_tree, 1653 const TransformTree& transform_tree,
1654 const ClipTree& clip_tree,
1605 const bool use_property_trees) { 1655 const bool use_property_trees) {
1606 if (layer_impl->touch_event_handler_region().IsEmpty()) 1656 if (layer_impl->touch_event_handler_region().IsEmpty())
1607 return false; 1657 return false;
1608 1658
1609 if (!PointHitsRegion(screen_space_point, layer_impl->ScreenSpaceTransform(), 1659 if (!PointHitsRegion(screen_space_point, layer_impl->ScreenSpaceTransform(),
1610 layer_impl->touch_event_handler_region())) 1660 layer_impl->touch_event_handler_region()))
1611 return false; 1661 return false;
1612 1662
1613 // At this point, we think the point does hit the touch event handler region 1663 // At this point, we think the point does hit the touch event handler region
1614 // on the layer, but we need to walk up the parents to ensure that the layer 1664 // on the layer, but we need to walk up the parents to ensure that the layer
1615 // was not clipped in such a way that the hit point actually should not hit 1665 // was not clipped in such a way that the hit point actually should not hit
1616 // the layer. 1666 // the layer.
1617 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl, 1667 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl,
1618 transform_tree, use_property_trees)) 1668 transform_tree, clip_tree,
1669 use_property_trees))
1619 return false; 1670 return false;
1620 1671
1621 return true; 1672 return true;
1622 } 1673 }
1623 1674
1624 struct FindWheelEventLayerFunctor { 1675 struct FindWheelEventLayerFunctor {
1625 bool operator()(LayerImpl* layer) const { 1676 bool operator()(LayerImpl* layer) const {
1626 return layer->have_wheel_event_handlers(); 1677 return layer->have_wheel_event_handlers();
1627 } 1678 }
1628 }; 1679 };
1629 1680
1630 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( 1681 LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint(
1631 const gfx::PointF& screen_space_point) { 1682 const gfx::PointF& screen_space_point) {
1632 if (!root_layer()) 1683 if (!root_layer())
1633 return NULL; 1684 return NULL;
1634 bool update_lcd_text = false; 1685 bool update_lcd_text = false;
1635 if (!UpdateDrawProperties(update_lcd_text)) 1686 if (!UpdateDrawProperties(update_lcd_text))
1636 return NULL; 1687 return NULL;
1637 bool use_property_trees = 1688 bool use_property_trees =
1638 settings().use_property_trees || settings().verify_property_trees; 1689 settings().use_property_trees || settings().verify_property_trees;
1639 FindWheelEventLayerFunctor func; 1690 FindWheelEventLayerFunctor func;
1640 FindClosestMatchingLayerDataForRecursion data_for_recursion; 1691 FindClosestMatchingLayerDataForRecursion data_for_recursion;
1641 FindClosestMatchingLayer(screen_space_point, root_layer(), func, 1692 FindClosestMatchingLayer(
1642 property_trees_.transform_tree, use_property_trees, 1693 screen_space_point, root_layer(), func, property_trees_.transform_tree,
1643 &data_for_recursion); 1694 property_trees_.clip_tree, use_property_trees, &data_for_recursion);
1644 return data_for_recursion.closest_match; 1695 return data_for_recursion.closest_match;
1645 } 1696 }
1646 1697
1647 struct FindTouchEventLayerFunctor { 1698 struct FindTouchEventLayerFunctor {
1648 bool operator()(LayerImpl* layer) const { 1699 bool operator()(LayerImpl* layer) const {
1649 return LayerHasTouchEventHandlersAt(screen_space_point, layer, 1700 return LayerHasTouchEventHandlersAt(screen_space_point, layer,
1650 transform_tree, use_property_trees); 1701 transform_tree, clip_tree,
1702 use_property_trees);
1651 } 1703 }
1652 const gfx::PointF screen_space_point; 1704 const gfx::PointF screen_space_point;
1653 const TransformTree& transform_tree; 1705 const TransformTree& transform_tree;
1706 const ClipTree& clip_tree;
1654 const bool use_property_trees; 1707 const bool use_property_trees;
1655 }; 1708 };
1656 1709
1657 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( 1710 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion(
1658 const gfx::PointF& screen_space_point) { 1711 const gfx::PointF& screen_space_point) {
1659 if (!root_layer()) 1712 if (!root_layer())
1660 return NULL; 1713 return NULL;
1661 bool update_lcd_text = false; 1714 bool update_lcd_text = false;
1662 if (!UpdateDrawProperties(update_lcd_text)) 1715 if (!UpdateDrawProperties(update_lcd_text))
1663 return NULL; 1716 return NULL;
1664 bool use_property_trees = 1717 bool use_property_trees =
1665 settings().use_property_trees || settings().verify_property_trees; 1718 settings().use_property_trees || settings().verify_property_trees;
1666 FindTouchEventLayerFunctor func = { 1719 FindTouchEventLayerFunctor func = {
1667 screen_space_point, property_trees_.transform_tree, use_property_trees}; 1720 screen_space_point, property_trees_.transform_tree,
1721 property_trees_.clip_tree, use_property_trees};
1668 FindClosestMatchingLayerDataForRecursion data_for_recursion; 1722 FindClosestMatchingLayerDataForRecursion data_for_recursion;
1669 FindClosestMatchingLayer(screen_space_point, root_layer(), func, 1723 FindClosestMatchingLayer(
1670 property_trees_.transform_tree, use_property_trees, 1724 screen_space_point, root_layer(), func, property_trees_.transform_tree,
1671 &data_for_recursion); 1725 property_trees_.clip_tree, use_property_trees, &data_for_recursion);
1672 return data_for_recursion.closest_match; 1726 return data_for_recursion.closest_match;
1673 } 1727 }
1674 1728
1675 void LayerTreeImpl::RegisterSelection(const LayerSelection& selection) { 1729 void LayerTreeImpl::RegisterSelection(const LayerSelection& selection) {
1676 selection_ = selection; 1730 selection_ = selection;
1677 } 1731 }
1678 1732
1679 static ViewportSelectionBound ComputeViewportSelectionBound( 1733 static ViewportSelectionBound ComputeViewportSelectionBound(
1680 const LayerSelectionBound& layer_bound, 1734 const LayerSelectionBound& layer_bound,
1681 LayerImpl* layer, 1735 LayerImpl* layer,
1682 float device_scale_factor, 1736 float device_scale_factor,
1683 const TransformTree& transform_tree, 1737 const TransformTree& transform_tree,
1738 const ClipTree& clip_tree,
1684 const bool use_property_trees) { 1739 const bool use_property_trees) {
1685 ViewportSelectionBound viewport_bound; 1740 ViewportSelectionBound viewport_bound;
1686 viewport_bound.type = layer_bound.type; 1741 viewport_bound.type = layer_bound.type;
1687 1742
1688 if (!layer || layer_bound.type == SELECTION_BOUND_EMPTY) 1743 if (!layer || layer_bound.type == SELECTION_BOUND_EMPTY)
1689 return viewport_bound; 1744 return viewport_bound;
1690 1745
1691 auto layer_top = gfx::PointF(layer_bound.edge_top); 1746 auto layer_top = gfx::PointF(layer_bound.edge_top);
1692 auto layer_bottom = gfx::PointF(layer_bound.edge_bottom); 1747 auto layer_bottom = gfx::PointF(layer_bound.edge_bottom);
1693 gfx::Transform screen_space_transform = layer->ScreenSpaceTransform(); 1748 gfx::Transform screen_space_transform = layer->ScreenSpaceTransform();
(...skipping 25 matching lines...) Expand all
1719 visibility_offset.Scale(device_scale_factor / visibility_offset.Length()); 1774 visibility_offset.Scale(device_scale_factor / visibility_offset.Length());
1720 gfx::PointF visibility_point = layer_bottom + visibility_offset; 1775 gfx::PointF visibility_point = layer_bottom + visibility_offset;
1721 if (visibility_point.x() <= 0) 1776 if (visibility_point.x() <= 0)
1722 visibility_point.set_x(visibility_point.x() + device_scale_factor); 1777 visibility_point.set_x(visibility_point.x() + device_scale_factor);
1723 visibility_point = 1778 visibility_point =
1724 MathUtil::MapPoint(screen_space_transform, visibility_point, &clipped); 1779 MathUtil::MapPoint(screen_space_transform, visibility_point, &clipped);
1725 1780
1726 float intersect_distance = 0.f; 1781 float intersect_distance = 0.f;
1727 viewport_bound.visible = 1782 viewport_bound.visible =
1728 PointHitsLayer(layer, visibility_point, &intersect_distance, 1783 PointHitsLayer(layer, visibility_point, &intersect_distance,
1729 transform_tree, use_property_trees); 1784 transform_tree, clip_tree, use_property_trees);
1730 1785
1731 return viewport_bound; 1786 return viewport_bound;
1732 } 1787 }
1733 1788
1734 void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) { 1789 void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) {
1735 DCHECK(selection); 1790 DCHECK(selection);
1736 1791
1737 bool use_property_trees = 1792 bool use_property_trees =
1738 settings().use_property_trees || settings().verify_property_trees; 1793 settings().use_property_trees || settings().verify_property_trees;
1739 selection->start = ComputeViewportSelectionBound( 1794 selection->start = ComputeViewportSelectionBound(
1740 selection_.start, 1795 selection_.start,
1741 selection_.start.layer_id ? LayerById(selection_.start.layer_id) : NULL, 1796 selection_.start.layer_id ? LayerById(selection_.start.layer_id) : NULL,
1742 device_scale_factor(), property_trees_.transform_tree, 1797 device_scale_factor(), property_trees_.transform_tree,
1743 use_property_trees); 1798 property_trees_.clip_tree, use_property_trees);
1744 selection->is_editable = selection_.is_editable; 1799 selection->is_editable = selection_.is_editable;
1745 selection->is_empty_text_form_control = selection_.is_empty_text_form_control; 1800 selection->is_empty_text_form_control = selection_.is_empty_text_form_control;
1746 if (selection->start.type == SELECTION_BOUND_CENTER || 1801 if (selection->start.type == SELECTION_BOUND_CENTER ||
1747 selection->start.type == SELECTION_BOUND_EMPTY) { 1802 selection->start.type == SELECTION_BOUND_EMPTY) {
1748 selection->end = selection->start; 1803 selection->end = selection->start;
1749 } else { 1804 } else {
1750 selection->end = ComputeViewportSelectionBound( 1805 selection->end = ComputeViewportSelectionBound(
1751 selection_.end, 1806 selection_.end,
1752 selection_.end.layer_id ? LayerById(selection_.end.layer_id) : NULL, 1807 selection_.end.layer_id ? LayerById(selection_.end.layer_id) : NULL,
1753 device_scale_factor(), property_trees_.transform_tree, 1808 device_scale_factor(), property_trees_.transform_tree,
1754 use_property_trees); 1809 property_trees_.clip_tree, use_property_trees);
1755 } 1810 }
1756 } 1811 }
1757 1812
1758 void LayerTreeImpl::InputScrollAnimationFinished() { 1813 void LayerTreeImpl::InputScrollAnimationFinished() {
1759 layer_tree_host_impl_->ScrollEnd(); 1814 layer_tree_host_impl_->ScrollEnd();
1760 } 1815 }
1761 1816
1762 bool LayerTreeImpl::SmoothnessTakesPriority() const { 1817 bool LayerTreeImpl::SmoothnessTakesPriority() const {
1763 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; 1818 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY;
1764 } 1819 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 const gfx::BoxF& box, 2000 const gfx::BoxF& box,
1946 gfx::BoxF* bounds) const { 2001 gfx::BoxF* bounds) const {
1947 *bounds = gfx::BoxF(); 2002 *bounds = gfx::BoxF();
1948 return layer_tree_host_impl_->animation_host() 2003 return layer_tree_host_impl_->animation_host()
1949 ? layer_tree_host_impl_->animation_host() 2004 ? layer_tree_host_impl_->animation_host()
1950 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) 2005 ->TransformAnimationBoundsForBox(layer->id(), box, bounds)
1951 : true; 2006 : true;
1952 } 2007 }
1953 2008
1954 } // namespace cc 2009 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698