⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249434 in webkit


Ignore:
Timestamp:
Sep 3, 2019, 11:25:27 AM (7 years ago)
Author:
Simon Fraser
Message:

Make "clips compositing descendants" an indirect compositing reason
https://bugs.webkit.org/show_bug.cgi?id=201381

Reviewed by Antti Koivisto.

Whether a layer has to composite to clip composited descendants is an "indirect" reason,
just like having to composite for filters if there's a composited descendant. So add
IndirectCompositingReason::Clipping, and have computeIndirectCompositingReason() compute this,
replacing the code that ran in computeCompositingRequirements().

This is some preparatory cleanup for webkit.org/b/201330.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::calculateClipRects const):

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

(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::requiresCompositingLayer const):
(WebCore::RenderLayerCompositor::reasonsForCompositing const):
(WebCore::RenderLayerCompositor::computeIndirectCompositingReason const):
(WebCore::RenderLayerCompositor::requiresCompositingForIndirectReason const): Deleted.

  • rendering/RenderLayerCompositor.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r249433 r249434  
     12019-09-03  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make "clips compositing descendants" an indirect compositing reason
     4        https://bugs.webkit.org/show_bug.cgi?id=201381
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Whether a layer has to composite to clip composited descendants is an "indirect" reason,
     9        just like having to composite for filters if there's a composited descendant. So add
     10        IndirectCompositingReason::Clipping, and have computeIndirectCompositingReason() compute this,
     11        replacing the code that ran in computeCompositingRequirements().
     12
     13        This is some preparatory cleanup for webkit.org/b/201330.
     14
     15        * rendering/RenderLayer.cpp:
     16        (WebCore::RenderLayer::calculateClipRects const):
     17        * rendering/RenderLayer.h:
     18        * rendering/RenderLayerCompositor.cpp:
     19        (WebCore::RenderLayerCompositor::computeCompositingRequirements):
     20        (WebCore::RenderLayerCompositor::requiresCompositingLayer const):
     21        (WebCore::RenderLayerCompositor::reasonsForCompositing const):
     22        (WebCore::RenderLayerCompositor::computeIndirectCompositingReason const):
     23        (WebCore::RenderLayerCompositor::requiresCompositingForIndirectReason const): Deleted.
     24        * rendering/RenderLayerCompositor.h:
     25
    1262019-09-03  Zalan Bujtas  <zalan@apple.com>
    227
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r249352 r249434  
    69226922    switch (reason) {
    69236923    case IndirectCompositingReason::None: ts << "none"; break;
     6924    case IndirectCompositingReason::Clipping: ts << "clipping"; break;
    69246925    case IndirectCompositingReason::Stacking: ts << "stacking"; break;
    69256926    case IndirectCompositingReason::OverflowScrollPositioning: ts << "overflow positioning"; break;
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r249339 r249434  
    120120enum class IndirectCompositingReason {
    121121    None,
     122    Clipping,
    122123    Stacking,
    123124    OverflowScrollPositioning,
     
    12391240    bool m_has3DTransformedAncestor : 1;
    12401241
    1241     unsigned m_indirectCompositingReason : 3;
    1242     unsigned m_viewportConstrainedNotCompositedReason : 2;
     1242    unsigned m_indirectCompositingReason : 4; // IndirectCompositingReason
     1243    unsigned m_viewportConstrainedNotCompositedReason : 2; // ViewportConstrainedNotCompositedReason
    12431244
    12441245#if PLATFORM(IOS_FAMILY)
     
    12581259
    12591260#if ENABLE(CSS_COMPOSITING)
    1260     unsigned m_blendMode : 5;
     1261    unsigned m_blendMode : 5; // BlendMode
    12611262    bool m_hasNotIsolatedCompositedBlendingDescendants : 1;
    12621263    bool m_hasNotIsolatedBlendingDescendants : 1;
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r249336 r249434  
    10151015#endif
    10161016    // Now check for reasons to become composited that depend on the state of descendant layers.
    1017     IndirectCompositingReason indirectCompositingReason;
    1018     if (!willBeComposited && canBeComposited(layer)
    1019         && requiresCompositingForIndirectReason(layer, currentState.subtreeIsCompositing, anyDescendantHas3DTransform, layerPaintsIntoProvidedBacking, indirectCompositingReason)) {
    1020         layer.setIndirectCompositingReason(indirectCompositingReason);
    1021         layerWillCompositePostDescendants();
    1022     }
    1023    
     1017    if (!willBeComposited && canBeComposited(layer)) {
     1018        auto indirectReason = computeIndirectCompositingReason(layer, currentState.subtreeIsCompositing, anyDescendantHas3DTransform, layerPaintsIntoProvidedBacking);
     1019        if (indirectReason != IndirectCompositingReason::None) {
     1020            layer.setIndirectCompositingReason(indirectReason);
     1021            layerWillCompositePostDescendants();
     1022        }
     1023    }
     1024
    10241025    if (layer.reflectionLayer()) {
    10251026        // FIXME: Shouldn't we call computeCompositingRequirements to handle a reflection overlapping with another renderer?
    10261027        layer.reflectionLayer()->setIndirectCompositingReason(willBeComposited ? IndirectCompositingReason::Stacking : IndirectCompositingReason::None);
    10271028    }
    1028 
    1029     // setHasCompositingDescendant() may have changed the answer to needsToBeComposited() when clipping, so test that now.
    1030     bool isCompositedClippingLayer = canBeComposited(layer) && clipsCompositingDescendants(layer);
    1031     if (isCompositedClippingLayer & !willBeComposited)
    1032         layerWillCompositePostDescendants();
    10331029
    10341030    // If we're back at the root, and no other layers need to be composited, and the root layer itself doesn't need
     
    23222318    return requiresCompositingForTransform(renderer)
    23232319        || requiresCompositingForAnimation(renderer)
    2324         || clipsCompositingDescendants(*renderer.layer())
    23252320        || requiresCompositingForPosition(renderer, *renderer.layer(), queryData)
    23262321        || requiresCompositingForCanvas(renderer)
     
    24492444        reasons.add(CompositingReason::BackfaceVisibilityHidden);
    24502445
    2451     if (clipsCompositingDescendants(*renderer.layer()))
    2452         reasons.add(CompositingReason::ClipsCompositingDescendants);
    2453 
    24542446    if (requiresCompositingForAnimation(renderer))
    24552447        reasons.add(CompositingReason::Animation);
     
    24692461    switch (renderer.layer()->indirectCompositingReason()) {
    24702462    case IndirectCompositingReason::None:
     2463        break;
     2464    case IndirectCompositingReason::Clipping:
     2465        reasons.add(CompositingReason::ClipsCompositingDescendants);
    24712466        break;
    24722467    case IndirectCompositingReason::Stacking:
     
    30433038}
    30443039
    3045 // FIXME: why doesn't this handle the clipping cases?
    3046 bool RenderLayerCompositor::requiresCompositingForIndirectReason(const RenderLayer& layer, bool hasCompositedDescendants, bool has3DTransformedDescendants, bool paintsIntoProvidedBacking, IndirectCompositingReason& reason) const
     3040IndirectCompositingReason RenderLayerCompositor::computeIndirectCompositingReason(const RenderLayer& layer, bool hasCompositedDescendants, bool has3DTransformedDescendants, bool paintsIntoProvidedBacking) const
    30473041{
    30483042    // When a layer has composited descendants, some effects, like 2d transforms, filters, masks etc must be implemented
    30493043    // via compositing so that they also apply to those composited descendants.
    30503044    auto& renderer = layer.renderer();
    3051     if (hasCompositedDescendants && (layer.isolatesCompositedBlending() || layer.transform() || renderer.createsGroup() || renderer.hasReflection())) {
    3052         reason = IndirectCompositingReason::GraphicalEffect;
    3053         return true;
    3054     }
     3045    if (hasCompositedDescendants && (layer.isolatesCompositedBlending() || layer.transform() || renderer.createsGroup() || renderer.hasReflection()))
     3046        return IndirectCompositingReason::GraphicalEffect;
    30553047
    30563048    // A layer with preserve-3d or perspective only needs to be composited if there are descendant layers that
    30573049    // will be affected by the preserve-3d or perspective.
    30583050    if (has3DTransformedDescendants) {
    3059         if (renderer.style().transformStyle3D() == TransformStyle3D::Preserve3D) {
    3060             reason = IndirectCompositingReason::Preserve3D;
    3061             return true;
    3062         }
     3051        if (renderer.style().transformStyle3D() == TransformStyle3D::Preserve3D)
     3052            return IndirectCompositingReason::Preserve3D;
    30633053   
    3064         if (renderer.style().hasPerspective()) {
    3065             reason = IndirectCompositingReason::Perspective;
    3066             return true;
    3067         }
     3054        if (renderer.style().hasPerspective())
     3055            return IndirectCompositingReason::Perspective;
    30683056    }
    30693057
     
    30713059    if (!paintsIntoProvidedBacking && layer.hasCompositedScrollingAncestor()) {
    30723060        auto* paintDestination = layer.paintOrderParent();
    3073         if (paintDestination && layerScrollBehahaviorRelativeToCompositedAncestor(layer, *paintDestination) != ScrollPositioningBehavior::None) {
    3074             reason = IndirectCompositingReason::OverflowScrollPositioning;
    3075             return true;
    3076         }
    3077     }
    3078 
    3079     reason = IndirectCompositingReason::None;
    3080     return false;
     3061        if (paintDestination && layerScrollBehahaviorRelativeToCompositedAncestor(layer, *paintDestination) != ScrollPositioningBehavior::None)
     3062            return IndirectCompositingReason::OverflowScrollPositioning;
     3063    }
     3064
     3065    // Check for clipping last; if compositing just for clipping, the layer doesn't need its own backing store.
     3066    if (hasCompositedDescendants && clipsCompositingDescendants(layer))
     3067        return IndirectCompositingReason::Clipping;
     3068
     3069    return IndirectCompositingReason::None;
    30813070}
    30823071
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r248762 r249434  
    499499    bool requiresCompositingForOverflowScrolling(const RenderLayer&, RequiresCompositingData&) const;
    500500    bool requiresCompositingForEditableImage(RenderLayerModelObject&) const;
    501     bool requiresCompositingForIndirectReason(const RenderLayer&, bool hasCompositedDescendants, bool has3DTransformedDescendants, bool paintsIntoProvidedBacking, IndirectCompositingReason&) const;
     501    IndirectCompositingReason computeIndirectCompositingReason(const RenderLayer&, bool hasCompositedDescendants, bool has3DTransformedDescendants, bool paintsIntoProvidedBacking) const;
    502502
    503503    static ScrollPositioningBehavior layerScrollBehahaviorRelativeToCompositedAncestor(const RenderLayer&, const RenderLayer& compositedAncestor);
Note: See TracChangeset for help on using the changeset viewer.