| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return layer->transform().IsBackFaceVisible(); | 125 return layer->transform().IsBackFaceVisible(); |
| 126 | 126 |
| 127 // If the renderSurface is not part of a new or existing rendering context,
then the | 127 // If the renderSurface is not part of a new or existing rendering context,
then the |
| 128 // layers that contribute to this surface will decide back-face visibility f
or themselves. | 128 // layers that contribute to this surface will decide back-face visibility f
or themselves. |
| 129 return false; | 129 return false; |
| 130 } | 130 } |
| 131 | 131 |
| 132 template<typename LayerType> | 132 template<typename LayerType> |
| 133 static inline bool layerClipsSubtree(LayerType* layer) | 133 static inline bool layerClipsSubtree(LayerType* layer) |
| 134 { | 134 { |
| 135 return layer->masksToBounds() || layer->maskLayer() || layer->hasDelegatedCo
ntent(); | 135 return layer->masksToBounds() || layer->maskLayer(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 template<typename LayerType> | 138 template<typename LayerType> |
| 139 static gfx::Rect calculateVisibleContentRect(LayerType* layer, const gfx::Rect&
ancestorClipRectInDescendantSurfaceSpace, const gfx::Rect& layerRectInTargetSpac
e) | 139 static gfx::Rect calculateVisibleContentRect(LayerType* layer, const gfx::Rect&
ancestorClipRectInDescendantSurfaceSpace, const gfx::Rect& layerRectInTargetSpac
e) |
| 140 { | 140 { |
| 141 DCHECK(layer->renderTarget()); | 141 DCHECK(layer->renderTarget()); |
| 142 | 142 |
| 143 // Nothing is visible if the layer bounds are empty. | 143 // Nothing is visible if the layer bounds are empty. |
| 144 if (!layer->drawsContent() || layer->contentBounds().IsEmpty() || layer->dra
wableContentRect().IsEmpty()) | 144 if (!layer->drawsContent() || layer->contentBounds().IsEmpty() || layer->dra
wableContentRect().IsEmpty()) |
| 145 return gfx::Rect(); | 145 return gfx::Rect(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 && !layer->d
rawProperties().descendants_can_clip_selves) | 294 bool layerClipsExternalContent = layerClipsSubtree(layer) || layer->hasDeleg
atedContent(); |
| 295 if (layerClipsExternalContent && !axisAlignedWithRespectToParent && !layer->
drawProperties().descendants_can_clip_selves) |
| 295 { | 296 { |
| 296 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping
"); | 297 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping
"); |
| 297 return true; | 298 return true; |
| 298 } | 299 } |
| 299 | 300 |
| 300 // If the layer has some translucency and does not have a preserves-3d trans
form style. | 301 // If the layer has some translucency and does not have a preserves-3d trans
form style. |
| 301 // This condition only needs a render surface if two or more layers in the | 302 // This condition only needs a render surface if two or more layers in the |
| 302 // subtree overlap. But checking layer overlaps is unnecessarily costly so | 303 // subtree overlap. But checking layer overlaps is unnecessarily costly so |
| 303 // instead we conservatively create a surface whenever at least two layers | 304 // instead we conservatively create a surface whenever at least two layers |
| 304 // draw content for this subtree. | 305 // draw content for this subtree. |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 | 1183 |
| 1183 // At this point, we think the point does hit the touch event handler region o
n the layer, but we need to walk up | 1184 // At this point, we think the point does hit the touch event handler region o
n the layer, but we need to walk up |
| 1184 // the parents to ensure that the layer was not clipped in such a way that the | 1185 // the parents to ensure that the layer was not clipped in such a way that the |
| 1185 // hit point actually should not hit the layer. | 1186 // hit point actually should not hit the layer. |
| 1186 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) | 1187 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) |
| 1187 return false; | 1188 return false; |
| 1188 | 1189 |
| 1189 return true; | 1190 return true; |
| 1190 } | 1191 } |
| 1191 } // namespace cc | 1192 } // namespace cc |
| OLD | NEW |