Title: [137498] trunk/Source/WebCore
Revision
137498
Author
[email protected]
Date
2012-12-12 12:10:55 -0800 (Wed, 12 Dec 2012)

Log Message

[Texmap] Consolidate redundant code for ARB_RECT texture
https://bugs.webkit.org/show_bug.cgi?id=104705

Patch by No'am Rosenthal <[email protected]> on 2012-12-12
Reviewed by Kenneth Rohde Christiansen.

Instead of having a whole different function for RECT textures,
keep the existing functions and pass a flag that tells
TextureMapperGL to use the non-normalized coordinates and the
RECT shaders.

No new tests, refactor only. Tested to not break WebGL on
Qt-Mac.

* platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
* platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
(WebCore::GraphicsSurface::platformPaintToTextureMapper):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawQuad):
    Compensate for rect textures in drawQuad.

(WebCore::TextureMapperGL::drawBorder):
(WebCore::TextureMapperGL::drawTexture):
(WebCore::TextureMapperGL::drawSolidColor):
(WebCore::TextureMapperGL::drawTextureWithAntialiasing):
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
    Pass flags to TextureMapperGL::drawQuad instead of a bool.

* platform/graphics/texmap/TextureMapperGL.h:
(TextureMapperGL):
* platform/graphics/texmap/TextureMapperShaderManager.cpp:
(WebCore::getShaderSpec):
* platform/graphics/texmap/TextureMapperShaderManager.h:
(TextureMapperShaderProgram):
    Compensate for the texture-size in the vertex
    shader instead of in the fragment shader.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (137497 => 137498)


--- trunk/Source/WebCore/ChangeLog	2012-12-12 20:06:31 UTC (rev 137497)
+++ trunk/Source/WebCore/ChangeLog	2012-12-12 20:10:55 UTC (rev 137498)
@@ -1,3 +1,41 @@
+2012-12-12  No'am Rosenthal  <[email protected]>
+
+        [Texmap] Consolidate redundant code for ARB_RECT texture
+        https://bugs.webkit.org/show_bug.cgi?id=104705
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Instead of having a whole different function for RECT textures,
+        keep the existing functions and pass a flag that tells
+        TextureMapperGL to use the non-normalized coordinates and the
+        RECT shaders.
+
+        No new tests, refactor only. Tested to not break WebGL on
+        Qt-Mac.
+
+        * platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
+        * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
+        (WebCore::GraphicsSurface::platformPaintToTextureMapper):
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::drawQuad):
+            Compensate for rect textures in drawQuad.
+
+        (WebCore::TextureMapperGL::drawBorder):
+        (WebCore::TextureMapperGL::drawTexture):
+        (WebCore::TextureMapperGL::drawSolidColor):
+        (WebCore::TextureMapperGL::drawTextureWithAntialiasing):
+        (WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
+            Pass flags to TextureMapperGL::drawQuad instead of a bool.
+
+        * platform/graphics/texmap/TextureMapperGL.h:
+        (TextureMapperGL):
+        * platform/graphics/texmap/TextureMapperShaderManager.cpp:
+        (WebCore::getShaderSpec):
+        * platform/graphics/texmap/TextureMapperShaderManager.h:
+        (TextureMapperShaderProgram):
+            Compensate for the texture-size in the vertex
+            shader instead of in the fragment shader.
+
 2012-12-12  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r137491.

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp (137497 => 137498)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp	2012-12-12 20:06:31 UTC (rev 137497)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp	2012-12-12 20:10:55 UTC (rev 137498)
@@ -138,7 +138,7 @@
     }
 
     TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
-    TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::SupportsBlending : 0);
+    TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
     IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight);
     texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity, mask);
 #endif // USE(ACCELERATED_COMPOSITING_GL)

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp (137497 => 137498)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp	2012-12-12 20:06:31 UTC (rev 137497)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp	2012-12-12 20:10:55 UTC (rev 137498)
@@ -439,7 +439,7 @@
     TransformationMatrix adjustedTransform = transform;
     adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
     TextureMapperGL::Flags flags = m_private->textureIsYInverted() ? TextureMapperGL::ShouldFlipTexture : 0;
-    flags |= TextureMapperGL::SupportsBlending;
+    flags |= TextureMapperGL::ShouldBlend;
     texMapGL->drawTexture(platformGetTextureID(), flags, m_private->size(), targetRect, adjustedTransform, opacity, mask);
 }
 

Modified: trunk/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp (137497 => 137498)


