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

Changeset 245977 in webkit


Ignore:
Timestamp:
May 31, 2019, 12:07:30 PM (7 years ago)
Author:
Simon Fraser
Message:

Move code that sets compositing paint phases into a single function
https://bugs.webkit.org/show_bug.cgi?id=198420

Reviewed by Zalan Bujtas.

Source/WebCore:

To compute the correct paint phases for the various GraphicsLayers in a RenderLayerBacking,
we have to know which set of layers we've created (m_scrollContainerLayer, m_foregroundLayer etc).
So move the code that sets phases into a single function which is called when that
set of layers changes.

The test dumps paint phases for a stacking-context-composited scroller with a negative z-index child.

Also have GraphicsLayer::setPaintingPhase() trigger the necessary repaint when the paint phase changes.

Test: compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html

  • platform/graphics/GraphicsLayer.cpp:

(WebCore::GraphicsLayer::setPaintingPhase):

  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::setPaintingPhase): Deleted.

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::updateForegroundLayer):
(WebCore::RenderLayerBacking::updateBackgroundLayer):
(WebCore::RenderLayerBacking::updateMaskingLayer):
(WebCore::RenderLayerBacking::updateScrollingLayers):
(WebCore::RenderLayerBacking::updatePaintingPhases):
(WebCore::RenderLayerBacking::paintingPhaseForPrimaryLayer const): Deleted.

  • rendering/RenderLayerBacking.h:

