Title: [91784] branches/chromium/835/Source/WebCore/platform/graphics/chromium
Revision
91784
Author
[email protected]
Date
2011-07-26 14:37:22 -0700 (Tue, 26 Jul 2011)

Log Message

Merge 91720 - [Chromium] Use correct vertex shader when rendering video layer.
https://bugs.webkit.org/show_bug.cgi?id=65131

Patch by David Reveman <[email protected]> on 2011-07-25
Reviewed by James Robinson.

Add new VertexShaderQuad program that is used by LayerTilerChromium.
Change VertexShaderPosTexTransform so it works with CCVideoLayerImpl.

* platform/graphics/chromium/LayerTilerChromium.h:
* platform/graphics/chromium/ShaderChromium.cpp:
(WebCore::VertexShaderPosTexTransform::VertexShaderPosTexTransform):
(WebCore::VertexShaderPosTexTransform::init):
(WebCore::VertexShaderPosTexTransform::getShaderString):
(WebCore::VertexShaderQuad::VertexShaderQuad):
(WebCore::VertexShaderQuad::init):
(WebCore::VertexShaderQuad::getShaderString):
* platform/graphics/chromium/ShaderChromium.h:
(WebCore::VertexShaderQuad::matrixLocation):
(WebCore::VertexShaderQuad::texTransformLocation):

[email protected]
Review URL: http://codereview.chromium.org/7477025

Modified Paths

Diff

Modified: branches/chromium/835/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h (91783 => 91784)


--- branches/chromium/835/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h	2011-07-26 21:26:18 UTC (rev 91783)
+++ branches/chromium/835/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h	2011-07-26 21:37:22 UTC (rev 91784)
@@ -75,10 +75,10 @@
     // recycled by the texture manager.
     void protectTileTextures(const IntRect& contentRect);
 
-    typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexAlpha> Program;
+    typedef ProgramBinding<VertexShaderQuad, FragmentShaderRGBATexAlpha> Program;
     // Shader program that swaps red and blue components of texture.
     // Used when texture format does not match native color format.
-    typedef ProgramBinding<VertexShaderPosTexTransform, FragmentShaderRGBATexSwizzleAlpha> ProgramSwizzle;
+    typedef ProgramBinding<VertexShaderQuad, FragmentShaderRGBATexSwizzleAlpha> ProgramSwizzle;
 
     // If this tiler has exactly one tile, return its texture. Otherwise, null.
     LayerTexture* getSingleTexture();

Modified: branches/chromium/835/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp (91783 => 91784)


--- branches/chromium/835/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp	2011-07-26 21:26:18 UTC (rev 91783)
+++ branches/chromium/835/Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp	2011-07-26 21:37:22 UTC (rev 91784)
@@ -124,7 +124,6 @@
 VertexShaderPosTexTransform::VertexShaderPosTexTransform()
     : m_matrixLocation(-1)
     , m_texTransformLocation(-1)
-    , m_pointLocation(-1)
 {
 }
 
@@ -132,11 +131,41 @@
 {
     m_matrixLocation = context->getUniformLocation(program, "matrix");
     m_texTransformLocation = context->getUniformLocation(program, "texTransform");
+    ASSERT(m_matrixLocation != -1 && m_texTransformLocation != -1);
+}
+
+String VertexShaderPosTexTransform::getShaderString() const
+{
+    return SHADER(
+        attribute vec4 a_position;
+        attribute vec2 a_texCoord;
+        uniform mat4 matrix;
+        uniform vec4 texTransform;
+        varying vec2 v_texCoord;
+        void main()
+        {
+            gl_Position = matrix * a_position;
+            v_texCoord = a_texCoord * texTransform.zw + texTransform.xy;
+        }
+    );
+}
+
+VertexShaderQuad::VertexShaderQuad()
+    : m_matrixLocation(-1)
+    , m_texTransformLocation(-1)
+    , m_pointLocation(-1)
+{
+}
+
+void VertexShaderQuad::init(GraphicsContext3D* context, unsigned program)
+{
+    m_matrixLocation = context->getUniformLocation(program, "matrix");
+    m_texTransformLocation = context->getUniformLocation(program, "texTransform");
     m_pointLocation = context->getUniformLocation(program, "point");
     ASSERT(m_matrixLocation != -1 && m_texTransformLocation != -1 && m_pointLocation != -1);
 }
 
-String VertexShaderPosTexTransform::getShaderString() const
+String VertexShaderQuad::getShaderString() const
 {
     return SHADER(
         attribute vec4 a_position;

Modified: branches/chromium/835/Source/WebCore/platform/graphics/chromium/ShaderChromium.h (91783 => 91784)


--- branches/chromium/835/Source/WebCore/platform/graphics/chromium/ShaderChromium.h	2011-07-26 21:26:18 UTC (rev 91783)
+++ branches/chromium/835/Source/WebCore/platform/graphics/chromium/ShaderChromium.h	2011-07-26 21:37:22 UTC (rev 91784)
@@ -90,6 +90,21 @@
 
     int matrixLocation() const { return m_matrixLocation; }
     int texTransformLocation() const { return m_texTransformLocation; }
+
+private:
+    int m_matrixLocation;
+    int m_texTransformLocation;
+};
+
+class VertexShaderQuad {
+public:
+    VertexShaderQuad();
+
+    void init(GraphicsContext3D*, unsigned program);
+    String getShaderString() const;
+
+    int matrixLocation() const { return m_matrixLocation; }
+    int texTransformLocation() const { return m_texTransformLocation; }
     int pointLocation() const { return m_pointLocation; }
 
 private:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to