--- trunk/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp	2012-12-12 20:06:31 UTC (rev 137497)
+++ trunk/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp	2012-12-12 20:10:55 UTC (rev 137498)
@@ -345,7 +345,7 @@
 {
     TransformationMatrix adjustedTransform = transform;
     adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
-    static_cast<TextureMapperGL*>(textureMapper)->drawTextureRectangleARB(m_private->frontBufferTextureID(), TextureMapperGL::SupportsBlending, m_private->size(), targetRect, adjustedTransform, opacity, mask);
+    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_private->frontBufferTextureID(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldUseARBTextureRect, m_private->size(), targetRect, adjustedTransform, opacity, mask);
 }
 
 uint32_t GraphicsSurface::platformFrontBuffer() const

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


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-12-12 20:06:31 UTC (rev 137497)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-12-12 20:10:55 UTC (rev 137498)
@@ -22,6 +22,7 @@
 #include "config.h"
 #include "TextureMapperGL.h"
 
+#include "Extensions3D.h"
 #include "GraphicsContext.h"
 #include "Image.h"
 #include "LengthFunctions.h"
@@ -56,7 +57,6 @@
 
 #if !USE(TEXMAP_OPENGL_ES_2)
 // FIXME: Move to Extensions3D.h.
-#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
 #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
 #define GL_UNPACK_ROW_LENGTH 0x0CF2
 #define GL_UNPACK_SKIP_PIXELS 0x0CF4
@@ -271,7 +271,7 @@
 #endif
 }
 
-void TextureMapperGL::drawQuad(const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram* shaderProgram, GC3Denum drawingMode, bool needsBlending)
+void TextureMapperGL::drawQuad(const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram* shaderProgram, GC3Denum drawingMode, Flags flags)
 {
     m_context3D->enableVertexAttribArray(shaderProgram->vertexLocation());
     m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0);
@@ -297,7 +297,7 @@
     };
     m_context3D->uniformMatrix4fv(shaderProgram->matrixLocation(), 1, false, m4);
 
-    if (needsBlending) {
+    if (flags & ShouldBlend) {
         m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
         m_context3D->enable(GraphicsContext3D::BLEND);
     } else
@@ -320,7 +320,7 @@
     m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
     m_context3D->lineWidth(width);
 
-    drawQuad(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::LINE_LOOP, color.hasAlpha());
+    drawQuad(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::LINE_LOOP, color.hasAlpha() ? ShouldBlend : 0);
 }
 
 void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPoint& targetPoint, const TransformationMatrix& modelViewMatrix)
@@ -401,55 +401,31 @@
         return;
 
     const BitmapTextureGL& textureGL = static_cast<const BitmapTextureGL&>(texture);
-    drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : SupportsBlending, textureGL.size(), targetRect, matrix, opacity, mask, exposedEdges);
+    drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : ShouldBlend, textureGL.size(), targetRect, matrix, opacity, mask, exposedEdges);
 }
 
-#if !USE(TEXMAP_OPENGL_ES_2)
-void TextureMapperGL::drawTextureRectangleARB(uint32_t texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
+void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges)
 {
-    RefPtr<TextureMapperShaderProgram> program;
-    if (maskTexture)
-        program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::MaskedRect);
-    else
-        program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Rect);
-    m_context3D->useProgram(program->programID());
-
-    m_context3D->enableVertexAttribArray(program->vertexLocation());
-    m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
-    m_context3D->bindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
-    m_context3D->uniform1i(program->samplerLocation(), 0);
-
-    m_context3D->uniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture));
-    m_context3D->uniform2f(program->samplerSizeLocation(), textureSize.width(), textureSize.height());
-    m_context3D->uniform1f(program->opacityLocation(), opacity);
-
-    if (maskTexture && maskTexture->isValid()) {
-        const BitmapTextureGL* maskTextureGL = static_cast<const BitmapTextureGL*>(maskTexture);
-        m_context3D->activeTexture(GraphicsContext3D::TEXTURE1);
-        m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureGL->id());
-        m_context3D->uniform1i(program->maskLocation(), 1);
-        m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
-    }
-
-    bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture;
-    drawQuad(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, needsBlending);
-}
-#endif // !USE(TEXMAP_OPENGL_ES_2)
-
-void TextureMapperGL::drawTexture(uint32_t texture, Flags flags, const IntSize& /* textureSize */, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges)
-{
     bool needsAntialiasing = m_enableEdgeDistanceAntialiasing && !modelViewMatrix.isIntegerTranslation();
-    if (needsAntialiasing && drawTextureWithAntialiasing(texture, flags, targetRect, modelViewMatrix, opacity, maskTexture, exposedEdges))
+    if (needsAntialiasing && drawTextureWithAntialiasing(texture, flags, textureSize, targetRect, modelViewMatrix, opacity, maskTexture, exposedEdges))
        return;
 
+    bool useRect = flags & ShouldUseARBTextureRect;
+    bool masked = !!maskTexture;
+
+    TextureMapperShaderManager::ShaderKey key = TextureMapperShaderManager::Default;
+    if (masked && useRect)
+        key = TextureMapperShaderManager::MaskedRect;
+    else if (masked)
+        key = TextureMapperShaderManager::Masked;
+    else if (useRect)
+        key = TextureMapperShaderManager::Rect;
+
     RefPtr<TextureMapperShaderProgram> program;
-    if (maskTexture)
-        program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Masked);
-    else
-        program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Default);
+    program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(key);
     m_context3D->useProgram(program->programID());
 
