| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 // Mask layers don't get this call, so explicitly update them so they can | 261 // Mask layers don't get this call, so explicitly update them so they can |
| 262 // kick off tile rasterization. | 262 // kick off tile rasterization. |
| 263 if (layer->mask_layer()) | 263 if (layer->mask_layer()) |
| 264 layer->mask_layer()->UpdateTilePriorities(); | 264 layer->mask_layer()->UpdateTilePriorities(); |
| 265 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) | 265 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) |
| 266 layer->replica_layer()->mask_layer()->UpdateTilePriorities(); | 266 layer->replica_layer()->mask_layer()->UpdateTilePriorities(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 static inline void UpdateTilePrioritiesForLayer(Layer* layer) {} | 269 static inline void UpdateTilePrioritiesForLayer(Layer* layer) {} |
| 270 | 270 |
| 271 static inline void PrepareToUpdateLayer(LayerImpl* layer) {} |
| 272 |
| 273 static inline void PrepareToUpdateLayer(Layer* layer) { |
| 274 layer->PrepareToUpdate(); |
| 275 |
| 276 if (layer->mask_layer()) |
| 277 layer->mask_layer()->PrepareToUpdate(); |
| 278 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) |
| 279 layer->replica_layer()->mask_layer()->PrepareToUpdate(); |
| 280 } |
| 281 |
| 271 template <typename LayerType> | 282 template <typename LayerType> |
| 272 static bool SubtreeShouldRenderToSeparateSurface( | 283 static bool SubtreeShouldRenderToSeparateSurface( |
| 273 LayerType* layer, | 284 LayerType* layer, |
| 274 bool axis_aligned_with_respect_to_parent) { | 285 bool axis_aligned_with_respect_to_parent) { |
| 275 // | 286 // |
| 276 // A layer and its descendants should render onto a new RenderSurfaceImpl if | 287 // A layer and its descendants should render onto a new RenderSurfaceImpl if |
| 277 // any of these rules hold: | 288 // any of these rules hold: |
| 278 // | 289 // |
| 279 | 290 |
| 280 // The root layer should always have a render_surface. | 291 // The root layer should always have a render_surface. |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 bool ancestor_clips_subtree, | 771 bool ancestor_clips_subtree, |
| 761 RenderSurfaceType* nearest_ancestor_that_moves_pixels, | 772 RenderSurfaceType* nearest_ancestor_that_moves_pixels, |
| 762 LayerList* render_surface_layer_list, | 773 LayerList* render_surface_layer_list, |
| 763 LayerList* layer_list, | 774 LayerList* layer_list, |
| 764 LayerSorter* layer_sorter, | 775 LayerSorter* layer_sorter, |
| 765 int max_texture_size, | 776 int max_texture_size, |
| 766 float device_scale_factor, | 777 float device_scale_factor, |
| 767 float page_scale_factor, | 778 float page_scale_factor, |
| 768 bool subtree_can_use_lcd_text, | 779 bool subtree_can_use_lcd_text, |
| 769 gfx::Rect* drawable_content_rect_of_subtree, | 780 gfx::Rect* drawable_content_rect_of_subtree, |
| 770 bool update_tile_priorities) { | 781 bool update_tile_priorities, |
| 782 bool prepare_to_update) { |
| 771 // This function computes the new matrix transformations recursively for this | 783 // This function computes the new matrix transformations recursively for this |
| 772 // layer and all its descendants. It also computes the appropriate render | 784 // layer and all its descendants. It also computes the appropriate render |
| 773 // surfaces. | 785 // surfaces. |
| 774 // Some important points to remember: | 786 // Some important points to remember: |
| 775 // | 787 // |
| 776 // 0. Here, transforms are notated in Matrix x Vector order, and in words we | 788 // 0. Here, transforms are notated in Matrix x Vector order, and in words we |
| 777 // describe what the transform does from left to right. | 789 // describe what the transform does from left to right. |
| 778 // | 790 // |
| 779 // 1. In our terminology, the "layer origin" refers to the top-left corner of | 791 // 1. In our terminology, the "layer origin" refers to the top-left corner of |
| 780 // a layer, and the positive Y-axis points downwards. This interpretation is | 792 // a layer, and the positive Y-axis points downwards. This interpretation is |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 subtree_should_be_clipped, | 1251 subtree_should_be_clipped, |
| 1240 nearest_ancestor_that_moves_pixels, | 1252 nearest_ancestor_that_moves_pixels, |
| 1241 render_surface_layer_list, | 1253 render_surface_layer_list, |
| 1242 &descendants, | 1254 &descendants, |
| 1243 layer_sorter, | 1255 layer_sorter, |
| 1244 max_texture_size, | 1256 max_texture_size, |
| 1245 device_scale_factor, | 1257 device_scale_factor, |
| 1246 page_scale_factor, | 1258 page_scale_factor, |
| 1247 subtree_can_use_lcd_text, | 1259 subtree_can_use_lcd_text, |
| 1248 &drawable_content_rect_of_child_subtree, | 1260 &drawable_content_rect_of_child_subtree, |
| 1249 update_tile_priorities); | 1261 update_tile_priorities, |
| 1262 prepare_to_update); |
| 1250 if (!drawable_content_rect_of_child_subtree.IsEmpty()) { | 1263 if (!drawable_content_rect_of_child_subtree.IsEmpty()) { |
| 1251 accumulated_drawable_content_rect_of_children.Union( | 1264 accumulated_drawable_content_rect_of_children.Union( |
| 1252 drawable_content_rect_of_child_subtree); | 1265 drawable_content_rect_of_child_subtree); |
| 1253 if (child->render_surface()) | 1266 if (child->render_surface()) |
| 1254 descendants.push_back(child); | 1267 descendants.push_back(child); |
| 1255 } | 1268 } |
| 1256 } | 1269 } |
| 1257 | 1270 |
| 1258 if (layer->render_surface() && !IsRootLayer(layer) && | 1271 if (layer->render_surface() && !IsRootLayer(layer) && |
| 1259 layer->render_surface()->layer_list().empty()) { | 1272 layer->render_surface()->layer_list().empty()) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 *drawable_content_rect_of_subtree = | 1415 *drawable_content_rect_of_subtree = |
| 1403 gfx::ToEnclosingRect(layer->render_surface()->DrawableContentRect()); | 1416 gfx::ToEnclosingRect(layer->render_surface()->DrawableContentRect()); |
| 1404 } else { | 1417 } else { |
| 1405 *drawable_content_rect_of_subtree = local_drawable_content_rect_of_subtree; | 1418 *drawable_content_rect_of_subtree = local_drawable_content_rect_of_subtree; |
| 1406 } | 1419 } |
| 1407 | 1420 |
| 1408 if (layer->HasContributingDelegatedRenderPasses()) { | 1421 if (layer->HasContributingDelegatedRenderPasses()) { |
| 1409 layer->render_target()->render_surface()-> | 1422 layer->render_target()->render_surface()-> |
| 1410 AddContributingDelegatedRenderPassLayer(layer); | 1423 AddContributingDelegatedRenderPassLayer(layer); |
| 1411 } | 1424 } |
| 1425 |
| 1426 if (prepare_to_update) |
| 1427 PrepareToUpdateLayer(layer); |
| 1412 } | 1428 } |
| 1413 | 1429 |
| 1414 void LayerTreeHostCommon::CalculateDrawProperties( | 1430 void LayerTreeHostCommon::CalculateDrawProperties( |
| 1415 Layer* root_layer, | 1431 Layer* root_layer, |
| 1416 gfx::Size device_viewport_size, | 1432 gfx::Size device_viewport_size, |
| 1417 float device_scale_factor, | 1433 float device_scale_factor, |
| 1418 float page_scale_factor, | 1434 float page_scale_factor, |
| 1419 int max_texture_size, | 1435 int max_texture_size, |
| 1420 bool can_use_lcd_text, | 1436 bool can_use_lcd_text, |
| 1421 LayerList* render_surface_layer_list) { | 1437 LayerList* render_surface_layer_list) { |
| 1422 gfx::Rect total_drawable_content_rect; | 1438 gfx::Rect total_drawable_content_rect; |
| 1423 gfx::Transform identity_matrix; | 1439 gfx::Transform identity_matrix; |
| 1424 gfx::Transform device_scale_transform; | 1440 gfx::Transform device_scale_transform; |
| 1425 device_scale_transform.Scale(device_scale_factor, device_scale_factor); | 1441 device_scale_transform.Scale(device_scale_factor, device_scale_factor); |
| 1426 LayerList dummy_layer_list; | 1442 LayerList dummy_layer_list; |
| 1427 | 1443 |
| 1428 // The root layer's render_surface should receive the device viewport as the | 1444 // The root layer's render_surface should receive the device viewport as the |
| 1429 // initial clip rect. | 1445 // initial clip rect. |
| 1430 bool subtree_should_be_clipped = true; | 1446 bool subtree_should_be_clipped = true; |
| 1431 gfx::Rect device_viewport_rect(device_viewport_size); | 1447 gfx::Rect device_viewport_rect(device_viewport_size); |
| 1432 bool update_tile_priorities = false; | 1448 bool update_tile_priorities = false; |
| 1449 bool prepare_to_update = true; |
| 1433 | 1450 |
| 1434 // This function should have received a root layer. | 1451 // This function should have received a root layer. |
| 1435 DCHECK(IsRootLayer(root_layer)); | 1452 DCHECK(IsRootLayer(root_layer)); |
| 1436 | 1453 |
| 1437 PreCalculateMetaInformation<Layer>(root_layer); | 1454 PreCalculateMetaInformation<Layer>(root_layer); |
| 1438 CalculateDrawPropertiesInternal<Layer, | 1455 CalculateDrawPropertiesInternal<Layer, |
| 1439 LayerList, | 1456 LayerList, |
| 1440 RenderSurface>(root_layer, | 1457 RenderSurface>(root_layer, |
| 1441 device_scale_transform, | 1458 device_scale_transform, |
| 1442 identity_matrix, | 1459 identity_matrix, |
| 1443 identity_matrix, | 1460 identity_matrix, |
| 1444 NULL, | 1461 NULL, |
| 1445 device_viewport_rect, | 1462 device_viewport_rect, |
| 1446 device_viewport_rect, | 1463 device_viewport_rect, |
| 1447 subtree_should_be_clipped, | 1464 subtree_should_be_clipped, |
| 1448 NULL, | 1465 NULL, |
| 1449 render_surface_layer_list, | 1466 render_surface_layer_list, |
| 1450 &dummy_layer_list, | 1467 &dummy_layer_list, |
| 1451 NULL, | 1468 NULL, |
| 1452 max_texture_size, | 1469 max_texture_size, |
| 1453 device_scale_factor, | 1470 device_scale_factor, |
| 1454 page_scale_factor, | 1471 page_scale_factor, |
| 1455 can_use_lcd_text, | 1472 can_use_lcd_text, |
| 1456 &total_drawable_content_rect, | 1473 &total_drawable_content_rect, |
| 1457 update_tile_priorities); | 1474 update_tile_priorities, |
| 1475 prepare_to_update); |
| 1458 | 1476 |
| 1459 // The dummy layer list should not have been used. | 1477 // The dummy layer list should not have been used. |
| 1460 DCHECK_EQ(0u, dummy_layer_list.size()); | 1478 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 1461 // A root layer render_surface should always exist after | 1479 // A root layer render_surface should always exist after |
| 1462 // CalculateDrawProperties. | 1480 // CalculateDrawProperties. |
| 1463 DCHECK(root_layer->render_surface()); | 1481 DCHECK(root_layer->render_surface()); |
| 1464 } | 1482 } |
| 1465 | 1483 |
| 1466 void LayerTreeHostCommon::CalculateDrawProperties( | 1484 void LayerTreeHostCommon::CalculateDrawProperties( |
| 1467 LayerImpl* root_layer, | 1485 LayerImpl* root_layer, |
| 1468 gfx::Size device_viewport_size, | 1486 gfx::Size device_viewport_size, |
| 1469 float device_scale_factor, | 1487 float device_scale_factor, |
| 1470 float page_scale_factor, | 1488 float page_scale_factor, |
| 1471 int max_texture_size, | 1489 int max_texture_size, |
| 1472 bool can_use_lcd_text, | 1490 bool can_use_lcd_text, |
| 1473 LayerImplList* render_surface_layer_list, | 1491 LayerImplList* render_surface_layer_list, |
| 1474 bool update_tile_priorities) { | 1492 bool update_tile_priorities) { |
| 1475 gfx::Rect total_drawable_content_rect; | 1493 gfx::Rect total_drawable_content_rect; |
| 1476 gfx::Transform identity_matrix; | 1494 gfx::Transform identity_matrix; |
| 1477 gfx::Transform device_scale_transform; | 1495 gfx::Transform device_scale_transform; |
| 1478 device_scale_transform.Scale(device_scale_factor, device_scale_factor); | 1496 device_scale_transform.Scale(device_scale_factor, device_scale_factor); |
| 1479 LayerImplList dummy_layer_list; | 1497 LayerImplList dummy_layer_list; |
| 1480 LayerSorter layer_sorter; | 1498 LayerSorter layer_sorter; |
| 1481 | 1499 |
| 1482 // The root layer's render_surface should receive the device viewport as the | 1500 // The root layer's render_surface should receive the device viewport as the |
| 1483 // initial clip rect. | 1501 // initial clip rect. |
| 1484 bool subtree_should_be_clipped = true; | 1502 bool subtree_should_be_clipped = true; |
| 1485 gfx::Rect device_viewport_rect(device_viewport_size); | 1503 gfx::Rect device_viewport_rect(device_viewport_size); |
| 1504 bool prepare_to_update = false; |
| 1486 | 1505 |
| 1487 // This function should have received a root layer. | 1506 // This function should have received a root layer. |
| 1488 DCHECK(IsRootLayer(root_layer)); | 1507 DCHECK(IsRootLayer(root_layer)); |
| 1489 | 1508 |
| 1490 PreCalculateMetaInformation<LayerImpl>(root_layer); | 1509 PreCalculateMetaInformation<LayerImpl>(root_layer); |
| 1491 CalculateDrawPropertiesInternal<LayerImpl, | 1510 CalculateDrawPropertiesInternal<LayerImpl, |
| 1492 LayerImplList, | 1511 LayerImplList, |
| 1493 RenderSurfaceImpl>( | 1512 RenderSurfaceImpl>( |
| 1494 root_layer, | 1513 root_layer, |
| 1495 device_scale_transform, | 1514 device_scale_transform, |
| 1496 identity_matrix, | 1515 identity_matrix, |
| 1497 identity_matrix, | 1516 identity_matrix, |
| 1498 NULL, | 1517 NULL, |
| 1499 device_viewport_rect, | 1518 device_viewport_rect, |
| 1500 device_viewport_rect, | 1519 device_viewport_rect, |
| 1501 subtree_should_be_clipped, | 1520 subtree_should_be_clipped, |
| 1502 NULL, | 1521 NULL, |
| 1503 render_surface_layer_list, | 1522 render_surface_layer_list, |
| 1504 &dummy_layer_list, | 1523 &dummy_layer_list, |
| 1505 &layer_sorter, | 1524 &layer_sorter, |
| 1506 max_texture_size, | 1525 max_texture_size, |
| 1507 device_scale_factor, | 1526 device_scale_factor, |
| 1508 page_scale_factor, | 1527 page_scale_factor, |
| 1509 can_use_lcd_text, | 1528 can_use_lcd_text, |
| 1510 &total_drawable_content_rect, | 1529 &total_drawable_content_rect, |
| 1511 update_tile_priorities); | 1530 update_tile_priorities, |
| 1531 prepare_to_update); |
| 1512 | 1532 |
| 1513 // The dummy layer list should not have been used. | 1533 // The dummy layer list should not have been used. |
| 1514 DCHECK_EQ(0u, dummy_layer_list.size()); | 1534 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 1515 // A root layer render_surface should always exist after | 1535 // A root layer render_surface should always exist after |
| 1516 // CalculateDrawProperties. | 1536 // CalculateDrawProperties. |
| 1517 DCHECK(root_layer->render_surface()); | 1537 DCHECK(root_layer->render_surface()); |
| 1518 } | 1538 } |
| 1519 | 1539 |
| 1520 static bool PointHitsRect( | 1540 static bool PointHitsRect( |
| 1521 gfx::PointF screen_space_point, | 1541 gfx::PointF screen_space_point, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 // At this point, we think the point does hit the touch event handler region | 1722 // At this point, we think the point does hit the touch event handler region |
| 1703 // on the layer, but we need to walk up the parents to ensure that the layer | 1723 // on the layer, but we need to walk up the parents to ensure that the layer |
| 1704 // was not clipped in such a way that the hit point actually should not hit | 1724 // was not clipped in such a way that the hit point actually should not hit |
| 1705 // the layer. | 1725 // the layer. |
| 1706 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 1726 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
| 1707 return false; | 1727 return false; |
| 1708 | 1728 |
| 1709 return true; | 1729 return true; |
| 1710 } | 1730 } |
| 1711 } // namespace cc | 1731 } // namespace cc |
| OLD | NEW |