RenderLayerCompositor.h [plain text]
#ifndef RenderLayerCompositor_h
#define RenderLayerCompositor_h
#include "ChromeClient.h"
#include "RenderLayer.h"
#include "RenderLayerBacking.h"
#include "ChromeClient.h"
namespace WebCore {
class GraphicsLayer;
class RenderEmbeddedObject;
class RenderPart;
class ScrollingCoordinator;
#if ENABLE(VIDEO)
class RenderVideo;
#endif
class ChromeClient;
enum CompositingUpdateType {
CompositingUpdateAfterStyleChange,
CompositingUpdateAfterLayout,
CompositingUpdateOnHitTest,
CompositingUpdateOnScroll
};
class RenderLayerCompositor : public GraphicsLayerClient {
public:
RenderLayerCompositor(RenderView*);
~RenderLayerCompositor();
bool inCompositingMode() const { return m_compositing; }
void enableCompositingMode(bool enable = true);
bool inForcedCompositingMode() const { return m_forceCompositingMode; }
bool hasAcceleratedCompositing() const { return m_hasAcceleratedCompositing; }
bool canRender3DTransforms() const;
void cacheAcceleratedCompositingFlags();
void setCompositingLayersNeedRebuild(bool needRebuild = true);
bool compositingLayersNeedRebuild() const { return m_compositingLayersNeedRebuild; }
void setCompositingConsultsOverlap(bool b) { m_compositingConsultsOverlap = b; }
bool compositingConsultsOverlap() const { return m_compositingConsultsOverlap; }
void scheduleLayerFlush();
void flushPendingLayerChanges(bool isFlushRoot = true);
RenderLayerCompositor* enclosingCompositorFlushingLayers() const;
void didFlushChangesForLayer(RenderLayer*);
void updateCompositingLayers(CompositingUpdateType, RenderLayer* updateRoot = 0);
void scheduleCompositingLayerUpdate();
enum CompositingChangeRepaint { CompositingChangeRepaintNow, CompositingChangeWillRepaintLater };
bool updateLayerCompositingState(RenderLayer*, CompositingChangeRepaint = CompositingChangeRepaintNow);
void updateCompositingDescendantGeometry(RenderLayer* compositingAncestor, RenderLayer* layer, RenderLayerBacking::UpdateDepth);
bool clippedByAncestor(RenderLayer*) const;
bool clipsCompositingDescendants(const RenderLayer*) const;
bool needsContentsCompositingLayer(const RenderLayer*) const;
IntRect calculateCompositedBounds(const RenderLayer*, const RenderLayer* ancestorLayer);
void repaintOnCompositingChange(RenderLayer*);
void repaintInCompositedAncestor(RenderLayer*, const LayoutRect&);
void layerWasAdded(RenderLayer* parent, RenderLayer* child);
void layerWillBeRemoved(RenderLayer* parent, RenderLayer* child);
RenderLayer* enclosingNonStackingClippingLayer(const RenderLayer* layer) const;
void repaintCompositedLayersAbsoluteRect(const IntRect&);
bool requiresOwnBackingStore(const RenderLayer*, const RenderLayer* compositingAncestorLayer) const;
RenderLayer* rootRenderLayer() const;
GraphicsLayer* rootGraphicsLayer() const;
GraphicsLayer* scrollLayer() const;
enum RootLayerAttachment {
RootLayerUnattached,
RootLayerAttachedViaChromeClient,
RootLayerAttachedViaEnclosingFrame
};
RootLayerAttachment rootLayerAttachment() const { return m_rootLayerAttachment; }
void updateRootLayerAttachment();
void updateRootLayerPosition();
void didMoveOnscreen();
void willMoveOffscreen();
void clearBackingForAllLayers();
void layerBecameComposited(const RenderLayer*) { ++m_compositedLayerCount; }
void layerBecameNonComposited(const RenderLayer*)
{
ASSERT(m_compositedLayerCount > 0);
--m_compositedLayerCount;
}
#if ENABLE(VIDEO)
bool canAccelerateVideoRendering(RenderVideo*) const;
#endif
bool has3DContent() const;
static bool allowsIndependentlyCompositedFrames(const FrameView*);
bool shouldPropagateCompositingToEnclosingFrame() const;
static RenderLayerCompositor* frameContentsCompositor(RenderPart*);
static bool parentFrameContentLayers(RenderPart*);
void frameViewDidChangeLocation(const IntPoint& contentsOffset);
void frameViewDidChangeSize();
void frameViewDidScroll();
String layerTreeAsText(bool showDebugInfo = false);
bool compositorShowDebugBorders() const { return m_showDebugBorders; }
bool compositorShowRepaintCounter() const { return m_showRepaintCounter; }
virtual float deviceScaleFactor() const;
virtual float pageScaleFactor() const;
virtual void didCommitChangesForLayer(const GraphicsLayer*) const;
bool keepLayersPixelAligned() const;
bool acceleratedDrawingEnabled() const { return m_acceleratedDrawingEnabled; }
void deviceOrPageScaleFactorChanged();
GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); }
GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); }
GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); }
#if ENABLE(RUBBER_BANDING)
GraphicsLayer* layerForOverhangAreas() const { return m_layerForOverhangAreas.get(); }
#endif
void documentBackgroundColorDidChange();
void updateFixedPositionStatus(RenderLayer*);
void removeFixedPositionLayer(RenderLayer*);
void platformLayerChanged(RenderLayer*, PlatformLayer* oldLayer, PlatformLayer* newLayer);
void registerAllFixedPositionLayers();
void unregisterAllFixedPositionLayers();
void scrollingLayerAddedOrUpdated(RenderLayer*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer, const IntSize& scrollSize);
void scrollingLayerRemoved(RenderLayer*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer);
void registerAllScrollingLayers();
void unregisterAllScrollingLayers();
virtual float minimumDocumentScale() const OVERRIDE;
virtual bool allowCompositingLayerVisualDegradation() const OVERRIDE;
private:
class OverlapMap;
virtual void notifyAnimationStarted(const GraphicsLayer*, double) { }
virtual void notifySyncRequired(const GraphicsLayer*) { scheduleLayerFlush(); }
virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect&);
virtual bool showDebugBorders(const GraphicsLayer*) const;
virtual bool showRepaintCounter(const GraphicsLayer*) const;
virtual void platformLayerChanged(GraphicsLayer*, PlatformLayer* , PlatformLayer* ) OVERRIDE { }
bool needsToBeComposited(const RenderLayer*) const;
bool requiresCompositingLayer(const RenderLayer*) const;
bool canBeComposited(const RenderLayer*) const;
bool updateBacking(RenderLayer*, CompositingChangeRepaint shouldRepaint);
void clearBackingForLayerIncludingDescendants(RenderLayer*);
void recursiveRepaintLayerRect(RenderLayer*, const IntRect&);
void addToOverlapMap(OverlapMap&, RenderLayer*, IntRect& layerBounds, bool& boundsComputed);
void addToOverlapMapRecursive(OverlapMap&, RenderLayer*, RenderLayer* ancestorLayer = 0);
void updateCompositingLayersTimerFired(Timer<RenderLayerCompositor>*);
void computeCompositingRequirements(RenderLayer* ancestorLayer, RenderLayer*, OverlapMap*, struct CompositingState&, bool& layersChanged, bool& descendantHas3DTransform);
void rebuildCompositingLayerTree(RenderLayer*, Vector<GraphicsLayer*>& childGraphicsLayersOfEnclosingLayer, int depth);
void updateLayerTreeGeometry(RenderLayer*, int depth);
void setCompositingParent(RenderLayer* childLayer, RenderLayer* parentLayer);
void removeCompositedChildren(RenderLayer*);
bool layerHas3DContent(const RenderLayer*) const;
bool isRunningAcceleratedTransformAnimation(RenderObject*) const;
bool hasAnyAdditionalCompositedLayers(const RenderLayer* rootLayer) const;
void ensureRootLayer();
void destroyRootLayer();
void attachRootLayer(RootLayerAttachment);
void detachRootLayer();
void rootLayerAttachmentChanged();
void updateOverflowControlsLayers();
void notifyIFramesOfCompositingChange();
bool isFlushingLayers() const { return m_flushingLayers; }
ScrollingCoordinator* scrollingCoordinator() const;
bool requiresCompositingForAnimation(RenderObject*) const;
bool requiresCompositingForTransform(RenderObject*) const;
bool requiresCompositingForVideo(RenderObject*) const;
bool requiresCompositingForCanvas(RenderObject*) const;
bool requiresCompositingForPlugin(RenderObject*) const;
bool requiresCompositingForFrame(RenderObject*) const;
bool requiresCompositingForFilters(RenderObject*) const;
bool requiresCompositingForScrollableFrame() const;
bool requiresCompositingForPosition(RenderObject*, const RenderLayer*) const;
bool requiresCompositingForIndirectReason(RenderObject*, bool hasCompositedDescendants, bool has3DTransformedDescendants, RenderLayer::IndirectCompositingReason&) const;
bool requiresCompositingForScrolling(RenderObject*) const;
void addFixedPositionLayer(RenderLayer*);
void registerOrUpdateFixedPositionLayer(RenderLayer*);
void unregisterFixedPositionLayer(RenderLayer*);
void getFixedPositionLayerSizing(RenderLayer*, ScrollingLayerSizing&, FloatRect&, FloatSize&);
ChromeClient* chromeClient() const;
bool requiresScrollLayer(RootLayerAttachment) const;
bool requiresHorizontalScrollbarLayer() const;
bool requiresVerticalScrollbarLayer() const;
bool requiresScrollCornerLayer() const;
#if ENABLE(RUBBER_BANDING)
bool requiresOverhangAreasLayer() const;
bool requiresContentShadowLayer() const;
#endif
#if !LOG_DISABLED
const char* reasonForCompositing(const RenderLayer*);
void logLayerInfo(const RenderLayer*, int depth);
#endif
private:
RenderView* m_renderView;
OwnPtr<GraphicsLayer> m_rootContentLayer;
Timer<RenderLayerCompositor> m_updateCompositingLayersTimer;
bool m_hasAcceleratedCompositing;
ChromeClient::CompositingTriggerFlags m_compositingTriggers;
int m_compositedLayerCount;
bool m_showDebugBorders;
bool m_showRepaintCounter;
bool m_acceleratedDrawingEnabled;
bool m_compositingConsultsOverlap;
mutable bool m_reevaluateCompositingAfterLayout;
bool m_compositing;
bool m_compositingLayersNeedRebuild;
bool m_flushingLayers;
bool m_forceCompositingMode;
RootLayerAttachment m_rootLayerAttachment;
OwnPtr<GraphicsLayer> m_clipLayer;
OwnPtr<GraphicsLayer> m_scrollLayer;
HashSet<RenderLayer*> m_fixedPositionLayers;
HashSet<RenderLayer*> m_scrollingLayers;
HashSet<RenderLayer*> m_fixedPositionLayersNeedingUpdate;
OwnPtr<GraphicsLayer> m_overflowControlsHostLayer;
OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar;
OwnPtr<GraphicsLayer> m_layerForScrollCorner;
#if ENABLE(RUBBER_BANDING)
OwnPtr<GraphicsLayer> m_layerForOverhangAreas;
OwnPtr<GraphicsLayer> m_contentShadowLayer;
#endif
#if !LOG_DISABLED
int m_rootLayerUpdateCount;
int m_obligateCompositedLayerCount; int m_secondaryCompositedLayerCount; double m_obligatoryBackingStoreBytes;
double m_secondaryBackingStoreBytes;
#endif
};
}
#endif // RenderLayerCompositor_h