Chromium Code Reviews| Index: cc/output/shader.cc |
| diff --git a/cc/output/shader.cc b/cc/output/shader.cc |
| index 6e1f6c5a915f341354100f7ea92021ef81bfde48..ef88ff586d190106e1eced76492d843827119bcc 100644 |
| --- a/cc/output/shader.cc |
| +++ b/cc/output/shader.cc |
| @@ -668,30 +668,65 @@ std::string FragmentShaderRGBATexColorMatrixAlpha::GetShaderString( |
| ); // NOLINT(whitespace/parens) |
| } |
| -std::string FragmentShaderRGBATexVaryingAlpha::GetShaderString( |
| +FragmentTexBackgroundBinding::FragmentTexBackgroundBinding() |
| + : background_color_location_(-1), |
| + sampler_location_(-1) { |
| +} |
| + |
| +void FragmentTexBackgroundBinding::Init(WebGraphicsContext3D* context, |
| + unsigned program, |
| + bool using_bind_uniform, |
| + int* base_uniform_index) { |
| + static const char* shader_uniforms[] = { |
| + "s_texture", |
| + "background_color", |
| + }; |
| + int locations[2]; |
| + |
| + GetProgramUniformLocations(context, |
| + program, |
| + shader_uniforms, |
| + arraysize(shader_uniforms), |
| + arraysize(locations), |
| + locations, |
| + using_bind_uniform, |
| + base_uniform_index); |
| + |
| + sampler_location_ = locations[0]; |
| + DCHECK_NE(sampler_location_, -1); |
| + |
| + background_color_location_ = locations[1]; |
| + DCHECK_NE(background_color_location_, -1); |
| +} |
| + |
| +std::string FragmentShaderTexture::GetShaderString( |
| TexCoordPrecision precision) const { |
| return FRAGMENT_SHADER( |
| precision mediump float; |
| varying TexCoordPrecision vec2 v_texCoord; |
| varying float v_alpha; |
| uniform sampler2D s_texture; |
| + uniform vec4 background_color; |
| void main() { |
| vec4 texColor = texture2D(s_texture, v_texCoord); |
| + texColor += background_color * (1.0 - texColor.a); |
|
piman
2013/07/02 01:26:30
drive-by: so, this extra cost is done on every pix
alokp
2013/07/02 22:03:54
I was hoping to not have to keep the existing shad
|
| gl_FragColor = texColor * v_alpha; |
|
enne (OOO)
2013/07/02 01:27:22
How does v_alpha interact with texColor.a? If the
alokp
2013/07/02 22:03:54
This order is correct for this specific use case.
enne (OOO)
2013/07/02 23:08:29
I think it's still correct. I guess if I think ab
|
| } |
| ); // NOLINT(whitespace/parens) |
| } |
| -std::string FragmentShaderRGBATexPremultiplyAlpha::GetShaderString( |
| +std::string FragmentShaderNonPremulTexture::GetShaderString( |
| TexCoordPrecision precision) const { |
| return FRAGMENT_SHADER( |
| precision mediump float; |
| varying TexCoordPrecision vec2 v_texCoord; |
| varying float v_alpha; |
| uniform sampler2D s_texture; |
| + uniform vec4 background_color; |
| void main() { |
| vec4 texColor = texture2D(s_texture, v_texCoord); |
| texColor.rgb *= texColor.a; |
| + texColor += background_color * (1.0 - texColor.a); |
| gl_FragColor = texColor * v_alpha; |
| } |
| ); // NOLINT(whitespace/parens) |