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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 return true; | 263 return true; |
264 | 264 |
265 // If the layer uses a CSS filter. | 265 // If the layer uses a CSS filter. |
266 if (!layer->filters().isEmpty() || !layer->backgroundFilters().isEmpty() ||
layer->filter()) | 266 if (!layer->filters().isEmpty() || !layer->backgroundFilters().isEmpty() ||
layer->filter()) |
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 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface flatteni
ng"); |
274 return true; | 275 return true; |
| 276 } |
275 | 277 |
276 // If the layer clips its descendants but it is not axis-aligned with respec
t to its parent. | 278 // 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) | 279 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && numDescen
dantsThatDrawContent > 0) { |
| 280 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping
"); |
278 return true; | 281 return true; |
| 282 } |
279 | 283 |
280 // If the layer has some translucency and does not have a preserves-3d trans
form style. | 284 // 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 | 285 // 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 | 286 // subtree overlap. But checking layer overlaps is unnecessarily costly so |
283 // instead we conservatively create a surface whenever at least two layers | 287 // instead we conservatively create a surface whenever at least two layers |
284 // draw content for this subtree. | 288 // draw content for this subtree. |
285 bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() || | 289 bool atLeastTwoLayersInSubtreeDrawContent = layer->hasDelegatedContent() || |
286 (numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDesce
ndantsThatDrawContent > 1)); | 290 (numDescendantsThatDrawContent > 0 && (layer->drawsContent() || numDesce
ndantsThatDrawContent > 1)); |
287 | 291 |
288 if (layer->opacity() != 1 && !layer->preserves3D() && atLeastTwoLayersInSubt
reeDrawContent) | 292 if (layer->opacity() != 1 && !layer->preserves3D() && atLeastTwoLayersInSubt
reeDrawContent) { |
| 293 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface opacity"
); |
289 return true; | 294 return true; |
| 295 } |
290 | 296 |
291 return false; | 297 return false; |
292 } | 298 } |
293 | 299 |
294 gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer,
const gfx::Transform& parentMatrix) | 300 gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer,
const gfx::Transform& parentMatrix) |
295 { | 301 { |
296 // For every layer that has non-zero scrollDelta, we have to compute a trans
form that can undo the | 302 // For every layer that has non-zero scrollDelta, we have to compute a trans
form that can undo the |
297 // scrollDelta translation. In particular, we want this matrix to premultipl
y a fixed-position layer's | 303 // scrollDelta translation. In particular, we want this matrix to premultipl
y a fixed-position layer's |
298 // parentMatrix, so we design this transform in three steps as follows. The
steps described here apply | 304 // parentMatrix, so we design this transform in three steps as follows. The
steps described here apply |
299 // from right-to-left, so Step 1 would be the right-most matrix: | 305 // from right-to-left, so Step 1 would be the right-most matrix: |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 | 1101 |
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 | 1102 // 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 | 1103 // 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. | 1104 // hit point actually should not hit the layer. |
1099 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) | 1105 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) |
1100 return false; | 1106 return false; |
1101 | 1107 |
1102 return true; | 1108 return true; |
1103 } | 1109 } |
1104 } // namespace cc | 1110 } // namespace cc |
OLD | NEW |