diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/platform/graphics/chromium/LayerChromium.h | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/platform/graphics/chromium/LayerChromium.h')
-rw-r--r-- | Source/WebCore/platform/graphics/chromium/LayerChromium.h | 141 |
1 files changed, 48 insertions, 93 deletions
diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerChromium.h index 5c7e2b1..29a2165 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.h @@ -38,13 +38,17 @@ #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 skia { @@ -53,13 +57,13 @@ class PlatformCanvas; namespace WebCore { +class CCLayerImpl; class GraphicsContext3D; class LayerRendererChromium; // Base class for composited layers. Special layer types are derived from // this class. class LayerChromium : public RefCounted<LayerChromium> { - friend class LayerRendererChromium; friend class LayerTilerChromium; public: static PassRefPtr<LayerChromium> create(GraphicsLayerChromium* owner = 0); @@ -85,21 +89,9 @@ public: void setBackgroundColor(const Color& color) { m_backgroundColor = color; setNeedsCommit(); } Color backgroundColor() const { return m_backgroundColor; } - void setBorderColor(const Color& color) { m_borderColor = color; setNeedsCommit(); } - Color borderColor() const { return m_borderColor; } - - void setBorderWidth(float width) { m_borderWidth = width; setNeedsCommit(); } - float borderWidth() const { return m_borderWidth; } - - void setBounds(const IntSize&); - IntSize bounds() const { return m_bounds; } - void setClearsContext(bool clears) { m_clearsContext = clears; setNeedsCommit(); } bool clearsContext() const { return m_clearsContext; } - void setDoubleSided(bool doubleSided) { m_doubleSided = doubleSided; setNeedsCommit(); } - bool doubleSided() const { return m_doubleSided; } - void setFrame(const FloatRect&); FloatRect frame() const { return m_frame; } @@ -109,10 +101,11 @@ public: void setMasksToBounds(bool masksToBounds) { m_masksToBounds = masksToBounds; } bool masksToBounds() const { return m_masksToBounds; } - void setName(const String& name) { m_name = name; } - String name() const { return m_name; } + 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); @@ -144,75 +137,60 @@ public: void setGeometryFlipped(bool flipped) { m_geometryFlipped = flipped; setNeedsCommit(); } bool geometryFlipped() const { return m_geometryFlipped; } - const TransformationMatrix& drawTransform() const { return m_drawTransform; } - float drawOpacity() const { return m_drawOpacity; } - bool preserves3D() { return m_owner && m_owner->preserves3D(); } // Derived types must override this method if they need to react to a change // in the LayerRendererChromium. virtual void setLayerRenderer(LayerRendererChromium*); + // Returns true if any of the layer's descendants has content to draw. + bool descendantsDrawContent(); + void setOwner(GraphicsLayerChromium* owner) { m_owner = owner; } void setReplicaLayer(LayerChromium* layer) { m_replicaLayer = layer; } LayerChromium* replicaLayer() { return m_replicaLayer; } - // Returns the rect containtaining this layer in the current view's coordinate system. - const IntRect getDrawRect() const; - // These methods typically need to be overwritten by derived classes. - virtual bool drawsContent() { return false; } + virtual bool drawsContent() const { return false; } virtual void updateContentsIfDirty() { } virtual void unreserveContentsTexture() { } virtual void bindContentsTexture() { } virtual void draw() { } + // These exists just for debugging (via drawDebugBorder()). + void setBorderColor(const Color&); + Color borderColor() const; + +#ifndef NDEBUG + int debugID() const { return m_debugID; } +#endif + void drawDebugBorder(); + String layerTreeAsText() const; + + void setBorderWidth(float); + float borderWidth() const; + + // Everything from here down in the public section will move to CCLayerImpl. - RenderSurfaceChromium* createRenderSurface(); - - // Stores values that are shared between instances of this class that are - // associated with the same LayerRendererChromium (and hence the same GL - // context). - class SharedValues { - public: - explicit SharedValues(GraphicsContext3D*); - ~SharedValues(); - - GraphicsContext3D* context() const { return m_context; } - unsigned quadVerticesVbo() const { return m_quadVerticesVbo; } - unsigned quadElementsVbo() const { return m_quadElementsVbo; } - int maxTextureSize() const { return m_maxTextureSize; } - unsigned borderShaderProgram() const { return m_borderShaderProgram; } - int borderShaderMatrixLocation() const { return m_borderShaderMatrixLocation; } - int borderShaderColorLocation() const { return m_borderShaderColorLocation; } - bool initialized() const { return m_initialized; } - - private: - GraphicsContext3D* m_context; - unsigned m_quadVerticesVbo; - unsigned m_quadElementsVbo; - int m_maxTextureSize; - unsigned m_borderShaderProgram; - int m_borderShaderMatrixLocation; - int m_borderShaderColorLocation; - bool m_initialized; - }; - - static void prepareForDraw(const SharedValues*); - - LayerRendererChromium* layerRenderer() const { return m_layerRenderer.get(); } - - static unsigned createShaderProgram(GraphicsContext3D*, const char* vertexShaderSource, const char* fragmentShaderSource); + CCLayerImpl* ccLayerImpl() const { return m_ccLayerImpl.get(); } static void drawTexturedQuad(GraphicsContext3D*, const TransformationMatrix& projectionMatrix, const TransformationMatrix& layerMatrix, float width, float height, float opacity, int matrixLocation, int alphaLocation); + // Begin calls that forward to the CCLayerImpl. + LayerRendererChromium* layerRenderer() const; + void setDoubleSided(bool); + void setBounds(const IntSize&); + const IntSize& bounds() const; + // End calls that forward to the CCLayerImpl. + + typedef ProgramBinding<VertexShaderPos, FragmentShaderColor> BorderProgram; protected: GraphicsLayerChromium* m_owner; - LayerChromium(GraphicsLayerChromium* owner); + explicit LayerChromium(GraphicsLayerChromium* owner); // This is called to clean up resources being held in the same context as // layerRendererContext(). Subclasses should override this method if they @@ -221,23 +199,18 @@ protected: GraphicsContext3D* layerRendererContext() const; - // Returns true if any of the layer's descendants has content to draw. - bool descendantsDrawContent(); - static void toGLMatrix(float*, const TransformationMatrix&); - IntSize m_bounds; + 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; - // Render surface this layer draws into. This is a surface that can belong - // either to this layer (if m_targetRenderSurface == m_renderSurface) or - // to an ancestor of this layer. The target render surface determines the - // coordinate system the layer's transforms are relative to. - RenderSurfaceChromium* m_targetRenderSurface; - // All layer shaders share the same attribute locations for the vertex positions // and texture coordinates. This allows switching shaders without rebinding attribute // arrays. @@ -265,48 +238,30 @@ private: Vector<RefPtr<LayerChromium> > m_sublayers; LayerChromium* m_superlayer; +#ifndef NDEBUG + int m_debugID; +#endif + // Layer properties. - IntSize m_backingStoreSize; FloatPoint m_position; FloatPoint m_anchorPoint; Color m_backgroundColor; - Color m_borderColor; float m_opacity; float m_zPosition; float m_anchorPointZ; - float m_borderWidth; - float m_drawOpacity; bool m_clearsContext; - bool m_doubleSided; bool m_hidden; bool m_masksToBounds; bool m_opaque; bool m_geometryFlipped; bool m_needsDisplayOnBoundsChange; - // The global depth value of the center of the layer. This value is used - // to sort layers from back to front. - float m_drawDepth; - - // Points to the layer renderer that updates and draws this layer. - RefPtr<LayerRendererChromium> m_layerRenderer; - - FloatRect m_frame; TransformationMatrix m_transform; TransformationMatrix m_sublayerTransform; - TransformationMatrix m_drawTransform; - - // The scissor rectangle that should be used when this layer is drawn. - // Inherited by the parent layer and further restricted if this layer masks - // to bounds. - IntRect m_scissorRect; - // Render surface associated with this layer. The layer and its descendants - // will render to this surface. - OwnPtr<RenderSurfaceChromium> m_renderSurface; - - // Hierarchical bounding rect containing the layer and its descendants. - IntRect m_drawableContentRect; + FloatRect m_frame; + // For now, the LayerChromium directly owns its CCLayerImpl. + RefPtr<CCLayerImpl> m_ccLayerImpl; // Replica layer used for reflections. LayerChromium* m_replicaLayer; |