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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 RenderSurfaceType* nearest_ancestor_that_moves_pixels, | 775 RenderSurfaceType* nearest_ancestor_that_moves_pixels, |
776 LayerList* render_surface_layer_list, | 776 LayerList* render_surface_layer_list, |
777 LayerList* layer_list, | 777 LayerList* layer_list, |
778 LayerSorter* layer_sorter, | 778 LayerSorter* layer_sorter, |
779 int max_texture_size, | 779 int max_texture_size, |
780 float device_scale_factor, | 780 float device_scale_factor, |
781 float page_scale_factor, | 781 float page_scale_factor, |
782 LayerType* page_scale_application_layer, | 782 LayerType* page_scale_application_layer, |
783 bool in_subtree_of_page_scale_application_layer, | 783 bool in_subtree_of_page_scale_application_layer, |
784 bool subtree_can_use_lcd_text, | 784 bool subtree_can_use_lcd_text, |
785 gfx::Rect* drawable_content_rect_of_subtree, | 785 gfx::Rect* drawable_content_rect_of_subtree) { |
786 bool update_tile_priorities) { | |
787 // This function computes the new matrix transformations recursively for this | 786 // This function computes the new matrix transformations recursively for this |
788 // layer and all its descendants. It also computes the appropriate render | 787 // layer and all its descendants. It also computes the appropriate render |
789 // surfaces. | 788 // surfaces. |
790 // Some important points to remember: | 789 // Some important points to remember: |
791 // | 790 // |
792 // 0. Here, transforms are notated in Matrix x Vector order, and in words we | 791 // 0. Here, transforms are notated in Matrix x Vector order, and in words we |
793 // describe what the transform does from left to right. | 792 // describe what the transform does from left to right. |
794 // | 793 // |
795 // 1. In our terminology, the "layer origin" refers to the top-left corner of | 794 // 1. In our terminology, the "layer origin" refers to the top-left corner of |
796 // a layer, and the positive Y-axis points downwards. This interpretation is | 795 // a layer, and the positive Y-axis points downwards. This interpretation is |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 nearest_ancestor_that_moves_pixels, | 1274 nearest_ancestor_that_moves_pixels, |
1276 render_surface_layer_list, | 1275 render_surface_layer_list, |
1277 &descendants, | 1276 &descendants, |
1278 layer_sorter, | 1277 layer_sorter, |
1279 max_texture_size, | 1278 max_texture_size, |
1280 device_scale_factor, | 1279 device_scale_factor, |
1281 page_scale_factor, | 1280 page_scale_factor, |
1282 page_scale_application_layer, | 1281 page_scale_application_layer, |
1283 in_subtree_of_page_scale_application_layer, | 1282 in_subtree_of_page_scale_application_layer, |
1284 subtree_can_use_lcd_text, | 1283 subtree_can_use_lcd_text, |
1285 &drawable_content_rect_of_child_subtree, | 1284 &drawable_content_rect_of_child_subtree); |
1286 update_tile_priorities); | |
1287 if (!drawable_content_rect_of_child_subtree.IsEmpty()) { | 1285 if (!drawable_content_rect_of_child_subtree.IsEmpty()) { |
1288 accumulated_drawable_content_rect_of_children.Union( | 1286 accumulated_drawable_content_rect_of_children.Union( |
1289 drawable_content_rect_of_child_subtree); | 1287 drawable_content_rect_of_child_subtree); |
1290 if (child->render_surface()) | 1288 if (child->render_surface()) |
1291 descendants.push_back(child); | 1289 descendants.push_back(child); |
1292 } | 1290 } |
1293 } | 1291 } |
1294 | 1292 |
1295 if (layer->render_surface() && !IsRootLayer(layer) && | 1293 if (layer->render_surface() && !IsRootLayer(layer) && |
1296 layer->render_surface()->layer_list().empty()) { | 1294 layer->render_surface()->layer_list().empty()) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 // Compute the replica's "screen_space_transform" that maps from the | 1408 // Compute the replica's "screen_space_transform" that maps from the |
1411 // replica's origin space to the screen's origin space. | 1409 // replica's origin space to the screen's origin space. |
1412 gfx::Transform replica_screen_space_transform = | 1410 gfx::Transform replica_screen_space_transform = |
1413 layer->render_surface()->screen_space_transform() * | 1411 layer->render_surface()->screen_space_transform() * |
1414 surface_origin_to_replica_origin_transform; | 1412 surface_origin_to_replica_origin_transform; |
1415 render_surface->SetReplicaScreenSpaceTransform( | 1413 render_surface->SetReplicaScreenSpaceTransform( |
1416 replica_screen_space_transform); | 1414 replica_screen_space_transform); |
1417 } | 1415 } |
1418 } | 1416 } |
1419 | 1417 |
1420 if (update_tile_priorities) | 1418 UpdateTilePrioritiesForLayer(layer); |
1421 UpdateTilePrioritiesForLayer(layer); | |
1422 | 1419 |
1423 // If neither this layer nor any of its children were added, early out. | 1420 // If neither this layer nor any of its children were added, early out. |
1424 if (sorting_start_index == descendants.size()) | 1421 if (sorting_start_index == descendants.size()) |
1425 return; | 1422 return; |
1426 | 1423 |
1427 // If preserves-3d then sort all the descendants in 3D so that they can be | 1424 // If preserves-3d then sort all the descendants in 3D so that they can be |
1428 // drawn from back to front. If the preserves-3d property is also set on the | 1425 // drawn from back to front. If the preserves-3d property is also set on the |
1429 // parent then skip the sorting as the parent will sort all the descendants | 1426 // parent then skip the sorting as the parent will sort all the descendants |
1430 // anyway. | 1427 // anyway. |
1431 if (layer_sorter && descendants.size() && layer->preserves_3d() && | 1428 if (layer_sorter && descendants.size() && layer->preserves_3d() && |
(...skipping 30 matching lines...) Expand all Loading... |
1462 gfx::Rect total_drawable_content_rect; | 1459 gfx::Rect total_drawable_content_rect; |
1463 gfx::Transform identity_matrix; | 1460 gfx::Transform identity_matrix; |
1464 gfx::Transform device_scale_transform; | 1461 gfx::Transform device_scale_transform; |
1465 device_scale_transform.Scale(device_scale_factor, device_scale_factor); | 1462 device_scale_transform.Scale(device_scale_factor, device_scale_factor); |
1466 LayerList dummy_layer_list; | 1463 LayerList dummy_layer_list; |
1467 | 1464 |
1468 // The root layer's render_surface should receive the device viewport as the | 1465 // The root layer's render_surface should receive the device viewport as the |
1469 // initial clip rect. | 1466 // initial clip rect. |
1470 bool subtree_should_be_clipped = true; | 1467 bool subtree_should_be_clipped = true; |
1471 gfx::Rect device_viewport_rect(device_viewport_size); | 1468 gfx::Rect device_viewport_rect(device_viewport_size); |
1472 bool update_tile_priorities = false; | |
1473 bool in_subtree_of_page_scale_application_layer = false; | 1469 bool in_subtree_of_page_scale_application_layer = false; |
1474 | 1470 |
1475 // This function should have received a root layer. | 1471 // This function should have received a root layer. |
1476 DCHECK(IsRootLayer(root_layer)); | 1472 DCHECK(IsRootLayer(root_layer)); |
1477 | 1473 |
1478 PreCalculateMetaInformation<Layer>(root_layer); | 1474 PreCalculateMetaInformation<Layer>(root_layer); |
1479 CalculateDrawPropertiesInternal<Layer, LayerList, RenderSurface>( | 1475 CalculateDrawPropertiesInternal<Layer, LayerList, RenderSurface>( |
1480 root_layer, | 1476 root_layer, |
1481 device_scale_transform, | 1477 device_scale_transform, |
1482 identity_matrix, | 1478 identity_matrix, |
1483 identity_matrix, | 1479 identity_matrix, |
1484 NULL, | 1480 NULL, |
1485 device_viewport_rect, | 1481 device_viewport_rect, |
1486 device_viewport_rect, | 1482 device_viewport_rect, |
1487 subtree_should_be_clipped, | 1483 subtree_should_be_clipped, |
1488 NULL, | 1484 NULL, |
1489 render_surface_layer_list, | 1485 render_surface_layer_list, |
1490 &dummy_layer_list, | 1486 &dummy_layer_list, |
1491 NULL, | 1487 NULL, |
1492 max_texture_size, | 1488 max_texture_size, |
1493 device_scale_factor, | 1489 device_scale_factor, |
1494 page_scale_factor, | 1490 page_scale_factor, |
1495 page_scale_application_layer, | 1491 page_scale_application_layer, |
1496 in_subtree_of_page_scale_application_layer, | 1492 in_subtree_of_page_scale_application_layer, |
1497 can_use_lcd_text, | 1493 can_use_lcd_text, |
1498 &total_drawable_content_rect, | 1494 &total_drawable_content_rect); |
1499 update_tile_priorities); | |
1500 | 1495 |
1501 // The dummy layer list should not have been used. | 1496 // The dummy layer list should not have been used. |
1502 DCHECK_EQ(0u, dummy_layer_list.size()); | 1497 DCHECK_EQ(0u, dummy_layer_list.size()); |
1503 // A root layer render_surface should always exist after | 1498 // A root layer render_surface should always exist after |
1504 // CalculateDrawProperties. | 1499 // CalculateDrawProperties. |
1505 DCHECK(root_layer->render_surface()); | 1500 DCHECK(root_layer->render_surface()); |
1506 } | 1501 } |
1507 | 1502 |
1508 void LayerTreeHostCommon::CalculateDrawProperties( | 1503 void LayerTreeHostCommon::CalculateDrawProperties( |
1509 LayerImpl* root_layer, | 1504 LayerImpl* root_layer, |
1510 gfx::Size device_viewport_size, | 1505 gfx::Size device_viewport_size, |
1511 float device_scale_factor, | 1506 float device_scale_factor, |
1512 float page_scale_factor, | 1507 float page_scale_factor, |
1513 LayerImpl* page_scale_application_layer, | 1508 LayerImpl* page_scale_application_layer, |
1514 int max_texture_size, | 1509 int max_texture_size, |
1515 bool can_use_lcd_text, | 1510 bool can_use_lcd_text, |
1516 LayerImplList* render_surface_layer_list, | 1511 LayerImplList* render_surface_layer_list) { |
1517 bool update_tile_priorities) { | |
1518 gfx::Rect total_drawable_content_rect; | 1512 gfx::Rect total_drawable_content_rect; |
1519 gfx::Transform identity_matrix; | 1513 gfx::Transform identity_matrix; |
1520 gfx::Transform device_scale_transform; | 1514 gfx::Transform device_scale_transform; |
1521 device_scale_transform.Scale(device_scale_factor, device_scale_factor); | 1515 device_scale_transform.Scale(device_scale_factor, device_scale_factor); |
1522 LayerImplList dummy_layer_list; | 1516 LayerImplList dummy_layer_list; |
1523 LayerSorter layer_sorter; | 1517 LayerSorter layer_sorter; |
1524 | 1518 |
1525 // The root layer's render_surface should receive the device viewport as the | 1519 // The root layer's render_surface should receive the device viewport as the |
1526 // initial clip rect. | 1520 // initial clip rect. |
1527 bool subtree_should_be_clipped = true; | 1521 bool subtree_should_be_clipped = true; |
(...skipping 18 matching lines...) Expand all Loading... |
1546 NULL, | 1540 NULL, |
1547 render_surface_layer_list, | 1541 render_surface_layer_list, |
1548 &dummy_layer_list, | 1542 &dummy_layer_list, |
1549 &layer_sorter, | 1543 &layer_sorter, |
1550 max_texture_size, | 1544 max_texture_size, |
1551 device_scale_factor, | 1545 device_scale_factor, |
1552 page_scale_factor, | 1546 page_scale_factor, |
1553 page_scale_application_layer, | 1547 page_scale_application_layer, |
1554 in_subtree_of_page_scale_application_layer, | 1548 in_subtree_of_page_scale_application_layer, |
1555 can_use_lcd_text, | 1549 can_use_lcd_text, |
1556 &total_drawable_content_rect, | 1550 &total_drawable_content_rect); |
1557 update_tile_priorities); | |
1558 | 1551 |
1559 // The dummy layer list should not have been used. | 1552 // The dummy layer list should not have been used. |
1560 DCHECK_EQ(0u, dummy_layer_list.size()); | 1553 DCHECK_EQ(0u, dummy_layer_list.size()); |
1561 // A root layer render_surface should always exist after | 1554 // A root layer render_surface should always exist after |
1562 // CalculateDrawProperties. | 1555 // CalculateDrawProperties. |
1563 DCHECK(root_layer->render_surface()); | 1556 DCHECK(root_layer->render_surface()); |
1564 } | 1557 } |
1565 | 1558 |
1566 static bool PointHitsRect( | 1559 static bool PointHitsRect( |
1567 gfx::PointF screen_space_point, | 1560 gfx::PointF screen_space_point, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 // At this point, we think the point does hit the touch event handler region | 1741 // At this point, we think the point does hit the touch event handler region |
1749 // on the layer, but we need to walk up the parents to ensure that the layer | 1742 // on the layer, but we need to walk up the parents to ensure that the layer |
1750 // was not clipped in such a way that the hit point actually should not hit | 1743 // was not clipped in such a way that the hit point actually should not hit |
1751 // the layer. | 1744 // the layer. |
1752 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 1745 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
1753 return false; | 1746 return false; |
1754 | 1747 |
1755 return true; | 1748 return true; |
1756 } | 1749 } |
1757 } // namespace cc | 1750 } // namespace cc |
OLD | NEW |