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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Update whether layer needs blending. | 87 // Update whether layer needs blending. |
88 void updateContentsOpaque(); | 88 void updateContentsOpaque(); |
89 | 89 |
90 GraphicsLayer* graphicsLayer() const { return m_graphicsLayer.get(); } | 90 GraphicsLayer* graphicsLayer() const { return m_graphicsLayer.get(); } |
91 | 91 |
92 // Layer to clip children | 92 // Layer to clip children |
93 bool hasClippingLayer() const { return m_childContainmentLayer; } | 93 bool hasClippingLayer() const { return m_childContainmentLayer; } |
94 GraphicsLayer* clippingLayer() const { return m_childContainmentLayer.get();
} | 94 GraphicsLayer* clippingLayer() const { return m_childContainmentLayer.get();
} |
95 | 95 |
96 // Layer to get clipped by ancestor | 96 // Layer to get clipped by ancestor |
97 bool hasAncestorClippingLayer() const { return m_ancestorClippingLayer != 0;
} | 97 bool hasAncestorClippingLayer() const { return m_ancestorClippingLayer; } |
98 GraphicsLayer* ancestorClippingLayer() const { return m_ancestorClippingLaye
r.get(); } | 98 GraphicsLayer* ancestorClippingLayer() const { return m_ancestorClippingLaye
r.get(); } |
99 | 99 |
| 100 bool hasAncestorScrollClippingLayer() const { return m_ancestorScrollClippin
gLayer; } |
| 101 GraphicsLayer* ancestorScrollClippingLayer() const { return m_ancestorScroll
ClippingLayer.get(); } |
| 102 |
100 bool hasContentsLayer() const { return m_foregroundLayer != 0; } | 103 bool hasContentsLayer() const { return m_foregroundLayer != 0; } |
101 GraphicsLayer* foregroundLayer() const { return m_foregroundLayer.get(); } | 104 GraphicsLayer* foregroundLayer() const { return m_foregroundLayer.get(); } |
102 | 105 |
103 GraphicsLayer* backgroundLayer() const { return m_backgroundLayer.get(); } | 106 GraphicsLayer* backgroundLayer() const { return m_backgroundLayer.get(); } |
104 bool backgroundLayerPaintsFixedRootBackground() const { return m_backgroundL
ayerPaintsFixedRootBackground; } | 107 bool backgroundLayerPaintsFixedRootBackground() const { return m_backgroundL
ayerPaintsFixedRootBackground; } |
105 | 108 |
106 bool hasScrollingLayer() const { return m_scrollingLayer; } | 109 bool hasScrollingLayer() const { return m_scrollingLayer; } |
107 GraphicsLayer* scrollingLayer() const { return m_scrollingLayer.get(); } | 110 GraphicsLayer* scrollingLayer() const { return m_scrollingLayer.get(); } |
108 GraphicsLayer* scrollingContentsLayer() const { return m_scrollingContentsLa
yer.get(); } | 111 GraphicsLayer* scrollingContentsLayer() const { return m_scrollingContentsLa
yer.get(); } |
109 | 112 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 private: | 185 private: |
183 void createPrimaryGraphicsLayer(); | 186 void createPrimaryGraphicsLayer(); |
184 void destroyGraphicsLayers(); | 187 void destroyGraphicsLayers(); |
185 | 188 |
186 PassOwnPtr<GraphicsLayer> createGraphicsLayer(CompositingReasons); | 189 PassOwnPtr<GraphicsLayer> createGraphicsLayer(CompositingReasons); |
187 | 190 |
188 RenderLayerModelObject* renderer() const { return m_owningLayer->renderer();
} | 191 RenderLayerModelObject* renderer() const { return m_owningLayer->renderer();
} |
189 RenderLayerCompositor* compositor() const { return m_owningLayer->compositor
(); } | 192 RenderLayerCompositor* compositor() const { return m_owningLayer->compositor
(); } |
190 | 193 |
191 void updateInternalHierarchy(); | 194 void updateInternalHierarchy(); |
192 bool updateClippingLayers(bool needsAncestorClip, bool needsDescendantClip); | 195 bool updateClippingLayers(bool needsAncestorClip, bool needsDescendantClip,
bool needsScrollClip); |
193 bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool n
eedsVerticalScrollbarLayer, bool needsScrollCornerLayer); | 196 bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool n
eedsVerticalScrollbarLayer, bool needsScrollCornerLayer); |
194 bool updateForegroundLayer(bool needsForegroundLayer); | 197 bool updateForegroundLayer(bool needsForegroundLayer); |
195 bool updateBackgroundLayer(bool needsBackgroundLayer); | 198 bool updateBackgroundLayer(bool needsBackgroundLayer); |
196 bool updateMaskLayer(bool needsMaskLayer); | 199 bool updateMaskLayer(bool needsMaskLayer); |
197 bool requiresHorizontalScrollbarLayer() const { return m_owningLayer->horizo
ntalScrollbar(); } | 200 bool requiresHorizontalScrollbarLayer() const { return m_owningLayer->horizo
ntalScrollbar(); } |
198 bool requiresVerticalScrollbarLayer() const { return m_owningLayer->vertical
Scrollbar(); } | 201 bool requiresVerticalScrollbarLayer() const { return m_owningLayer->vertical
Scrollbar(); } |
199 bool requiresScrollCornerLayer() const { return !m_owningLayer->scrollCorner
AndResizerRect().isEmpty(); } | 202 bool requiresScrollCornerLayer() const { return !m_owningLayer->scrollCorner
AndResizerRect().isEmpty(); } |
200 bool updateScrollingLayers(bool scrollingLayers); | 203 bool updateScrollingLayers(bool scrollingLayers); |
| 204 void updateScrollParent(RenderLayer*); |
| 205 void updateClipParent(RenderLayer*); |
201 void updateDrawsContent(bool isSimpleContainer); | 206 void updateDrawsContent(bool isSimpleContainer); |
202 void registerScrollingLayers(); | 207 void registerScrollingLayers(); |
203 | 208 |
204 void setBackgroundLayerPaintsFixedRootBackground(bool); | 209 void setBackgroundLayerPaintsFixedRootBackground(bool); |
205 | 210 |
206 GraphicsLayerPaintingPhase paintingPhaseForPrimaryLayer() const; | 211 GraphicsLayerPaintingPhase paintingPhaseForPrimaryLayer() const; |
207 | 212 |
208 IntSize contentOffsetInCompostingLayer() const; | 213 IntSize contentOffsetInCompostingLayer() const; |
209 // Result is transform origin in pixels. | 214 // Result is transform origin in pixels. |
210 FloatPoint3D computeTransformOrigin(const IntRect& borderBox) const; | 215 FloatPoint3D computeTransformOrigin(const IntRect& borderBox) const; |
(...skipping 29 matching lines...) Expand all Loading... |
240 | 245 |
241 bool shouldClipCompositedBounds() const; | 246 bool shouldClipCompositedBounds() const; |
242 | 247 |
243 void doPaintTask(GraphicsLayerPaintInfo&, GraphicsContext*, const IntRect& c
lip); | 248 void doPaintTask(GraphicsLayerPaintInfo&, GraphicsContext*, const IntRect& c
lip); |
244 | 249 |
245 static CSSPropertyID graphicsLayerToCSSProperty(AnimatedPropertyID); | 250 static CSSPropertyID graphicsLayerToCSSProperty(AnimatedPropertyID); |
246 static AnimatedPropertyID cssToGraphicsLayerProperty(CSSPropertyID); | 251 static AnimatedPropertyID cssToGraphicsLayerProperty(CSSPropertyID); |
247 | 252 |
248 RenderLayer* m_owningLayer; | 253 RenderLayer* m_owningLayer; |
249 | 254 |
| 255 // The hierarchy of layers that is maintained by the RenderLayerBacking look
s like this: |
| 256 // |
| 257 // m_ancestorScrollClippingLayer [OPTIONAL] |
| 258 // + m_ancestorClippingLayer [OPTIONAL] |
| 259 // + m_graphicsLayer |
| 260 // + m_childContainmentLayer [OPTIONAL] <-OR-> m_scrollingLayer [OPTI
ONAL] |
| 261 // + m_scrollingContents
Layer [OPTIONAL] |
| 262 // |
| 263 // We need an ancestor scroll clipping layer if we have a "scroll parent". T
hat is, if |
| 264 // our scrolling ancestor is not our ancestor in the stacking tree. Similarl
y, we need |
| 265 // an ancestor clipping layer if our clipping ancestor is not our ancestor i
n the clipping |
| 266 // tree. Here's what that might look like. |
| 267 // |
| 268 // Let A = the scrolling ancestor, |
| 269 // B = the clipping ancestor, |
| 270 // C = the scroll/clip descendant, and |
| 271 // SC = the stacking context that is the ancestor of A, B and C in the s
tacking tree. |
| 272 // |
| 273 // SC |
| 274 // + A = m_graphicsLayer |
| 275 // | + m_scrollingLayer [*] |
| 276 // | + m_scrollingContentsLayer [+] |
| 277 // | + ... |
| 278 // ... |
| 279 // | |
| 280 // + B = m_graphicsLayer |
| 281 // | + m_childContainmentLayer |
| 282 // | + ... |
| 283 // ... |
| 284 // | |
| 285 // + C = m_ancestorScrollClippingLayer [**] |
| 286 // + m_ancestorClippingLayer [++] |
| 287 // + m_graphicsLayer |
| 288 // + ... |
| 289 // |
| 290 // Note that [*] and [**] exist for the same reason: to clip scrolling conte
nt. That is, |
| 291 // when we scroll A, in fact [+] and [++] are moved and are clipped to [*] a
nd [**], |
| 292 // respectively. |
| 293 // |
| 294 // Now, it may also be the case that C is also clipped by another layer that
doesn't happen |
| 295 // to be its scrolling ancestor. B, in this case. When this happens, we crea
te an |
| 296 // ancestor clipping layer for C, [++]. Unlike the scroll clipping layer, [*
*], which must |
| 297 // stay put during a scroll to do its job, the ancestor clipping layer [++]
does move with |
| 298 // the content it clips. |
| 299 OwnPtr<GraphicsLayer> m_ancestorScrollClippingLayer; // Used if and only if
we have a scroll parent. |
250 OwnPtr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clippe
d by an ancestor which is not a stacking context. | 300 OwnPtr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clippe
d by an ancestor which is not a stacking context. |
251 OwnPtr<GraphicsLayer> m_graphicsLayer; | 301 OwnPtr<GraphicsLayer> m_graphicsLayer; |
| 302 OwnPtr<GraphicsLayer> m_childContainmentLayer; // Only used if we have clipp
ing on a stacking context with compositing children. |
| 303 OwnPtr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using c
omposited scrolling. |
| 304 OwnPtr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is
using composited scrolling. |
| 305 |
| 306 // This layer is also added to the hierarchy by the RLB, but in a different
way than |
| 307 // the layers above. It's added to m_graphicsLayer as its mask layer (natura
lly) if |
| 308 // we have a mask, and isn't part of the typical hierarchy (it has no childr
en). |
| 309 OwnPtr<GraphicsLayer> m_maskLayer; // Only used if we have a mask. |
| 310 |
| 311 // There are two other (optional) layers whose painting is managed by the Re
nderLayerBacking, |
| 312 // but whose position in the hierarchy is maintained by the RenderLayerCompo
sitor. These |
| 313 // are the foreground and background layers. The foreground layer exists if
we have composited |
| 314 // descendants with negative z-order. We need the extra layer in this case b
ecause the layer |
| 315 // needs to draw both below (for the background, say) and above (for the nor
mal flow content, say) |
| 316 // the negative z-order descendants and this is impossible with a single lay
er. The RLC handles |
| 317 // inserting m_foregroundLayer in the correct position in our descendant lis
t for us (right after |
| 318 // the neg z-order dsecendants). |
| 319 // |
| 320 // The background layer is only created if this is the root layer and our ba
ckground is entirely |
| 321 // fixed. In this case we want to put the background in a separate composite
d layer so that when |
| 322 // we scroll, we don't have to re-raster the background into position. This
layer is also inserted |
| 323 // into the tree by the RLC as it gets a special home. This layer becomes a
descendant of the |
| 324 // frame clipping layer. That is: |
| 325 // ... |
| 326 // + frame clipping layer |
| 327 // + m_backgroundLayer |
| 328 // + frame scrolling layer |
| 329 // + root content layer |
| 330 // |
| 331 // With the hierarchy set up like this, the root content layer is able to sc
roll without affecting |
| 332 // the background layer (or repainting). |
252 OwnPtr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need
to draw the foreground separately. | 333 OwnPtr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need
to draw the foreground separately. |
253 OwnPtr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need
to draw the background separately. | 334 OwnPtr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need
to draw the background separately. |
254 OwnPtr<GraphicsLayer> m_childContainmentLayer; // Only used if we have clipp
ing on a stacking context with compositing children, or if the layer has a tile
cache. | |
255 OwnPtr<GraphicsLayer> m_maskLayer; // Only used if we have a mask. | |
256 | 335 |
257 OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar; | 336 OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar; |
258 OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar; | 337 OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar; |
259 OwnPtr<GraphicsLayer> m_layerForScrollCorner; | 338 OwnPtr<GraphicsLayer> m_layerForScrollCorner; |
260 | 339 |
261 OwnPtr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using c
omposited scrolling. | |
262 OwnPtr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is
using composited scrolling. | |
263 | |
264 uint64_t m_scrollLayerID; | |
265 | |
266 IntRect m_compositedBounds; | 340 IntRect m_compositedBounds; |
267 | 341 |
268 bool m_artificiallyInflatedBounds; // bounds had to be made non-zero to make
transform-origin work | 342 bool m_artificiallyInflatedBounds; // bounds had to be made non-zero to make
transform-origin work |
269 bool m_boundsConstrainedByClipping; | 343 bool m_boundsConstrainedByClipping; |
270 bool m_isMainFrameRenderViewLayer; | 344 bool m_isMainFrameRenderViewLayer; |
271 bool m_requiresOwnBackingStore; | 345 bool m_requiresOwnBackingStore; |
272 bool m_canCompositeFilters; | 346 bool m_canCompositeFilters; |
273 bool m_backgroundLayerPaintsFixedRootBackground; | 347 bool m_backgroundLayerPaintsFixedRootBackground; |
274 }; | 348 }; |
275 | 349 |
276 } // namespace WebCore | 350 } // namespace WebCore |
277 | 351 |
278 #endif // RenderLayerBacking_h | 352 #endif // RenderLayerBacking_h |
OLD | NEW |