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

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: 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
« cc/draw_properties.h ('K') | « cc/draw_properties.h ('k') | no next file » | 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/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) && !layer->drawProperties().all_children_can_cl ip)
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // layers from the end of the list. 422 // layers from the end of the list.
423 while (renderSurfaceLayerList.back() != layerToRemove) { 423 while (renderSurfaceLayerList.back() != layerToRemove) {
424 renderSurfaceLayerList.back()->clearRenderSurface(); 424 renderSurfaceLayerList.back()->clearRenderSurface();
425 renderSurfaceLayerList.pop_back(); 425 renderSurfaceLayerList.pop_back();
426 } 426 }
427 DCHECK(renderSurfaceLayerList.back() == layerToRemove); 427 DCHECK(renderSurfaceLayerList.back() == layerToRemove);
428 renderSurfaceLayerList.pop_back(); 428 renderSurfaceLayerList.pop_back();
429 layerToRemove->clearRenderSurface(); 429 layerToRemove->clearRenderSurface();
430 } 430 }
431 431
432 inline bool isPositiveScaleOrTranslation(const gfx::Transform& xform)
433 {
434 if (!xform.IsScaleOrTranslation())
435 return false;
436
437 // Grab our scale and make sure it's positive.
438 float x_scale = xform.matrix().getDouble(0,0);
jamesr 2012/12/14 04:31:19 do we have to do a double->float conversion here?
whunt 2012/12/14 18:17:01 There's no reason to do the conversion. I'm just
439 float y_scale = xform.matrix().getDouble(1,1);
440 if (x_scale <= 0.0f || y_scale <= 0.0f)
441 return false;
442
443 return true;
444 }
445
432 // Recursively walks the layer tree to compute any information that is needed 446 // Recursively walks the layer tree to compute any information that is needed
433 // before doing the main recursion. 447 // before doing the main recursion.
434 template<typename LayerType> 448 template<typename LayerType>
435 static void preCalculateMetaInformation(LayerType* layer) 449 static void preCalculateMetaInformation(LayerType* layer)
436 { 450 {
437 int numDescendantsThatDrawContent = 0; 451 int numDescendantsThatDrawContent = 0;
452 bool allChildrenCanClip = true;
453
454 bool sublayerPreventsClip = !isPositiveScaleOrTranslation(layer->sublayerTra nsform());
jamesr 2012/12/14 04:31:19 I'm not sure that this is sufficient. If the tran
shawnsingh 2012/12/14 07:34:44 +1 james comment; we do need the additional condit
Ian Vollick 2012/12/14 12:02:16 Sorry for the drive-by, but I wanted to mention th
whunt 2012/12/14 18:17:01 I'm aware this isn't sufficient. I'm working on f
whunt 2012/12/14 18:17:01 The clipper wont work on rotations by 90 degrees s
438 455
439 for (size_t i = 0; i < layer->children().size(); ++i) { 456 for (size_t i = 0; i < layer->children().size(); ++i) {
440 LayerType* childLayer = layer->children()[i]; 457 LayerType* childLayer = layer->children()[i];
441 preCalculateMetaInformation<LayerType>(childLayer); 458 preCalculateMetaInformation<LayerType>(childLayer);
442 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0; 459
443 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content; 460 int numChildDescendantsThatDrawContent = 0;
461 numChildDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0 ;
shawnsingh 2012/12/14 07:34:44 I'm not sure about this rename, how about we omit
whunt 2012/12/14 18:17:01 I need the intermediate value. I didn't change yo
462 numChildDescendantsThatDrawContent += childLayer->drawProperties().num_d escendants_that_draw_content;
463 numDescendantsThatDrawContent += numChildDescendantsThatDrawContent;
464
465 if (!childLayer->drawProperties().all_children_can_clip ||
466 numChildDescendantsThatDrawContent > 0 && (sublayerPreventsClip || ! isPositiveScaleOrTranslation(childLayer->transform())))
467 allChildrenCanClip = false;
444 } 468 }
445 469
446 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent; 470 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent;
471 layer->drawProperties().all_children_can_clip = allChildrenCanClip;
447 } 472 }
448 473
449 // Recursively walks the layer tree starting at the given node and computes all the 474 // Recursively walks the layer tree starting at the given node and computes all the
450 // necessary transformations, clipRects, render surfaces, etc. 475 // necessary transformations, clipRects, render surfaces, etc.
451 template<typename LayerType, typename LayerList, typename RenderSurfaceType> 476 template<typename LayerType, typename LayerList, typename RenderSurfaceType>
452 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, 477 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix,
453 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, 478 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix,
454 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree, 479 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree,
455 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, 480 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList,
456 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText, 481 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText,
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1120
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 1121 // 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 1122 // 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. 1123 // hit point actually should not hit the layer.
1099 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) 1124 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl))
1100 return false; 1125 return false;
1101 1126
1102 return true; 1127 return true;
1103 } 1128 }
1104 } // namespace cc 1129 } // namespace cc
OLDNEW
« cc/draw_properties.h ('K') | « cc/draw_properties.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698