Chromium Code Reviews| Index: cc/shader.cc |
| diff --git a/cc/shader.cc b/cc/shader.cc |
| index 89474299e4fb1a569870a5014feef9f7056f36a3..dda19c5f991b65f26e32d5ba8a8b86091fa317df 100644 |
| --- a/cc/shader.cc |
| +++ b/cc/shader.cc |
| @@ -892,6 +892,71 @@ std::string FragmentShaderYUVVideo::getShaderString() const |
| ); |
| } |
| +FragmentShaderYUVAVideo::FragmentShaderYUVAVideo() |
| + : m_yTextureLocation(-1) |
| + , m_uTextureLocation(-1) |
| + , m_vTextureLocation(-1) |
| + , m_aTextureLocation(-1) |
| + , m_alphaLocation(-1) |
| + , m_yuvMatrixLocation(-1) |
| + , m_yuvAdjLocation(-1) |
| +{ |
| +} |
| + |
| +void FragmentShaderYUVAVideo::init(WebGraphicsContext3D* context, unsigned program, bool usingBindUniform, int* baseUniformIndex) |
| +{ |
| + static const char* shaderUniforms[] = { |
| + "y_texture", |
| + "u_texture", |
| + "v_texture", |
| + "a_texture", |
| + "alpha", |
| + "cc_matrix", |
| + "yuv_adj", |
| + }; |
| + int locations[7]; |
| + |
| + getProgramUniformLocations(context, program, shaderUniforms, arraysize(shaderUniforms), arraysize(locations), locations, usingBindUniform, baseUniformIndex); |
| + |
| + m_yTextureLocation = locations[0]; |
| + m_uTextureLocation = locations[1]; |
| + m_vTextureLocation = locations[2]; |
| + m_aTextureLocation = locations[3]; |
| + m_alphaLocation = locations[4]; |
| + m_yuvMatrixLocation = locations[5]; |
| + m_yuvAdjLocation = locations[6]; |
| + |
| + DCHECK(m_yTextureLocation != -1 && m_uTextureLocation != -1 && m_vTextureLocation != -1 && m_aTextureLocation != -1 |
| + && m_alphaLocation != -1 && m_yuvMatrixLocation != -1 && m_yuvAdjLocation != -1); |
| +} |
| + |
| +std::string FragmentShaderYUVAVideo::getShaderString() const |
| +{ |
| + return SHADER( |
| + precision mediump float; |
| + precision mediump int; |
| + varying vec2 y_texCoord; |
| + varying vec2 uv_texCoord; |
| + uniform sampler2D y_texture; |
| + uniform sampler2D u_texture; |
| + uniform sampler2D v_texture; |
| + uniform sampler2D a_texture; |
| + uniform float alpha; |
| + uniform vec3 yuv_adj; |
| + uniform mat3 cc_matrix; |
| + void main() |
| + { |
| + float y_raw = texture2D(y_texture, y_texCoord).x; |
| + float u_unsigned = texture2D(u_texture, uv_texCoord).x; |
| + float v_unsigned = texture2D(v_texture, uv_texCoord).x; |
| + float a_raw = texture2D(a_texture, y_texCoord).x; |
| + vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) yuv_adj; |
|
jzern
2013/02/13 19:56:14
'+' yuv_adj ?
vigneshv
2013/02/15 18:05:02
Done.
|
| + vec3 rgb = cc_matrix * yuv; |
| + gl_FragColor = vec4(rgb, float(1)) * (a_raw * alpha); |
| + } |
| + ); |
| +} |
| + |
| FragmentShaderColor::FragmentShaderColor() |
| : m_colorLocation(-1) |
| { |