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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 if (!context->hasAlpha()) | 302 if (!context->hasAlpha()) |
303 m_graphicsLayer->setContentsOpaque(true); | 303 m_graphicsLayer->setContentsOpaque(true); |
304 else if (WebLayer* layer = context->platformLayer()) | 304 else if (WebLayer* layer = context->platformLayer()) |
305 m_graphicsLayer->setContentsOpaque(!Color(layer->backgroundColor()). hasAlpha()); | 305 m_graphicsLayer->setContentsOpaque(!Color(layer->backgroundColor()). hasAlpha()); |
306 else | 306 else |
307 m_graphicsLayer->setContentsOpaque(false); | 307 m_graphicsLayer->setContentsOpaque(false); |
308 } else if (m_backgroundLayer) { | 308 } else if (m_backgroundLayer) { |
309 m_graphicsLayer->setContentsOpaque(false); | 309 m_graphicsLayer->setContentsOpaque(false); |
310 m_backgroundLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBe OpaqueInRect(compositedBounds())); | 310 m_backgroundLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBe OpaqueInRect(compositedBounds())); |
311 } else { | 311 } else { |
312 // For non-root layers, background is always painted by the primary grap hics layer. | 312 // For non-root layers, background is painted by the scrolling contents layer if all backgrounds |
313 m_graphicsLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBeOp aqueInRect(compositedBounds())); | 313 // are background attachment local, otherwise background is painted by t he primary graphics layer. |
314 if (hasScrollingLayer() && shouldPaintBackgroundOntoScrollingContentsLay er()) { | |
315 // Backgrounds painted onto the foreground are clipped by the paddin g box rect. | |
316 // TODO(flackr): This should actually check the entire overflow rect within the | |
317 // scrolling contents layer but since we currently only trigger this for solid | |
318 // color backgrounds the answer will be the same. | |
319 m_scrollingContentsLayer->setContentsOpaque(m_owningLayer.background IsKnownToBeOpaqueInRect(toLayoutBox(layoutObject())->paddingBoxRect())); | |
320 | |
321 // When we paint the background onto the scrolling contents layer we are going | |
322 // to leave a hole in the m_graphicsLayer where the background is so it is | |
323 // not opaque. | |
324 m_graphicsLayer->setContentsOpaque(false); | |
325 } else { | |
326 m_graphicsLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownTo BeOpaqueInRect(compositedBounds())); | |
327 } | |
314 } | 328 } |
315 } | 329 } |
316 | 330 |
317 void CompositedLayerMapping::updateCompositedBounds() | 331 void CompositedLayerMapping::updateCompositedBounds() |
318 { | 332 { |
319 ASSERT(m_owningLayer.compositor()->lifecycle().state() == DocumentLifecycle: :InCompositingUpdate); | 333 ASSERT(m_owningLayer.compositor()->lifecycle().state() == DocumentLifecycle: :InCompositingUpdate); |
320 // FIXME: if this is really needed for performance, it would be better to st ore it on Layer. | 334 // FIXME: if this is really needed for performance, it would be better to st ore it on Layer. |
321 m_compositedBounds = m_owningLayer.boundingBoxForCompositing(); | 335 m_compositedBounds = m_owningLayer.boundingBoxForCompositing(); |
322 m_contentOffsetInCompositingLayerDirty = true; | 336 m_contentOffsetInCompositingLayerDirty = true; |
323 } | 337 } |
(...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2406 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead. | 2420 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead. |
2407 if (Page* page = layoutObject()->frame()->page()) | 2421 if (Page* page = layoutObject()->frame()->page()) |
2408 page->setIsPainting(true); | 2422 page->setIsPainting(true); |
2409 #endif | 2423 #endif |
2410 | 2424 |
2411 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); | 2425 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); |
2412 | 2426 |
2413 PaintLayerFlags paintLayerFlags = 0; | 2427 PaintLayerFlags paintLayerFlags = 0; |
2414 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground) | 2428 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground) |
2415 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase; | 2429 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase; |
2430 else | |
2431 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; | |
2416 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground) | 2432 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground) |
2417 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; | 2433 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; |
2418 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) | 2434 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) |
2419 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; | 2435 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; |
2420 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) | 2436 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) |
2421 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; | 2437 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; |
2422 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) | 2438 if (graphicsLayerPaintingPhase & GraphicsLayerPaintOverflowContents) |
2423 paintLayerFlags |= PaintLayerPaintingOverflowContents; | 2439 paintLayerFlags |= PaintLayerPaintingOverflowContents; |
2424 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) | 2440 if (graphicsLayerPaintingPhase & GraphicsLayerPaintCompositedScroll) |
2425 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; | 2441 paintLayerFlags |= PaintLayerPaintingCompositingScrollingPhase; |
2426 | 2442 |
2427 if (graphicsLayer == m_backgroundLayer.get()) | 2443 if (graphicsLayer == m_backgroundLayer.get()) |
2428 paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPai ntingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroun dPhase to walk child layers. | 2444 paintLayerFlags |= (PaintLayerPaintingRootBackgroundOnly | PaintLayerPai ntingCompositingForegroundPhase); // Need PaintLayerPaintingCompositingForegroun dPhase to walk child layers. |
2429 else if (compositor()->fixedRootBackgroundLayer()) | 2445 else if (compositor()->fixedRootBackgroundLayer() && m_owningLayer.isRootLay er()) |
2430 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; | 2446 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; |
2431 | 2447 |
2432 if (graphicsLayer == m_graphicsLayer.get() | 2448 if (graphicsLayer == m_graphicsLayer.get() |
2433 || graphicsLayer == m_foregroundLayer.get() | 2449 || graphicsLayer == m_foregroundLayer.get() |
2434 || graphicsLayer == m_backgroundLayer.get() | 2450 || graphicsLayer == m_backgroundLayer.get() |
2435 || graphicsLayer == m_maskLayer.get() | 2451 || graphicsLayer == m_maskLayer.get() |
2436 || graphicsLayer == m_childClippingMaskLayer.get() | 2452 || graphicsLayer == m_childClippingMaskLayer.get() |
2437 || graphicsLayer == m_scrollingContentsLayer.get()) { | 2453 || graphicsLayer == m_scrollingContentsLayer.get()) { |
2438 | 2454 |
2455 bool paintRootBackgroundOntoScrollingContentsLayer = shouldPaintBackgrou ndOntoScrollingContentsLayer(); | |
2456 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer || (!m_backgroundL ayer && !m_foregroundLayer)); | |
2457 if (paintRootBackgroundOntoScrollingContentsLayer) { | |
2458 if (graphicsLayer == m_scrollingContentsLayer.get()) | |
2459 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground; | |
2460 else | |
2461 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; | |
2462 } | |
2439 GraphicsLayerPaintInfo paintInfo; | 2463 GraphicsLayerPaintInfo paintInfo; |
2440 paintInfo.paintLayer = &m_owningLayer; | 2464 paintInfo.paintLayer = &m_owningLayer; |
2441 paintInfo.compositedBounds = compositedBounds(); | 2465 paintInfo.compositedBounds = compositedBounds(); |
2442 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject (); | 2466 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject (); |
2443 adjustForCompositedScrolling(graphicsLayer, paintInfo.offsetFromLayoutOb ject); | 2467 adjustForCompositedScrolling(graphicsLayer, paintInfo.offsetFromLayoutOb ject); |
2444 | 2468 |
2445 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. | 2469 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. |
2446 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, context, interes tRect); | 2470 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, context, interes tRect); |
2447 } else if (graphicsLayer == m_squashingLayer.get()) { | 2471 } else if (graphicsLayer == m_squashingLayer.get()) { |
2448 for (size_t i = 0; i < m_squashedLayers.size(); ++i) | 2472 for (size_t i = 0; i < m_squashedLayers.size(); ++i) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2540 if (m_squashedLayers[previousIndex].paintLayer == layerToRemove) | 2564 if (m_squashedLayers[previousIndex].paintLayer == layerToRemove) |
2541 break; | 2565 break; |
2542 } | 2566 } |
2543 if (previousIndex == indexToClear && layerToRemove->groupedMapping() == this ) { | 2567 if (previousIndex == indexToClear && layerToRemove->groupedMapping() == this ) { |
2544 compositor()->paintInvalidationOnCompositingChange(layerToRemove); | 2568 compositor()->paintInvalidationOnCompositingChange(layerToRemove); |
2545 return true; | 2569 return true; |
2546 } | 2570 } |
2547 return false; | 2571 return false; |
2548 } | 2572 } |
2549 | 2573 |
2574 bool CompositedLayerMapping::shouldPaintBackgroundOntoScrollingContentsLayer() c onst | |
chrishtr
2016/08/08 21:16:40
Unittest this method with a few cases. Those cases
flackr
2016/08/09 18:35:27
Done, but I think we should keep all of the added
| |
2575 { | |
2576 // TODO(flackr): Add support for painting locally attached background images . https://crbug.com/625882 | |
2577 const FillLayer& backgroundLayer = m_owningLayer.layoutObject()->style()->ba ckgroundLayers(); | |
2578 return !m_owningLayer.isRootLayer() | |
2579 && m_owningLayer.scrollsOverflow() | |
2580 && !backgroundLayer.image() | |
2581 && !backgroundLayer.next() | |
2582 && (backgroundLayer.attachment() == LocalBackgroundAttachment | |
2583 || backgroundLayer.clip() == PaddingFillBox) | |
2584 && !m_owningLayer.stackingNode()->hasNegativeZOrderList(); | |
2585 } | |
2586 | |
2550 bool CompositedLayerMapping::updateSquashingLayerAssignment(PaintLayer* squashed Layer, size_t nextSquashedLayerIndex) | 2587 bool CompositedLayerMapping::updateSquashingLayerAssignment(PaintLayer* squashed Layer, size_t nextSquashedLayerIndex) |
2551 { | 2588 { |
2552 GraphicsLayerPaintInfo paintInfo; | 2589 GraphicsLayerPaintInfo paintInfo; |
2553 paintInfo.paintLayer = squashedLayer; | 2590 paintInfo.paintLayer = squashedLayer; |
2554 // NOTE: composited bounds are updated elsewhere | 2591 // NOTE: composited bounds are updated elsewhere |
2555 // NOTE: offsetFromLayoutObject is updated elsewhere | 2592 // NOTE: offsetFromLayoutObject is updated elsewhere |
2556 | 2593 |
2557 // Change tracking on squashing layers: at the first sign of something chang ed, just invalidate the layer. | 2594 // Change tracking on squashing layers: at the first sign of something chang ed, just invalidate the layer. |
2558 // FIXME: Perhaps we can find a tighter more clever mechanism later. | 2595 // FIXME: Perhaps we can find a tighter more clever mechanism later. |
2559 if (nextSquashedLayerIndex < m_squashedLayers.size()) { | 2596 if (nextSquashedLayerIndex < m_squashedLayers.size()) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2660 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2697 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
2661 name = "Scrolling Contents Layer"; | 2698 name = "Scrolling Contents Layer"; |
2662 } else { | 2699 } else { |
2663 ASSERT_NOT_REACHED(); | 2700 ASSERT_NOT_REACHED(); |
2664 } | 2701 } |
2665 | 2702 |
2666 return name; | 2703 return name; |
2667 } | 2704 } |
2668 | 2705 |
2669 } // namespace blink | 2706 } // namespace blink |
OLD | NEW |