Title: [119247] trunk/Source/WebCore
Revision
119247
Author
[email protected]
Date
2012-06-01 10:02:00 -0700 (Fri, 01 Jun 2012)

Log Message

Make TextureMapper work with GraphicsSurface.
https://bugs.webkit.org/show_bug.cgi?id=87738

Add TextureMapperSurfaceBackingStore, a new backing store
that allows to import textures from a GraphicsSurface.
On Mac the GraphicsSurface is backed by an IOSurface
which must be used with a GL_TEXTURE_RECTANGLE_ARB texture.
Therefore it is also necessary to add new shader programs
for directly painting these textures on screen.

Reviewed by Noam Rosenthal.

* platform/graphics/texmap/TextureMapperBackingStore.cpp:
Add a new TextureMapperBackingStore implementation that can directly
reuse textures as they are being passed from the GraphicsSurface.
(WebCore::TextureMapperSurfaceBackingStore::setGraphicsSurface):
(WebCore::TextureMapperSurfaceBackingStore::texture):
(WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):
* platform/graphics/texmap/TextureMapperBackingStore.h:
(GraphicsSurfaceData):
(WebCore::GraphicsSurfaceData::setSurface):
(WebCore::GraphicsSurfaceData::GraphicsSurfaceData):
(TextureMapperSurfaceBackingStore):
(WebCore::TextureMapperSurfaceBackingStore::create):
(WebCore::TextureMapperSurfaceBackingStore::~TextureMapperSurfaceBackingStore):
(WebCore::TextureMapperSurfaceBackingStore::TextureMapperSurfaceBackingStore):

* platform/graphics/texmap/TextureMapperGL.cpp:
Add a drawing function for textures of type GL_TEXTURE_RECTANGLE_ARB.
(WebCore::TextureMapperGL::drawTextureRectangleARB):
* platform/graphics/texmap/TextureMapperShaderManager.cpp:
(WebCore::TextureMapperShaderManager::getShaderProgram):
(WebCore::TextureMapperShaderProgramSimple::create):
(WebCore::TextureMapperShaderProgramSimple::initialize):
(WebCore::TextureMapperShaderProgramSolidColor::create):
(WebCore::TextureMapperShaderProgramSolidColor::initialize):
(WebCore::TextureMapperShaderProgramRectSimple::create):
(WebCore::TextureMapperShaderProgramRectSimple::fragmentShaderSource):
(WebCore::TextureMapperShaderProgramOpacityAndMask::create):
(WebCore::TextureMapperShaderProgramOpacityAndMask::initialize):
(WebCore::TextureMapperShaderProgramRectOpacityAndMask::create):
(WebCore::TextureMapperShaderProgramRectOpacityAndMask::fragmentShaderSource):

