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

Side by Side Diff: cc/layer_tree_host_common.cc

Issue 11567034: Changes subtreeShouldRenderToSeparateSurface logic to account for explicit clipping (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reworking the test for creating a layer, should work correctly now. Created 8 years 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/layer_tree_host_common.h" 5 #include "cc/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/layer.h" 10 #include "cc/layer.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 // If the layer has a reflection. 261 // If the layer has a reflection.
262 if (layer->replicaLayer()) 262 if (layer->replicaLayer())
263 return true; 263 return true;
264 264
265 // If the layer uses a CSS filter. 265 // If the layer uses a CSS filter.
266 if (!layer->filters().isEmpty() || !layer->backgroundFilters().isEmpty() || layer->filter()) 266 if (!layer->filters().isEmpty() || !layer->backgroundFilters().isEmpty() || layer->filter())
267 return true; 267 return true;
268 268
269 int numDescendantsThatDrawContent = layer->drawProperties().num_descendants_ that_draw_content; 269 int numDescendantsThatDrawContent = layer->drawProperties().num_descendants_ that_draw_content;
270 int numDescendantsThatDrawContentAndCantClipThemselves = layer->drawProperti es().num_descendants_that_draw_content_and_cant_clip_themselves;
270 271
271 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b ut it is 272 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b ut it is
272 // treated as a 3D object by its parent (i.e. parent does preserve-3d). 273 // treated as a 3D object by its parent (i.e. parent does preserve-3d).
273 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && n umDescendantsThatDrawContent > 0) 274 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && n umDescendantsThatDrawContent > 0)
274 return true; 275 return true;
275 276
276 // If the layer clips its descendants but it is not axis-aligned with respec t to its parent. 277 // If the layer clips its descendants but it is not axis-aligned with respec t to its parent.
277 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && numDescen dantsThatDrawContent > 0) 278 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && numDescen dantsThatDrawContentAndCantClipThemselves > 0)
278 return true; 279 return true;
279 280
280 // If the layer has some translucency and does not have a preserves-3d trans form style. 281 // If the layer has some translucency and does not have a preserves-3d trans form style.
281 // This condition only needs a render surface if two or more layers in the 282 // This condition only needs a render surface if two or more layers in the
282 // subtree overlap. But checking layer overlaps is unnecessarily costly so 283 // subtree overlap. But checking layer overlaps is unnecessarily costly so
283 // instead we conservatively create a surface whenever at least two layers 284 // instead we conservatively create a surface whenever at least two layers
284 // draw content for this subtree. 285 // draw content for this subtree.
285 bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() || 286 bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() ||
286 (numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDesce ndantsThatDrawContent > 1)); 287 (numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDesce ndantsThatDrawContent > 1));
287 288
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // layers from the end of the list. 423 // layers from the end of the list.
423 while (renderSurfaceLayerList.back() != layerToRemove) { 424 while (renderSurfaceLayerList.back() != layerToRemove) {
424 renderSurfaceLayerList.back()->clearRenderSurface(); 425 renderSurfaceLayerList.back()->clearRenderSurface();
425 renderSurfaceLayerList.pop_back(); 426 renderSurfaceLayerList.pop_back();
426 } 427 }
427 DCHECK(renderSurfaceLayerList.back() == layerToRemove); 428 DCHECK(renderSurfaceLayerList.back() == layerToRemove);
428 renderSurfaceLayerList.pop_back(); 429 renderSurfaceLayerList.pop_back();
429 layerToRemove->clearRenderSurface(); 430 layerToRemove->clearRenderSurface();
430 } 431 }
431 432
433 inline bool isPositiveScaleOrTranslation(const gfx::Transform& xform)
jamesr 2012/12/14 21:48:54 is there a caller to this function? I can't find i
whunt 2012/12/14 22:12:20 This function is no longer used due to the relianc
434 {
435 if (!xform.IsScaleOrTranslation())
436 return false;
437
438 // Grab our scale and make sure it's positive.
439 double x_scale = xform.matrix().getDouble(0,0);
jamesr 2012/12/14 21:48:54 nit: space after the comma
440 double y_scale = xform.matrix().getDouble(1,1);
441 if (x_scale <= 0.0f || y_scale <= 0.0f)
jamesr 2012/12/14 21:48:54 nit: "0.0", not "0.0f" since it's a double-double
442 return false;
443
444 return true;
445 }
446
432 // Recursively walks the layer tree to compute any information that is needed 447 // Recursively walks the layer tree to compute any information that is needed
433 // before doing the main recursion. 448 // before doing the main recursion.
434 template<typename LayerType> 449 template<typename LayerType>
435 static void preCalculateMetaInformation(LayerType* layer) 450 static void preCalculateMetaInformation(LayerType* layer)
436 { 451 {
437 int numDescendantsThatDrawContent = 0; 452 int numDescendantsThatDrawContent = 0;
453 int numDescendantsThatDrawContentAndCantClipThemsleves = 0;
438 454
439 for (size_t i = 0; i < layer->children().size(); ++i) { 455 for (size_t i = 0; i < layer->children().size(); ++i) {
440 LayerType* childLayer = layer->children()[i]; 456 LayerType* childLayer = layer->children()[i];
441 preCalculateMetaInformation<LayerType>(childLayer); 457 preCalculateMetaInformation<LayerType>(childLayer);
458
442 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0; 459 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0;
443 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content; 460 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content;
461
462 numDescendantsThatDrawContentAndCantClipThemsleves += childLayer->drawsC ontent() && !childLayer->CanClipSelf() ? 1 : 0;
463 numDescendantsThatDrawContentAndCantClipThemsleves += childLayer->drawPr operties().num_descendants_that_draw_content_and_cant_clip_themselves;
444 } 464 }
445 465
446 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent; 466 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent;
467 layer->drawProperties().num_descendants_that_draw_content_and_cant_clip_them selves = numDescendantsThatDrawContentAndCantClipThemsleves;
447 } 468 }
448 469
449 // Recursively walks the layer tree starting at the given node and computes all the 470 // Recursively walks the layer tree starting at the given node and computes all the
450 // necessary transformations, clipRects, render surfaces, etc. 471 // necessary transformations, clipRects, render surfaces, etc.
451 template<typename LayerType, typename LayerList, typename RenderSurfaceType> 472 template<typename LayerType, typename LayerList, typename RenderSurfaceType>
452 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, 473 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix,
453 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, 474 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix,
454 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree, 475 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree,
455 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, 476 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList,
456 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText, 477 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText,
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1116
1096 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up 1117 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up
1097 // the parents to ensure that the layer was not clipped in such a way that the 1118 // the parents to ensure that the layer was not clipped in such a way that the
1098 // hit point actually should not hit the layer. 1119 // hit point actually should not hit the layer.
1099 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) 1120 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl))
1100 return false; 1121 return false;
1101 1122
1102 return true; 1123 return true;
1103 } 1124 }
1104 } // namespace cc 1125 } // namespace cc
OLDNEW
« cc/draw_properties.h ('K') | « cc/layer_impl.h ('k') | cc/texture_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698