diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderLayerBacking.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/rendering/RenderLayerBacking.h')
-rw-r--r-- | Source/WebCore/rendering/RenderLayerBacking.h | 221 |
1 files changed, 138 insertions, 83 deletions
diff --git a/Source/WebCore/rendering/RenderLayerBacking.h b/Source/WebCore/rendering/RenderLayerBacking.h index ce0f420f0..ff73ea7c1 100644 --- a/Source/WebCore/rendering/RenderLayerBacking.h +++ b/Source/WebCore/rendering/RenderLayerBacking.h @@ -13,7 +13,7 @@ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -23,16 +23,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef RenderLayerBacking_h -#define RenderLayerBacking_h - -#if USE(ACCELERATED_COMPOSITING) +#pragma once #include "FloatPoint.h" #include "FloatPoint3D.h" #include "GraphicsLayer.h" #include "GraphicsLayerClient.h" #include "RenderLayer.h" +#include "ScrollingCoordinator.h" namespace WebCore { @@ -54,7 +52,7 @@ enum CompositingLayerType { // // There is one RenderLayerBacking for each RenderLayer that is composited. -class RenderLayerBacking : public GraphicsLayerClient { +class RenderLayerBacking final : public GraphicsLayerClient { WTF_MAKE_NONCOPYABLE(RenderLayerBacking); WTF_MAKE_FAST_ALLOCATED; public: explicit RenderLayerBacking(RenderLayer&); @@ -75,27 +73,30 @@ public: void updateAfterLayout(UpdateAfterLayoutFlags); // Returns true if layer configuration changed. - bool updateGraphicsLayerConfiguration(); + bool updateConfiguration(); + // Update graphics layer position and bounds. - void updateGraphicsLayerGeometry(); // make private + void updateGeometry(); + + // Update state the requires that descendant layers have been updated. + void updateAfterDescendants(); + // Update contents and clipping structure. void updateDrawsContent(); GraphicsLayer* graphicsLayer() const { return m_graphicsLayer.get(); } // Layer to clip children - bool hasClippingLayer() const { return (m_childContainmentLayer && !m_usingTiledCacheLayer); } - GraphicsLayer* clippingLayer() const { return !m_usingTiledCacheLayer ? m_childContainmentLayer.get() : 0; } + bool hasClippingLayer() const { return (m_childContainmentLayer && !m_isMainFrameLayerWithTiledBacking); } + GraphicsLayer* clippingLayer() const { return !m_isMainFrameLayerWithTiledBacking ? m_childContainmentLayer.get() : nullptr; } // Layer to get clipped by ancestor - bool hasAncestorClippingLayer() const { return m_ancestorClippingLayer != 0; } + bool hasAncestorClippingLayer() const { return m_ancestorClippingLayer != nullptr; } GraphicsLayer* ancestorClippingLayer() const { return m_ancestorClippingLayer.get(); } GraphicsLayer* contentsContainmentLayer() const { return m_contentsContainmentLayer.get(); } - bool hasContentsLayer() const { return m_foregroundLayer != 0; } GraphicsLayer* foregroundLayer() const { return m_foregroundLayer.get(); } - GraphicsLayer* backgroundLayer() const { return m_backgroundLayer.get(); } bool backgroundLayerPaintsFixedRootBackground() const { return m_backgroundLayerPaintsFixedRootBackground; } @@ -103,11 +104,38 @@ public: GraphicsLayer* scrollingLayer() const { return m_scrollingLayer.get(); } GraphicsLayer* scrollingContentsLayer() const { return m_scrollingContentsLayer.get(); } - void attachToScrollingCoordinatorWithParent(RenderLayerBacking* parent); - void detachFromScrollingCoordinator(); - uint64_t scrollLayerID() const { return m_scrollLayerID; } + void detachFromScrollingCoordinator(LayerScrollCoordinationRoles); + + ScrollingNodeID scrollingNodeIDForRole(LayerScrollCoordinationRole role) const + { + switch (role) { + case Scrolling: + return m_scrollingNodeID; + case ViewportConstrained: + return m_viewportConstrainedNodeID; + } + return 0; + } + + void setScrollingNodeIDForRole(ScrollingNodeID nodeID, LayerScrollCoordinationRole role) + { + switch (role) { + case Scrolling: + m_scrollingNodeID = nodeID; + break; + case ViewportConstrained: + m_viewportConstrainedNodeID = nodeID; + setIsScrollCoordinatedWithViewportConstrainedRole(nodeID); + break; + } + } + ScrollingNodeID scrollingNodeIDForChildren() const { return m_scrollingNodeID ? m_scrollingNodeID : m_viewportConstrainedNodeID; } + + void setIsScrollCoordinatedWithViewportConstrainedRole(bool); + bool hasMaskLayer() const { return m_maskLayer != 0; } + bool hasChildClippingMaskLayer() const { return m_childClippingMaskLayer != nullptr; } GraphicsLayer* parentForSublayers() const; GraphicsLayer* childForSuperlayers() const; @@ -128,7 +156,7 @@ public: void setContentsNeedDisplay(GraphicsLayer::ShouldClipToLayer = GraphicsLayer::ClipToLayer); // r is in the coordinate space of the layer's render object - void setContentsNeedDisplayInRect(const IntRect&, GraphicsLayer::ShouldClipToLayer = GraphicsLayer::ClipToLayer); + void setContentsNeedDisplayInRect(const LayoutRect&, GraphicsLayer::ShouldClipToLayer = GraphicsLayer::ClipToLayer); // Notification from the renderer that its content changed. void contentChanged(ContentChangeType); @@ -153,60 +181,78 @@ public: void positionOverflowControlsLayers(); bool hasUnpositionedOverflowControlsLayers() const; - bool usingTiledBacking() const { return m_usingTiledCacheLayer; } - bool tiledBackingHasMargin() const; - TiledBacking* tiledBacking() const; + bool isMainFrameLayerWithTiledBacking() const { return m_isMainFrameLayerWithTiledBacking; } + + WEBCORE_EXPORT TiledBacking* tiledBacking() const; void adjustTiledBackingCoverage(); - void setTiledBackingHasMargins(bool); + void setTiledBackingHasMargins(bool hasExtendedBackgroundOnLeftAndRight, bool hasExtendedBackgroundOnTopAndBottom); void updateDebugIndicators(bool showBorder, bool showRepaintCounter); // GraphicsLayerClient interface - virtual bool shouldUseTiledBacking(const GraphicsLayer*) const override; - virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) override; - virtual void notifyAnimationStarted(const GraphicsLayer*, double startTime) override; - virtual void notifyFlushRequired(const GraphicsLayer*) override; - virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) override; + void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) override; + void notifyAnimationStarted(const GraphicsLayer*, const String& animationKey, double startTime) override; + void notifyFlushRequired(const GraphicsLayer*) override; + void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) override; + + void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& clip) override; + + float deviceScaleFactor() const override; + float contentsScaleMultiplierForNewTiles(const GraphicsLayer*) const override; + + bool paintsOpaquelyAtNonIntegralScales(const GraphicsLayer*) const override; + + float pageScaleFactor() const override; + float zoomedOutPageScaleFactor() const override; + void didCommitChangesForLayer(const GraphicsLayer*) const override; + bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const override; - virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& clip) override; + bool isTrackingRepaints() const override; + bool shouldSkipLayerInDump(const GraphicsLayer*, LayerTreeAsTextBehavior) const override; + bool shouldDumpPropertyForLayer(const GraphicsLayer*, const char* propertyName) const override; - virtual float deviceScaleFactor() const override; - virtual float contentsScaleMultiplierForNewTiles(const GraphicsLayer*) const override; + bool shouldAggressivelyRetainTiles(const GraphicsLayer*) const override; + bool shouldTemporarilyRetainTileCohorts(const GraphicsLayer*) const override; + bool useGiantTiles() const override; + bool needsPixelAligment() const override { return !m_isMainFrameRenderViewLayer; } - virtual float pageScaleFactor() const override; - virtual void didCommitChangesForLayer(const GraphicsLayer*) const override; - virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const override; + LayoutSize subpixelOffsetFromRenderer() const { return m_subpixelOffsetFromRenderer; } - virtual bool isTrackingRepaints() const override; - virtual bool shouldSkipLayerInDump(const GraphicsLayer*) const override; - virtual bool shouldDumpPropertyForLayer(const GraphicsLayer*, const char* propertyName) const override; +#if PLATFORM(IOS) + bool needsIOSDumpRenderTreeMainFrameRenderViewLayerIsAlwaysOpaqueHack(const GraphicsLayer&) const override; +#endif #ifndef NDEBUG - virtual void verifyNotPainting(); + void verifyNotPainting() override; #endif - LayoutRect contentsBox() const; - IntRect backgroundBox() const; + WEBCORE_EXPORT LayoutRect contentsBox() const; // For informative purposes only. - CompositingLayerType compositingLayerType() const; + WEBCORE_EXPORT CompositingLayerType compositingLayerType() const; GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); } GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); } GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); } -#if ENABLE(CSS_FILTERS) bool canCompositeFilters() const { return m_canCompositeFilters; } +#if ENABLE(FILTERS_LEVEL_2) + bool canCompositeBackdropFilters() const { return m_canCompositeBackdropFilters; } #endif // Return an estimate of the backing store area (in pixels) allocated by this object's GraphicsLayers. - double backingStoreMemoryEstimate() const; + WEBCORE_EXPORT double backingStoreMemoryEstimate() const; + + // For testing only. + WEBCORE_EXPORT void setUsesDisplayListDrawing(bool); + WEBCORE_EXPORT String displayListAsText(DisplayList::AsTextFlags) const; -#if ENABLE(CSS_COMPOSITING) - void setBlendMode(BlendMode); -#endif + WEBCORE_EXPORT void setIsTrackingDisplayListReplay(bool); + WEBCORE_EXPORT String replayDisplayListAsText(DisplayList::AsTextFlags) const; private: + FloatRect backgroundBoxForSimpleContainerPainting() const; + void createPrimaryGraphicsLayer(); void destroyGraphicsLayers(); @@ -214,9 +260,10 @@ private: LayoutRect compositedBoundsIncludingMargin() const; - std::unique_ptr<GraphicsLayer> createGraphicsLayer(const String&); + std::unique_ptr<GraphicsLayer> createGraphicsLayer(const String&, GraphicsLayer::Type = GraphicsLayer::Type::Normal); RenderLayerModelObject& renderer() const { return m_owningLayer.renderer(); } + RenderBox* renderBox() const { return m_owningLayer.renderBox(); } RenderLayerCompositor& compositor() const { return m_owningLayer.compositor(); } void updateInternalHierarchy(); @@ -225,13 +272,15 @@ private: bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool needsVerticalScrollbarLayer, bool needsScrollCornerLayer); bool updateForegroundLayer(bool needsForegroundLayer); bool updateBackgroundLayer(bool needsBackgroundLayer); - bool updateMaskLayer(bool needsMaskLayer); + void updateMaskingLayer(bool hasMask, bool hasClipPath); bool requiresHorizontalScrollbarLayer() const; bool requiresVerticalScrollbarLayer() const; bool requiresScrollCornerLayer() const; bool updateScrollingLayers(bool scrollingLayers); void updateDrawsContent(bool isSimpleContainer); - void registerScrollingLayers(); + void updateChildClippingStrategy(bool needsDescendantsClippingLayer); + + void updateMaskingLayerGeometry(); void updateRootLayerConfiguration(); @@ -240,26 +289,28 @@ private: GraphicsLayerPaintingPhase paintingPhaseForPrimaryLayer() const; LayoutSize contentOffsetInCompostingLayer() const; - // Result is transform origin in pixels. - FloatPoint3D computeTransformOrigin(const IntRect& borderBox) const; - // Result is perspective origin in pixels. - FloatPoint computePerspectiveOrigin(const IntRect& borderBox) const; - - void updateOpacity(const RenderStyle*); - void updateTransform(const RenderStyle*); -#if ENABLE(CSS_FILTERS) - void updateFilters(const RenderStyle*); + // Result is transform origin in device pixels. + FloatPoint3D computeTransformOriginForPainting(const LayoutRect& borderBox) const; + + void updateOpacity(const RenderStyle&); + void updateTransform(const RenderStyle&); + void updateFilters(const RenderStyle&); +#if ENABLE(FILTERS_LEVEL_2) + void updateBackdropFilters(const RenderStyle&); + void updateBackdropFiltersGeometry(); #endif #if ENABLE(CSS_COMPOSITING) - void updateBlendMode(const RenderStyle*); + void updateBlendMode(const RenderStyle&); #endif + void updateCustomAppearance(const RenderStyle&); + // Return the opacity value that this layer should use for compositing. float compositingOpacity(float rendererOpacity) const; bool isMainFrameRenderViewLayer() const; bool paintsBoxDecorations() const; - bool paintsChildren() const; + bool paintsChildRenderers() const; // Returns true if this compositing layer has no visible content. bool isSimpleContainerCompositingLayer() const; @@ -270,27 +321,33 @@ private: void updateImageContents(); Color rendererBackgroundColor() const; + + void updateDirectlyCompositedBoxDecorations(bool isSimpleContainer, bool& didUpdateContentsRect); void updateDirectlyCompositedBackgroundColor(bool isSimpleContainer, bool& didUpdateContentsRect); void updateDirectlyCompositedBackgroundImage(bool isSimpleContainer, bool& didUpdateContentsRect); - void updateDirectlyCompositedContents(bool isSimpleContainer, bool& didUpdateContentsRect); void resetContentsRect(); - bool hasVisibleNonCompositingDescendantLayers() const; + bool isPaintDestinationForDescendantLayers() const; + bool hasVisibleNonCompositedDescendants() const; bool shouldClipCompositedBounds() const; - bool hasTiledBackingFlatteningLayer() const { return (m_childContainmentLayer && m_usingTiledCacheLayer); } - GraphicsLayer* tileCacheFlatteningLayer() const { return m_usingTiledCacheLayer ? m_childContainmentLayer.get() : 0; } + bool hasTiledBackingFlatteningLayer() const { return (m_childContainmentLayer && m_isMainFrameLayerWithTiledBacking); } + GraphicsLayer* tileCacheFlatteningLayer() const { return m_isMainFrameLayerWithTiledBacking ? m_childContainmentLayer.get() : nullptr; } - void paintIntoLayer(const GraphicsLayer*, GraphicsContext*, const IntRect& paintDirtyRect, PaintBehavior, GraphicsLayerPaintingPhase); + void paintIntoLayer(const GraphicsLayer*, GraphicsContext&, const IntRect& paintDirtyRect, PaintBehavior, GraphicsLayerPaintingPhase); - // Helper function for updateGraphicsLayerGeometry. - void adjustAncestorCompositingBoundsForFlowThread(IntRect& ancestorCompositingBounds, const RenderLayer* compositingAncestor) const; + // Helper function for updateGeometry. + void adjustAncestorCompositingBoundsForFlowThread(LayoutRect& ancestorCompositingBounds, const RenderLayer* compositingAncestor) const; static CSSPropertyID graphicsLayerToCSSProperty(AnimatedPropertyID); static AnimatedPropertyID cssToGraphicsLayerProperty(CSSPropertyID); + bool canIssueSetNeedsDisplay() const { return !paintsIntoWindow() && !paintsIntoCompositedAncestor(); } + LayoutRect computeParentGraphicsLayerRect(RenderLayer* compositedAncestor, LayoutSize& ancestorClippingLayerOffset) const; + LayoutRect computePrimaryGraphicsLayerRect(const LayoutRect& parentGraphicsLayerRect) const; + RenderLayer& m_owningLayer; std::unique_ptr<GraphicsLayer> m_ancestorClippingLayer; // Only used if we are clipped by an ancestor which is not a stacking context. @@ -299,7 +356,8 @@ private: std::unique_ptr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately. std::unique_ptr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately. std::unique_ptr<GraphicsLayer> m_childContainmentLayer; // Only used if we have clipping on a stacking context with compositing children, or if the layer has a tile cache. - std::unique_ptr<GraphicsLayer> m_maskLayer; // Only used if we have a mask. + std::unique_ptr<GraphicsLayer> m_maskLayer; // Only used if we have a mask and/or clip-path. + std::unique_ptr<GraphicsLayer> m_childClippingMaskLayer; // Only used if we have to clip child layers or accelerated contents with border radius or clip-path. std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar; std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar; @@ -308,21 +366,22 @@ private: std::unique_ptr<GraphicsLayer> m_scrollingLayer; // Only used if the layer is using composited scrolling. std::unique_ptr<GraphicsLayer> m_scrollingContentsLayer; // Only used if the layer is using composited scrolling. - uint64_t m_scrollLayerID; - LayoutRect m_compositedBounds; - LayoutSize m_subpixelAccumulation; // The accumulated subpixel offset of the compositedBounds compared to absolute coordinates. - - bool m_artificiallyInflatedBounds; // bounds had to be made non-zero to make transform-origin work - bool m_isMainFrameRenderViewLayer; - bool m_usingTiledCacheLayer; - bool m_requiresOwnBackingStore; -#if ENABLE(CSS_FILTERS) - bool m_canCompositeFilters; + LayoutSize m_subpixelOffsetFromRenderer; // This is the subpixel distance between the primary graphics layer and the associated renderer's bounds. + LayoutSize m_compositedBoundsOffsetFromGraphicsLayer; // This is the subpixel distance between the primary graphics layer and the render layer bounds. + + ScrollingNodeID m_viewportConstrainedNodeID { 0 }; + ScrollingNodeID m_scrollingNodeID { 0 }; + + bool m_artificiallyInflatedBounds { false }; // bounds had to be made non-zero to make transform-origin work + bool m_isMainFrameRenderViewLayer { false }; + bool m_isMainFrameLayerWithTiledBacking { false }; + bool m_requiresOwnBackingStore { true }; + bool m_canCompositeFilters { false }; +#if ENABLE(FILTERS_LEVEL_2) + bool m_canCompositeBackdropFilters { false }; #endif - bool m_backgroundLayerPaintsFixedRootBackground; - - static bool m_creatingPrimaryGraphicsLayer; + bool m_backgroundLayerPaintsFixedRootBackground { false }; }; enum CanvasCompositingStrategy { @@ -333,7 +392,3 @@ enum CanvasCompositingStrategy { CanvasCompositingStrategy canvasCompositingStrategy(const RenderObject&); } // namespace WebCore - -#endif // USE(ACCELERATED_COMPOSITING) - -#endif // RenderLayerBacking_h |