Chromium Code Reviews| Index: cc/output/shader.cc |
| diff --git a/cc/output/shader.cc b/cc/output/shader.cc |
| index c4ca0a9f35cd9a1f782457fb8fd893f67a466f70..056afede175c3bd83d25724a1e6868194533ee63 100644 |
| --- a/cc/output/shader.cc |
| +++ b/cc/output/shader.cc |
| @@ -6,10 +6,13 @@ |
| #include "base/basictypes.h" |
| #include "base/logging.h" |
| +#include "cc/output/gl_renderer.h" // For the GLC() macro. |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" |
| +#include "third_party/khronos/GLES2/gl2.h" |
| #define SHADER0(Src) #Src |
| -#define SHADER(Src) SHADER0(Src) |
| +#define VERTEX_SHADER(Src) setVertexTexCoordPrecision(SHADER0(Src)) |
| +#define FRAGMENT_SHADER(Src) setFragTexCoordPrecision(precision, SHADER0(Src)) |
| using WebKit::WebGraphicsContext3D; |
| @@ -30,6 +33,50 @@ static void getProgramUniformLocations(WebGraphicsContext3D* context, unsigned p |
| } |
| } |
| +static std::string setFragTexCoordPrecision(TexCoordPrecision requestedPrecision, |
| + const char* shaderString) |
| +{ |
| + if (requestedPrecision == TexCoordPrecisionHigh) { |
| + return "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" |
| + " #define TexCoordPrecision highp\n" |
| + "#else\n" |
| + " #define TexCoordPrecision mediump\n" |
| + "#endif\n"+ |
| + std::string(shaderString); |
| + } else { |
|
Sami
2013/03/22 11:14:34
Just an idea, feel free to ignore: if we're given
|
| + return "#define TexCoordPrecision mediump\n" + |
| + std::string(shaderString); |
| + } |
| +} |
| + |
| +static std::string setVertexTexCoordPrecision(const char* shaderString) |
| +{ |
| + // We unconditionally use highp in the vertex shader since |
| + // we are unlikely to be vertex shader bound when drawing large quads. |
| + // Also, some vertex shaders mutate the texture coordinate in such a |
| + // way that the effective precision might be lower than expected. |
| + return "#define TexCoordPrecision highp\n" + |
| + std::string(shaderString); |
| +} |
| + |
| +} |
| + |
| +int TexCoordHighpThreshold(WebKit::WebGraphicsContext3D* context) { |
| + GLint range[2]; |
| + GLint precision = 0; |
| + GLC(context, context->getShaderPrecisionFormat(GL_FRAGMENT_SHADER, |
| + GL_MEDIUM_FLOAT, |
| + range, &precision)); |
| + return 1 << precision; |
| +} |
| + |
| +TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context, |
| + const gfx::Point &max_coordinate) { |
|
Sami
2013/03/22 11:14:34
Nit: "Point&" instead of "Point &"
|
| + int highp_threshold = TexCoordHighpThreshold(context); |
| + if (max_coordinate.x() > highp_threshold || |
| + max_coordinate.y() > highp_threshold) |
| + return TexCoordPrecisionHigh; |
| + return TexCoordPrecisionMedium; |
| } |
| VertexShaderPosTex::VertexShaderPosTex() |
| @@ -52,11 +99,11 @@ void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program, b |
| std::string VertexShaderPosTex::getShaderString() const |
| { |
| - return SHADER( |
| + return VERTEX_SHADER( |
| attribute vec4 a_position; |
| - attribute vec2 a_texCoord; |
| + attribute TexCoordPrecision vec2 a_texCoord; |
| uniform mat4 matrix; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| void main() |
| { |
| gl_Position = matrix * a_position; |
| @@ -88,13 +135,13 @@ void VertexShaderPosTexYUVStretch::init(WebGraphicsContext3D* context, unsigned |
| std::string VertexShaderPosTexYUVStretch::getShaderString() const |
| { |
| - return SHADER( |
| + return VERTEX_SHADER( |
| precision mediump float; |
| attribute vec4 a_position; |
| - attribute vec2 a_texCoord; |
| + attribute TexCoordPrecision vec2 a_texCoord; |
| uniform mat4 matrix; |
| - varying vec2 v_texCoord; |
| - uniform vec2 texScale; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| + uniform TexCoordPrecision vec2 texScale; |
| void main() |
| { |
| gl_Position = matrix * a_position; |
| @@ -123,7 +170,7 @@ void VertexShaderPos::init(WebGraphicsContext3D* context, unsigned program, bool |
| std::string VertexShaderPos::getShaderString() const |
| { |
| - return SHADER( |
| + return VERTEX_SHADER( |
| attribute vec4 a_position; |
| uniform mat4 matrix; |
| void main() |
| @@ -159,19 +206,19 @@ void VertexShaderPosTexTransform::init(WebGraphicsContext3D* context, unsigned p |
| std::string VertexShaderPosTexTransform::getShaderString() const |
| { |
| - return SHADER( |
| + return VERTEX_SHADER( |
| attribute vec4 a_position; |
| - attribute vec2 a_texCoord; |
| + attribute TexCoordPrecision vec2 a_texCoord; |
| attribute float a_index; |
| uniform mat4 matrix[8]; |
| - uniform vec4 texTransform[8]; |
| + uniform TexCoordPrecision vec4 texTransform[8]; |
| uniform float opacity[32]; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| varying float v_alpha; |
| void main() |
| { |
| gl_Position = matrix[int(a_index * 0.25)] * a_position; |
| - vec4 texTrans = texTransform[int(a_index * 0.25)]; |
| + TexCoordPrecision vec4 texTrans = texTransform[int(a_index * 0.25)]; |
| v_texCoord = a_texCoord * texTrans.zw + texTrans.xy; |
| v_alpha = opacity[int(a_index)]; |
| } |
| @@ -180,19 +227,19 @@ std::string VertexShaderPosTexTransform::getShaderString() const |
| std::string VertexShaderPosTexTransformFlip::getShaderString() const |
| { |
| - return SHADER( |
| + return VERTEX_SHADER( |
| attribute vec4 a_position; |
| - attribute vec2 a_texCoord; |
| + attribute TexCoordPrecision vec2 a_texCoord; |
| attribute float a_index; |
| uniform mat4 matrix[8]; |
| - uniform vec4 texTransform[8]; |
| + uniform TexCoordPrecision vec4 texTransform[8]; |
| uniform float opacity[32]; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| varying float v_alpha; |
| void main() |
| { |
| gl_Position = matrix[int(a_index * 0.25)] * a_position; |
| - vec4 texTrans = texTransform[int(a_index * 0.25)]; |
| + TexCoordPrecision vec4 texTrans = texTransform[int(a_index * 0.25)]; |
| v_texCoord = a_texCoord * texTrans.zw + texTrans.xy; |
| v_texCoord.y = 1.0 - v_texCoord.y; |
| v_alpha = opacity[int(a_index)]; |
| @@ -202,9 +249,9 @@ std::string VertexShaderPosTexTransformFlip::getShaderString() const |
| std::string VertexShaderPosTexIdentity::getShaderString() const |
| { |
| - return SHADER( |
| + return VERTEX_SHADER( |
| attribute vec4 a_position; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| void main() |
| { |
| gl_Position = a_position; |
| @@ -241,17 +288,17 @@ void VertexShaderQuad::init(WebGraphicsContext3D* context, unsigned program, boo |
| std::string VertexShaderQuad::getShaderString() const |
| { |
| - return SHADER( |
| - attribute vec4 a_position; |
| - attribute vec2 a_texCoord; |
| + return VERTEX_SHADER( |
| + attribute TexCoordPrecision vec4 a_position; |
| + attribute TexCoordPrecision vec2 a_texCoord; |
| uniform mat4 matrix; |
| - uniform vec2 point[4]; |
| - uniform vec2 texScale; |
| - varying vec2 v_texCoord; |
| + uniform TexCoordPrecision vec2 point[4]; |
| + uniform TexCoordPrecision vec2 texScale; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| void main() |
| { |
| - vec2 complement = abs(a_texCoord - 1.0); |
| - vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w); |
| + TexCoordPrecision vec2 complement = abs(a_texCoord - 1.0); |
| + TexCoordPrecision vec4 pos = vec4(0.0, 0.0, a_position.z, a_position.w); |
| pos.xy += (complement.x * complement.y) * point[0]; |
| pos.xy += (a_texCoord.x * complement.y) * point[1]; |
| pos.xy += (a_texCoord.x * a_texCoord.y) * point[2]; |
| @@ -288,13 +335,13 @@ void VertexShaderTile::init(WebGraphicsContext3D* context, unsigned program, boo |
| std::string VertexShaderTile::getShaderString() const |
| { |
| - return SHADER( |
| - attribute vec4 a_position; |
| - attribute vec2 a_texCoord; |
| + return VERTEX_SHADER( |
| + attribute TexCoordPrecision vec4 a_position; |
| + attribute TexCoordPrecision vec2 a_texCoord; |
| uniform mat4 matrix; |
| - uniform vec2 point[4]; |
| - uniform vec4 vertexTexTransform; |
| - varying vec2 v_texCoord; |
| + uniform TexCoordPrecision vec2 point[4]; |
| + uniform TexCoordPrecision vec4 vertexTexTransform; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| void main() |
| { |
| vec2 complement = abs(a_texCoord - 1.0); |
| @@ -332,12 +379,12 @@ bool VertexShaderVideoTransform::init(WebGraphicsContext3D* context, unsigned pr |
| std::string VertexShaderVideoTransform::getShaderString() const |
| { |
| - return SHADER( |
| + return VERTEX_SHADER( |
| attribute vec4 a_position; |
| - attribute vec2 a_texCoord; |
| + attribute TexCoordPrecision vec2 a_texCoord; |
| uniform mat4 matrix; |
| - uniform mat4 texMatrix; |
| - varying vec2 v_texCoord; |
| + uniform TexCoordPrecision mat4 texMatrix; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| void main() |
| { |
| gl_Position = matrix * a_position; |
| @@ -398,25 +445,26 @@ bool FragmentShaderOESImageExternal::init(WebGraphicsContext3D* context, unsigne |
| return m_samplerLocation != -1; |
| } |
| -std::string FragmentShaderOESImageExternal::getShaderString() const |
| +std::string FragmentShaderOESImageExternal::getShaderString(TexCoordPrecision precision) const |
| { |
| - // Cannot use the SHADER() macro because of the '#' char |
| - return "#extension GL_OES_EGL_image_external : require \n" |
| + // Cannot use the FRAGMENT_SHADER() macro because of the '#' char |
| + return setFragTexCoordPrecision(precision, |
| + "#extension GL_OES_EGL_image_external : require \n" |
| "precision mediump float;\n" |
| - "varying vec2 v_texCoord;\n" |
| + "varying TexCoordPrecision vec2 v_texCoord;\n" |
| "uniform samplerExternalOES s_texture;\n" |
| "void main()\n" |
| "{\n" |
| " vec4 texColor = texture2D(s_texture, v_texCoord);\n" |
| " gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w);\n" |
| - "}\n"; |
| + "}\n"); |
| } |
| -std::string FragmentShaderRGBATexAlpha::getShaderString() const |
| +std::string FragmentShaderRGBATexAlpha::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| uniform float alpha; |
| void main() |
| @@ -427,11 +475,11 @@ std::string FragmentShaderRGBATexAlpha::getShaderString() const |
| ); |
| } |
| -std::string FragmentShaderRGBATexVaryingAlpha::getShaderString() const |
| +std::string FragmentShaderRGBATexVaryingAlpha::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| varying float v_alpha; |
| uniform sampler2D s_texture; |
| void main() |
| @@ -442,25 +490,26 @@ std::string FragmentShaderRGBATexVaryingAlpha::getShaderString() const |
| ); |
| } |
| -std::string FragmentShaderRGBATexRectVaryingAlpha::getShaderString() const |
| +std::string FragmentShaderRGBATexRectVaryingAlpha::getShaderString(TexCoordPrecision precision) const |
| { |
| - return "#extension GL_ARB_texture_rectangle : require\n" |
| + return setFragTexCoordPrecision(precision, |
| + "#extension GL_ARB_texture_rectangle : require\n" |
| "precision mediump float;\n" |
| - "varying vec2 v_texCoord;\n" |
| + "varying TexCoordPrecision vec2 v_texCoord;\n" |
| "varying float v_alpha;\n" |
| "uniform sampler2DRect s_texture;\n" |
| "void main()\n" |
| "{\n" |
| " vec4 texColor = texture2DRect(s_texture, v_texCoord);\n" |
| " gl_FragColor = texColor * v_alpha;\n" |
| - "}\n"; |
| + "}\n"); |
| } |
| -std::string FragmentShaderRGBATexOpaque::getShaderString() const |
| +std::string FragmentShaderRGBATexOpaque::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| void main() |
| { |
| @@ -470,11 +519,11 @@ std::string FragmentShaderRGBATexOpaque::getShaderString() const |
| ); |
| } |
| -std::string FragmentShaderRGBATex::getShaderString() const |
| +std::string FragmentShaderRGBATex::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| void main() |
| { |
| @@ -483,11 +532,11 @@ std::string FragmentShaderRGBATex::getShaderString() const |
| ); |
| } |
| -std::string FragmentShaderRGBATexSwizzleAlpha::getShaderString() const |
| +std::string FragmentShaderRGBATexSwizzleAlpha::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| uniform float alpha; |
| void main() |
| @@ -498,11 +547,11 @@ std::string FragmentShaderRGBATexSwizzleAlpha::getShaderString() const |
| ); |
| } |
| -std::string FragmentShaderRGBATexSwizzleOpaque::getShaderString() const |
| +std::string FragmentShaderRGBATexSwizzleOpaque::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| void main() |
| { |
| @@ -536,11 +585,11 @@ void FragmentShaderRGBATexAlphaAA::init(WebGraphicsContext3D* context, unsigned |
| DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation != -1); |
| } |
| -std::string FragmentShaderRGBATexAlphaAA::getShaderString() const |
| +std::string FragmentShaderRGBATexAlphaAA::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| uniform float alpha; |
| uniform vec3 edge[8]; |
| @@ -588,18 +637,18 @@ void FragmentTexClampAlphaAABinding::init(WebGraphicsContext3D* context, unsigne |
| DCHECK(m_samplerLocation != -1 && m_alphaLocation != -1 && m_fragmentTexTransformLocation != -1 && m_edgeLocation != -1); |
| } |
| -std::string FragmentShaderRGBATexClampAlphaAA::getShaderString() const |
| +std::string FragmentShaderRGBATexClampAlphaAA::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| uniform float alpha; |
| - uniform vec4 fragmentTexTransform; |
| + uniform TexCoordPrecision vec4 fragmentTexTransform; |
| uniform vec3 edge[8]; |
| void main() |
| { |
| - vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw + fragmentTexTransform.xy; |
| + TexCoordPrecision vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw + fragmentTexTransform.xy; |
| vec4 texColor = texture2D(s_texture, texCoord); |
| vec3 pos = vec3(gl_FragCoord.xy, 1); |
| float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); |
| @@ -615,18 +664,18 @@ std::string FragmentShaderRGBATexClampAlphaAA::getShaderString() const |
| ); |
| } |
| -std::string FragmentShaderRGBATexClampSwizzleAlphaAA::getShaderString() const |
| +std::string FragmentShaderRGBATexClampSwizzleAlphaAA::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| uniform float alpha; |
| - uniform vec4 fragmentTexTransform; |
| + uniform TexCoordPrecision vec4 fragmentTexTransform; |
| uniform vec3 edge[8]; |
| void main() |
| { |
| - vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw + fragmentTexTransform.xy; |
| + TexCoordPrecision vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * fragmentTexTransform.zw + fragmentTexTransform.xy; |
| vec4 texColor = texture2D(s_texture, texCoord); |
| vec3 pos = vec3(gl_FragCoord.xy, 1); |
| float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); |
| @@ -671,20 +720,20 @@ void FragmentShaderRGBATexAlphaMask::init(WebGraphicsContext3D* context, unsigne |
| DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLocation != -1); |
| } |
| -std::string FragmentShaderRGBATexAlphaMask::getShaderString() const |
| +std::string FragmentShaderRGBATexAlphaMask::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| uniform sampler2D s_mask; |
| - uniform vec2 maskTexCoordScale; |
| - uniform vec2 maskTexCoordOffset; |
| + uniform TexCoordPrecision vec2 maskTexCoordScale; |
| + uniform TexCoordPrecision vec2 maskTexCoordOffset; |
| uniform float alpha; |
| void main() |
| { |
| vec4 texColor = texture2D(s_texture, v_texCoord); |
| - vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); |
| + TexCoordPrecision vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); |
| vec4 maskColor = texture2D(s_mask, maskTexCoord); |
| gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha * maskColor.w; |
| } |
| @@ -723,21 +772,21 @@ void FragmentShaderRGBATexAlphaMaskAA::init(WebGraphicsContext3D* context, unsig |
| DCHECK(m_samplerLocation != -1 && m_maskSamplerLocation != -1 && m_alphaLocation != -1 && m_edgeLocation != -1); |
| } |
| -std::string FragmentShaderRGBATexAlphaMaskAA::getShaderString() const |
| +std::string FragmentShaderRGBATexAlphaMaskAA::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D s_texture; |
| uniform sampler2D s_mask; |
| - uniform vec2 maskTexCoordScale; |
| - uniform vec2 maskTexCoordOffset; |
| + uniform TexCoordPrecision vec2 maskTexCoordScale; |
| + uniform TexCoordPrecision vec2 maskTexCoordOffset; |
| uniform float alpha; |
| uniform vec3 edge[8]; |
| void main() |
| { |
| vec4 texColor = texture2D(s_texture, v_texCoord); |
| - vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); |
| + TexCoordPrecision vec2 maskTexCoord = vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); |
| vec4 maskColor = texture2D(s_mask, maskTexCoord); |
| vec3 pos = vec3(gl_FragCoord.xy, 1); |
| float a0 = clamp(dot(edge[0], pos), 0.0, 1.0); |
| @@ -788,12 +837,12 @@ void FragmentShaderYUVVideo::init(WebGraphicsContext3D* context, unsigned progra |
| && m_alphaLocation != -1 && m_yuvMatrixLocation != -1 && m_yuvAdjLocation != -1); |
| } |
| -std::string FragmentShaderYUVVideo::getShaderString() const |
| +std::string FragmentShaderYUVVideo::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| precision mediump int; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform sampler2D y_texture; |
| uniform sampler2D u_texture; |
| uniform sampler2D v_texture; |
| @@ -830,9 +879,9 @@ void FragmentShaderColor::init(WebGraphicsContext3D* context, unsigned program, |
| DCHECK(m_colorLocation != -1); |
| } |
| -std::string FragmentShaderColor::getShaderString() const |
| +std::string FragmentShaderColor::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| uniform vec4 color; |
| void main() |
| @@ -863,9 +912,9 @@ void FragmentShaderColorAA::init(WebGraphicsContext3D* context, unsigned program |
| DCHECK(m_edgeLocation != -1 && m_colorLocation != -1); |
| } |
| -std::string FragmentShaderColorAA::getShaderString() const |
| +std::string FragmentShaderColorAA::getShaderString(TexCoordPrecision precision) const |
| { |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| uniform vec4 color; |
| uniform vec3 edge[8]; |
| @@ -911,14 +960,14 @@ void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned pr |
| DCHECK(m_alphaLocation != -1 && m_texTransformLocation != -1 && m_frequencyLocation != -1 && m_colorLocation != -1); |
| } |
| -std::string FragmentShaderCheckerboard::getShaderString() const |
| +std::string FragmentShaderCheckerboard::getShaderString(TexCoordPrecision precision) const |
| { |
| // Shader based on Example 13-17 of "OpenGL ES 2.0 Programming Guide" |
| // by Munshi, Ginsburg, Shreiner. |
| - return SHADER( |
| + return FRAGMENT_SHADER( |
| precision mediump float; |
| precision mediump int; |
| - varying vec2 v_texCoord; |
| + varying TexCoordPrecision vec2 v_texCoord; |
| uniform float alpha; |
| uniform float frequency; |
| uniform vec4 texTransform; |
| @@ -927,7 +976,7 @@ std::string FragmentShaderCheckerboard::getShaderString() const |
| { |
| vec4 color1 = vec4(1.0, 1.0, 1.0, 1.0); |
| vec4 color2 = color; |
| - vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; |
| + TexCoordPrecision vec2 texCoord = clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; |
| vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
| float picker = abs(coord.x - coord.y); |
| gl_FragColor = mix(color1, color2, picker) * alpha; |