RenderLayerCompositor.h [plain text]
#ifndef RenderLayerCompositor_h
#define RenderLayerCompositor_h
#include "ChromeClient.h"
#include "RenderLayer.h"
#include "RenderLayerBacking.h"
namespace WebCore {
#define PROFILE_LAYER_REBUILD 0
class GraphicsLayer;
class RenderEmbeddedObject;
class RenderPart;
#if ENABLE(VIDEO)
class RenderVideo;
#endif
enum CompositingUpdateType {
CompositingUpdateAfterLayoutOrStyleChange,
CompositingUpdateOnHitTest,
CompositingUpdateOnScroll
};
class RenderLayerCompositor : public GraphicsLayerClient {
public:
RenderLayerCompositor(RenderView*);
~RenderLayerCompositor();
bool inCompositingMode() const { return m_compositing; }
void enableCompositingMode(bool enable = true);
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 isFlushingLayers() const { return m_flushingLayers; }
RenderLayerCompositor* enclosingCompositorFlushingLayers() const;
void didFlushChangesForLayer(RenderLayer*);
void updateCompositingLayers(CompositingUpdateType = CompositingUpdateAfterLayoutOrStyleChange, RenderLayer* updateRoot = 0);
void scheduleCompositingLayerUpdate();
bool compositingLayerUpdatePending() const;
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* layer, const RenderLayer* ancestorLayer);
void repaintOnCompositingChange(RenderLayer*);
void layerWasAdded(RenderLayer* parent, RenderLayer* child);
void layerWillBeRemoved(RenderLayer* parent, RenderLayer* child);
RenderLayer* enclosingNonStackingClippingLayer(const RenderLayer* layer) const;
void repaintCompositedLayersAbsoluteRect(const IntRect&);
RenderLayer* rootRenderLayer() const;
GraphicsLayer* rootPlatformLayer() const;
enum RootLayerAttachment {
RootLayerUnattached,
RootLayerAttachedViaChromeClient,
RootLayerAttachedViaEnclosingFrame
};
RootLayerAttachment rootLayerAttachment() const { return m_rootLayerAttachment; }
void updateRootLayerAttachment();
void updateRootLayerPosition();
void didMoveOnscreen();
void willMoveOffscreen();
void layerBecameComposited(const RenderLayer*) { ++m_compositedLayerCount; }
void layerBecameNonComposited(const RenderLayer*)
{
ASSERT(m_compositedLayerCount > 0);
--m_compositedLayerCount;
}
void didStartAcceleratedAnimation(CSSPropertyID);
#if ENABLE(VIDEO)
bool canAccelerateVideoRendering(RenderVideo*) const;
#endif
bool has3DContent() const;
static bool allowsIndependentlyCompositedFrames(const FrameView*);
bool shouldPropagateCompositingToEnclosingFrame() const;
HTMLFrameOwnerElement* enclosingFrameElement() const;
static RenderLayerCompositor* frameContentsCompositor(RenderPart*);
static bool parentFrameContentLayers(RenderPart*);
void frameViewDidChangeLocation(const IntPoint& contentsOffset);
void frameViewDidChangeSize();
void frameViewDidScroll(const IntPoint& = IntPoint());
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;
void deviceOrPageScaleFactorChanged();
GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); }
GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); }
GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); }
private:
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 { return false; }
virtual bool showRepaintCounter() const { return false; }
bool needsToBeComposited(const RenderLayer*) const;
bool requiresCompositingLayer(const RenderLayer*) const;
bool canBeComposited(const RenderLayer*) const;
bool updateBacking(RenderLayer*, CompositingChangeRepaint shouldRepaint);
void recursiveRepaintLayerRect(RenderLayer* layer, const IntRect& rect);
typedef HashMap<RenderLayer*, IntRect> OverlapMap;
static void addToOverlapMap(OverlapMap&, RenderLayer*, IntRect& layerBounds, bool& boundsComputed);
static bool overlapsCompositedLayers(OverlapMap&, const IntRect& layerBounds);
void updateCompositingLayersTimerFired(Timer<RenderLayerCompositor>*);
void computeCompositingRequirements(RenderLayer*, OverlapMap*, struct CompositingState&, bool& layersChanged);
void rebuildCompositingLayerTree(RenderLayer* layer, const struct CompositingState&, Vector<GraphicsLayer*>& childGraphicsLayersOfEnclosingLayer);
void updateLayerTreeGeometry(RenderLayer*);
void setCompositingParent(RenderLayer* childLayer, RenderLayer* parentLayer);
void removeCompositedChildren(RenderLayer*);
bool layerHas3DContent(const RenderLayer*) const;
bool hasAnyAdditionalCompositedLayers(const RenderLayer* rootLayer) const;
void ensureRootPlatformLayer();
void destroyRootPlatformLayer();
void attachRootPlatformLayer(RootLayerAttachment);
void detachRootPlatformLayer();
void rootLayerAttachmentChanged();
void updateOverflowControlsLayers();
void scheduleNeedsStyleRecalc(Element*);
void notifyIFramesOfCompositingChange();
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 requiresCompositingWhenDescendantsAreCompositing(RenderObject*) const;
bool requiresCompositingForFullScreen(RenderObject*) const;
bool requiresScrollLayer(RootLayerAttachment) const;
bool requiresHorizontalScrollbarLayer() const;
bool requiresVerticalScrollbarLayer() const;
bool requiresScrollCornerLayer() const;
private:
RenderView* m_renderView;
OwnPtr<GraphicsLayer> m_rootPlatformLayer;
Timer<RenderLayerCompositor> m_updateCompositingLayersTimer;
bool m_hasAcceleratedCompositing;
ChromeClient::CompositingTriggerFlags m_compositingTriggers;
int m_compositedLayerCount;
bool m_showDebugBorders;
bool m_showRepaintCounter;
bool m_compositingConsultsOverlap;
mutable bool m_compositingDependsOnGeometry;
bool m_compositing;
bool m_compositingLayersNeedRebuild;
bool m_flushingLayers;
bool m_forceCompositingMode;
RootLayerAttachment m_rootLayerAttachment;
OwnPtr<GraphicsLayer> m_clipLayer;
OwnPtr<GraphicsLayer> m_scrollLayer;
OwnPtr<GraphicsLayer> m_overflowControlsHostLayer;
OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar;
OwnPtr<GraphicsLayer> m_layerForScrollCorner;
#if PROFILE_LAYER_REBUILD
int m_rootLayerUpdateCount;
#endif
};
}
#endif // RenderLayerCompositor_h