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

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

Issue 13939005: cc: Add strict layer property change checking and handle bounds changes during paint. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add PaintProperties 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
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_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_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
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 SavePaintPropertiesLayer(LayerImpl* layer) {}
272
273 static inline void SavePaintPropertiesLayer(Layer* layer) {
274 layer->SavePaintProperties();
275
276 if (layer->mask_layer())
277 layer->mask_layer()->SavePaintProperties();
278 if (layer->replica_layer() && layer->replica_layer()->mask_layer())
279 layer->replica_layer()->mask_layer()->SavePaintProperties();
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
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 save_paint_properties) {
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
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 save_paint_properties);
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
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 (save_paint_properties)
1427 SavePaintPropertiesLayer(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 save_paint_properties = 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 save_paint_properties);
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 save_paint_properties = 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 save_paint_properties);
enne (OOO) 2013/04/12 23:03:22 I don't think you need this. We can just always c
reveman 2013/04/12 23:41:48 Done.
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
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
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698