#ifndef LayerChromium_h
#define LayerChromium_h
#if USE(ACCELERATED_COMPOSITING)
#include "FloatPoint.h"
#include "GraphicsContext.h"
#include "GraphicsLayerChromium.h"
#include "PlatformString.h"
#include "ProgramBinding.h"
#include "RenderSurfaceChromium.h"
#include "ShaderChromium.h"
#include "TransformationMatrix.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class CCLayerImpl;
class GraphicsContext3D;
class LayerRendererChromium;
class LayerChromium : public RefCounted<LayerChromium> {
friend class LayerTilerChromium;
public:
static PassRefPtr<LayerChromium> create(GraphicsLayerChromium* owner = 0);
virtual ~LayerChromium();
const LayerChromium* rootLayer() const;
LayerChromium* parent() const;
void addChild(PassRefPtr<LayerChromium>);
void insertChild(PassRefPtr<LayerChromium>, size_t index);
void replaceChild(LayerChromium* reference, PassRefPtr<LayerChromium> newLayer);
void removeFromParent();
void removeAllChildren();
void setChildren(const Vector<RefPtr<LayerChromium> >&);
const Vector<RefPtr<LayerChromium> >& children() const { return m_children; }
void setAnchorPoint(const FloatPoint& anchorPoint) { m_anchorPoint = anchorPoint; setNeedsCommit(); }
FloatPoint anchorPoint() const { return m_anchorPoint; }
void setAnchorPointZ(float anchorPointZ) { m_anchorPointZ = anchorPointZ; setNeedsCommit(); }
float anchorPointZ() const { return m_anchorPointZ; }
void setBackgroundColor(const Color& color) { m_backgroundColor = color; setNeedsCommit(); }
Color backgroundColor() const { return m_backgroundColor; }
void setBounds(const IntSize&);
const IntSize& bounds() const { return m_bounds; }
void setClearsContext(bool clears) { m_clearsContext = clears; setNeedsCommit(); }
bool clearsContext() const { return m_clearsContext; }
void setFrame(const FloatRect&);
FloatRect frame() const { return m_frame; }
void setHidden(bool hidden) { m_hidden = hidden; setNeedsCommit(); }
bool isHidden() const { return m_hidden; }
void setMasksToBounds(bool masksToBounds) { m_masksToBounds = masksToBounds; }
bool masksToBounds() const { return m_masksToBounds; }
void setName(const String&);
const String& name() const { return m_name; }
void setMaskLayer(LayerChromium* maskLayer) { m_maskLayer = maskLayer; }
CCLayerImpl* maskDrawLayer() const { return m_maskLayer ? m_maskLayer->ccLayerImpl() : 0; }
LayerChromium* maskLayer() const { return m_maskLayer.get(); }
void setNeedsDisplay(const FloatRect& dirtyRect);
void setNeedsDisplay();
virtual void invalidateRect(const FloatRect& dirtyRect) {}
const FloatRect& dirtyRect() const { return m_dirtyRect; }
void resetNeedsDisplay();
void setNeedsDisplayOnBoundsChange(bool needsDisplay) { m_needsDisplayOnBoundsChange = needsDisplay; }
void setOpacity(float opacity) { m_opacity = opacity; setNeedsCommit(); }
float opacity() const { return m_opacity; }
void setOpaque(bool opaque) { m_opaque = opaque; setNeedsCommit(); }
bool opaque() const { return m_opaque; }
void setPosition(const FloatPoint& position) { m_position = position; setNeedsCommit(); }
FloatPoint position() const { return m_position; }
void setZPosition(float zPosition) { m_zPosition = zPosition; setNeedsCommit(); }
float zPosition() const { return m_zPosition; }
void setSublayerTransform(const TransformationMatrix& transform) { m_sublayerTransform = transform; setNeedsCommit(); }
const TransformationMatrix& sublayerTransform() const { return m_sublayerTransform; }
void setTransform(const TransformationMatrix& transform) { m_transform = transform; setNeedsCommit(); }
const TransformationMatrix& transform() const { return m_transform; }
bool doubleSided() const { return m_doubleSided; }
void setDoubleSided(bool doubleSided) { m_doubleSided = doubleSided; setNeedsCommit(); }
void setGeometryFlipped(bool flipped) { m_geometryFlipped = flipped; setNeedsCommit(); }
bool geometryFlipped() const { return m_geometryFlipped; }
bool preserves3D() { return m_owner && m_owner->preserves3D(); }
virtual void setLayerRenderer(LayerRendererChromium*);
void setOwner(GraphicsLayerChromium* owner) { m_owner = owner; }
void setReplicaLayer(LayerChromium* layer) { m_replicaLayer = layer; }
LayerChromium* replicaLayer() { return m_replicaLayer; }
virtual bool drawsContent() const { return false; }
virtual void paintContentsIfDirty(const IntRect&) { }
virtual void paintContentsIfDirty() { }
virtual void updateCompositorResources() { }
virtual void setIsMask(bool) {}
virtual void unreserveContentsTexture() { }
virtual void bindContentsTexture() { }
virtual void draw(const IntRect&) { }
void setBorderColor(const Color&);
void drawDebugBorder();
String layerTreeAsText() const;
void setBorderWidth(float);
CCLayerImpl* ccLayerImpl();
static void drawTexturedQuad(GraphicsContext3D*, const TransformationMatrix& projectionMatrix, const TransformationMatrix& layerMatrix,
float width, float height, float opacity,
int matrixLocation, int alphaLocation);
virtual void pushPropertiesTo(CCLayerImpl*);
LayerRendererChromium* layerRenderer() const;
typedef ProgramBinding<VertexShaderPos, FragmentShaderColor> BorderProgram;
int id() const { return m_layerId; }
protected:
GraphicsLayerChromium* m_owner;
explicit LayerChromium(GraphicsLayerChromium* owner);
virtual void cleanupResources();
GraphicsContext3D* layerRendererContext() const;
static void toGLMatrix(float*, const TransformationMatrix&);
void dumpLayer(TextStream&, int indent) const;
virtual const char* layerTypeAsString() const { return "LayerChromium"; }
virtual void dumpLayerProperties(TextStream&, int indent) const;
FloatRect m_dirtyRect;
bool m_contentsDirty;
RefPtr<LayerChromium> m_maskLayer;
static const unsigned s_positionAttribLocation;
static const unsigned s_texCoordAttribLocation;
friend class TreeSynchronizer;
virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
void setCCLayerImpl(CCLayerImpl* impl) { m_ccLayerImpl = impl; }
int m_layerId;
private:
void setNeedsCommit();
void setParent(LayerChromium* parent) { m_parent = parent; }
size_t numChildren() const
{
return m_children.size();
}
int indexOfChild(const LayerChromium*);
void removeChild(LayerChromium*);
Vector<RefPtr<LayerChromium> > m_children;
LayerChromium* m_parent;
RefPtr<LayerRendererChromium> m_layerRenderer;
CCLayerImpl* m_ccLayerImpl;
IntSize m_bounds;
FloatPoint m_position;
FloatPoint m_anchorPoint;
Color m_backgroundColor;
Color m_debugBorderColor;
float m_debugBorderWidth;
float m_opacity;
float m_zPosition;
float m_anchorPointZ;
bool m_clearsContext;
bool m_hidden;
bool m_masksToBounds;
bool m_opaque;
bool m_geometryFlipped;
bool m_needsDisplayOnBoundsChange;
bool m_doubleSided;
TransformationMatrix m_transform;
TransformationMatrix m_sublayerTransform;
FloatRect m_frame;
LayerChromium* m_replicaLayer;
String m_name;
};
}
#endif // USE(ACCELERATED_COMPOSITING)
#endif