RenderLayerCompositor.h [plain text]
#ifndef RenderLayerCompositor_h
#define RenderLayerCompositor_h
#include "ChromeClient.h"
#include "RenderLayer.h"
#include "RenderLayerBacking.h"
namespace WebCore {
class GraphicsLayer;
class RenderEmbeddedObject;
class RenderPart;
class ScrollingCoordinator;
#if ENABLE(VIDEO)
class RenderVideo;
#endif
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 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* 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();
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;
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*);
void updateCompositingLayersTimerFired(Timer<RenderLayerCompositor>*);
void computeCompositingRequirements(RenderLayer*, OverlapMap*, struct CompositingState&, bool& layersChanged);
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 hasNonAffineTransform(RenderObject*) 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 requiresCompositingWhenDescendantsAreCompositing(RenderObject*) const;
bool requiresCompositingForFilters(RenderObject*) const;
bool requiresCompositingForScrollableFrame() const;
bool requiresCompositingForPosition(RenderObject*, const RenderLayer*) 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;
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_obligatoryBackingAreaMegaPixels;
double m_secondaryBackingAreaMegaPixels;
#endif
};
}
#endif // RenderLayerCompositor_h