* platform/graphics/texmap/TextureMapperShaderManager.h:
Add new shader programs that can be used with GL_TEXTURE_RECTANGLE_ARB textures.
This is mainly necessary, because this type of texture uses non-normalized coordinates.
Further move the calls to initializeProgram() from the constructor into a separate
initialize() function, as initializeProgram() calls vertexShaderSource() (and friends)
and we should not call virtual functions in the constructor.
(WebCore::TextureMapperShaderProgram::initialize):
(TextureMapperShaderProgramSimple):
(WebCore::TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple):
(TextureMapperShaderProgramRectSimple):
(WebCore::TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple):
(TextureMapperShaderProgramOpacityAndMask):
(WebCore::TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask):
(TextureMapperShaderProgramRectOpacityAndMask):
(WebCore::TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpacityAndMask):
(TextureMapperShaderProgramSolidColor):
(WebCore::TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (119246 => 119247)


--- trunk/Source/WebCore/ChangeLog	2012-06-01 16:57:29 UTC (rev 119246)
+++ trunk/Source/WebCore/ChangeLog	2012-06-01 17:02:00 UTC (rev 119247)
@@ -1,3 +1,66 @@
+2012-06-01  Zeno Albisser  <[email protected]>
+
+        Make TextureMapper work with GraphicsSurface.
+        https://bugs.webkit.org/show_bug.cgi?id=87738
+
+        Add TextureMapperSurfaceBackingStore, a new backing store
+        that allows to import textures from a GraphicsSurface.
+        On Mac the GraphicsSurface is backed by an IOSurface
+        which must be used with a GL_TEXTURE_RECTANGLE_ARB texture.
+        Therefore it is also necessary to add new shader programs
+        for directly painting these textures on screen.
+
+        Reviewed by Noam Rosenthal.
+
+        * platform/graphics/texmap/TextureMapperBackingStore.cpp:
+        Add a new TextureMapperBackingStore implementation that can directly
+        reuse textures as they are being passed from the GraphicsSurface.
+        (WebCore::TextureMapperSurfaceBackingStore::setGraphicsSurface):
+        (WebCore::TextureMapperSurfaceBackingStore::texture):
+        (WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):
+        * platform/graphics/texmap/TextureMapperBackingStore.h:
+        (GraphicsSurfaceData):
+        (WebCore::GraphicsSurfaceData::setSurface):
+        (WebCore::GraphicsSurfaceData::GraphicsSurfaceData):
+        (TextureMapperSurfaceBackingStore):
+        (WebCore::TextureMapperSurfaceBackingStore::create):
+        (WebCore::TextureMapperSurfaceBackingStore::~TextureMapperSurfaceBackingStore):
+        (WebCore::TextureMapperSurfaceBackingStore::TextureMapperSurfaceBackingStore):
+
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        Add a drawing function for textures of type GL_TEXTURE_RECTANGLE_ARB.
+        (WebCore::TextureMapperGL::drawTextureRectangleARB):
+        * platform/graphics/texmap/TextureMapperShaderManager.cpp:
+        (WebCore::TextureMapperShaderManager::getShaderProgram):
+        (WebCore::TextureMapperShaderProgramSimple::create):
+        (WebCore::TextureMapperShaderProgramSimple::initialize):
+        (WebCore::TextureMapperShaderProgramSolidColor::create):
+        (WebCore::TextureMapperShaderProgramSolidColor::initialize):
+        (WebCore::TextureMapperShaderProgramRectSimple::create):
+        (WebCore::TextureMapperShaderProgramRectSimple::fragmentShaderSource):
+        (WebCore::TextureMapperShaderProgramOpacityAndMask::create):
+        (WebCore::TextureMapperShaderProgramOpacityAndMask::initialize):
+        (WebCore::TextureMapperShaderProgramRectOpacityAndMask::create):
+        (WebCore::TextureMapperShaderProgramRectOpacityAndMask::fragmentShaderSource):
+
+        * platform/graphics/texmap/TextureMapperShaderManager.h:
+        Add new shader programs that can be used with GL_TEXTURE_RECTANGLE_ARB textures.
+        This is mainly necessary, because this type of texture uses non-normalized coordinates.
+        Further move the calls to initializeProgram() from the constructor into a separate
+        initialize() function, as initializeProgram() calls vertexShaderSource() (and friends)
+        and we should not call virtual functions in the constructor.
+        (WebCore::TextureMapperShaderProgram::initialize):
+        (TextureMapperShaderProgramSimple):
+        (WebCore::TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple):
+        (TextureMapperShaderProgramRectSimple):
+        (WebCore::TextureMapperShaderProgramRectSimple::TextureMapperShaderProgramRectSimple):
+        (TextureMapperShaderProgramOpacityAndMask):
+        (WebCore::TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask):
+        (TextureMapperShaderProgramRectOpacityAndMask):
+        (WebCore::TextureMapperShaderProgramRectOpacityAndMask::TextureMapperShaderProgramRectOpacityAndMask):
+        (TextureMapperShaderProgramSolidColor):
+        (WebCore::TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor):
+
 2012-06-01  Christophe Dumez  <[email protected]>
 
         [EFL] EFL port does not enable WEB_INTENTS_TAG flag

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp (119246 => 119247)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp	2012-06-01 16:57:29 UTC (rev 119246)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp	2012-06-01 17:02:00 UTC (rev 119247)
@@ -21,11 +21,48 @@
 #include "TextureMapperBackingStore.h"
 
 #include "GraphicsLayer.h"
+#include "GraphicsSurface.h"
 #include "ImageBuffer.h"
 #include "TextureMapper.h"
+#include "TextureMapperGL.h"
 
 namespace WebCore {
 
+#if USE(GRAPHICS_SURFACE)
+void TextureMapperSurfaceBackingStore::setGraphicsSurface(uint32_t graphicsSurfaceToken, const IntSize& surfaceSize)
+{
+    if (graphicsSurfaceToken != m_backBufferGraphicsSurfaceData.m_graphicsSurfaceToken) {
+        GraphicsSurface::Flags surfaceFlags = GraphicsSurface::SupportsTextureTarget
+                                            | GraphicsSurface::SupportsSharing;
+        m_backBufferGraphicsSurfaceData.setSurface(GraphicsSurface::create(surfaceSize, surfaceFlags, graphicsSurfaceToken));
+        m_graphicsSurfaceSize = surfaceSize;
+    }
+
+    std::swap(m_backBufferGraphicsSurfaceData, m_frontBufferGraphicsSurfaceData);
+}
+
+PassRefPtr<BitmapTexture> TextureMapperSurfaceBackingStore::texture() const
+{
+    // FIXME: Instead of just returning an empty texture, we should wrap the texture contents into a BitmapTexture.
+    RefPtr<BitmapTexture> emptyTexture;
+    return emptyTexture;
+}
+
+void TextureMapperSurfaceBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
+{
+    TransformationMatrix adjustedTransform = transform;
+    adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_graphicsSurfaceSize), targetRect));
+#if OS(DARWIN)
+    // This is specific to the Mac implementation of GraphicsSurface. IOSurface requires GL_TEXTURE_RECTANGLE_ARB to be used.
+    static_cast<TextureMapperGL*>(textureMapper)->drawTextureRectangleARB(m_frontBufferGraphicsSurfaceData.m_textureID, 0, m_graphicsSurfaceSize, targetRect, adjustedTransform, opacity, mask);
+#else
+    UNUSED_PARAM(textureMapper);
+    UNUSED_PARAM(opacity);
+    UNUSED_PARAM(mask);
+#endif
+}
+#endif
+
 void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect)
 {
     IntRect targetRect = enclosingIntRect(m_rect);

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h (119246 => 119247)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h	2012-06-01 16:57:29 UTC (rev 119246)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h	2012-06-01 17:02:00 UTC (rev 119247)
@@ -21,6 +21,7 @@
 #define TextureMapperBackingStore_h
 
 #include "FloatRect.h"
+#include "GraphicsSurface.h"
 #include "Image.h"
 #include "TextureMapper.h"
 #include "TextureMapperPlatformLayer.h"
@@ -38,6 +39,39 @@
     virtual ~TextureMapperBackingStore() { }
 };
 
