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

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: very minor change Created 7 years, 11 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/layer_impl.cc ('k') | cc/layer_tree_host_common_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/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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 int numDescendantsThatDrawContent = layer->drawProperties().num_descendants_ that_draw_content; 284 int numDescendantsThatDrawContent = layer->drawProperties().num_descendants_ that_draw_content;
285 285
286 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b ut it is 286 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b ut it is
287 // treated as a 3D object by its parent (i.e. parent does preserve-3d). 287 // treated as a 3D object by its parent (i.e. parent does preserve-3d).
288 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && n umDescendantsThatDrawContent > 0) { 288 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && n umDescendantsThatDrawContent > 0) {
289 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface flatteni ng"); 289 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface flatteni ng");
290 return true; 290 return true;
291 } 291 }
292 292
293 // If the layer clips its descendants but it is not axis-aligned with respec t to its parent. 293 // If the layer clips its descendants but it is not axis-aligned with respec t to its parent.
294 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && numDescen dantsThatDrawContent > 0) { 294 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && !layer->d rawProperties().descendants_can_clip_selves)
295 {
295 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping "); 296 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping ");
296 return true; 297 return true;
297 } 298 }
298 299
299 // If the layer has some translucency and does not have a preserves-3d trans form style. 300 // If the layer has some translucency and does not have a preserves-3d trans form style.
300 // This condition only needs a render surface if two or more layers in the 301 // This condition only needs a render surface if two or more layers in the
301 // subtree overlap. But checking layer overlaps is unnecessarily costly so 302 // subtree overlap. But checking layer overlaps is unnecessarily costly so
302 // instead we conservatively create a surface whenever at least two layers 303 // instead we conservatively create a surface whenever at least two layers
303 // draw content for this subtree. 304 // draw content for this subtree.
304 bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() || 305 bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() ||
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 renderSurfaceLayerList.pop_back(); 489 renderSurfaceLayerList.pop_back();
489 layerToRemove->clearRenderSurface(); 490 layerToRemove->clearRenderSurface();
490 } 491 }
491 492
492 // Recursively walks the layer tree to compute any information that is needed 493 // Recursively walks the layer tree to compute any information that is needed
493 // before doing the main recursion. 494 // before doing the main recursion.
494 template<typename LayerType> 495 template<typename LayerType>
495 static void preCalculateMetaInformation(LayerType* layer) 496 static void preCalculateMetaInformation(LayerType* layer)
496 { 497 {
497 int numDescendantsThatDrawContent = 0; 498 int numDescendantsThatDrawContent = 0;
499 bool descendantsCanClipSelves = true;
500 bool sublayerTransformPreventsClip = !layer->sublayerTransform().IsPositiveS caleOrTranslation();
498 501
499 for (size_t i = 0; i < layer->children().size(); ++i) { 502 for (size_t i = 0; i < layer->children().size(); ++i) {
500 LayerType* childLayer = layer->children()[i]; 503 LayerType* childLayer = layer->children()[i];
501 preCalculateMetaInformation<LayerType>(childLayer); 504 preCalculateMetaInformation<LayerType>(childLayer);
505
502 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0; 506 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0;
503 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content; 507 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content;
508
509 if ((childLayer->drawsContent() && !childLayer->canClipSelf()) ||
510 !childLayer->drawProperties().descendants_can_clip_selves ||
511 sublayerTransformPreventsClip ||
512 !childLayer->transform().IsPositiveScaleOrTranslation())
513 descendantsCanClipSelves = false;
504 } 514 }
505 515
506 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent; 516 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent;
517 layer->drawProperties().descendants_can_clip_selves = descendantsCanClipSelv es;
507 } 518 }
508 519
509 // Recursively walks the layer tree starting at the given node and computes all the 520 // Recursively walks the layer tree starting at the given node and computes all the
510 // necessary transformations, clipRects, render surfaces, etc. 521 // necessary transformations, clipRects, render surfaces, etc.
511 template<typename LayerType, typename LayerList, typename RenderSurfaceType> 522 template<typename LayerType, typename LayerList, typename RenderSurfaceType>
512 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, 523 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix,
513 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, 524 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix,
514 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree, 525 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree,
515 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, 526 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList,
516 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText, 527 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText,
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 1174
1164 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up 1175 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up
1165 // the parents to ensure that the layer was not clipped in such a way that the 1176 // the parents to ensure that the layer was not clipped in such a way that the
1166 // hit point actually should not hit the layer. 1177 // hit point actually should not hit the layer.
1167 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) 1178 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl))
1168 return false; 1179 return false;
1169 1180
1170 return true; 1181 return true;
1171 } 1182 }
1172 } // namespace cc 1183 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_impl.cc ('k') | cc/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698