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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return (!page) ? nullptr : page->scrollingCoordinator(); | 167 return (!page) ? nullptr : page->scrollingCoordinator(); |
168 } | 168 } |
169 | 169 |
170 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer) | 170 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer) |
171 : m_owningLayer(layer) | 171 : m_owningLayer(layer) |
172 , m_contentOffsetInCompositingLayerDirty(false) | 172 , m_contentOffsetInCompositingLayerDirty(false) |
173 , m_pendingUpdateScope(GraphicsLayerUpdateNone) | 173 , m_pendingUpdateScope(GraphicsLayerUpdateNone) |
174 , m_isMainFrameLayoutViewLayer(false) | 174 , m_isMainFrameLayoutViewLayer(false) |
175 , m_backgroundLayerPaintsFixedRootBackground(false) | 175 , m_backgroundLayerPaintsFixedRootBackground(false) |
176 , m_scrollingContentsAreEmpty(false) | 176 , m_scrollingContentsAreEmpty(false) |
| 177 , m_backgroundPaintsOntoScrollingContentsLayer(false) |
177 { | 178 { |
178 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame()) | 179 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame()) |
179 m_isMainFrameLayoutViewLayer = true; | 180 m_isMainFrameLayoutViewLayer = true; |
180 | 181 |
181 createPrimaryGraphicsLayer(); | 182 createPrimaryGraphicsLayer(); |
182 } | 183 } |
183 | 184 |
184 CompositedLayerMapping::~CompositedLayerMapping() | 185 CompositedLayerMapping::~CompositedLayerMapping() |
185 { | 186 { |
186 // Hits in compositing/squashing/squash-onto-nephew.html. | 187 // Hits in compositing/squashing/squash-onto-nephew.html. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 void CompositedLayerMapping::updateIsRootForIsolatedGroup() | 288 void CompositedLayerMapping::updateIsRootForIsolatedGroup() |
288 { | 289 { |
289 bool isolate = m_owningLayer.shouldIsolateCompositedDescendants(); | 290 bool isolate = m_owningLayer.shouldIsolateCompositedDescendants(); |
290 | 291 |
291 // non stacking context layers should never isolate | 292 // non stacking context layers should never isolate |
292 ASSERT(m_owningLayer.stackingNode()->isStackingContext() || !isolate); | 293 ASSERT(m_owningLayer.stackingNode()->isStackingContext() || !isolate); |
293 | 294 |
294 m_graphicsLayer->setIsRootForIsolatedGroup(isolate); | 295 m_graphicsLayer->setIsRootForIsolatedGroup(isolate); |
295 } | 296 } |
296 | 297 |
| 298 void CompositedLayerMapping::updateBackgroundPaintsOntoScrollingContentsLayer() |
| 299 { |
| 300 bool shouldPaintOntoScrollingContentsLayer = shouldPaintBackgroundOntoScroll
ingContentsLayer(); |
| 301 if (shouldPaintOntoScrollingContentsLayer != backgroundPaintsOntoScrollingCo
ntentsLayer()) { |
| 302 m_backgroundPaintsOntoScrollingContentsLayer = shouldPaintOntoScrollingC
ontentsLayer; |
| 303 // If the background is no longer painted onto the scrolling contents |
| 304 // layer the scrolling contents layer needs to be updated. If it is |
| 305 // going to be painted onto the scrolling contents layer this update |
| 306 // will be triggered by LayoutBoxModelObject::setBackingNeedsPaintInvali
dationInRect |
| 307 if (hasScrollingLayer() && !shouldPaintOntoScrollingContentsLayer) |
| 308 m_scrollingContentsLayer->setNeedsDisplay(); |
| 309 } |
| 310 } |
| 311 |
297 void CompositedLayerMapping::updateContentsOpaque() | 312 void CompositedLayerMapping::updateContentsOpaque() |
298 { | 313 { |
299 ASSERT(m_isMainFrameLayoutViewLayer || !m_backgroundLayer); | |
300 if (isAcceleratedCanvas(layoutObject())) { | 314 if (isAcceleratedCanvas(layoutObject())) { |
301 // Determine whether the rendering context's external texture layer is o
paque. | 315 // Determine whether the rendering context's external texture layer is o
paque. |
302 CanvasRenderingContext* context = toHTMLCanvasElement(layoutObject()->no
de())->renderingContext(); | 316 CanvasRenderingContext* context = toHTMLCanvasElement(layoutObject()->no
de())->renderingContext(); |
303 if (!context->hasAlpha()) | 317 if (!context->hasAlpha()) |
304 m_graphicsLayer->setContentsOpaque(true); | 318 m_graphicsLayer->setContentsOpaque(true); |
305 else if (WebLayer* layer = context->platformLayer()) | 319 else if (WebLayer* layer = context->platformLayer()) |
306 m_graphicsLayer->setContentsOpaque(!Color(layer->backgroundColor()).
hasAlpha()); | 320 m_graphicsLayer->setContentsOpaque(!Color(layer->backgroundColor()).
hasAlpha()); |
307 else | 321 else |
308 m_graphicsLayer->setContentsOpaque(false); | 322 m_graphicsLayer->setContentsOpaque(false); |
309 } else if (m_backgroundLayer) { | 323 } else if (m_backgroundLayer) { |
310 m_graphicsLayer->setContentsOpaque(false); | 324 m_graphicsLayer->setContentsOpaque(false); |
311 m_backgroundLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBe
OpaqueInRect(compositedBounds())); | 325 m_backgroundLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBe
OpaqueInRect(compositedBounds())); |
312 } else { | 326 } else { |
313 // For non-root layers, background is painted by the scrolling contents
layer if all backgrounds | 327 // For non-root layers, background is painted by the scrolling contents
layer if all backgrounds |
314 // are background attachment local, otherwise background is painted by t
he primary graphics layer. | 328 // are background attachment local, otherwise background is painted by t
he primary graphics layer. |
315 if (hasScrollingLayer() && shouldPaintBackgroundOntoScrollingContentsLay
er()) { | 329 if (hasScrollingLayer() && m_backgroundPaintsOntoScrollingContentsLayer)
{ |
316 // Backgrounds painted onto the foreground are clipped by the paddin
g box rect. | 330 // Backgrounds painted onto the foreground are clipped by the paddin
g box rect. |
317 // TODO(flackr): This should actually check the entire overflow rect
within the | 331 // TODO(flackr): This should actually check the entire overflow rect
within the |
318 // scrolling contents layer but since we currently only trigger this
for solid | 332 // scrolling contents layer but since we currently only trigger this
for solid |
319 // color backgrounds the answer will be the same. | 333 // color backgrounds the answer will be the same. |
320 m_scrollingContentsLayer->setContentsOpaque(m_owningLayer.background
IsKnownToBeOpaqueInRect(toLayoutBox(layoutObject())->paddingBoxRect())); | 334 m_scrollingContentsLayer->setContentsOpaque(m_owningLayer.background
IsKnownToBeOpaqueInRect(toLayoutBox(layoutObject())->paddingBoxRect())); |
321 | 335 |
322 // When we paint the background onto the scrolling contents layer we
are going | 336 // When we paint the background onto the scrolling contents layer we
are going |
323 // to leave a hole in the m_graphicsLayer where the background is so
it is | 337 // to leave a hole in the m_graphicsLayer where the background is so
it is |
324 // not opaque. | 338 // not opaque. |
325 m_graphicsLayer->setContentsOpaque(false); | 339 m_graphicsLayer->setContentsOpaque(false); |
326 } else { | 340 } else { |
| 341 if (hasScrollingLayer()) |
| 342 m_scrollingContentsLayer->setContentsOpaque(false); |
327 m_graphicsLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownTo
BeOpaqueInRect(compositedBounds())); | 343 m_graphicsLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownTo
BeOpaqueInRect(compositedBounds())); |
328 } | 344 } |
329 } | 345 } |
330 } | 346 } |
331 | 347 |
332 void CompositedLayerMapping::updateCompositedBounds() | 348 void CompositedLayerMapping::updateCompositedBounds() |
333 { | 349 { |
334 ASSERT(m_owningLayer.compositor()->lifecycle().state() == DocumentLifecycle:
:InCompositingUpdate); | 350 ASSERT(m_owningLayer.compositor()->lifecycle().state() == DocumentLifecycle:
:InCompositingUpdate); |
335 // FIXME: if this is really needed for performance, it would be better to st
ore it on Layer. | 351 // FIXME: if this is really needed for performance, it would be better to st
ore it on Layer. |
336 m_compositedBounds = m_owningLayer.boundingBoxForCompositing(); | 352 m_compositedBounds = m_owningLayer.boundingBoxForCompositing(); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 | 778 |
763 if (m_owningLayer.getScrollableArea() && m_owningLayer.getScrollableArea()->
scrollsOverflow()) | 779 if (m_owningLayer.getScrollableArea() && m_owningLayer.getScrollableArea()->
scrollsOverflow()) |
764 m_owningLayer.getScrollableArea()->positionOverflowControls(); | 780 m_owningLayer.getScrollableArea()->positionOverflowControls(); |
765 | 781 |
766 updateLayerBlendMode(layoutObject()->styleRef()); | 782 updateLayerBlendMode(layoutObject()->styleRef()); |
767 updateIsRootForIsolatedGroup(); | 783 updateIsRootForIsolatedGroup(); |
768 updateContentsRect(); | 784 updateContentsRect(); |
769 updateBackgroundColor(); | 785 updateBackgroundColor(); |
770 updateDrawsContent(); | 786 updateDrawsContent(); |
771 updateElementIdAndCompositorMutableProperties(); | 787 updateElementIdAndCompositorMutableProperties(); |
| 788 updateBackgroundPaintsOntoScrollingContentsLayer(); |
772 updateContentsOpaque(); | 789 updateContentsOpaque(); |
773 updateAfterPartResize(); | 790 updateAfterPartResize(); |
774 updateRenderingContext(); | 791 updateRenderingContext(); |
775 updateShouldFlattenTransform(); | 792 updateShouldFlattenTransform(); |
776 updateChildrenTransform(); | 793 updateChildrenTransform(); |
777 updateScrollParent(scrollParent()); | 794 updateScrollParent(scrollParent()); |
778 registerScrollingLayers(); | 795 registerScrollingLayers(); |
779 | 796 |
780 updateCompositingReasons(); | 797 updateCompositingReasons(); |
781 } | 798 } |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2454 else if (compositor()->fixedRootBackgroundLayer() && m_owningLayer.isRootLay
er()) | 2471 else if (compositor()->fixedRootBackgroundLayer() && m_owningLayer.isRootLay
er()) |
2455 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; | 2472 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; |
2456 | 2473 |
2457 if (graphicsLayer == m_graphicsLayer.get() | 2474 if (graphicsLayer == m_graphicsLayer.get() |
2458 || graphicsLayer == m_foregroundLayer.get() | 2475 || graphicsLayer == m_foregroundLayer.get() |
2459 || graphicsLayer == m_backgroundLayer.get() | 2476 || graphicsLayer == m_backgroundLayer.get() |
2460 || graphicsLayer == m_maskLayer.get() | 2477 || graphicsLayer == m_maskLayer.get() |
2461 || graphicsLayer == m_childClippingMaskLayer.get() | 2478 || graphicsLayer == m_childClippingMaskLayer.get() |
2462 || graphicsLayer == m_scrollingContentsLayer.get()) { | 2479 || graphicsLayer == m_scrollingContentsLayer.get()) { |
2463 | 2480 |
2464 bool paintRootBackgroundOntoScrollingContentsLayer = shouldPaintBackgrou
ndOntoScrollingContentsLayer(); | 2481 bool paintRootBackgroundOntoScrollingContentsLayer = m_backgroundPaintsO
ntoScrollingContentsLayer; |
2465 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer || (!m_backgroundL
ayer && !m_foregroundLayer)); | 2482 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer || (!m_backgroundL
ayer && !m_foregroundLayer)); |
2466 if (paintRootBackgroundOntoScrollingContentsLayer) { | 2483 if (paintRootBackgroundOntoScrollingContentsLayer) { |
2467 if (graphicsLayer == m_scrollingContentsLayer.get()) | 2484 if (graphicsLayer == m_scrollingContentsLayer.get()) |
2468 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground; | 2485 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground; |
2469 else | 2486 else |
2470 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; | 2487 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; |
2471 } | 2488 } |
2472 GraphicsLayerPaintInfo paintInfo; | 2489 GraphicsLayerPaintInfo paintInfo; |
2473 paintInfo.paintLayer = &m_owningLayer; | 2490 paintInfo.paintLayer = &m_owningLayer; |
2474 paintInfo.compositedBounds = compositedBounds(); | 2491 paintInfo.compositedBounds = compositedBounds(); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2694 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2711 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
2695 name = "Scrolling Contents Layer"; | 2712 name = "Scrolling Contents Layer"; |
2696 } else { | 2713 } else { |
2697 ASSERT_NOT_REACHED(); | 2714 ASSERT_NOT_REACHED(); |
2698 } | 2715 } |
2699 | 2716 |
2700 return name; | 2717 return name; |
2701 } | 2718 } |
2702 | 2719 |
2703 } // namespace blink | 2720 } // namespace blink |
OLD | NEW |