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

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

Issue 12259027: cc: Simplify the logic for deciding to update tile priorities. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: in_seconds Created 7 years, 8 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 | Annotate | Revision Log
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_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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // Note: Again, Concat is used to conver the result coordinate space from 405 // Note: Again, Concat is used to conver the result coordinate space from
406 // the container render surface to the container layer. 406 // the container render surface to the container layer.
407 target_surface_space_to_container_layer_space.ConcatTransform( 407 target_surface_space_to_container_layer_space.ConcatTransform(
408 container_target_surface_space_to_container_layer_space); 408 container_target_surface_space_to_container_layer_space);
409 } 409 }
410 } 410 }
411 411
412 // Apply step 3 412 // Apply step 3
413 gfx::Transform container_layer_space_to_target_surface_space; 413 gfx::Transform container_layer_space_to_target_surface_space;
414 if (target_surface_space_to_container_layer_space.GetInverse( 414 if (target_surface_space_to_container_layer_space.GetInverse(
415 &container_layer_space_to_target_surface_space)) 415 &container_layer_space_to_target_surface_space)) {
416 result_transform.PreconcatTransform( 416 result_transform.PreconcatTransform(
417 container_layer_space_to_target_surface_space); 417 container_layer_space_to_target_surface_space);
418 else { 418 } else {
419 // FIXME: A non-invertible matrix could still make meaningful projection. 419 // FIXME: A non-invertible matrix could still make meaningful projection.
420 // For example ScaleZ(0) is non-invertible but the layer is still visible. 420 // For example ScaleZ(0) is non-invertible but the layer is still visible.
421 return gfx::Transform(); 421 return gfx::Transform();
422 } 422 }
423 423
424 // Apply step 2 424 // Apply step 2
425 result_transform.Translate(position_offset.x(), position_offset.y()); 425 result_transform.Translate(position_offset.x(), position_offset.y());
426 426
427 // Apply step 1 427 // Apply step 1
428 result_transform.PreconcatTransform( 428 result_transform.PreconcatTransform(
429 target_surface_space_to_container_layer_space); 429 target_surface_space_to_container_layer_space);
430 430
431 return result_transform; 431 return result_transform;
432 } 432 }
433 433
434 void ApplyPositionAdjustment( 434 void ApplyPositionAdjustment(
435 Layer* layer, 435 Layer* layer,
436 Layer* container, 436 Layer* container,
437 const gfx::Transform& scroll_compensation, 437 const gfx::Transform& scroll_compensation,
438 gfx::Transform* combined_transform) { } 438 gfx::Transform* combined_transform) { }
439 void ApplyPositionAdjustment( 439 void ApplyPositionAdjustment(
440 LayerImpl* layer, 440 LayerImpl* layer,
441 LayerImpl* container, 441 LayerImpl* container,
442 const gfx::Transform& scroll_compensation, 442 const gfx::Transform& scroll_compensation,
443 gfx::Transform* combined_transform) 443 gfx::Transform* combined_transform) {
444 {
445 if (!layer->position_constraint().is_fixed_position()) 444 if (!layer->position_constraint().is_fixed_position())
446 return; 445 return;
447 446
448 // Special case: this layer is a composited fixed-position layer; we need to 447 // Special case: this layer is a composited fixed-position layer; we need to
449 // explicitly compensate for all ancestors' nonzero scroll_deltas to keep 448 // explicitly compensate for all ancestors' nonzero scroll_deltas to keep
450 // this layer fixed correctly. 449 // this layer fixed correctly.
451 // Note carefully: this is Concat, not Preconcat 450 // Note carefully: this is Concat, not Preconcat
452 // (current_scroll_compensation * combined_transform). 451 // (current_scroll_compensation * combined_transform).
453 combined_transform->ConcatTransform(scroll_compensation); 452 combined_transform->ConcatTransform(scroll_compensation);
454 453
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 gfx::Rect clip_rect_from_ancestor_in_descendant_space, 769 gfx::Rect clip_rect_from_ancestor_in_descendant_space,
771 bool ancestor_clips_subtree, 770 bool ancestor_clips_subtree,
772 RenderSurfaceType* nearest_ancestor_that_moves_pixels, 771 RenderSurfaceType* nearest_ancestor_that_moves_pixels,
773 LayerList* render_surface_layer_list, 772 LayerList* render_surface_layer_list,
774 LayerList* layer_list, 773 LayerList* layer_list,
775 LayerSorter* layer_sorter, 774 LayerSorter* layer_sorter,
776 int max_texture_size, 775 int max_texture_size,
777 float device_scale_factor, 776 float device_scale_factor,
778 float page_scale_factor, 777 float page_scale_factor,
779 bool subtree_can_use_lcd_text, 778 bool subtree_can_use_lcd_text,
780 gfx::Rect* drawable_content_rect_of_subtree, 779 gfx::Rect* drawable_content_rect_of_subtree) {
781 bool update_tile_priorities) {
782 // This function computes the new matrix transformations recursively for this 780 // This function computes the new matrix transformations recursively for this
783 // layer and all its descendants. It also computes the appropriate render 781 // layer and all its descendants. It also computes the appropriate render
784 // surfaces. 782 // surfaces.
785 // Some important points to remember: 783 // Some important points to remember:
786 // 784 //
787 // 0. Here, transforms are notated in Matrix x Vector order, and in words we 785 // 0. Here, transforms are notated in Matrix x Vector order, and in words we
788 // describe what the transform does from left to right. 786 // describe what the transform does from left to right.
789 // 787 //
790 // 1. In our terminology, the "layer origin" refers to the top-left corner of 788 // 1. In our terminology, the "layer origin" refers to the top-left corner of
791 // a layer, and the positive Y-axis points downwards. This interpretation is 789 // a layer, and the positive Y-axis points downwards. This interpretation is
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 clip_rect_for_subtree_in_descendant_space, 1247 clip_rect_for_subtree_in_descendant_space,
1250 subtree_should_be_clipped, 1248 subtree_should_be_clipped,
1251 nearest_ancestor_that_moves_pixels, 1249 nearest_ancestor_that_moves_pixels,
1252 render_surface_layer_list, 1250 render_surface_layer_list,
1253 &descendants, 1251 &descendants,
1254 layer_sorter, 1252 layer_sorter,
1255 max_texture_size, 1253 max_texture_size,
1256 device_scale_factor, 1254 device_scale_factor,
1257 page_scale_factor, 1255 page_scale_factor,
1258 subtree_can_use_lcd_text, 1256 subtree_can_use_lcd_text,
1259 &drawable_content_rect_of_child_subtree, 1257 &drawable_content_rect_of_child_subtree);
1260 update_tile_priorities);
1261 if (!drawable_content_rect_of_child_subtree.IsEmpty()) { 1258 if (!drawable_content_rect_of_child_subtree.IsEmpty()) {
1262 accumulated_drawable_content_rect_of_children.Union( 1259 accumulated_drawable_content_rect_of_children.Union(
1263 drawable_content_rect_of_child_subtree); 1260 drawable_content_rect_of_child_subtree);
1264 if (child->render_surface()) 1261 if (child->render_surface())
1265 descendants.push_back(child); 1262 descendants.push_back(child);
1266 } 1263 }
1267 } 1264 }
1268 1265
1269 if (layer->render_surface() && !IsRootLayer(layer) && 1266 if (layer->render_surface() && !IsRootLayer(layer) &&
1270 layer->render_surface()->layer_list().empty()) { 1267 layer->render_surface()->layer_list().empty()) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 // Compute the replica's "screen_space_transform" that maps from the 1381 // Compute the replica's "screen_space_transform" that maps from the
1385 // replica's origin space to the screen's origin space. 1382 // replica's origin space to the screen's origin space.
1386 gfx::Transform replica_screen_space_transform = 1383 gfx::Transform replica_screen_space_transform =
1387 layer->render_surface()->screen_space_transform() * 1384 layer->render_surface()->screen_space_transform() *
1388 surface_origin_to_replica_origin_transform; 1385 surface_origin_to_replica_origin_transform;
1389 render_surface->SetReplicaScreenSpaceTransform( 1386 render_surface->SetReplicaScreenSpaceTransform(
1390 replica_screen_space_transform); 1387 replica_screen_space_transform);
1391 } 1388 }
1392 } 1389 }
1393 1390
1394 if (update_tile_priorities) 1391 UpdateTilePrioritiesForLayer(layer);
1395 UpdateTilePrioritiesForLayer(layer);
1396 1392
1397 // If neither this layer nor any of its children were added, early out. 1393 // If neither this layer nor any of its children were added, early out.
1398 if (sorting_start_index == descendants.size()) 1394 if (sorting_start_index == descendants.size())
1399 return; 1395 return;
1400 1396
1401 // If preserves-3d then sort all the descendants in 3D so that they can be 1397 // If preserves-3d then sort all the descendants in 3D so that they can be
1402 // drawn from back to front. If the preserves-3d property is also set on the 1398 // drawn from back to front. If the preserves-3d property is also set on the
1403 // parent then skip the sorting as the parent will sort all the descendants 1399 // parent then skip the sorting as the parent will sort all the descendants
1404 // anyway. 1400 // anyway.
1405 if (layer_sorter && descendants.size() && layer->preserves_3d() && 1401 if (layer_sorter && descendants.size() && layer->preserves_3d() &&
(...skipping 29 matching lines...) Expand all
1435 gfx::Rect total_drawable_content_rect; 1431 gfx::Rect total_drawable_content_rect;
1436 gfx::Transform identity_matrix; 1432 gfx::Transform identity_matrix;
1437 gfx::Transform device_scale_transform; 1433 gfx::Transform device_scale_transform;
1438 device_scale_transform.Scale(device_scale_factor, device_scale_factor); 1434 device_scale_transform.Scale(device_scale_factor, device_scale_factor);
1439 LayerList dummy_layer_list; 1435 LayerList dummy_layer_list;
1440 1436
1441 // The root layer's render_surface should receive the device viewport as the 1437 // The root layer's render_surface should receive the device viewport as the
1442 // initial clip rect. 1438 // initial clip rect.
1443 bool subtree_should_be_clipped = true; 1439 bool subtree_should_be_clipped = true;
1444 gfx::Rect device_viewport_rect(device_viewport_size); 1440 gfx::Rect device_viewport_rect(device_viewport_size);
1445 bool update_tile_priorities = false;
1446 1441
1447 // This function should have received a root layer. 1442 // This function should have received a root layer.
1448 DCHECK(IsRootLayer(root_layer)); 1443 DCHECK(IsRootLayer(root_layer));
1449 1444
1450 PreCalculateMetaInformation<Layer>(root_layer); 1445 PreCalculateMetaInformation<Layer>(root_layer);
1451 CalculateDrawPropertiesInternal<Layer, 1446 CalculateDrawPropertiesInternal<Layer,
1452 LayerList, 1447 LayerList,
1453 RenderSurface>(root_layer, 1448 RenderSurface>(root_layer,
1454 device_scale_transform, 1449 device_scale_transform,
1455 identity_matrix, 1450 identity_matrix,
1456 identity_matrix, 1451 identity_matrix,
1457 NULL, 1452 NULL,
1458 device_viewport_rect, 1453 device_viewport_rect,
1459 device_viewport_rect, 1454 device_viewport_rect,
1460 subtree_should_be_clipped, 1455 subtree_should_be_clipped,
1461 NULL, 1456 NULL,
1462 render_surface_layer_list, 1457 render_surface_layer_list,
1463 &dummy_layer_list, 1458 &dummy_layer_list,
1464 NULL, 1459 NULL,
1465 max_texture_size, 1460 max_texture_size,
1466 device_scale_factor, 1461 device_scale_factor,
1467 page_scale_factor, 1462 page_scale_factor,
1468 can_use_lcd_text, 1463 can_use_lcd_text,
1469 &total_drawable_content_rect, 1464 &total_drawable_content_rect);
1470 update_tile_priorities);
1471 1465
1472 // The dummy layer list should not have been used. 1466 // The dummy layer list should not have been used.
1473 DCHECK_EQ(0u, dummy_layer_list.size()); 1467 DCHECK_EQ(0u, dummy_layer_list.size());
1474 // A root layer render_surface should always exist after 1468 // A root layer render_surface should always exist after
1475 // CalculateDrawProperties. 1469 // CalculateDrawProperties.
1476 DCHECK(root_layer->render_surface()); 1470 DCHECK(root_layer->render_surface());
1477 } 1471 }
1478 1472
1479 void LayerTreeHostCommon::CalculateDrawProperties( 1473 void LayerTreeHostCommon::CalculateDrawProperties(
1480 LayerImpl* root_layer, 1474 LayerImpl* root_layer,
1481 gfx::Size device_viewport_size, 1475 gfx::Size device_viewport_size,
1482 float device_scale_factor, 1476 float device_scale_factor,
1483 float page_scale_factor, 1477 float page_scale_factor,
1484 int max_texture_size, 1478 int max_texture_size,
1485 bool can_use_lcd_text, 1479 bool can_use_lcd_text,
1486 LayerImplList* render_surface_layer_list, 1480 LayerImplList* render_surface_layer_list) {
1487 bool update_tile_priorities) {
1488 gfx::Rect total_drawable_content_rect; 1481 gfx::Rect total_drawable_content_rect;
1489 gfx::Transform identity_matrix; 1482 gfx::Transform identity_matrix;
1490 gfx::Transform device_scale_transform; 1483 gfx::Transform device_scale_transform;
1491 device_scale_transform.Scale(device_scale_factor, device_scale_factor); 1484 device_scale_transform.Scale(device_scale_factor, device_scale_factor);
1492 LayerImplList dummy_layer_list; 1485 LayerImplList dummy_layer_list;
1493 LayerSorter layer_sorter; 1486 LayerSorter layer_sorter;
1494 1487
1495 // The root layer's render_surface should receive the device viewport as the 1488 // The root layer's render_surface should receive the device viewport as the
1496 // initial clip rect. 1489 // initial clip rect.
1497 bool subtree_should_be_clipped = true; 1490 bool subtree_should_be_clipped = true;
(...skipping 15 matching lines...) Expand all
1513 device_viewport_rect, 1506 device_viewport_rect,
1514 subtree_should_be_clipped, 1507 subtree_should_be_clipped,
1515 NULL, 1508 NULL,
1516 render_surface_layer_list, 1509 render_surface_layer_list,
1517 &dummy_layer_list, 1510 &dummy_layer_list,
1518 &layer_sorter, 1511 &layer_sorter,
1519 max_texture_size, 1512 max_texture_size,
1520 device_scale_factor, 1513 device_scale_factor,
1521 page_scale_factor, 1514 page_scale_factor,
1522 can_use_lcd_text, 1515 can_use_lcd_text,
1523 &total_drawable_content_rect, 1516 &total_drawable_content_rect);
1524 update_tile_priorities);
1525 1517
1526 // The dummy layer list should not have been used. 1518 // The dummy layer list should not have been used.
1527 DCHECK_EQ(0u, dummy_layer_list.size()); 1519 DCHECK_EQ(0u, dummy_layer_list.size());
1528 // A root layer render_surface should always exist after 1520 // A root layer render_surface should always exist after
1529 // CalculateDrawProperties. 1521 // CalculateDrawProperties.
1530 DCHECK(root_layer->render_surface()); 1522 DCHECK(root_layer->render_surface());
1531 } 1523 }
1532 1524
1533 static bool PointHitsRect( 1525 static bool PointHitsRect(
1534 gfx::PointF screen_space_point, 1526 gfx::PointF screen_space_point,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 // At this point, we think the point does hit the touch event handler region 1707 // At this point, we think the point does hit the touch event handler region
1716 // on the layer, but we need to walk up the parents to ensure that the layer 1708 // on the layer, but we need to walk up the parents to ensure that the layer
1717 // was not clipped in such a way that the hit point actually should not hit 1709 // was not clipped in such a way that the hit point actually should not hit
1718 // the layer. 1710 // the layer.
1719 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 1711 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
1720 return false; 1712 return false;
1721 1713
1722 return true; 1714 return true;
1723 } 1715 }
1724 } // namespace cc 1716 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698