+#if USE(GRAPHICS_SURFACE)
+struct GraphicsSurfaceData {
+    void setSurface(PassRefPtr<GraphicsSurface> surface)
+    {
+        m_graphicsSurface = surface;
+        m_graphicsSurfaceToken = m_graphicsSurface->exportToken();
+        m_textureID = m_graphicsSurface->getTextureID();
+    }
+
+    GraphicsSurfaceData()
+        : m_textureID(0)
+        , m_graphicsSurfaceToken(0)
+    { }
+
+    uint32_t m_textureID;
+    uint32_t m_graphicsSurfaceToken;
+    RefPtr<WebCore::GraphicsSurface> m_graphicsSurface;
+};
+
+class TextureMapperSurfaceBackingStore : public TextureMapperBackingStore {
+public:
+    static PassRefPtr<TextureMapperSurfaceBackingStore> create() { return adoptRef(new TextureMapperSurfaceBackingStore); }
+    void setGraphicsSurface(uint32_t graphicsSurfaceToken, const IntSize& surfaceSize);
+    virtual PassRefPtr<BitmapTexture> texture() const;
+    virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*);
+    virtual ~TextureMapperSurfaceBackingStore() { }
+private:
+    IntSize m_graphicsSurfaceSize;
+    GraphicsSurfaceData m_frontBufferGraphicsSurfaceData;
+    GraphicsSurfaceData m_backBufferGraphicsSurfaceData;
+};
+#endif
+
 class TextureMapperTile {
 public:
     inline PassRefPtr<BitmapTexture> texture() const { return m_texture; }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (119246 => 119247)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-06-01 16:57:29 UTC (rev 119246)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-06-01 17:02:00 UTC (rev 119247)
@@ -21,6 +21,7 @@
 #include "TextureMapperGL.h"
 
 #include "GraphicsContext.h"
+#include "GraphicsSurface.h"
 #include "Image.h"
 #include "TextureMapperShaderManager.h"
 #include "Timer.h"
@@ -366,6 +367,34 @@
     drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : SupportsBlending, textureGL.size(), targetRect, matrix, opacity, mask);
 }
 
