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 updateAfterDescendants();
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() : nullptr; }
bool hasAncestorClippingLayer() const { return m_ancestorClippingLayer != nullptr; }
GraphicsLayer* ancestorClippingLayer() const { return m_ancestorClippingLayer.get(); }
GraphicsLayer* contentsContainmentLayer() const { return m_contentsContainmentLayer.get(); }
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(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;
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; }
WEBCORE_EXPORT TiledBacking* tiledBacking() const;
void adjustTiledBackingCoverage();
void setTiledBackingHasMargins(bool hasExtendedBackgroundOnLeftAndRight, bool hasExtendedBackgroundOnTopAndBottom);
void updateDebugIndicators(bool showBorder, bool showRepaintCounter);
void tiledBackingUsageChanged(const GraphicsLayer*, bool ) 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;
bool isTrackingRepaints() const override;
bool shouldSkipLayerInDump(const GraphicsLayer*, LayerTreeAsTextBehavior) const override;
bool shouldDumpPropertyForLayer(const GraphicsLayer*, const char* propertyName) 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; }
#if PLATFORM(IOS)
bool needsIOSDumpRenderTreeMainFrameRenderViewLayerIsAlwaysOpaqueHack(const GraphicsLayer&) const override;
#endif
#ifndef NDEBUG
void verifyNotPainting() override;
#endif
WEBCORE_EXPORT LayoutRect contentsBox() 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(); }
bool canCompositeFilters() const { return m_canCompositeFilters; }
#if ENABLE(FILTERS_LEVEL_2)
bool canCompositeBackdropFilters() const { return m_canCompositeBackdropFilters; }
#endif
WEBCORE_EXPORT double backingStoreMemoryEstimate() const;
WEBCORE_EXPORT void setUsesDisplayListDrawing(bool);
WEBCORE_EXPORT String displayListAsText(DisplayList::AsTextFlags) const;
WEBCORE_EXPORT void setIsTrackingDisplayListReplay(bool);
WEBCORE_EXPORT String replayDisplayListAsText(DisplayList::AsTextFlags) const;
LayoutSize devicePixelFractionFromRenderer() const { return m_devicePixelFractionFromRenderer; }
private:
FloatRect backgroundBoxForSimpleContainerPainting() const;
void createPrimaryGraphicsLayer();
void destroyGraphicsLayers();
void willDestroyLayer(const GraphicsLayer*);
LayoutRect compositedBoundsIncludingMargin() const;
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();
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 updateMaskingLayer(bool hasMask, bool hasClipPath);
bool requiresHorizontalScrollbarLayer() const;
bool requiresVerticalScrollbarLayer() const;
bool requiresScrollCornerLayer() const;
bool updateScrollingLayers(bool scrollingLayers);
void updateDrawsContent(bool isSimpleContainer);
void updateChildClippingStrategy(bool needsDescendantsClippingLayer);
void updateMaskingLayerGeometry();
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&);
void updateFilters(const RenderStyle&);
#if ENABLE(FILTERS_LEVEL_2)
void updateBackdropFilters(const RenderStyle&);
void updateBackdropFiltersGeometry();
#endif
#if ENABLE(CSS_COMPOSITING)
void updateBlendMode(const RenderStyle&);
#endif
void updateCustomAppearance(const RenderStyle&);
float compositingOpacity(float rendererOpacity) const;
bool isMainFrameRenderViewLayer() const;
bool paintsNonDirectCompositedBoxDecoration() 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 isPaintDestinationForDescendantLayers() const;
bool shouldClipCompositedBounds() const;
bool hasTiledBackingFlatteningLayer() const { return (m_childContainmentLayer && m_usingTiledCacheLayer); }
GraphicsLayer* tileCacheFlatteningLayer() const { return m_usingTiledCacheLayer ? m_childContainmentLayer.get() : nullptr; }
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);
bool canIssueSetNeedsDisplay() const { return !paintsIntoWindow() && !paintsIntoCompositedAncestor(); }
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_childClippingMaskLayer;
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;
LayoutSize m_compositedBoundsDeltaFromGraphicsLayer;
bool m_artificiallyInflatedBounds; bool m_isMainFrameRenderViewLayer;
bool m_usingTiledCacheLayer;
bool m_requiresOwnBackingStore;
bool m_canCompositeFilters;
#if ENABLE(FILTERS_LEVEL_2)
bool m_canCompositeBackdropFilters;
#endif
bool m_backgroundLayerPaintsFixedRootBackground;
};
enum CanvasCompositingStrategy {
UnacceleratedCanvas,
CanvasPaintedToLayer,
CanvasAsLayerContents
};
CanvasCompositingStrategy canvasCompositingStrategy(const RenderObject&);
}
#endif // RenderLayerBacking_h