Changeset 180948 in webkit


Ignore:
Timestamp:
Mar 3, 2015, 12:12:54 PM (11 years ago)
Author:
Simon Fraser
Message:

Avoid applying the clip-path when painting, if a layer also has a shape layer mask
https://bugs.webkit.org/show_bug.cgi?id=142212

Reviewed by Zalan Bujtas.

After r180882 we translate clip-path into a composited shape mask when the layer
is composited. However, we were also still applying the clip-path when painting
the layer contents.

Now, we set the GraphicsLayer bits GraphicsLayerPaintClipPath and GraphicsLayerPaintMask
only for the m_maskLayer's painting. This translate into setting PaintLayerPaintingCompositingMaskPhase
and PaintLayerPaintingCompositingClipPathPhase only when painting that same mask layer,
rather than always. To ensure that masks and clip-path get applied for software paints,
add shouldPaintMask() and shouldApplyClipPath() that return true for non-composited layers,
and when doing a flattening paint.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::paintLayerContents): Use shouldApplyClipPath().
Pull three chunks of code under a single "if (shouldPaintContent && !selectionOnly)" condition.
The condition for paintChildClippingMaskForFragments() is changed slightly; we need to call this
only when painting the clip-path/mask layer contents, but also only when there is no mask to fill
the clipped area for us.
(WebCore::RenderLayer::calculateClipRects):
(WebCore::RenderLayer::paintsWithClipPath): Deleted.

  • rendering/RenderLayer.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateMaskingLayer): Be sure to set the GraphicsLayerPaintClipPath bit
