#ifndef CCLayerImpl_h
#define CCLayerImpl_h
#include "Color.h"
#include "FloatRect.h"
#include "IntRect.h"
#include "TextStream.h"
#include "TransformationMatrix.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class LayerChromium;
class LayerRendererChromium;
class RenderSurfaceChromium;
class CCLayerImpl : public RefCounted<CCLayerImpl> {
public:
static PassRefPtr<CCLayerImpl> create(LayerChromium* owner, int id)
{
return adoptRef(new CCLayerImpl(owner, id));
}
virtual ~CCLayerImpl();
CCLayerImpl* parent() const { return m_parent; }
const Vector<RefPtr<CCLayerImpl> >& children() const { return m_children; }
void addChild(PassRefPtr<CCLayerImpl>);
void removeFromParent();
void removeAllChildren();
void setMaskLayer(PassRefPtr<CCLayerImpl> maskLayer) { m_maskLayer = maskLayer; }
CCLayerImpl* maskLayer() const { return m_maskLayer.get(); }
void setReplicaLayer(PassRefPtr<CCLayerImpl> replicaLayer) { m_replicaLayer = replicaLayer; }
CCLayerImpl* replicaLayer() const { return m_replicaLayer.get(); }
int id() const { return m_layerId; }
#ifndef NDEBUG
int debugID() const { return m_debugID; }
#endif
virtual void draw(const IntRect& contentRect);
virtual void updateCompositorResources();
void unreserveContentsTexture();
void bindContentsTexture();
virtual bool drawsContent() const;
bool descendantsDrawsContent();
void cleanupResources();
void setAnchorPoint(const FloatPoint& anchorPoint) { m_anchorPoint = anchorPoint; }
const FloatPoint& anchorPoint() const { return m_anchorPoint; }
void setAnchorPointZ(float anchorPointZ) { m_anchorPointZ = anchorPointZ; }
float anchorPointZ() const { return m_anchorPointZ; }
void setMasksToBounds(bool masksToBounds) { m_masksToBounds = masksToBounds; }
bool masksToBounds() const { return m_masksToBounds; }
void setOpacity(float opacity) { m_opacity = opacity; }
float opacity() const { return m_opacity; }
void setPosition(const FloatPoint& position) { m_position = position; }
const FloatPoint& position() const { return m_position; }
void setPreserves3D(bool preserves3D) { m_preserves3D = preserves3D; }
bool preserves3D() const { return m_preserves3D; }
void setSublayerTransform(const TransformationMatrix& sublayerTransform) { m_sublayerTransform = sublayerTransform; }
const TransformationMatrix& sublayerTransform() const { return m_sublayerTransform; }
void setTransform(const TransformationMatrix& transform) { m_transform = transform; }
const TransformationMatrix& transform() const { return m_transform; }
void setName(const String& name) { m_name = name; }
const String& name() const { return m_name; }
void setDebugBorderColor(Color c) { m_debugBorderColor = c; }
Color debugBorderColor() const { return m_debugBorderColor; }
void setDebugBorderWidth(float width) { m_debugBorderWidth = width; }
float debugBorderWidth() const { return m_debugBorderWidth; }
void drawDebugBorder();
void setLayerRenderer(LayerRendererChromium*);
LayerRendererChromium* layerRenderer() const { return m_layerRenderer.get(); }
RenderSurfaceChromium* createRenderSurface();
RenderSurfaceChromium* renderSurface() const { return m_renderSurface.get(); }
void clearRenderSurface() { m_renderSurface.clear(); }
float drawOpacity() const { return m_drawOpacity; }
void setDrawOpacity(float opacity) { m_drawOpacity = opacity; }
const IntRect& scissorRect() const { return m_scissorRect; }
void setScissorRect(const IntRect& rect) { m_scissorRect = rect; }
RenderSurfaceChromium* targetRenderSurface() const { return m_targetRenderSurface; }
void setTargetRenderSurface(RenderSurfaceChromium* surface) { m_targetRenderSurface = surface; }
bool doubleSided() const { return m_doubleSided; }
void setDoubleSided(bool doubleSided) { m_doubleSided = doubleSided; }
const IntSize& bounds() const { return m_bounds; }
void setBounds(const IntSize& bounds) { m_bounds = bounds; }
const IntRect getDrawRect() const;
const TransformationMatrix& drawTransform() const { return m_drawTransform; }
void setDrawTransform(const TransformationMatrix& matrix) { m_drawTransform = matrix; }
const IntRect& drawableContentRect() const { return m_drawableContentRect; }
void setDrawableContentRect(const IntRect& rect) { m_drawableContentRect = rect; }
virtual void dumpLayerProperties(TextStream&, int indent) const;
LayerChromium* owner() const { return m_owner; }
void clearOwner() { m_owner = 0; }
protected:
LayerChromium* m_owner;
CCLayerImpl(LayerChromium*, int);
static void writeIndent(TextStream&, int indent);
private:
void setParent(CCLayerImpl* parent) { m_parent = parent; }
friend class TreeSynchronizer;
void clearChildList();
CCLayerImpl* m_parent;
Vector<RefPtr<CCLayerImpl> > m_children;
RefPtr<CCLayerImpl> m_maskLayer;
RefPtr<CCLayerImpl> m_replicaLayer;
int m_layerId;
FloatPoint m_anchorPoint;
float m_anchorPointZ;
IntSize m_bounds;
bool m_doubleSided;
bool m_masksToBounds;
float m_opacity;
FloatPoint m_position;
bool m_preserves3D;
TransformationMatrix m_sublayerTransform;
TransformationMatrix m_transform;
#ifndef NDEBUG
int m_debugID;
#endif
String m_name;
RenderSurfaceChromium* m_targetRenderSurface;
float m_drawDepth;
float m_drawOpacity;
Color m_debugBorderColor;
float m_debugBorderWidth;
TransformationMatrix m_drawTransform;
IntRect m_scissorRect;
OwnPtr<RenderSurfaceChromium> m_renderSurface;
IntRect m_drawableContentRect;
RefPtr<LayerRendererChromium> m_layerRenderer;
};
}
#endif // CCLayerImpl_h