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 "cc/layer.h" | 9 #include "cc/layer.h" |
10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 243 |
244 // If the layer has a reflection. | 244 // If the layer has a reflection. |
245 if (layer->replicaLayer()) | 245 if (layer->replicaLayer()) |
246 return true; | 246 return true; |
247 | 247 |
248 // If the layer uses a CSS filter. | 248 // If the layer uses a CSS filter. |
249 if (!layer->filters().isEmpty() || !layer->backgroundFilters().isEmpty() ||
layer->filter()) | 249 if (!layer->filters().isEmpty() || !layer->backgroundFilters().isEmpty() ||
layer->filter()) |
250 return true; | 250 return true; |
251 | 251 |
252 // Cache this value, because otherwise it walks the entire subtree several t
imes. | 252 // Cache this value, because otherwise it walks the entire subtree several t
imes. |
253 bool descendantDrawsContent = layer->descendantDrawsContent(); | 253 int descendantsDrawContent = layer->descendantsDrawContent(); |
254 | 254 |
255 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b
ut it is | 255 // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), b
ut it is |
256 // treated as a 3D object by its parent (i.e. parent does preserve-3d). | 256 // treated as a 3D object by its parent (i.e. parent does preserve-3d). |
257 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && d
escendantDrawsContent) | 257 if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves3D() && d
escendantsDrawContent > 0) |
258 return true; | 258 return true; |
259 | 259 |
260 // If the layer clips its descendants but it is not axis-aligned with respec
t to its parent. | 260 // If the layer clips its descendants but it is not axis-aligned with respec
t to its parent. |
261 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && descendan
tDrawsContent) | 261 if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && descendan
tsDrawContent > 0) |
262 return true; | 262 return true; |
263 | 263 |
264 // If the layer has opacity != 1 and does not have a preserves-3d transform
style. | 264 // If the layer has opacity != 1 and does not have a preserves-3d transform
style. |
265 if (layer->opacity() != 1 && !layer->preserves3D() && descendantDrawsContent
) | 265 if (layer->opacity() != 1 && !layer->preserves3D() && descendantsDrawContent
> 0 |
| 266 && (layer->drawsContent() || descendantsDrawContent > 1)) |
266 return true; | 267 return true; |
267 | 268 |
268 return false; | 269 return false; |
269 } | 270 } |
270 | 271 |
271 gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer,
const gfx::Transform& parentMatrix) | 272 gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer,
const gfx::Transform& parentMatrix) |
272 { | 273 { |
273 // For every layer that has non-zero scrollDelta, we have to compute a trans
form that can undo the | 274 // For every layer that has non-zero scrollDelta, we have to compute a trans
form that can undo the |
274 // scrollDelta translation. In particular, we want this matrix to premultipl
y a fixed-position layer's | 275 // scrollDelta translation. In particular, we want this matrix to premultipl
y a fixed-position layer's |
275 // parentMatrix, so we design this transform in three steps as follows. The
steps described here apply | 276 // parentMatrix, so we design this transform in three steps as follows. The
steps described here apply |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 481 |
481 // If we early-exit anywhere in this function, the drawableContentRect of th
is subtree should be considered empty. | 482 // If we early-exit anywhere in this function, the drawableContentRect of th
is subtree should be considered empty. |
482 drawableContentRectOfSubtree = gfx::Rect(); | 483 drawableContentRectOfSubtree = gfx::Rect(); |
483 | 484 |
484 // The root layer cannot skip calcDrawTransforms. | 485 // The root layer cannot skip calcDrawTransforms. |
485 if (!isRootLayer(layer) && subtreeShouldBeSkipped(layer)) | 486 if (!isRootLayer(layer) && subtreeShouldBeSkipped(layer)) |
486 return; | 487 return; |
487 | 488 |
488 gfx::Rect clipRectForSubtree; | 489 gfx::Rect clipRectForSubtree; |
489 bool subtreeShouldBeClipped = false; | 490 bool subtreeShouldBeClipped = false; |
490 | 491 |
491 float drawOpacity = layer->opacity(); | 492 float drawOpacity = layer->opacity(); |
492 bool drawOpacityIsAnimating = layer->opacityIsAnimating(); | 493 bool drawOpacityIsAnimating = layer->opacityIsAnimating(); |
493 if (layer->parent() && layer->parent()->preserves3D()) { | 494 if (layer->parent()) { |
494 drawOpacity *= layer->parent()->drawOpacity(); | 495 drawOpacity *= layer->parent()->drawOpacity(); |
495 drawOpacityIsAnimating |= layer->parent()->drawOpacityIsAnimating(); | 496 drawOpacityIsAnimating |= layer->parent()->drawOpacityIsAnimating(); |
496 } | 497 } |
497 | 498 |
498 bool animatingTransformToTarget = layer->transformIsAnimating(); | 499 bool animatingTransformToTarget = layer->transformIsAnimating(); |
499 bool animatingTransformToScreen = animatingTransformToTarget; | 500 bool animatingTransformToScreen = animatingTransformToTarget; |
500 if (layer->parent()) { | 501 if (layer->parent()) { |
501 animatingTransformToTarget |= layer->parent()->drawTransformIsAnimating(
); | 502 animatingTransformToTarget |= layer->parent()->drawTransformIsAnimating(
); |
502 animatingTransformToScreen |= layer->parent()->screenSpaceTransformIsAni
mating(); | 503 animatingTransformToScreen |= layer->parent()->screenSpaceTransformIsAni
mating(); |
503 } | 504 } |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 | 993 |
993 foundLayer = currentLayer; | 994 foundLayer = currentLayer; |
994 break; | 995 break; |
995 } | 996 } |
996 | 997 |
997 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. | 998 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. |
998 return foundLayer; | 999 return foundLayer; |
999 } | 1000 } |
1000 | 1001 |
1001 } // namespace cc | 1002 } // namespace cc |
OLD | NEW |