-    drawTexturedQuadWithProgram(program.get(), texture, flags, targetRect, modelViewMatrix, opacity, maskTexture);
+    drawTexturedQuadWithProgram(program.get(), texture, flags, textureSize, targetRect, modelViewMatrix, opacity, maskTexture);
 }
 
 void TextureMapperGL::drawSolidColor(const FloatRect& rect, const TransformationMatrix& matrix, const Color& color)
@@ -461,7 +437,7 @@
     color.getRGBA(r, g, b, a);
     m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
 
-    drawQuad(rect, matrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, a < 1);
+    drawQuad(rect, matrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, a < 1 ? ShouldBlend : 0);
 }
 
 static TransformationMatrix viewportMatrix(GraphicsContext3D* context3D)
@@ -548,7 +524,7 @@
     return expandedQuad;
 }
 
-bool TextureMapperGL::drawTextureWithAntialiasing(uint32_t texture, Flags flags, const FloatRect& originalTargetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges)
+bool TextureMapperGL::drawTextureWithAntialiasing(uint32_t texture, Flags flags, const IntSize& size, const FloatRect& originalTargetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges)
 {
     // The antialiasing path does not support mask textures at the moment.
     if (maskTexture)
@@ -591,17 +567,20 @@
     m_context3D->useProgram(program->programID());
     m_context3D->uniform3fv(program->expandedQuadEdgesInScreenSpaceLocation(), 8, targetQuadEdges);
 
-    drawTexturedQuadWithProgram(program.get(), texture, flags, DrawQuad(originalTargetRect, expandedQuadInTextureCoordinates), modelViewMatrix, opacity, 0 /* maskTexture */);
+    drawTexturedQuadWithProgram(program.get(), texture, flags, size, DrawQuad(originalTargetRect, expandedQuadInTextureCoordinates), modelViewMatrix, opacity, 0 /* maskTexture */);
     return true;
 }
 
-void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* program, uint32_t texture, Flags flags, const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
+void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* program, uint32_t texture, Flags flags, const IntSize& size, const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
 {
     m_context3D->enableVertexAttribArray(program->vertexLocation());
     m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
-    m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, texture);
+    GC3Denum target = flags & ShouldUseARBTextureRect ? GC3Denum(Extensions3D::TEXTURE_RECTANGLE_ARB) : GC3Denum(GraphicsContext3D::TEXTURE_2D);
+    m_context3D->bindTexture(target, texture);
     m_context3D->uniform1i(program->samplerLocation(), 0);
 
+    FloatSize sizeParameter = flags & ShouldUseARBTextureRect ? size : FloatSize(1, 1);
+    m_context3D->uniform2f(program->textureSizeLocation(), sizeParameter.width(), sizeParameter.height());
     m_context3D->uniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture));
     m_context3D->uniform1f(program->opacityLocation(), opacity);
 
@@ -613,8 +592,10 @@
         m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
     }
 
-    bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture;
-    drawQuad(quadToDraw, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, needsBlending);
+    if (opacity < 1 || maskTexture)
+        flags |= ShouldBlend;
+
+    drawQuad(quadToDraw, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, flags);
 }
 
 BitmapTextureGL::BitmapTextureGL(TextureMapperGL* textureMapper)

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


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2012-12-12 20:06:31 UTC (rev 137497)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h	2012-12-12 20:10:55 UTC (rev 137498)
@@ -43,8 +43,9 @@
     virtual ~TextureMapperGL();
 
     enum Flag {
-        SupportsBlending = 0x01,
-        ShouldFlipTexture = 0x02
+        ShouldBlend = 0x01,
+        ShouldFlipTexture = 0x02,
+        ShouldUseARBTextureRect = 0x04
     };
 
     typedef int Flags;