+void TextureMapperGL::drawTextureRectangleARB(uint32_t texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
+{
+    RefPtr<TextureMapperShaderProgram> shaderInfo;
+    if (maskTexture)
+        shaderInfo = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::RectOpacityAndMask);
+    else
+        shaderInfo = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::RectSimple);
+    GL_CMD(glUseProgram(shaderInfo->id()));
+
+    GL_CMD(glEnableVertexAttribArray(shaderInfo->vertexAttrib()));
+    GL_CMD(glActiveTexture(GL_TEXTURE0));
+    GL_CMD(glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture));
+    GL_CMD(glUniform1i(shaderInfo->sourceTextureVariable(), 0));
+
+    const GLfloat m4src[] = {
+        targetRect.width(), 0, 0, 0,
+        0, (flags & ShouldFlipTexture) ? -targetRect.height() : targetRect.height(), 0, 0,
+        0, 0, 1, 0,
+        0, (flags & ShouldFlipTexture) ? 1 : 0, 0, 1};
+
+    GL_CMD(glUniformMatrix4fv(shaderInfo->sourceMatrixVariable(), 1, GL_FALSE, m4src));
+
+    shaderInfo->prepare(opacity, maskTexture);
+
+    bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture;
+    drawRect(targetRect, modelViewMatrix, shaderInfo.get(), GL_TRIANGLE_FAN, needsBlending);
+}
+
 void TextureMapperGL::drawTexture(uint32_t texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
 {
     RefPtr<TextureMapperShaderProgram> shaderInfo;

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (119246 => 119247)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2012-06-01 16:57:29 UTC (rev 119246)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2012-06-01 17:02:00 UTC (rev 119247)
@@ -52,6 +52,7 @@
     virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
     virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture) OVERRIDE;
     virtual void drawTexture(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
+    virtual void drawTextureRectangleARB(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
     virtual void bindSurface(BitmapTexture* surface) OVERRIDE;
     virtual void beginClip(const TransformationMatrix&, const FloatRect&) OVERRIDE;
     virtual void beginPainting(PaintFlags = 0) OVERRIDE;

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp (119246 => 119247)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp	2012-06-01 16:57:29 UTC (rev 119246)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp	2012-06-01 17:02:00 UTC (rev 119247)
@@ -55,6 +55,20 @@
         }
     );
 
+static const char* fragmentShaderSourceRectOpacityAndMask =
+    FRAGMENT_SHADER(
+        uniform sampler2DRect SourceTexture, MaskTexture;
+        uniform lowp float Opacity;
+        varying highp vec2 OutTexCoordSource, OutTexCoordMask;
+        void main(void)
+        {
+            lowp vec4 color = texture2DRect(SourceTexture, OutTexCoordSource);
+            lowp vec4 maskColor = texture2DRect(MaskTexture, OutTexCoordMask);
+            lowp float fragmentAlpha = Opacity * maskColor.a;
+            gl_FragColor = vec4(color.rgb * fragmentAlpha, color.a * fragmentAlpha);
+        }
+    );
+
 static const char* vertexShaderSourceOpacityAndMask =
     VERTEX_SHADER(
         uniform mat4 InMatrix, InSourceMatrix;
@@ -80,6 +94,18 @@
         }
     );
 
