RenderLayerBacking.h [plain text]
#ifndef RenderLayerBacking_h
#define RenderLayerBacking_h
#include "FloatPoint.h"
#include "FloatPoint3D.h"
#include "GraphicsLayer.h"
#include "GraphicsLayerClient.h"
#include "RenderLayer.h"
#include "ScrollingCoordinator.h"
namespace WebCore {
class KeyframeList;
class RenderLayerCompositor;
class TiledBacking;
class TransformationMatrix;
enum CompositingLayerType {
NormalCompositingLayer, TiledCompositingLayer, MediaCompositingLayer, ContainerCompositingLayer };
class RenderLayerBacking final : public GraphicsLayerClient {
WTF_MAKE_NONCOPYABLE(RenderLayerBacking); WTF_MAKE_FAST_ALLOCATED;
public:
explicit RenderLayerBacking(RenderLayer&);
~RenderLayerBacking();
#if PLATFORM(IOS)
void layerWillBeDestroyed();
#endif
RenderLayer& owningLayer() const { return m_owningLayer; }
enum UpdateAfterLayoutFlag {
CompositingChildrenOnly = 1 << 0,
NeedsFullRepaint = 1 << 1,
IsUpdateRoot = 1 << 2
};
typedef unsigned UpdateAfterLayoutFlags;
void updateAfterLayout(UpdateAfterLayoutFlags);
bool updateConfiguration();
void updateGeometry();
void updateAfterDescendents();
void updateDrawsContent();
GraphicsLayer* graphicsLayer() const { return m_graphicsLayer.get(); }
bool hasClippingLayer() const { return (m_childContainmentLayer && !m_usingTiledCacheLayer); }
GraphicsLayer* clippingLayer() const { return !m_usingTiledCacheLayer ? m_childContainmentLayer.get() : 0; }
bool hasAncestorClippingLayer() const { return m_ancestorClippingLayer != 0; }
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; }
bool hasScrollingLayer() const { return m_scrollingLayer != nullptr; }
GraphicsLayer* scrollingLayer() const { return m_scrollingLayer.get(); }
GraphicsLayer* scrollingContentsLayer() const { return m_scrollingContentsLayer.get(); }
void detachFromScrollingCoordinator();
ScrollingNodeID scrollingNodeIDForRole(ScrollingNodeType nodeType) const
{
switch (nodeType) {
case FrameScrollingNode:
case OverflowScrollingNode:
return m_scrollingNodeID;
case FixedNode:
case StickyNode:
return m_viewportConstrainedNodeID;
}
return 0;
}
void setScrollingNodeIDForRole(ScrollingNodeID nodeID, ScrollingNodeType nodeType)
{
switch (nodeType) {
case FrameScrollingNode:
case OverflowScrollingNode:
m_scrollingNodeID = nodeID;
break;
case FixedNode:
case StickyNode:
m_viewportConstrainedNodeID = nodeID;
break;
}
}
ScrollingNodeID scrollingNodeIDForChildren() const { return m_scrollingNodeID ? m_scrollingNodeID : m_viewportConstrainedNodeID; }
bool hasMaskLayer() const { return m_maskLayer != 0; }
GraphicsLayer* parentForSublayers() const;
GraphicsLayer* childForSuperlayers() const;
bool paintsIntoWindow() const;
bool paintsIntoCompositedAncestor() const { return !m_requiresOwnBackingStore; }
void setRequiresOwnBackingStore(bool);
void setContentsNeedDisplay(GraphicsLayer::ShouldClipToLayer = GraphicsLayer::ClipToLayer);
void setContentsNeedDisplayInRect(const LayoutRect&, GraphicsLayer::ShouldClipToLayer = GraphicsLayer::ClipToLayer);
void contentChanged(ContentChangeType);
bool startTransition(double, CSSPropertyID, const RenderStyle* fromStyle, const RenderStyle* toStyle);
void transitionPaused(double timeOffset, CSSPropertyID);
void transitionFinished(CSSPropertyID);
bool startAnimation(double timeOffset, const Animation* anim, const KeyframeList& keyframes);
void animationPaused(double timeOffset, const String& name);
void animationFinished(const String& name);
void suspendAnimations(double time = 0);
void resumeAnimations();
LayoutRect compositedBounds() const;
void setCompositedBounds(const LayoutRect&);
void updateCompositedBounds();
void updateAfterWidgetResize();
void positionOverflowControlsLayers();
bool hasUnpositionedOverflowControlsLayers() const;
bool usingTiledBacking() const { return m_usingTiledCacheLayer; }
TiledBacking* tiledBacking() const;
void adjustTiledBackingCoverage();
void setTiledBackingHasMargins(bool hasExtendedBackgroundOnLeftAndRight, bool hasExtendedBackgroundOnTopAndBottom);
void updateDebugIndicators(bool showBorder, bool showRepaintCounter);
virtual bool shouldUseTiledBacking(const GraphicsLayer*) const override;
virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool ) override;
virtual void notifyAnimationStarted(const GraphicsLayer*, double startTime) override;
virtual void notifyFlushRequired(const GraphicsLayer*) override;
virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) override;
virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& clip) override;
virtual float deviceScaleFactor() const override;
virtual float contentsScaleMultiplierForNewTiles(const GraphicsLayer*) const override;
virtual bool paintsOpaquelyAtNonIntegralScales(const GraphicsLayer*) const override;
virtual float pageScaleFactor() const override;
virtual float zoomedOutPageScaleFactor() const override;
virtual void didCommitChangesForLayer(const GraphicsLayer*) const override;
virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const override;
virtual bool isTrackingRepaints() const override;
virtual bool shouldSkipLayerInDump(const GraphicsLayer*) const override;
virtual bool shouldDumpPropertyForLayer(const GraphicsLayer*, const char* propertyName) const override;
virtual bool shouldAggressivelyRetainTiles(const GraphicsLayer*) const override;
virtual bool shouldTemporarilyRetainTileCohorts(const GraphicsLayer*) const override;
virtual bool needsPixelAligment() const override { return !m_isMainFrameRenderViewLayer; }
#ifndef NDEBUG
virtual void verifyNotPainting();
#endif
LayoutRect contentsBox() const;
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; }
#endif
double backingStoreMemoryEstimate() const;
LayoutSize devicePixelFractionFromRenderer() const { return m_devicePixelFractionFromRenderer; }
private:
FloatRect backgroundBoxForPainting() const;
void createPrimaryGraphicsLayer();
void destroyGraphicsLayers();
void willDestroyLayer(const GraphicsLayer*);
LayoutRect compositedBoundsIncludingMargin() const;
std::unique_ptr<GraphicsLayer> createGraphicsLayer(const String&);
RenderLayerModelObject& renderer() const { return m_owningLayer.renderer(); }
RenderLayerCompositor& compositor() const { return m_owningLayer.compositor(); }
void updateInternalHierarchy();
bool updateAncestorClippingLayer(bool needsAncestorClip);
bool updateDescendantClippingLayer(bool needsDescendantClip);
bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool needsVerticalScrollbarLayer, bool needsScrollCornerLayer);
bool updateForegroundLayer(bool needsForegroundLayer);
bool updateBackgroundLayer(bool needsBackgroundLayer);
void updateMaskLayer(bool needsMaskLayer);
bool requiresHorizontalScrollbarLayer() const;
bool requiresVerticalScrollbarLayer() const;
bool requiresScrollCornerLayer() const;
bool updateScrollingLayers(bool scrollingLayers);
void updateDrawsContent(bool isSimpleContainer);
void updateRootLayerConfiguration();
void setBackgroundLayerPaintsFixedRootBackground(bool);
GraphicsLayerPaintingPhase paintingPhaseForPrimaryLayer() const;
LayoutSize contentOffsetInCompostingLayer() const;
FloatPoint3D computeTransformOriginForPainting(const LayoutRect& borderBox) const;
void updateOpacity(const RenderStyle&);
void updateTransform(const RenderStyle&);
#if ENABLE(CSS_FILTERS)
void updateFilters(const RenderStyle&);
#endif
#if ENABLE(CSS_COMPOSITING)
void updateBlendMode(const RenderStyle&);
#endif
float compositingOpacity(float rendererOpacity) const;
bool isMainFrameRenderViewLayer() const;
bool paintsBoxDecorations() const;
bool paintsChildren() const;
bool isSimpleContainerCompositingLayer() const;
bool containsPaintedContent(bool isSimpleContainer) const;
bool isDirectlyCompositedImage() const;
void updateImageContents();
Color rendererBackgroundColor() const;
void updateDirectlyCompositedBackgroundColor(bool isSimpleContainer, bool& didUpdateContentsRect);
void updateDirectlyCompositedBackgroundImage(bool isSimpleContainer, bool& didUpdateContentsRect);
void updateDirectlyCompositedContents(bool isSimpleContainer, bool& didUpdateContentsRect);
void resetContentsRect();
bool isPaintDestinationForDescendentLayers() const;
bool shouldClipCompositedBounds() const;
bool hasTiledBackingFlatteningLayer() const { return (m_childContainmentLayer && m_usingTiledCacheLayer); }
GraphicsLayer* tileCacheFlatteningLayer() const { return m_usingTiledCacheLayer ? m_childContainmentLayer.get() : 0; }
void paintIntoLayer(const GraphicsLayer*, GraphicsContext*, const IntRect& paintDirtyRect, PaintBehavior, GraphicsLayerPaintingPhase);
void adjustAncestorCompositingBoundsForFlowThread(LayoutRect& ancestorCompositingBounds, const RenderLayer* compositingAncestor) const;
static CSSPropertyID graphicsLayerToCSSProperty(AnimatedPropertyID);
static AnimatedPropertyID cssToGraphicsLayerProperty(CSSPropertyID);
RenderLayer& m_owningLayer;
std::unique_ptr<GraphicsLayer> m_ancestorClippingLayer; std::unique_ptr<GraphicsLayer> m_contentsContainmentLayer; std::unique_ptr<GraphicsLayer> m_graphicsLayer;
std::unique_ptr<GraphicsLayer> m_foregroundLayer; std::unique_ptr<GraphicsLayer> m_backgroundLayer; std::unique_ptr<GraphicsLayer> m_childContainmentLayer; std::unique_ptr<GraphicsLayer> m_maskLayer;
std::unique_ptr<GraphicsLayer> m_layerForHorizontalScrollbar;
std::unique_ptr<GraphicsLayer> m_layerForVerticalScrollbar;
std::unique_ptr<GraphicsLayer> m_layerForScrollCorner;
std::unique_ptr<GraphicsLayer> m_scrollingLayer; std::unique_ptr<GraphicsLayer> m_scrollingContentsLayer;
ScrollingNodeID m_viewportConstrainedNodeID;
ScrollingNodeID m_scrollingNodeID;
LayoutRect m_compositedBounds;
LayoutSize m_devicePixelFractionFromRenderer;
bool m_artificiallyInflatedBounds; bool m_isMainFrameRenderViewLayer;
bool m_usingTiledCacheLayer;
bool m_requiresOwnBackingStore;
#if ENABLE(CSS_FILTERS)
bool m_canCompositeFilters;
#endif
bool m_backgroundLayerPaintsFixedRootBackground;
static bool m_creatingPrimaryGraphicsLayer;
};
enum CanvasCompositingStrategy {
UnacceleratedCanvas,
CanvasPaintedToLayer,
CanvasAsLayerContents
};
CanvasCompositingStrategy canvasCompositingStrategy(const RenderObject&);
}
#endif // RenderLayerBacking_h