when having a mask forces us onto the painting path.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r180946 r180948  
     12015-03-03  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Avoid applying the clip-path when painting, if a layer also has a shape layer mask
     4        https://bugs.webkit.org/show_bug.cgi?id=142212
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        After r180882 we translate clip-path into a composited shape mask when the layer
     9        is composited. However, we were also still applying the clip-path when painting
     10        the layer contents.
     11       
     12        Now, we set the GraphicsLayer bits GraphicsLayerPaintClipPath and GraphicsLayerPaintMask
     13        only for the m_maskLayer's painting. This translate into setting PaintLayerPaintingCompositingMaskPhase
     14        and PaintLayerPaintingCompositingClipPathPhase only when painting that same mask layer,
     15        rather than always. To ensure that masks and clip-path get applied for software paints,
     16        add shouldPaintMask() and shouldApplyClipPath() that return true for non-composited layers,
     17        and when doing a flattening paint.
     18
     19        * rendering/RenderLayer.cpp:
     20        (WebCore::RenderLayer::paintLayerContents): Use shouldApplyClipPath().
     21        Pull three chunks of code under a single "if (shouldPaintContent && !selectionOnly)" condition.
     22        The condition for paintChildClippingMaskForFragments() is changed slightly; we need to call this
     23        only when painting the clip-path/mask layer contents, but also only when there is no mask to fill
     24        the clipped area for us.
     25        (WebCore::RenderLayer::calculateClipRects):
     26        (WebCore::RenderLayer::paintsWithClipPath): Deleted.
     27        * rendering/RenderLayer.h:
     28        * rendering/RenderLayerBacking.cpp:
     29        (WebCore::RenderLayerBacking::updateMaskingLayer): Be sure to set the GraphicsLayerPaintClipPath bit
     30        when having a mask forces us onto the painting path.
     31
    1322015-03-03  Anders Carlsson  <andersca@apple.com>
    233
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r180882 r180948  
    40244024}
    40254025
    4026 bool RenderLayer::paintsWithClipPath() const
    4027 {
    4028     return renderer().style().clipPath() && !isComposited();
    4029 }
    4030 
    40314026Path RenderLayer::computeClipPath(const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, WindRule& windRule) const
    40324027{
     
    42404235
    42414236    bool hasClipPath = false;
    4242     if (paintsWithClipPath() || (localPaintFlags & PaintLayerPaintingCompositingClipPathPhase) || (localPaintFlags & PaintLayerPaintingCompositingMaskPhase))
     4237    if (shouldApplyClipPath(paintingInfo.paintBehavior, localPaintFlags))
    42434238        hasClipPath = setupClipPath(context, paintingInfo, columnAwareOffsetFromRoot, rootRelativeBounds, rootRelativeBoundsComputed);
    42444239
     
    43374332    ASSERT(transparencyLayerContext == context);
    43384333
    4339     if ((localPaintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && renderer().hasMask() && !selectionOnly) {
    4340         // Paint the mask for the fragments.
    4341         paintMaskForFragments(layerFragments, context, localPaintingInfo, subtreePaintRootForRenderer);
    4342     }
    4343 
    4344     if ((localPaintFlags & PaintLayerPaintingCompositingClipPathPhase) && shouldPaintContent && !selectionOnly) {
    4345         // Re-use paintChildClippingMaskForFragments to paint black for the compositing clipping mask.
    4346         paintChildClippingMaskForFragments(layerFragments, context, localPaintingInfo, subtreePaintRootForRenderer);
    4347     }
    4348    
    4349     if ((localPaintFlags & PaintLayerPaintingChildClippingMaskPhase) && shouldPaintContent && !selectionOnly) {
    4350         // Paint the border radius mask for the fragments.
    4351         paintChildClippingMaskForFragments(layerFragments, context, localPaintingInfo, subtreePaintRootForRenderer);
     4334    if (shouldPaintContent && !selectionOnly) {
     4335        if (shouldPaintMask(paintingInfo.paintBehavior, localPaintFlags)) {
     4336            // Paint the mask for the fragments.
     4337            paintMaskForFragments(layerFragments, context, localPaintingInfo, subtreePaintRootForRenderer);
     4338        }
     4339
     4340        if (!(paintFlags & PaintLayerPaintingCompositingMaskPhase) && (paintFlags & PaintLayerPaintingCompositingClipPathPhase)) {
     4341            // Re-use paintChildClippingMaskForFragments to paint black for the compositing clipping mask.
     4342            paintChildClippingMaskForFragments(layerFragments, context, localPaintingInfo, subtreePaintRootForRenderer);
     4343        }
     4344       
     4345        if ((localPaintFlags & PaintLayerPaintingChildClippingMaskPhase)) {
     4346            // Paint the border radius mask for the fragments.
     4347            paintChildClippingMaskForFragments(layerFragments, context, localPaintingInfo, subtreePaintRootForRenderer);
     4348        }
    43524349    }
    43534350
     
    60636060}
    60646061
     6062bool RenderLayer::shouldPaintMask(PaintBehavior paintBehavior, PaintLayerFlags paintFlags) const
     6063{
     6064    if (!renderer().hasMask())
     6065        return false;
     6066
     6067    bool paintsToWindow = !isComposited() || backing()->paintsIntoWindow();
     6068    if (paintsToWindow || (paintBehavior & PaintBehaviorFlattenCompositingLayers))
     6069        return true;
     6070
     6071    return (paintFlags & PaintLayerPaintingCompositingMaskPhase);
     6072}
     6073
     6074bool RenderLayer::shouldApplyClipPath(PaintBehavior paintBehavior, PaintLayerFlags paintFlags) const
     6075{
     6076    if (!renderer().hasClipPath())
     6077        return false;
     6078
     6079    bool paintsToWindow = !isComposited() || backing()->paintsIntoWindow();
     6080    if (paintsToWindow || (paintBehavior & PaintBehaviorFlattenCompositingLayers))
     6081        return true;
     6082
     6083    return (paintFlags & PaintLayerPaintingCompositingClipPathPhase);
     6084}
     6085
    60656086bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
    60666087{
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r180882 r180948  
    443443        PaintLayerPaintingSkipRootBackground            = 1 << 12,
    444444        PaintLayerPaintingChildClippingMaskPhase        = 1 << 13,
    445         PaintLayerPaintingCompositingAllPhases          = PaintLayerPaintingCompositingBackgroundPhase | PaintLayerPaintingCompositingForegroundPhase | PaintLayerPaintingCompositingMaskPhase
     445        PaintLayerPaintingCompositingAllPhases          = PaintLayerPaintingCompositingBackgroundPhase | PaintLayerPaintingCompositingForegroundPhase
    446446    };
    447447   
     
    606606
    607607    bool paintsWithTransform(PaintBehavior) const;
     608    bool shouldPaintMask(PaintBehavior, PaintLayerFlags) const;
     609    bool shouldApplyClipPath(PaintBehavior, PaintLayerFlags) const;
    608610
    609611    // Returns true if background phase is painted opaque in the given rect.
     
    754756
    755757    bool setupFontSubpixelQuantization(GraphicsContext*, bool& didQuantizeFonts);
    756 
    757     bool paintsWithClipPath() const;
    758758
    759759    Path computeClipPath(const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, WindRule&) const;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r180882 r180948  
    14391439       
    14401440        if (hasClipPath) {
    1441             bool clipNeedsPainting = renderer().style().clipPath()->type() == ClipPathOperation::Reference;
    1442             if (clipNeedsPainting || !GraphicsLayer::supportsLayerType(GraphicsLayer::Type::Shape))
     1441            // If we have a mask, we need to paint the combined clip-path and mask into the mask layer.
     1442            if (hasMask || renderer().style().clipPath()->type() == ClipPathOperation::Reference || !GraphicsLayer::supportsLayerType(GraphicsLayer::Type::Shape))
    14431443                maskPhases |= GraphicsLayerPaintClipPath;
    14441444        }
Note: See TracChangeset for help on using the changeset viewer.