OLD | NEW |
---|---|
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_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 } | 791 } |
792 | 792 |
793 // Recursively walks the layer tree starting at the given node and computes all | 793 // Recursively walks the layer tree starting at the given node and computes all |
794 // the necessary transformations, clip rects, render surfaces, etc. | 794 // the necessary transformations, clip rects, render surfaces, etc. |
795 template <typename LayerType, typename LayerList, typename RenderSurfaceType> | 795 template <typename LayerType, typename LayerList, typename RenderSurfaceType> |
796 static void CalculateDrawPropertiesInternal( | 796 static void CalculateDrawPropertiesInternal( |
797 LayerType* layer, | 797 LayerType* layer, |
798 const gfx::Transform& parent_matrix, | 798 const gfx::Transform& parent_matrix, |
799 const gfx::Transform& full_hierarchy_matrix, | 799 const gfx::Transform& full_hierarchy_matrix, |
800 const gfx::Transform& current_scroll_compensation_matrix, | 800 const gfx::Transform& current_scroll_compensation_matrix, |
801 const gfx::Transform& next_sublayer_matrix, | |
enne (OOO)
2013/05/29 20:34:12
I'm always skeptical about adding more parameters
| |
801 LayerType* current_fixed_container, | 802 LayerType* current_fixed_container, |
802 gfx::Rect clip_rect_from_ancestor, | 803 gfx::Rect clip_rect_from_ancestor, |
803 gfx::Rect clip_rect_from_ancestor_in_descendant_space, | 804 gfx::Rect clip_rect_from_ancestor_in_descendant_space, |
804 bool ancestor_clips_subtree, | 805 bool ancestor_clips_subtree, |
805 RenderSurfaceType* nearest_ancestor_that_moves_pixels, | 806 RenderSurfaceType* nearest_ancestor_that_moves_pixels, |
806 LayerList* render_surface_layer_list, | 807 LayerList* render_surface_layer_list, |
807 LayerList* layer_list, | 808 LayerList* layer_list, |
808 LayerSorter* layer_sorter, | 809 LayerSorter* layer_sorter, |
809 int max_texture_size, | 810 int max_texture_size, |
810 float device_scale_factor, | 811 float device_scale_factor, |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1304 | 1305 |
1305 // Apply the sublayer transform at the anchor point of the layer. | 1306 // Apply the sublayer transform at the anchor point of the layer. |
1306 if (!layer->sublayer_transform().IsIdentity()) { | 1307 if (!layer->sublayer_transform().IsIdentity()) { |
1307 sublayer_matrix.Translate(layer->anchor_point().x() * bounds.width(), | 1308 sublayer_matrix.Translate(layer->anchor_point().x() * bounds.width(), |
1308 layer->anchor_point().y() * bounds.height()); | 1309 layer->anchor_point().y() * bounds.height()); |
1309 sublayer_matrix.PreconcatTransform(layer->sublayer_transform()); | 1310 sublayer_matrix.PreconcatTransform(layer->sublayer_transform()); |
1310 sublayer_matrix.Translate(-layer->anchor_point().x() * bounds.width(), | 1311 sublayer_matrix.Translate(-layer->anchor_point().x() * bounds.width(), |
1311 -layer->anchor_point().y() * bounds.height()); | 1312 -layer->anchor_point().y() * bounds.height()); |
1312 } | 1313 } |
1313 | 1314 |
1315 sublayer_matrix.PreconcatTransform(next_sublayer_matrix); | |
1316 | |
1314 LayerList& descendants = | 1317 LayerList& descendants = |
1315 (layer->render_surface() ? layer->render_surface()->layer_list() | 1318 (layer->render_surface() ? layer->render_surface()->layer_list() |
1316 : *layer_list); | 1319 : *layer_list); |
1317 | 1320 |
1318 // Any layers that are appended after this point are in the layer's subtree | 1321 // Any layers that are appended after this point are in the layer's subtree |
1319 // and should be included in the sorting process. | 1322 // and should be included in the sorting process. |
1320 size_t sorting_start_index = descendants.size(); | 1323 size_t sorting_start_index = descendants.size(); |
1321 | 1324 |
1322 if (!LayerShouldBeSkipped(layer)) | 1325 if (!LayerShouldBeSkipped(layer)) |
1323 descendants.push_back(layer); | 1326 descendants.push_back(layer); |
1324 | 1327 |
1325 gfx::Transform next_scroll_compensation_matrix = | 1328 gfx::Transform next_scroll_compensation_matrix = |
1326 ComputeScrollCompensationMatrixForChildren( | 1329 ComputeScrollCompensationMatrixForChildren( |
1327 layer, | 1330 layer, |
1328 page_scale_factor_for_transforms, | 1331 page_scale_factor_for_transforms, |
1329 parent_matrix, | 1332 parent_matrix, |
1330 current_scroll_compensation_matrix); | 1333 current_scroll_compensation_matrix); |
1331 LayerType* next_fixed_container = | 1334 LayerType* next_fixed_container = |
1332 layer->IsContainerForFixedPositionLayers() ? | 1335 layer->IsContainerForFixedPositionLayers() ? |
1333 layer : current_fixed_container; | 1336 layer : current_fixed_container; |
1334 | 1337 |
1335 gfx::Rect accumulated_drawable_content_rect_of_children; | 1338 gfx::Rect accumulated_drawable_content_rect_of_children; |
1336 for (size_t i = 0; i < layer->children().size(); ++i) { | 1339 for (size_t i = 0; i < layer->children().size(); ++i) { |
1337 LayerType* child = | 1340 LayerType* child = |
1338 LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i); | 1341 LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i); |
1339 gfx::Rect drawable_content_rect_of_child_subtree; | 1342 gfx::Rect drawable_content_rect_of_child_subtree; |
1343 gfx::Transform identity_matrix; | |
1340 CalculateDrawPropertiesInternal<LayerType, LayerList, RenderSurfaceType>( | 1344 CalculateDrawPropertiesInternal<LayerType, LayerList, RenderSurfaceType>( |
1341 child, | 1345 child, |
1342 sublayer_matrix, | 1346 sublayer_matrix, |
1343 next_hierarchy_matrix, | 1347 next_hierarchy_matrix, |
1344 next_scroll_compensation_matrix, | 1348 next_scroll_compensation_matrix, |
1349 identity_matrix, | |
1345 next_fixed_container, | 1350 next_fixed_container, |
1346 clip_rect_for_subtree, | 1351 clip_rect_for_subtree, |
1347 clip_rect_for_subtree_in_descendant_space, | 1352 clip_rect_for_subtree_in_descendant_space, |
1348 subtree_should_be_clipped, | 1353 subtree_should_be_clipped, |
1349 nearest_ancestor_that_moves_pixels, | 1354 nearest_ancestor_that_moves_pixels, |
1350 render_surface_layer_list, | 1355 render_surface_layer_list, |
1351 &descendants, | 1356 &descendants, |
1352 layer_sorter, | 1357 layer_sorter, |
1353 max_texture_size, | 1358 max_texture_size, |
1354 device_scale_factor, | 1359 device_scale_factor, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1544 bool subtree_should_be_clipped = true; | 1549 bool subtree_should_be_clipped = true; |
1545 gfx::Rect device_viewport_rect(device_viewport_size); | 1550 gfx::Rect device_viewport_rect(device_viewport_size); |
1546 bool in_subtree_of_page_scale_application_layer = false; | 1551 bool in_subtree_of_page_scale_application_layer = false; |
1547 | 1552 |
1548 // This function should have received a root layer. | 1553 // This function should have received a root layer. |
1549 DCHECK(IsRootLayer(root_layer)); | 1554 DCHECK(IsRootLayer(root_layer)); |
1550 | 1555 |
1551 PreCalculateMetaInformation<Layer>(root_layer); | 1556 PreCalculateMetaInformation<Layer>(root_layer); |
1552 CalculateDrawPropertiesInternal<Layer, LayerList, RenderSurface>( | 1557 CalculateDrawPropertiesInternal<Layer, LayerList, RenderSurface>( |
1553 root_layer, | 1558 root_layer, |
1554 device_scale_transform, | |
1555 identity_matrix, | 1559 identity_matrix, |
1556 identity_matrix, | 1560 identity_matrix, |
1561 identity_matrix, | |
1562 device_scale_transform, | |
1557 NULL, | 1563 NULL, |
1558 device_viewport_rect, | 1564 device_viewport_rect, |
1559 device_viewport_rect, | 1565 device_viewport_rect, |
1560 subtree_should_be_clipped, | 1566 subtree_should_be_clipped, |
1561 NULL, | 1567 NULL, |
1562 render_surface_layer_list, | 1568 render_surface_layer_list, |
1563 &dummy_layer_list, | 1569 &dummy_layer_list, |
1564 NULL, | 1570 NULL, |
1565 max_texture_size, | 1571 max_texture_size, |
1566 device_scale_factor, | 1572 device_scale_factor, |
1567 page_scale_factor, | 1573 page_scale_factor, |
1568 page_scale_application_layer, | 1574 page_scale_application_layer, |
1569 in_subtree_of_page_scale_application_layer, | 1575 in_subtree_of_page_scale_application_layer, |
1570 can_use_lcd_text, | 1576 can_use_lcd_text, |
1571 can_adjust_raster_scales, | 1577 can_adjust_raster_scales, |
1572 &total_drawable_content_rect); | 1578 &total_drawable_content_rect); |
1573 | 1579 |
1574 // The dummy layer list should not have been used. | 1580 // The dummy layer list should not have been used. |
1575 DCHECK_EQ(0u, dummy_layer_list.size()); | 1581 DCHECK_EQ(0u, dummy_layer_list.size()); |
1576 // A root layer render_surface should always exist after | 1582 // A root layer render_surface should always exist after |
1577 // CalculateDrawProperties. | 1583 // CalculateDrawProperties. |
1578 DCHECK(root_layer->render_surface()); | 1584 DCHECK(root_layer->render_surface()); |
1579 } | 1585 } |
1580 | 1586 |
1581 void LayerTreeHostCommon::CalculateDrawProperties( | 1587 void LayerTreeHostCommon::CalculateDrawProperties( |
1582 LayerImpl* root_layer, | 1588 LayerImpl* root_layer, |
1583 gfx::Size device_viewport_size, | 1589 gfx::Size device_viewport_size, |
1590 const gfx::Transform& device_transform, | |
1584 float device_scale_factor, | 1591 float device_scale_factor, |
1585 float page_scale_factor, | 1592 float page_scale_factor, |
1586 LayerImpl* page_scale_application_layer, | 1593 LayerImpl* page_scale_application_layer, |
1587 int max_texture_size, | 1594 int max_texture_size, |
1588 bool can_use_lcd_text, | 1595 bool can_use_lcd_text, |
1589 bool can_adjust_raster_scales, | 1596 bool can_adjust_raster_scales, |
1590 LayerImplList* render_surface_layer_list) { | 1597 LayerImplList* render_surface_layer_list) { |
1591 gfx::Rect total_drawable_content_rect; | 1598 gfx::Rect total_drawable_content_rect; |
1592 gfx::Transform identity_matrix; | 1599 gfx::Transform identity_matrix; |
1593 gfx::Transform device_scale_transform; | |
1594 device_scale_transform.Scale(device_scale_factor, device_scale_factor); | |
1595 LayerImplList dummy_layer_list; | 1600 LayerImplList dummy_layer_list; |
1596 LayerSorter layer_sorter; | 1601 LayerSorter layer_sorter; |
1597 | 1602 |
1598 // The root layer's render_surface should receive the device viewport as the | 1603 // The root layer's render_surface should receive the device viewport as the |
1599 // initial clip rect. | 1604 // initial clip rect. |
1600 bool subtree_should_be_clipped = true; | 1605 bool subtree_should_be_clipped = true; |
1601 gfx::Rect device_viewport_rect(device_viewport_size); | 1606 gfx::Rect device_viewport_rect(device_viewport_size); |
1602 bool in_subtree_of_page_scale_application_layer = false; | 1607 bool in_subtree_of_page_scale_application_layer = false; |
1603 | 1608 |
1604 // This function should have received a root layer. | 1609 // This function should have received a root layer. |
1605 DCHECK(IsRootLayer(root_layer)); | 1610 DCHECK(IsRootLayer(root_layer)); |
1606 | 1611 |
1607 PreCalculateMetaInformation<LayerImpl>(root_layer); | 1612 PreCalculateMetaInformation<LayerImpl>(root_layer); |
1608 CalculateDrawPropertiesInternal<LayerImpl, | 1613 CalculateDrawPropertiesInternal<LayerImpl, |
1609 LayerImplList, | 1614 LayerImplList, |
1610 RenderSurfaceImpl>( | 1615 RenderSurfaceImpl>( |
1611 root_layer, | 1616 root_layer, |
1612 device_scale_transform, | |
1613 identity_matrix, | 1617 identity_matrix, |
1614 identity_matrix, | 1618 identity_matrix, |
1619 identity_matrix, | |
1620 device_transform, | |
1615 NULL, | 1621 NULL, |
1616 device_viewport_rect, | 1622 device_viewport_rect, |
1617 device_viewport_rect, | 1623 device_viewport_rect, |
1618 subtree_should_be_clipped, | 1624 subtree_should_be_clipped, |
1619 NULL, | 1625 NULL, |
1620 render_surface_layer_list, | 1626 render_surface_layer_list, |
1621 &dummy_layer_list, | 1627 &dummy_layer_list, |
1622 &layer_sorter, | 1628 &layer_sorter, |
1623 max_texture_size, | 1629 max_texture_size, |
1624 device_scale_factor, | 1630 device_scale_factor, |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1821 // At this point, we think the point does hit the touch event handler region | 1827 // At this point, we think the point does hit the touch event handler region |
1822 // on the layer, but we need to walk up the parents to ensure that the layer | 1828 // on the layer, but we need to walk up the parents to ensure that the layer |
1823 // was not clipped in such a way that the hit point actually should not hit | 1829 // was not clipped in such a way that the hit point actually should not hit |
1824 // the layer. | 1830 // the layer. |
1825 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 1831 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
1826 return false; | 1832 return false; |
1827 | 1833 |
1828 return true; | 1834 return true; |
1829 } | 1835 } |
1830 } // namespace cc | 1836 } // namespace cc |
OLD | NEW |