Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 // positives (e.g. layers get this called on them but don't actually get drawn). | 232 // positives (e.g. layers get this called on them but don't actually get drawn). |
| 233 static inline void markLayerAsUpdated(LayerImpl* layer) | 233 static inline void markLayerAsUpdated(LayerImpl* layer) |
| 234 { | 234 { |
| 235 layer->didUpdateTransforms(); | 235 layer->didUpdateTransforms(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 static inline void markLayerAsUpdated(Layer* layer) | 238 static inline void markLayerAsUpdated(Layer* layer) |
| 239 { | 239 { |
| 240 } | 240 } |
| 241 | 241 |
| 242 | |
|
shawnsingh
2012/12/18 19:11:00
nit: no need to add extra line here
| |
| 242 template<typename LayerType> | 243 template<typename LayerType> |
| 243 static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig nedWithRespectToParent) | 244 static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig nedWithRespectToParent) |
| 244 { | 245 { |
| 245 // | 246 // |
| 246 // A layer and its descendants should render onto a new RenderSurfaceImpl if any of these rules hold: | 247 // A layer and its descendants should render onto a new RenderSurfaceImpl if any of these rules hold: |
| 247 // | 248 // |
| 248 | 249 |
| 249 // The root layer should always have a renderSurface. | 250 // The root layer should always have a renderSurface. |
| 250 if (isRootLayer(layer)) | 251 if (isRootLayer(layer)) |
| 251 return true; | 252 return true; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 267 return true; | 268 return true; |
| 268 | 269 |
| 269 int numDescendantsThatDrawContent = layer->drawProperties().num_descendants_ that_draw_content; | 270 int numDescendantsThatDrawContent = layer->drawProperties().num_descendants_ that_draw_content; |
| 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 && !layer->d rawProperties().does_not_require_scissoring) |
| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 renderSurfaceLayerList.pop_back(); | 429 renderSurfaceLayerList.pop_back(); |
| 429 layerToRemove->clearRenderSurface(); | 430 layerToRemove->clearRenderSurface(); |
| 430 } | 431 } |
| 431 | 432 |
| 432 // Recursively walks the layer tree to compute any information that is needed | 433 // Recursively walks the layer tree to compute any information that is needed |
| 433 // before doing the main recursion. | 434 // before doing the main recursion. |
| 434 template<typename LayerType> | 435 template<typename LayerType> |
| 435 static void preCalculateMetaInformation(LayerType* layer) | 436 static void preCalculateMetaInformation(LayerType* layer) |
| 436 { | 437 { |
| 437 int numDescendantsThatDrawContent = 0; | 438 int numDescendantsThatDrawContent = 0; |
| 439 bool doesNotRequireScissoring = true; | |
| 440 bool sublayerXformPreventsClip = !layer->sublayerTransform().IsPositiveScale OrTranslation(); | |
|
shawnsingh
2012/12/18 19:11:00
like Dana, I also prefer Transform instead of Xfor
| |
| 438 | 441 |
| 439 for (size_t i = 0; i < layer->children().size(); ++i) { | 442 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 440 LayerType* childLayer = layer->children()[i]; | 443 LayerType* childLayer = layer->children()[i]; |
| 441 preCalculateMetaInformation<LayerType>(childLayer); | 444 preCalculateMetaInformation<LayerType>(childLayer); |
| 445 | |
| 442 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0; | 446 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0; |
| 443 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content; | 447 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content; |
| 448 | |
| 449 if ((childLayer->drawsContent() && !childLayer->canClipSelf()) || | |
| 450 !childLayer->drawProperties().does_not_require_scissoring || | |
|
shawnsingh
2012/12/18 19:11:00
I feel like my proposed variable name in earlier c
| |
| 451 sublayerXformPreventsClip || | |
| 452 !childLayer->transform().IsPositiveScaleOrTranslation()) | |
| 453 doesNotRequireScissoring = false; | |
| 444 } | 454 } |
| 445 | 455 |
| 446 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent; | 456 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent; |
| 457 layer->drawProperties().does_not_require_scissoring = doesNotRequireScissori ng; | |
| 447 } | 458 } |
| 448 | 459 |
| 449 // Recursively walks the layer tree starting at the given node and computes all the | 460 // Recursively walks the layer tree starting at the given node and computes all the |
| 450 // necessary transformations, clipRects, render surfaces, etc. | 461 // necessary transformations, clipRects, render surfaces, etc. |
| 451 template<typename LayerType, typename LayerList, typename RenderSurfaceType> | 462 template<typename LayerType, typename LayerList, typename RenderSurfaceType> |
| 452 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, | 463 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, |
| 453 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, | 464 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, |
| 454 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree, | 465 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree, |
| 455 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, | 466 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, |
| 456 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText, | 467 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText, |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1095 | 1106 |
| 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 | 1107 // 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 | 1108 // 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. | 1109 // hit point actually should not hit the layer. |
| 1099 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) | 1110 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) |
| 1100 return false; | 1111 return false; |
| 1101 | 1112 |
| 1102 return true; | 1113 return true; |
| 1103 } | 1114 } |
| 1104 } // namespace cc | 1115 } // namespace cc |
| OLD | NEW |