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(); | 135 return layer->masksToBounds() || layer->maskLayer() || layer->hasDelegatedCo ntent(); |
piman
2013/01/19 02:39:09
I wonder if this could have a bad side effect if w
danakj
2013/01/19 02:43:00
In my mind the DRLayer should never have any child
| |
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 { | 295 { |
296 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping "); | 296 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping "); |
297 return true; | 297 return true; |
298 } | 298 } |
299 | 299 |
300 // 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. |
301 // 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 |
302 // subtree overlap. But checking layer overlaps is unnecessarily costly so | 302 // subtree overlap. But checking layer overlaps is unnecessarily costly so |
303 // instead we conservatively create a surface whenever at least two layers | 303 // instead we conservatively create a surface whenever at least two layers |
304 // draw content for this subtree. | 304 // draw content for this subtree. |
305 bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() || | 305 bool atLeastTwoLayersInSubtreeDrawContent = numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDescendantsThatDrawContent > 1); |
306 (numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDesce ndantsThatDrawContent > 1)); | |
307 | 306 |
308 if (layer->opacity() != 1 && !layer->preserves3D() && atLeastTwoLayersInSubt reeDrawContent) { | 307 if (layer->opacity() != 1 && !layer->preserves3D() && atLeastTwoLayersInSubt reeDrawContent) { |
309 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface opacity" ); | 308 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface opacity" ); |
310 return true; | 309 return true; |
311 } | 310 } |
312 | 311 |
313 return false; | 312 return false; |
314 } | 313 } |
315 | 314 |
316 gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer, const gfx::Transform& parentMatrix) | 315 gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer, const gfx::Transform& parentMatrix) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 DCHECK(renderSurfaceLayerList.back() == layerToRemove); | 487 DCHECK(renderSurfaceLayerList.back() == layerToRemove); |
489 renderSurfaceLayerList.pop_back(); | 488 renderSurfaceLayerList.pop_back(); |
490 layerToRemove->clearRenderSurface(); | 489 layerToRemove->clearRenderSurface(); |
491 } | 490 } |
492 | 491 |
493 // Recursively walks the layer tree to compute any information that is needed | 492 // Recursively walks the layer tree to compute any information that is needed |
494 // before doing the main recursion. | 493 // before doing the main recursion. |
495 template<typename LayerType> | 494 template<typename LayerType> |
496 static void preCalculateMetaInformation(LayerType* layer) | 495 static void preCalculateMetaInformation(LayerType* layer) |
497 { | 496 { |
497 if (layer->hasDelegatedContent()) { | |
498 // Layers with delegated content need to be treated as if they have as m any children as the number | |
499 // of layers they own delegated quads for. Since we don't know this numb er right now, we choose | |
500 // one that acts like infinity for our purposes. | |
501 layer->drawProperties().num_descendants_that_draw_content = 1000; | |
502 layer->drawProperties().descendants_can_clip_selves = false; | |
503 return; | |
504 } | |
505 | |
498 int numDescendantsThatDrawContent = 0; | 506 int numDescendantsThatDrawContent = 0; |
499 bool descendantsCanClipSelves = true; | 507 bool descendantsCanClipSelves = true; |
500 bool sublayerTransformPreventsClip = !layer->sublayerTransform().IsPositiveS caleOrTranslation(); | 508 bool sublayerTransformPreventsClip = !layer->sublayerTransform().IsPositiveS caleOrTranslation(); |
501 | 509 |
502 for (size_t i = 0; i < layer->children().size(); ++i) { | 510 for (size_t i = 0; i < layer->children().size(); ++i) { |
503 LayerType* childLayer = layer->children()[i]; | 511 LayerType* childLayer = layer->children()[i]; |
504 preCalculateMetaInformation<LayerType>(childLayer); | 512 preCalculateMetaInformation<LayerType>(childLayer); |
505 | 513 |
506 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0; | 514 numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0; |
507 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content; | 515 numDescendantsThatDrawContent += childLayer->drawProperties().num_descen dants_that_draw_content; |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1174 | 1182 |
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 | 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 |
1176 // the parents to ensure that the layer was not clipped in such a way that the | 1184 // the parents to ensure that the layer was not clipped in such a way that the |
1177 // hit point actually should not hit the layer. | 1185 // hit point actually should not hit the layer. |
1178 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) | 1186 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) |
1179 return false; | 1187 return false; |
1180 | 1188 |
1181 return true; | 1189 return true; |
1182 } | 1190 } |
1183 } // namespace cc | 1191 } // namespace cc |
OLD | NEW |