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

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