+static const char* fragmentShaderSourceRectSimple =
+    FRAGMENT_SHADER(
+        uniform sampler2DRect SourceTexture;
+        uniform lowp float Opacity;
+        varying highp vec2 OutTexCoordSource;
+        void main(void)
+        {
+            lowp vec4 color = texture2DRect(SourceTexture, OutTexCoordSource);
+            gl_FragColor = vec4(color.rgb * Opacity, color.a * Opacity);
+        }
+    );
+
 static const char* vertexShaderSourceSimple =
     VERTEX_SHADER(
         uniform mat4 InMatrix, InSourceMatrix;
@@ -131,9 +157,15 @@
     case Simple:
         program = TextureMapperShaderProgramSimple::create();
         break;
+    case RectSimple:
+        program = TextureMapperShaderProgramRectSimple::create();
+        break;
     case OpacityAndMask:
         program = TextureMapperShaderProgramOpacityAndMask::create();
         break;
+    case RectOpacityAndMask:
+        program = TextureMapperShaderProgramRectOpacityAndMask::create();
+        break;
     case SolidColor:
         program = TextureMapperShaderProgramSolidColor::create();
         break;
@@ -186,10 +218,13 @@
 
 PassRefPtr<TextureMapperShaderProgramSimple> TextureMapperShaderProgramSimple::create()
 {
-    return adoptRef(new TextureMapperShaderProgramSimple());
+    RefPtr<TextureMapperShaderProgramSimple> program = adoptRef(new TextureMapperShaderProgramSimple());
+    // Avoid calling virtual functions in constructor.
+    program->initialize();
+    return program.release();
 }
 
-TextureMapperShaderProgramSimple::TextureMapperShaderProgramSimple()
+void TextureMapperShaderProgramSimple::initialize()
 {
     initializeProgram();
     getUniformLocation(m_sourceMatrixVariable, "InSourceMatrix");
@@ -215,10 +250,13 @@
 
 PassRefPtr<TextureMapperShaderProgramSolidColor> TextureMapperShaderProgramSolidColor::create()
 {
-    return adoptRef(new TextureMapperShaderProgramSolidColor());
+    RefPtr<TextureMapperShaderProgramSolidColor> program = adoptRef(new TextureMapperShaderProgramSolidColor());
+    // Avoid calling virtual functions in constructor.
+    program->initialize();
+    return program.release();
 }
 
-TextureMapperShaderProgramSolidColor::TextureMapperShaderProgramSolidColor()
+void TextureMapperShaderProgramSolidColor::initialize()
 {
     initializeProgram();
     getUniformLocation(m_matrixVariable, "InMatrix");
@@ -235,12 +273,28 @@
     return fragmentShaderSourceSolidColor;
 }
 
+PassRefPtr<TextureMapperShaderProgramRectSimple> TextureMapperShaderProgramRectSimple::create()
+{
+    RefPtr<TextureMapperShaderProgramRectSimple> program = adoptRef(new TextureMapperShaderProgramRectSimple());
+    // Avoid calling virtual functions in constructor.
+    program->initialize();
+    return program.release();
+}
+
+const char* TextureMapperShaderProgramRectSimple::fragmentShaderSource() const
+{
+    return fragmentShaderSourceRectSimple;
+}
+
 PassRefPtr<TextureMapperShaderProgramOpacityAndMask> TextureMapperShaderProgramOpacityAndMask::create()
 {
-    return adoptRef(new TextureMapperShaderProgramOpacityAndMask());
+    RefPtr<TextureMapperShaderProgramOpacityAndMask> program = adoptRef(new TextureMapperShaderProgramOpacityAndMask());
+    // Avoid calling virtual functions in constructor.
+    program->initialize();
+    return program.release();
 }
 
-TextureMapperShaderProgramOpacityAndMask::TextureMapperShaderProgramOpacityAndMask()
+void TextureMapperShaderProgramOpacityAndMask::initialize()
 {
     initializeProgram();
     getUniformLocation(m_matrixVariable, "InMatrix");
@@ -273,6 +327,19 @@
     glActiveTexture(GL_TEXTURE0);
 }
 
+PassRefPtr<TextureMapperShaderProgramRectOpacityAndMask> TextureMapperShaderProgramRectOpacityAndMask::create()
+{
+    RefPtr<TextureMapperShaderProgramRectOpacityAndMask> program = adoptRef(new TextureMapperShaderProgramRectOpacityAndMask());
+    // Avoid calling virtual functions in constructor.
+    program->initialize();
+    return program.release();
+}
+
+const char* TextureMapperShaderProgramRectOpacityAndMask::fragmentShaderSource() const
+{
+    return fragmentShaderSourceRectOpacityAndMask;
+}
+
 TextureMapperShaderManager::TextureMapperShaderManager()
 {
     ASSERT(initializeOpenGLShims());

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h (119246 => 119247)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h	2012-06-01 16:57:29 UTC (rev 119246)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h	2012-06-01 17:02:00 UTC (rev 119247)
@@ -56,6 +56,7 @@
 protected:
     void getUniformLocation(GLint& var, const char* name);
     void initializeProgram();
+    virtual void initialize() { }
     virtual const char* vertexShaderSource() const = 0;
     virtual const char* fragmentShaderSource() const = 0;
 
@@ -103,46 +104,78 @@
     static PassRefPtr<TextureMapperShaderProgramSimple> create();
     virtual void prepare(float opacity, const BitmapTexture*);
 
+protected:
+    virtual void initialize();
+
 private:
     virtual const char* vertexShaderSource() const;
     virtual const char* fragmentShaderSource() const;
-    TextureMapperShaderProgramSimple();
+    TextureMapperShaderProgramSimple() { }
+
+    friend class TextureMapperShaderProgramRectSimple;
 };
 
+class TextureMapperShaderProgramRectSimple : public TextureMapperShaderProgramSimple {
+public:
+    static PassRefPtr<TextureMapperShaderProgramRectSimple> create();
+
+private:
+    virtual const char* fragmentShaderSource() const;
+    TextureMapperShaderProgramRectSimple() { }
+};
+
 class TextureMapperShaderProgramOpacityAndMask : public TextureMapperShaderProgram {
 public:
     static PassRefPtr<TextureMapperShaderProgramOpacityAndMask> create();
     virtual void prepare(float opacity, const BitmapTexture*);
     GLint maskTextureVariable() const { return m_maskTextureVariable; }
 
+protected:
+    virtual void initialize();
+
 private:
     static int m_classID;
     virtual const char* vertexShaderSource() const;
     virtual const char* fragmentShaderSource() const;
-    TextureMapperShaderProgramOpacityAndMask();
+    TextureMapperShaderProgramOpacityAndMask() { }
     GLint m_maskTextureVariable;
+
+    friend class TextureMapperShaderProgramRectOpacityAndMask;
 };
 
+class TextureMapperShaderProgramRectOpacityAndMask : public TextureMapperShaderProgramOpacityAndMask {
+public:
+    static PassRefPtr<TextureMapperShaderProgramRectOpacityAndMask> create();
+
+private:
+    virtual const char* fragmentShaderSource() const;
+    TextureMapperShaderProgramRectOpacityAndMask() { }
+};
+
 class TextureMapperShaderProgramSolidColor : public TextureMapperShaderProgram {
 public:
     static PassRefPtr<TextureMapperShaderProgramSolidColor> create();
     GLint colorVariable() const { return m_colorVariable; }
 
+protected:
+    virtual void initialize();
+
 private:
     virtual const char* vertexShaderSource() const;
     virtual const char* fragmentShaderSource() const;
-    TextureMapperShaderProgramSolidColor();
+    TextureMapperShaderProgramSolidColor() { }
     GLint m_colorVariable;
 };
 
-
 class TextureMapperShaderManager {
 public:
     enum ShaderType {
         Invalid = 0, // HashMaps do not like 0 as a key.
         Simple,
+        RectSimple,
         OpacityAndMask,
-        SolidColor,
+        RectOpacityAndMask,
+        SolidColor
     };
 
     TextureMapperShaderManager();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to