LayoutTests:

  • compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
  • compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html: Added.
  • platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
  • platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245974 r245977  
     12019-05-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Move code that sets compositing paint phases into a single function
     4        https://bugs.webkit.org/show_bug.cgi?id=198420
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        * compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
     9        * compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html: Added.
     10        * platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
     11        * platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt: Added.
     12
    1132019-05-31  Saam Barati  <sbarati@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r245974 r245977  
     12019-05-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Move code that sets compositing paint phases into a single function
     4        https://bugs.webkit.org/show_bug.cgi?id=198420
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        To compute the correct paint phases for the various GraphicsLayers in a RenderLayerBacking,
     9        we have to know which set of layers we've created (m_scrollContainerLayer, m_foregroundLayer etc).
     10        So move the code that sets phases into a single function which is called when that
     11        set of layers changes.
     12
     13        The test dumps paint phases for a stacking-context-composited scroller with a negative z-index child.
     14
     15        Also have GraphicsLayer::setPaintingPhase() trigger the necessary repaint when the paint phase changes.
     16
     17        Test: compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html
     18
     19        * platform/graphics/GraphicsLayer.cpp:
     20        (WebCore::GraphicsLayer::setPaintingPhase):
     21        * platform/graphics/GraphicsLayer.h:
     22        (WebCore::GraphicsLayer::setPaintingPhase): Deleted.
     23        * rendering/RenderLayerBacking.cpp:
     24        (WebCore::RenderLayerBacking::updateConfiguration):
     25        (WebCore::RenderLayerBacking::updateForegroundLayer):
     26        (WebCore::RenderLayerBacking::updateBackgroundLayer):
     27        (WebCore::RenderLayerBacking::updateMaskingLayer):
     28        (WebCore::RenderLayerBacking::updateScrollingLayers):
     29        (WebCore::RenderLayerBacking::updatePaintingPhases):
     30        (WebCore::RenderLayerBacking::paintingPhaseForPrimaryLayer const): Deleted.
     31        * rendering/RenderLayerBacking.h:
     32
    1332019-05-31  Saam Barati  <sbarati@apple.com>
    234
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r245974 r245977  
    490490{
    491491    m_backgroundColor = color;
     492}
     493
     494void GraphicsLayer::setPaintingPhase(OptionSet<GraphicsLayerPaintingPhase> phase)
     495{
     496    if (phase == m_paintingPhase)
     497        return;
     498
     499    setNeedsDisplay();
     500    m_paintingPhase = phase;
    492501}
    493502
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r245974 r245977  
    416416    // Some GraphicsLayers paint only the foreground or the background content
    417417    OptionSet<GraphicsLayerPaintingPhase> paintingPhase() const { return m_paintingPhase; }
    418     void setPaintingPhase(OptionSet<GraphicsLayerPaintingPhase> phase) { m_paintingPhase = phase; }
     418    void setPaintingPhase(OptionSet<GraphicsLayerPaintingPhase>);
    419419
    420420    enum ShouldClipToLayer {
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r245950 r245977  
    820820    }
    821821
    822     updateMaskingLayer(renderer().hasMask(), renderer().hasClipPath());
     822    if (updateMaskingLayer(renderer().hasMask(), renderer().hasClipPath()))
     823        layerConfigChanged = true;
    823824
    824825    updateChildClippingStrategy(needsDescendantsClippingLayer);
     
    888889        }
    889890    }
     891
     892    if (layerConfigChanged)
     893        updatePaintingPhases();
    890894
    891895    return layerConfigChanged;
     
    17101714            m_foregroundLayer = createGraphicsLayer(layerName);
    17111715            m_foregroundLayer->setDrawsContent(true);
    1712             m_foregroundLayer->setPaintingPhase({ GraphicsLayerPaintingPhase::Foreground });
    17131716            layerChanged = true;
    17141717        }
     
    17171720        GraphicsLayer::unparentAndClear(m_foregroundLayer);
    17181721        layerChanged = true;
    1719     }
    1720 
    1721     if (layerChanged) {
    1722         m_graphicsLayer->setNeedsDisplay();
    1723         m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
    17241722    }
    17251723
     
    17361734            m_backgroundLayer->setDrawsContent(true);
    17371735            m_backgroundLayer->setAnchorPoint(FloatPoint3D());
    1738             m_backgroundLayer->setPaintingPhase({ GraphicsLayerPaintingPhase::Background });
    17391736            layerChanged = true;
    17401737        }
     
    17601757        }
    17611758    }
    1762    
    1763     if (layerChanged)
    1764         m_graphicsLayer->setNeedsDisplay();
    1765    
     1759
    17661760    return layerChanged;
    17671761}
    17681762
    17691763// Masking layer is used for masks or clip-path.
    1770 void RenderLayerBacking::updateMaskingLayer(bool hasMask, bool hasClipPath)
     1764bool RenderLayerBacking::updateMaskingLayer(bool hasMask, bool hasClipPath)
    17711765{
    17721766    bool layerChanged = false;
     
    18061800    }
    18071801
    1808     if (layerChanged)
    1809         m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
     1802    return layerChanged;
    18101803}
    18111804
     
    18471840
    18481841    if (!m_scrollContainerLayer) {
    1849         // Outer layer which corresponds with the scroll view.
     1842        // Outer layer which corresponds with the scroll view. This never paints content.
    18501843        m_scrollContainerLayer = createGraphicsLayer("scroll container", GraphicsLayer::Type::ScrollContainer);
     1844        m_scrollContainerLayer->setPaintingPhase({ });
    18511845        m_scrollContainerLayer->setDrawsContent(false);
    18521846        m_scrollContainerLayer->setMasksToBounds(true);
     
    18561850        m_scrolledContentsLayer->setDrawsContent(true);
    18571851        m_scrolledContentsLayer->setAnchorPoint({ });
    1858 
    1859         OptionSet<GraphicsLayerPaintingPhase> paintPhases = { GraphicsLayerPaintingPhase::OverflowContents, GraphicsLayerPaintingPhase::CompositedScroll };
    1860         if (!m_foregroundLayer)
    1861             paintPhases.add(GraphicsLayerPaintingPhase::Foreground);
    1862         m_scrolledContentsLayer->setPaintingPhase(paintPhases);
    18631852        m_scrollContainerLayer->addChild(*m_scrolledContentsLayer);
    18641853    } else {
     
    18721861    }
    18731862
    1874     m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
    1875     m_graphicsLayer->setNeedsDisplay(); // Because painting phases changed.
    1876 
    18771863    if (m_scrollContainerLayer)
    18781864        compositor().didAddScrollingLayer(m_owningLayer);
     
    19381924{
    19391925    m_graphicsLayer->setIsViewportConstrained(viewportCoordinated);
    1940 }
    1941 
    1942 OptionSet<GraphicsLayerPaintingPhase> RenderLayerBacking::paintingPhaseForPrimaryLayer() const
    1943 {
    1944     OptionSet<GraphicsLayerPaintingPhase> phases;
    1945     if (!m_backgroundLayer)
    1946         phases.add(GraphicsLayerPaintingPhase::Background);
    1947     if (!m_foregroundLayer)
    1948         phases.add(GraphicsLayerPaintingPhase::Foreground);
    1949 
    1950     if (m_scrolledContentsLayer) {
    1951         phases.remove(GraphicsLayerPaintingPhase::Foreground);
    1952         phases.add(GraphicsLayerPaintingPhase::CompositedScroll);
    1953     }
    1954 
    1955     return phases;
    19561926}
    19571927
     
    21222092        m_graphicsLayer->setContentsOpaque(!viewIsTransparent);
    21232093    }
     2094}
     2095
     2096void RenderLayerBacking::updatePaintingPhases()
     2097{
     2098    // Phases for m_childClippingMaskLayer and m_maskLayer are set elsewhere.
     2099    OptionSet<GraphicsLayerPaintingPhase> primaryLayerPhases = { GraphicsLayerPaintingPhase::Background, GraphicsLayerPaintingPhase::Foreground };
     2100   
     2101    if (m_foregroundLayer) {
     2102        OptionSet<GraphicsLayerPaintingPhase> foregroundLayerPhases { GraphicsLayerPaintingPhase::Foreground };
     2103        m_foregroundLayer->setPaintingPhase(foregroundLayerPhases);
     2104        primaryLayerPhases.remove(GraphicsLayerPaintingPhase::Foreground);
     2105    }
     2106
     2107    if (m_backgroundLayer) {
     2108        m_backgroundLayer->setPaintingPhase(GraphicsLayerPaintingPhase::Background);
     2109        primaryLayerPhases.remove(GraphicsLayerPaintingPhase::Background);
     2110    }
     2111
     2112    if (m_scrolledContentsLayer) {
     2113        OptionSet<GraphicsLayerPaintingPhase> scrolledContentLayerPhases = { GraphicsLayerPaintingPhase::OverflowContents, GraphicsLayerPaintingPhase::CompositedScroll };
     2114        if (!m_foregroundLayer)
     2115            scrolledContentLayerPhases.add(GraphicsLayerPaintingPhase::Foreground);
     2116        m_scrolledContentsLayer->setPaintingPhase(scrolledContentLayerPhases);
     2117
     2118        primaryLayerPhases.remove(GraphicsLayerPaintingPhase::Foreground);
     2119        primaryLayerPhases.add(GraphicsLayerPaintingPhase::CompositedScroll);
     2120    }
     2121
     2122    m_graphicsLayer->setPaintingPhase(primaryLayerPhases);
    21242123}
    21252124
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r245950 r245977  
    317317    bool updateForegroundLayer(bool needsForegroundLayer);
    318318    bool updateBackgroundLayer(bool needsBackgroundLayer);
    319     void updateMaskingLayer(bool hasMask, bool hasClipPath);
     319    bool updateMaskingLayer(bool hasMask, bool hasClipPath);
    320320    bool requiresHorizontalScrollbarLayer() const;
    321321    bool requiresVerticalScrollbarLayer() const;
     
    327327
    328328    void updateChildClippingStrategy(bool needsDescendantsClippingLayer);
    329 
    330329    void updateMaskingLayerGeometry();
    331    
    332330    void updateRootLayerConfiguration();
     331    void updatePaintingPhases();
    333332
    334333    void setBackgroundLayerPaintsFixedRootBackground(bool);
    335334
    336     OptionSet<GraphicsLayerPaintingPhase> paintingPhaseForPrimaryLayer() const;
    337    
    338335    LayoutSize contentOffsetInCompositingLayer() const;
    339336    // Result is transform origin in device pixels.
Note: See TracChangeset for help on using the changeset viewer.