RenderLayerBacking.h [plain text]
#ifndef RenderLayerBacking_h
#define RenderLayerBacking_h
#if USE(ACCELERATED_COMPOSITING)
#include "FloatPoint.h"
#include "FloatPoint3D.h"
#include "GraphicsLayer.h"
#include "GraphicsLayerClient.h"
#include "RenderLayer.h"
namespace WebCore {
class KeyframeList;
class RenderLayerCompositor;
class TiledBacking;
class TransformationMatrix;
enum CompositingLayerType {
NormalCompositingLayer, TiledCompositingLayer, MediaCompositingLayer, ContainerCompositingLayer };
class RenderLayerBacking : public GraphicsLayerClient {
WTF_MAKE_NONCOPYABLE(RenderLayerBacking); WTF_MAKE_FAST_ALLOCATED;
public:
explicit RenderLayerBacking(RenderLayer*);
~RenderLayerBacking();
RenderLayer* owningLayer() const { return m_owningLayer; }
enum UpdateAfterLayoutFlag {
CompositingChildrenOnly = 1 << 0,
NeedsFullRepaint = 1 << 1,
IsUpdateRoot = 1 << 2
};
typedef unsigned UpdateAfterLayoutFlags;
void updateAfterLayout(UpdateAfterLayoutFlags);
bool updateGraphicsLayerConfiguration();
void updateGraphicsLayerGeometry(); 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; }
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; }
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();
void setContentsNeedDisplayInRect(const IntRect&);
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();
IntRect compositedBounds() const;
void setCompositedBounds(const IntRect&);
void updateCompositedBounds();
void updateAfterWidgetResize();
void positionOverflowControlsLayers(const IntSize& offsetFromRoot);
bool hasUnpositionedOverflowControlsLayers() const;
bool usingTiledBacking() const { return m_usingTiledCacheLayer; }
TiledBacking* tiledBacking() const;
void adjustTiledBackingCoverage();
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 IntRect& clip) OVERRIDE;
virtual float deviceScaleFactor() const OVERRIDE;
virtual float pageScaleFactor() const OVERRIDE;
virtual void didCommitChangesForLayer(const GraphicsLayer*) const OVERRIDE;
virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const OVERRIDE;
virtual bool isTrackingRepaints() const OVERRIDE;
#ifndef NDEBUG
virtual void verifyNotPainting();
#endif
IntRect contentsBox() const;
IntRect backgroundBox() 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;
bool didSwitchToFullTileCoverageDuringLoading() const { return m_didSwitchToFullTileCoverageDuringLoading; }
void setDidSwitchToFullTileCoverageDuringLoading() { m_didSwitchToFullTileCoverageDuringLoading = true; }
#if ENABLE(CSS_COMPOSITING)
void setBlendMode(BlendMode);
#endif
private:
void createPrimaryGraphicsLayer();
void destroyGraphicsLayers();
void willDestroyLayer(const GraphicsLayer*);
PassOwnPtr<GraphicsLayer> createGraphicsLayer(const String&);
RenderLayerModelObject* renderer() const { return m_owningLayer->renderer(); }
RenderLayerCompositor* compositor() const { return m_owningLayer->compositor(); }
void updateInternalHierarchy();
bool updateClippingLayers(bool needsAncestorClip, bool needsDescendantClip);
bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool needsVerticalScrollbarLayer, bool needsScrollCornerLayer);
bool updateForegroundLayer(bool needsForegroundLayer);
bool updateBackgroundLayer(bool needsBackgroundLayer);
bool updateMaskLayer(bool needsMaskLayer);
bool requiresHorizontalScrollbarLayer() const;
bool requiresVerticalScrollbarLayer() const;
bool requiresScrollCornerLayer() const;
bool updateScrollingLayers(bool scrollingLayers);
void updateDrawsContent(bool isSimpleContainer);
void registerScrollingLayers();
void updateRootLayerConfiguration();
void setBackgroundLayerPaintsFixedRootBackground(bool);
GraphicsLayerPaintingPhase paintingPhaseForPrimaryLayer() const;
IntSize contentOffsetInCompostingLayer() const;
FloatPoint3D computeTransformOrigin(const IntRect& borderBox) const;
FloatPoint computePerspectiveOrigin(const IntRect& borderBox) const;
void updateOpacity(const RenderStyle*);
void updateTransform(const RenderStyle*);
#if ENABLE(CSS_FILTERS)
void updateFilters(const RenderStyle*);
#endif
#if ENABLE(CSS_COMPOSITING)
void updateLayerBlendMode(const RenderStyle*);
#endif
float compositingOpacity(float rendererOpacity) const;
bool isMainFrameRenderViewLayer() const;
bool paintsBoxDecorations() const;
bool paintsChildren() const;
bool isSimpleContainerCompositingLayer() const;
bool containsPaintedContent() 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 hasVisibleNonCompositingDescendantLayers() 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);
static CSSPropertyID graphicsLayerToCSSProperty(AnimatedPropertyID);
static AnimatedPropertyID cssToGraphicsLayerProperty(CSSPropertyID);
RenderLayer* m_owningLayer;
OwnPtr<GraphicsLayer> m_ancestorClippingLayer; OwnPtr<GraphicsLayer> m_contentsContainmentLayer; OwnPtr<GraphicsLayer> m_graphicsLayer;
OwnPtr<GraphicsLayer> m_foregroundLayer; OwnPtr<GraphicsLayer> m_backgroundLayer; OwnPtr<GraphicsLayer> m_childContainmentLayer; OwnPtr<GraphicsLayer> m_maskLayer;
OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar;
OwnPtr<GraphicsLayer> m_layerForScrollCorner;
OwnPtr<GraphicsLayer> m_scrollingLayer; OwnPtr<GraphicsLayer> m_scrollingContentsLayer;
uint64_t m_scrollLayerID;
IntRect m_compositedBounds;
bool m_artificiallyInflatedBounds; bool m_isMainFrameRenderViewLayer;
bool m_usingTiledCacheLayer;
bool m_requiresOwnBackingStore;
#if ENABLE(CSS_FILTERS)
bool m_canCompositeFilters;
#endif
bool m_backgroundLayerPaintsFixedRootBackground;
bool m_didSwitchToFullTileCoverageDuringLoading;
static bool m_creatingPrimaryGraphicsLayer;
};
}
#endif // USE(ACCELERATED_COMPOSITING)
#endif // RenderLayerBacking_h