@@ -53,13 +54,9 @@
     virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
     virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
     virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
-    virtual void drawTexture(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges = AllEdges);
+    virtual void drawTexture(Platform3DObject texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges = AllEdges);
     virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) OVERRIDE;
 
-#if !USE(TEXMAP_OPENGL_ES_2)
-    virtual void drawTextureRectangleARB(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
-#endif
-
     virtual void bindSurface(BitmapTexture* surface) OVERRIDE;
     virtual void beginClip(const TransformationMatrix&, const FloatRect&) OVERRIDE;
     virtual void beginPainting(PaintFlags = 0) OVERRIDE;
@@ -117,9 +114,9 @@
 
     TextureMapperGL();
 
-    bool drawTextureWithAntialiasing(uint32_t texture, Flags, const FloatRect& originalTargetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges);
-    void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const DrawQuad&, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
-    void drawQuad(const DrawQuad&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GC3Denum drawingMode, bool needsBlending);
+    bool drawTextureWithAntialiasing(uint32_t texture, Flags, const IntSize&, const FloatRect& originalTargetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges);
+    void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const IntSize&, const DrawQuad&, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
+    void drawQuad(const DrawQuad&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GC3Denum drawingMode, Flags);
 
     bool beginScissorClip(const TransformationMatrix&, const FloatRect&);
     void bindDefaultSurface();

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


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp	2012-12-12 20:06:31 UTC (rev 137497)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp	2012-12-12 20:10:55 UTC (rev 137498)
@@ -157,12 +157,13 @@
         STRINGIFY(
             uniform mat4 u_matrix;
             uniform lowp float u_flip;
+            uniform lowp vec2 u_textureSize;
             attribute vec4 a_vertex;
             varying highp vec2 v_sourceTexCoord;
             varying highp vec2 v_maskTexCoord;
             void main(void)
             {
-                v_sourceTexCoord = vec2(a_vertex.x, mix(a_vertex.y, 1. - a_vertex.y, u_flip));
+                v_sourceTexCoord = vec2(a_vertex.x, mix(a_vertex.y, 1. - a_vertex.y, u_flip)) * u_textureSize;
                 v_maskTexCoord = vec2(a_vertex);
                 gl_Position = u_matrix * a_vertex;
             }
@@ -242,12 +243,11 @@
         STRINGIFY(
             precision mediump float;
             uniform sampler2DRect s_sampler;
-            uniform lowp vec2 u_samplerSize;
             uniform lowp float u_opacity;
             varying highp vec2 v_sourceTexCoord;
             void main(void)
             {
-                lowp vec4 color = texture2DRect(s_sampler, u_samplerSize * v_sourceTexCoord);
+                lowp vec4 color = texture2DRect(s_sampler, v_sourceTexCoord);
                 gl_FragColor = vec4(color.rgb * u_opacity, color.a * u_opacity);
             }
         );
@@ -256,11 +256,12 @@
         STRINGIFY(
             uniform mat4 u_matrix;
             uniform lowp float u_flip;
+            uniform lowp vec2 u_textureSize;
             attribute vec4 a_vertex;
             varying highp vec2 v_sourceTexCoord;
             void main(void)
             {
-                v_sourceTexCoord = vec2(a_vertex.x, mix(a_vertex.y, 1. - a_vertex.y, u_flip));
+                v_sourceTexCoord = vec2(a_vertex.x, mix(a_vertex.y, 1. - a_vertex.y, u_flip)) * u_textureSize;
                 gl_Position = u_matrix * a_vertex;
             }
         );

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


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h	2012-12-12 20:06:31 UTC (rev 137497)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h	2012-12-12 20:10:55 UTC (rev 137498)
@@ -51,7 +51,7 @@
 
     TEXMAP_DECLARE_UNIFORM(matrix)
     TEXMAP_DECLARE_UNIFORM(flip)
-    TEXMAP_DECLARE_UNIFORM(samplerSize)
+    TEXMAP_DECLARE_UNIFORM(textureSize)
     TEXMAP_DECLARE_UNIFORM(opacity)
     TEXMAP_DECLARE_UNIFORM(color)
     TEXMAP_DECLARE_UNIFORM(expandedQuadEdgesInScreenSpace)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to