#ifndef CompositedLayerMapping_h
#define CompositedLayerMapping_h
#include "core/rendering/RenderLayer.h"
#include "core/rendering/compositing/GraphicsLayerUpdater.h"
#include "platform/geometry/FloatPoint.h"
#include "platform/geometry/FloatPoint3D.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/GraphicsLayerClient.h"
#include "platform/transforms/TransformationMatrix.h"
namespace WebCore {
class KeyframeList;
class RenderLayerCompositor;
struct GraphicsLayerPaintInfo {
RenderLayer* renderLayer;
LayoutRect compositedBounds;
LayoutSize offsetFromSquashingCLM;
IntSize offsetFromRenderer;
LayoutSize subpixelAccumulation;
GraphicsLayerPaintingPhase paintingPhase;
bool isBackgroundLayer;
bool isEquivalentForSquashing(const GraphicsLayerPaintInfo& other)
{
return renderLayer == other.renderLayer
&& offsetFromSquashingCLM == other.offsetFromSquashingCLM
&& paintingPhase == other.paintingPhase
&& isBackgroundLayer == other.isBackgroundLayer;
}
};
class CompositedLayerMapping FINAL : public GraphicsLayerClient {
WTF_MAKE_NONCOPYABLE(CompositedLayerMapping); WTF_MAKE_FAST_ALLOCATED;
public:
explicit CompositedLayerMapping(RenderLayer&);
virtual ~CompositedLayerMapping();
RenderLayer& owningLayer() const { return m_owningLayer; }
bool updateGraphicsLayerConfiguration(GraphicsLayerUpdater::UpdateType);
void updateGraphicsLayerGeometry(GraphicsLayerUpdater::UpdateType);
void updateContentsOpaque();
GraphicsLayer* mainGraphicsLayer() const { return m_graphicsLayer.get(); }
bool hasClippingLayer() const { return m_childContainmentLayer; }
GraphicsLayer* clippingLayer() const { return m_childContainmentLayer.get(); }
bool hasAncestorClippingLayer() const { return m_ancestorClippingLayer; }
GraphicsLayer* ancestorClippingLayer() const { return m_ancestorClippingLayer.get(); }
bool hasContentsLayer() const { return m_foregroundLayer; }
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(); }
bool hasMaskLayer() const { return m_maskLayer; }
GraphicsLayer* maskLayer() const { return m_maskLayer.get(); }
bool hasChildClippingMaskLayer() const { return m_childClippingMaskLayer; }
GraphicsLayer* childClippingMaskLayer() const { return m_childClippingMaskLayer.get(); }
GraphicsLayer* parentForSublayers() const;
GraphicsLayer* childForSuperlayers() const;
GraphicsLayer* localRootForOwningLayer() const;
GraphicsLayer* childTransformLayer() const { return m_childTransformLayer.get(); }
GraphicsLayer* squashingContainmentLayer() const { return m_squashingContainmentLayer.get(); }
GraphicsLayer* squashingLayer() const { return m_squashingLayer.get(); }
GraphicsLayer* layerForChildrenTransform() const;
bool paintsIntoCompositedAncestor() const { return !(m_requiresOwnBackingStoreForAncestorReasons || m_requiresOwnBackingStoreForIntrinsicReasons); }
bool updateRequiresOwnBackingStoreForAncestorReasons(const RenderLayer* compositingAncestor);
bool updateRequiresOwnBackingStoreForIntrinsicReasons();
void setContentsNeedDisplay();
void setContentsNeedDisplayInRect(const IntRect&);
void contentChanged(ContentChangeType);
LayoutRect compositedBounds() const { return m_compositedBounds; }
IntRect pixelSnappedCompositedBounds() const;
void updateCompositedBounds(GraphicsLayerUpdater::UpdateType);
void updateAfterWidgetResize();
void positionOverflowControlsLayers(const IntSize& offsetFromRoot);
bool hasUnpositionedOverflowControlsLayers() const;
bool updateSquashingLayerAssignment(RenderLayer*, LayoutSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex);
void removeRenderLayerFromSquashingGraphicsLayer(const RenderLayer*);
void finishAccumulatingSquashingLayers(size_t nextSquashedLayerIndex);
void updateRenderingContext();
void updateShouldFlattenTransform();
virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTime) OVERRIDE;
virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& clip) OVERRIDE;
virtual bool isTrackingRepaints() const OVERRIDE;
PassOwnPtr<Vector<FloatRect> > collectTrackedRepaintRects() const;
#ifndef NDEBUG
virtual void verifyNotPainting() OVERRIDE;
#endif
LayoutRect contentsBox() const;
GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); }
GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); }
GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); }
void updateFilters(const RenderStyle*);
bool canCompositeFilters() const { return m_canCompositeFilters; }
void setBlendMode(blink::WebBlendMode);
void setNeedsGraphicsLayerUpdate();
bool shouldUpdateGraphicsLayer(GraphicsLayerUpdater::UpdateType updateType) const { return m_needToUpdateGraphicsLayer || updateType == GraphicsLayerUpdater::ForceUpdate; }
GraphicsLayerUpdater::UpdateType updateTypeForChildren(GraphicsLayerUpdater::UpdateType) const;
void clearNeedsGraphicsLayerUpdate();
#if !ASSERT_DISABLED
void assertNeedsToUpdateGraphicsLayerBitsCleared();
#endif
virtual String debugName(const GraphicsLayer*) OVERRIDE;
private:
void createPrimaryGraphicsLayer();
void destroyGraphicsLayers();
PassOwnPtr<GraphicsLayer> createGraphicsLayer(CompositingReasons);
bool toggleScrollbarLayerIfNeeded(OwnPtr<GraphicsLayer>&, bool needsLayer, CompositingReasons);
RenderLayerModelObject* renderer() const { return m_owningLayer.renderer(); }
RenderLayerCompositor* compositor() const { return m_owningLayer.compositor(); }
void updateInternalHierarchy();
bool updateClippingLayers(bool needsAncestorClip, bool needsDescendantClip);
bool updateChildTransformLayer(bool needsChildTransformLayer);
bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool needsVerticalScrollbarLayer, bool needsScrollCornerLayer);
bool updateForegroundLayer(bool needsForegroundLayer);
bool updateBackgroundLayer(bool needsBackgroundLayer);
bool updateMaskLayer(bool needsMaskLayer);
bool updateClippingMaskLayers(bool needsChildClippingMaskLayer);
bool requiresHorizontalScrollbarLayer() const { return m_owningLayer.scrollableArea() && m_owningLayer.scrollableArea()->horizontalScrollbar(); }
bool requiresVerticalScrollbarLayer() const { return m_owningLayer.scrollableArea() && m_owningLayer.scrollableArea()->verticalScrollbar(); }
bool requiresScrollCornerLayer() const { return m_owningLayer.scrollableArea() && !m_owningLayer.scrollableArea()->scrollCornerAndResizerRect().isEmpty(); }
bool updateScrollingLayers(bool scrollingLayers);
void updateScrollParent(RenderLayer*);
void updateClipParent(RenderLayer*);
bool updateSquashingLayers(bool needsSquashingLayers);
void updateDrawsContent();
void updateChildrenTransform();
void registerScrollingLayers();
void adjustBoundsForSubPixelAccumulation(const RenderLayer* compositedAncestor, IntRect& localCompositingBounds, IntRect& relativeCompositingBounds, IntPoint& delta);
void setBackgroundLayerPaintsFixedRootBackground(bool);
GraphicsLayerPaintingPhase paintingPhaseForPrimaryLayer() const;
LayoutSize contentOffsetInCompostingLayer() const;
FloatPoint3D computeTransformOrigin(const IntRect& borderBox) const;
FloatPoint computePerspectiveOrigin(const IntRect& borderBox) const;
void updateSquashingLayerGeometry(const IntPoint& delta);
void updateOpacity(const RenderStyle*);
void updateTransform(const RenderStyle*);
void updateLayerBlendMode(const RenderStyle*);
void updateIsRootForIsolatedGroup();
void updateHasGpuRasterizationHint(const RenderStyle*);
float compositingOpacity(float rendererOpacity) const;
bool isMainFrameRenderViewLayer() const;
bool paintsChildren() const;
bool containsPaintedContent() const;
bool isDirectlyCompositedImage() const;
void updateImageContents();
Color rendererBackgroundColor() const;
void updateBackgroundColor();
void updateContentsRect();
void updateCompositingReasons();
bool hasVisibleNonCompositingDescendantLayers() const;
bool shouldClipCompositedBounds() const;
void paintsIntoCompositedAncestorChanged();
void doPaintTask(GraphicsLayerPaintInfo&, GraphicsContext*, const IntRect& clip);
RenderLayer& m_owningLayer;
OwnPtr<GraphicsLayer> m_ancestorClippingLayer;
OwnPtr<GraphicsLayer> m_graphicsLayer;
OwnPtr<GraphicsLayer> m_childContainmentLayer;
OwnPtr<GraphicsLayer> m_childTransformLayer;
OwnPtr<GraphicsLayer> m_scrollingLayer;
OwnPtr<GraphicsLayer> m_scrollingContentsLayer;
OwnPtr<GraphicsLayer> m_maskLayer;
OwnPtr<GraphicsLayer> m_childClippingMaskLayer;
OwnPtr<GraphicsLayer> m_foregroundLayer;
OwnPtr<GraphicsLayer> m_backgroundLayer;
OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar;
OwnPtr<GraphicsLayer> m_layerForScrollCorner;
OwnPtr<GraphicsLayer> m_squashingContainmentLayer;
OwnPtr<GraphicsLayer> m_squashingLayer;
Vector<GraphicsLayerPaintInfo> m_squashedLayers;
LayoutRect m_compositedBounds;
bool m_artificiallyInflatedBounds : 1;
bool m_isMainFrameRenderViewLayer : 1;
bool m_requiresOwnBackingStoreForIntrinsicReasons : 1;
bool m_requiresOwnBackingStoreForAncestorReasons : 1;
bool m_canCompositeFilters : 1;
bool m_backgroundLayerPaintsFixedRootBackground : 1;
bool m_needToUpdateGraphicsLayer : 1;
bool m_needToUpdateGraphicsLayerOfAllDecendants : 1;
};
}
#endif