| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #ifndef CompositedLayerMapping_h | 26 #ifndef CompositedLayerMapping_h |
| 27 #define CompositedLayerMapping_h | 27 #define CompositedLayerMapping_h |
| 28 | 28 |
| 29 #include "core/layout/compositing/GraphicsLayerUpdater.h" | 29 #include "core/layout/compositing/GraphicsLayerUpdater.h" |
| 30 #include "core/paint/PaintLayer.h" | 30 #include "core/paint/PaintLayer.h" |
| 31 #include "platform/geometry/FloatPoint.h" | 31 #include "platform/geometry/FloatPoint.h" |
| 32 #include "platform/geometry/FloatPoint3D.h" | 32 #include "platform/geometry/FloatPoint3D.h" |
| 33 #include "platform/graphics/GraphicsLayer.h" | 33 #include "platform/graphics/GraphicsLayer.h" |
| 34 #include "platform/graphics/GraphicsLayerClient.h" | 34 #include "platform/graphics/GraphicsLayerClient.h" |
| 35 #include "wtf/Allocator.h" | 35 #include "wtf/Allocator.h" |
| 36 #include <memory> |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 class PaintLayerCompositor; | 40 class PaintLayerCompositor; |
| 40 | 41 |
| 41 // A GraphicsLayerPaintInfo contains all the info needed to paint a partial subt
ree of Layers into a GraphicsLayer. | 42 // A GraphicsLayerPaintInfo contains all the info needed to paint a partial subt
ree of Layers into a GraphicsLayer. |
| 42 struct GraphicsLayerPaintInfo { | 43 struct GraphicsLayerPaintInfo { |
| 43 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 44 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 44 PaintLayer* paintLayer; | 45 PaintLayer* paintLayer; |
| 45 | 46 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 void updateTransformGeometry(const IntPoint& snappedOffsetFromCompositedAnce
stor, const IntRect& relativeCompositingBounds); | 242 void updateTransformGeometry(const IntPoint& snappedOffsetFromCompositedAnce
stor, const IntRect& relativeCompositingBounds); |
| 242 void updateForegroundLayerGeometry(const FloatSize& relativeCompositingBound
sSize, const IntRect& clippingBox); | 243 void updateForegroundLayerGeometry(const FloatSize& relativeCompositingBound
sSize, const IntRect& clippingBox); |
| 243 void updateBackgroundLayerGeometry(const FloatSize& relativeCompositingBound
sSize); | 244 void updateBackgroundLayerGeometry(const FloatSize& relativeCompositingBound
sSize); |
| 244 void updateReflectionLayerGeometry(Vector<PaintLayer*>& layersNeedingPaintIn
validation); | 245 void updateReflectionLayerGeometry(Vector<PaintLayer*>& layersNeedingPaintIn
validation); |
| 245 void updateScrollingLayerGeometry(const IntRect& localCompositingBounds); | 246 void updateScrollingLayerGeometry(const IntRect& localCompositingBounds); |
| 246 void updateChildClippingMaskLayerGeometry(); | 247 void updateChildClippingMaskLayerGeometry(); |
| 247 | 248 |
| 248 void createPrimaryGraphicsLayer(); | 249 void createPrimaryGraphicsLayer(); |
| 249 void destroyGraphicsLayers(); | 250 void destroyGraphicsLayers(); |
| 250 | 251 |
| 251 PassOwnPtr<GraphicsLayer> createGraphicsLayer(CompositingReasons, SquashingD
isallowedReasons = SquashingDisallowedReasonsNone); | 252 std::unique_ptr<GraphicsLayer> createGraphicsLayer(CompositingReasons, Squas
hingDisallowedReasons = SquashingDisallowedReasonsNone); |
| 252 bool toggleScrollbarLayerIfNeeded(OwnPtr<GraphicsLayer>&, bool needsLayer, C
ompositingReasons); | 253 bool toggleScrollbarLayerIfNeeded(std::unique_ptr<GraphicsLayer>&, bool need
sLayer, CompositingReasons); |
| 253 | 254 |
| 254 LayoutBoxModelObject* layoutObject() const { return m_owningLayer.layoutObje
ct(); } | 255 LayoutBoxModelObject* layoutObject() const { return m_owningLayer.layoutObje
ct(); } |
| 255 PaintLayerCompositor* compositor() const { return m_owningLayer.compositor()
; } | 256 PaintLayerCompositor* compositor() const { return m_owningLayer.compositor()
; } |
| 256 | 257 |
| 257 void updateInternalHierarchy(); | 258 void updateInternalHierarchy(); |
| 258 void updatePaintingPhases(); | 259 void updatePaintingPhases(); |
| 259 bool updateClippingLayers(bool needsAncestorClip, bool needsDescendantClip); | 260 bool updateClippingLayers(bool needsAncestorClip, bool needsDescendantClip); |
| 260 bool updateChildTransformLayer(bool needsChildTransformLayer); | 261 bool updateChildTransformLayer(bool needsChildTransformLayer); |
| 261 bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool n
eedsVerticalScrollbarLayer, bool needsScrollCornerLayer, bool needsAncestorClip)
; | 262 bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool n
eedsVerticalScrollbarLayer, bool needsScrollCornerLayer, bool needsAncestorClip)
; |
| 262 bool updateForegroundLayer(bool needsForegroundLayer); | 263 bool updateForegroundLayer(bool needsForegroundLayer); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 // | + ... | 357 // | + ... |
| 357 // ... | 358 // ... |
| 358 // | | 359 // | |
| 359 // + B = m_ancestorClippingLayer [+] | 360 // + B = m_ancestorClippingLayer [+] |
| 360 // + m_graphicsLayer | 361 // + m_graphicsLayer |
| 361 // + ... | 362 // + ... |
| 362 // | 363 // |
| 363 // In this case B is clipped by another layer that doesn't happen to be its
ancestor: A. | 364 // In this case B is clipped by another layer that doesn't happen to be its
ancestor: A. |
| 364 // So we create an ancestor clipping layer for B, [+], which ensures that B
is clipped | 365 // So we create an ancestor clipping layer for B, [+], which ensures that B
is clipped |
| 365 // as if it had been A's descendant. | 366 // as if it had been A's descendant. |
| 366 OwnPtr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clippe
d by an ancestor which is not a stacking context. | 367 std::unique_ptr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we a
re clipped by an ancestor which is not a stacking context. |
| 367 OwnPtr<GraphicsLayer> m_graphicsLayer; | 368 std::unique_ptr<GraphicsLayer> m_graphicsLayer; |
| 368 OwnPtr<GraphicsLayer> m_childContainmentLayer; // Only used if we have clipp
ing on a stacking context with compositing children. | 369 std::unique_ptr<GraphicsLayer> m_childContainmentLayer; // Only used if we h
ave clipping on a stacking context with compositing children. |
| 369 OwnPtr<GraphicsLayer> m_childTransformLayer; // Only used if we have perspec
tive. | 370 std::unique_ptr<GraphicsLayer> m_childTransformLayer; // Only used if we hav
e perspective. |
| 370 OwnPtr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using c
omposited scrolling. | 371 std::unique_ptr<GraphicsLayer> m_scrollingLayer; // Only used if the layer i
s using composited scrolling. |
| 371 OwnPtr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is
using composited scrolling. | 372 std::unique_ptr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the
layer is using composited scrolling. |
| 372 | 373 |
| 373 // This layer is also added to the hierarchy by the RLB, but in a different
way than | 374 // This layer is also added to the hierarchy by the RLB, but in a different
way than |
| 374 // the layers above. It's added to m_graphicsLayer as its mask layer (natura
lly) if | 375 // the layers above. It's added to m_graphicsLayer as its mask layer (natura
lly) if |
| 375 // we have a mask, and isn't part of the typical hierarchy (it has no childr
en). | 376 // we have a mask, and isn't part of the typical hierarchy (it has no childr
en). |
| 376 OwnPtr<GraphicsLayer> m_maskLayer; // Only used if we have a mask. | 377 std::unique_ptr<GraphicsLayer> m_maskLayer; // Only used if we have a mask. |
| 377 OwnPtr<GraphicsLayer> m_childClippingMaskLayer; // Only used if we have to c
lip child layers or accelerated contents with border radius or clip-path. | 378 std::unique_ptr<GraphicsLayer> m_childClippingMaskLayer; // Only used if we
have to clip child layers or accelerated contents with border radius or clip-pat
h. |
| 378 | 379 |
| 379 // There are two other (optional) layers whose painting is managed by the Co
mpositedLayerMapping, | 380 // There are two other (optional) layers whose painting is managed by the Co
mpositedLayerMapping, |
| 380 // but whose position in the hierarchy is maintained by the PaintLayerCompos
itor. These | 381 // but whose position in the hierarchy is maintained by the PaintLayerCompos
itor. These |
| 381 // are the foreground and background layers. The foreground layer exists if
we have composited | 382 // are the foreground and background layers. The foreground layer exists if
we have composited |
| 382 // descendants with negative z-order. We need the extra layer in this case b
ecause the layer | 383 // descendants with negative z-order. We need the extra layer in this case b
ecause the layer |
| 383 // needs to draw both below (for the background, say) and above (for the nor
mal flow content, say) | 384 // needs to draw both below (for the background, say) and above (for the nor
mal flow content, say) |
| 384 // the negative z-order descendants and this is impossible with a single lay
er. The RLC handles | 385 // the negative z-order descendants and this is impossible with a single lay
er. The RLC handles |
| 385 // inserting m_foregroundLayer in the correct position in our descendant lis
t for us (right after | 386 // inserting m_foregroundLayer in the correct position in our descendant lis
t for us (right after |
| 386 // the neg z-order dsecendants). | 387 // the neg z-order dsecendants). |
| 387 // | 388 // |
| 388 // The background layer is only created if this is the root layer and our ba
ckground is entirely | 389 // The background layer is only created if this is the root layer and our ba
ckground is entirely |
| 389 // fixed. In this case we want to put the background in a separate composite
d layer so that when | 390 // fixed. In this case we want to put the background in a separate composite
d layer so that when |
| 390 // we scroll, we don't have to re-raster the background into position. This
layer is also inserted | 391 // we scroll, we don't have to re-raster the background into position. This
layer is also inserted |
| 391 // into the tree by the RLC as it gets a special home. This layer becomes a
descendant of the | 392 // into the tree by the RLC as it gets a special home. This layer becomes a
descendant of the |
| 392 // frame clipping layer. That is: | 393 // frame clipping layer. That is: |
| 393 // ... | 394 // ... |
| 394 // + frame clipping layer | 395 // + frame clipping layer |
| 395 // + m_backgroundLayer | 396 // + m_backgroundLayer |
| 396 // + frame scrolling layer | 397 // + frame scrolling layer |
| 397 // + root content layer | 398 // + root content layer |
| 398 // | 399 // |
| 399 // With the hierarchy set up like this, the root content layer is able to sc
roll without affecting | 400 // With the hierarchy set up like this, the root content layer is able to sc
roll without affecting |
| 400 // the background layer (or paint invalidation). | 401 // the background layer (or paint invalidation). |
| 401 OwnPtr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need
to draw the foreground separately. | 402 std::unique_ptr<GraphicsLayer> m_foregroundLayer; // Only used in cases wher
e we need to draw the foreground separately. |
| 402 OwnPtr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need
to draw the background separately. | 403 std::unique_ptr<GraphicsLayer> m_backgroundLayer; // Only used in cases wher
e we need to draw the background separately. |
| 403 | 404 |
| 404 OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar; | 405 std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar; |
| 405 OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar; | 406 std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar; |
| 406 OwnPtr<GraphicsLayer> m_layerForScrollCorner; | 407 std::unique_ptr<GraphicsLayer> m_layerForScrollCorner; |
| 407 | 408 |
| 408 // This layer contains the scrollbar and scroll corner layers and clips them
to the border box | 409 // This layer contains the scrollbar and scroll corner layers and clips them
to the border box |
| 409 // bounds of our LayoutObject. It is usually added to m_graphicsLayer, but m
ay be reparented by | 410 // bounds of our LayoutObject. It is usually added to m_graphicsLayer, but m
ay be reparented by |
| 410 // GraphicsLayerTreeBuilder to ensure that scrollbars appear above scrolling
content. | 411 // GraphicsLayerTreeBuilder to ensure that scrollbars appear above scrolling
content. |
| 411 OwnPtr<GraphicsLayer> m_overflowControlsHostLayer; | 412 std::unique_ptr<GraphicsLayer> m_overflowControlsHostLayer; |
| 412 | 413 |
| 413 // The reparented overflow controls sometimes need to be clipped by a non-an
cestor. In just the same | 414 // The reparented overflow controls sometimes need to be clipped by a non-an
cestor. In just the same |
| 414 // way we need an ancestor clipping layer to clip this CLM's internal hierar
chy, we add another layer | 415 // way we need an ancestor clipping layer to clip this CLM's internal hierar
chy, we add another layer |
| 415 // to clip the overflow controls. We could combine this with m_overflowContr
olsHostLayer, but that | 416 // to clip the overflow controls. We could combine this with m_overflowContr
olsHostLayer, but that |
| 416 // would require manually intersecting their clips, and shifting the overflo
w controls to compensate | 417 // would require manually intersecting their clips, and shifting the overflo
w controls to compensate |
| 417 // for this clip's offset. By using a separate layer, the overflow controls
can remain ignorant of | 418 // for this clip's offset. By using a separate layer, the overflow controls
can remain ignorant of |
| 418 // ancestor clipping. | 419 // ancestor clipping. |
| 419 OwnPtr<GraphicsLayer> m_overflowControlsAncestorClippingLayer; | 420 std::unique_ptr<GraphicsLayer> m_overflowControlsAncestorClippingLayer; |
| 420 | 421 |
| 421 // A squashing CLM has two possible squashing-related structures. | 422 // A squashing CLM has two possible squashing-related structures. |
| 422 // | 423 // |
| 423 // If m_ancestorClippingLayer is present: | 424 // If m_ancestorClippingLayer is present: |
| 424 // | 425 // |
| 425 // m_ancestorClippingLayer | 426 // m_ancestorClippingLayer |
| 426 // + m_graphicsLayer | 427 // + m_graphicsLayer |
| 427 // + m_squashingLayer | 428 // + m_squashingLayer |
| 428 // | 429 // |
| 429 // If not: | 430 // If not: |
| 430 // | 431 // |
| 431 // m_squashingContainmentLayer | 432 // m_squashingContainmentLayer |
| 432 // + m_graphicsLayer | 433 // + m_graphicsLayer |
| 433 // + m_squashingLayer | 434 // + m_squashingLayer |
| 434 // | 435 // |
| 435 // Stacking children of a squashed layer receive graphics layers that are pa
rented to the compositd ancestor of the | 436 // Stacking children of a squashed layer receive graphics layers that are pa
rented to the compositd ancestor of the |
| 436 // squashed layer (i.e. nearest enclosing composited layer that is not squas
hed). | 437 // squashed layer (i.e. nearest enclosing composited layer that is not squas
hed). |
| 437 OwnPtr<GraphicsLayer> m_squashingContainmentLayer; // Only used if any squas
hed layers exist and m_squashingContainmentLayer is not present, to contain the
squashed layers as siblings to the rest of the GraphicsLayer tree chunk. | 438 std::unique_ptr<GraphicsLayer> m_squashingContainmentLayer; // Only used if
any squashed layers exist and m_squashingContainmentLayer is not present, to con
tain the squashed layers as siblings to the rest of the GraphicsLayer tree chunk
. |
| 438 OwnPtr<GraphicsLayer> m_squashingLayer; // Only used if any squashed layers
exist, this is the backing that squashed layers paint into. | 439 std::unique_ptr<GraphicsLayer> m_squashingLayer; // Only used if any squashe
d layers exist, this is the backing that squashed layers paint into. |
| 439 Vector<GraphicsLayerPaintInfo> m_squashedLayers; | 440 Vector<GraphicsLayerPaintInfo> m_squashedLayers; |
| 440 LayoutPoint m_squashingLayerOffsetFromTransformedAncestor; | 441 LayoutPoint m_squashingLayerOffsetFromTransformedAncestor; |
| 441 | 442 |
| 442 LayoutRect m_compositedBounds; | 443 LayoutRect m_compositedBounds; |
| 443 | 444 |
| 444 LayoutSize m_contentOffsetInCompositingLayer; | 445 LayoutSize m_contentOffsetInCompositingLayer; |
| 445 | 446 |
| 446 // We keep track of the scrolling contents offset, so that when it changes w
e can notify the ScrollingCoordinator, which | 447 // We keep track of the scrolling contents offset, so that when it changes w
e can notify the ScrollingCoordinator, which |
| 447 // passes on main-thread scrolling updates to the compositor. | 448 // passes on main-thread scrolling updates to the compositor. |
| 448 DoubleSize m_scrollingContentsOffset; | 449 DoubleSize m_scrollingContentsOffset; |
| 449 | 450 |
| 450 unsigned m_contentOffsetInCompositingLayerDirty : 1; | 451 unsigned m_contentOffsetInCompositingLayerDirty : 1; |
| 451 | 452 |
| 452 unsigned m_pendingUpdateScope : 2; | 453 unsigned m_pendingUpdateScope : 2; |
| 453 unsigned m_isMainFrameLayoutViewLayer : 1; | 454 unsigned m_isMainFrameLayoutViewLayer : 1; |
| 454 | 455 |
| 455 unsigned m_backgroundLayerPaintsFixedRootBackground : 1; | 456 unsigned m_backgroundLayerPaintsFixedRootBackground : 1; |
| 456 unsigned m_scrollingContentsAreEmpty : 1; | 457 unsigned m_scrollingContentsAreEmpty : 1; |
| 457 | 458 |
| 458 friend class CompositedLayerMappingTest; | 459 friend class CompositedLayerMappingTest; |
| 459 }; | 460 }; |
| 460 | 461 |
| 461 } // namespace blink | 462 } // namespace blink |
| 462 | 463 |
| 463 #endif // CompositedLayerMapping_h | 464 #endif // CompositedLayerMapping_h |
| OLD | NEW |