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

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: moving IsPositiveScaleOrTranslation into gfx::Transform 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 270
271 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b ut it is 271 // 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). 272 // treated as a 3D object by its parent (i.e. parent does preserve-3d).
273 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && n umDescendantsThatDrawContent > 0) 273 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && n umDescendantsThatDrawContent > 0)
274 return true; 274 return true;
275 275
276 // If the layer clips its descendants but it is not axis-aligned with respec t to its parent. 276 // 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) 277 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && !layer->d rawProperties().can_clip_self)
danakj 2012/12/15 18:49:12 Why doesn't a layer need to know that all layers i
278 return true; 278 return true;
279 279
280 // If the layer has some translucency and does not have a preserves-3d trans form style. 280 // 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 281 // 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 282 // subtree overlap. But checking layer overlaps is unnecessarily costly so
283 // instead we conservatively create a surface whenever at least two layers 283 // instead we conservatively create a surface whenever at least two layers
284 // draw content for this subtree. 284 // draw content for this subtree.
285 bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() || 285 bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() ||
286 (numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDesce ndantsThatDrawContent > 1)); 286 (numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDesce ndantsThatDrawContent > 1));
287 287
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 renderSurfaceLayerList.pop_back(); 428 renderSurfaceLayerList.pop_back();
429 layerToRemove->clearRenderSurface(); 429 layerToRemove->clearRenderSurface();
430 } 430 }
431 431
432 // Recursively walks the layer tree to compute any information that is needed 432 // Recursively walks the layer tree to compute any information that is needed
433 // before doing the main recursion. 433 // before doing the main recursion.
434 template<typename LayerType> 434 template<typename LayerType>
435 static void preCalculateMetaInformation(LayerType* layer) 435 static void preCalculateMetaInformation(LayerType* layer)
436 { 436 {
437 int numDescendantsThatDrawContent = 0; 437 int numDescendantsThatDrawContent = 0;
438 bool canClipSelf = true;
danakj 2012/12/15 18:49:12 Why isn't this initialized to the return for the c
439 bool sublayerXformPreventsClip = !layer->sublayerTransform().IsPositiveScale OrTranslation();
438 440
439 for (size_t i = 0; i < layer->children().size(); ++i) { 441 for (size_t i = 0; i < layer->children().size(); ++i) {
440 LayerType* childLayer = layer->children()[i]; 442 LayerType* childLayer = layer->children()[i];
441 preCalculateMetaInformation<LayerType>(childLayer); 443 preCalculateMetaInformation<LayerType>(childLayer);
444
442 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0; 445 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0;
443 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content; 446 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content;
447
448 if ((childLayer->drawsContent() && !childLayer->canClipSelf()) ||
449 !childLayer->drawProperties().can_clip_self ||
450 sublayerXformPreventsClip ||
451 !childLayer->transform().IsPositiveScaleOrTranslation())
452 canClipSelf = false;
444 } 453 }
445 454
446 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent; 455 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent;
456 layer->drawProperties().can_clip_self = canClipSelf;
447 } 457 }
448 458
449 // Recursively walks the layer tree starting at the given node and computes all the 459 // Recursively walks the layer tree starting at the given node and computes all the
450 // necessary transformations, clipRects, render surfaces, etc. 460 // necessary transformations, clipRects, render surfaces, etc.
451 template<typename LayerType, typename LayerList, typename RenderSurfaceType> 461 template<typename LayerType, typename LayerList, typename RenderSurfaceType>
452 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, 462 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix,
453 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, 463 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix,
454 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree, 464 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree,
455 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, 465 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList,
456 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText, 466 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText,
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1105
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 1106 // 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 1107 // 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. 1108 // hit point actually should not hit the layer.
1099 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) 1109 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl))
1100 return false; 1110 return false;
1101 1111
1102 return true; 1112 return true;
1103 } 1113 }
1104 } // namespace cc 1114 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698