Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2434)

Unified Diff: cc/output/shader.cc

Issue 18432002: Blend TextureLayer background-color at draw time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resolved conflicts with TOT Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/shader.h ('k') | cc/output/software_renderer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/shader.cc
diff --git a/cc/output/shader.cc b/cc/output/shader.cc
index a1637a120d7eab6d7f1bc289034e94fb206f7881..df2c5dcba2f2c4b013df890b84681052eb1d3e08 100644
--- a/cc/output/shader.cc
+++ b/cc/output/shader.cc
@@ -788,6 +788,68 @@ std::string FragmentShaderRGBATexPremultiplyAlpha::GetShaderString(
); // NOLINT(whitespace/parens)
}
+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* uniforms[] = {
+ "s_texture",
+ "background_color",
+ };
+ int locations[arraysize(uniforms)];
+
+ GetProgramUniformLocations(context,
+ program,
+ arraysize(uniforms),
+ uniforms,
+ 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 FragmentShaderTexBackgroundVaryingAlpha::GetShaderString(
+ TexCoordPrecision precision) const {
+ return FRAGMENT_SHADER(
+ precision mediump float;
+ varying TexCoordPrecision vec2 v_texCoord;
+ varying float v_alpha;
+ uniform vec4 background_color;
+ uniform sampler2D s_texture;
+ void main() {
+ vec4 texColor = texture2D(s_texture, v_texCoord);
+ texColor += background_color * (1.0 - texColor.a);
+ gl_FragColor = texColor * v_alpha;
+ }
+ ); // NOLINT(whitespace/parens)
+}
+
+std::string FragmentShaderTexBackgroundPremultiplyAlpha::GetShaderString(
+ TexCoordPrecision precision) const {
+ return FRAGMENT_SHADER(
+ precision mediump float;
+ varying TexCoordPrecision vec2 v_texCoord;
+ varying float v_alpha;
+ uniform sampler2D s_texture;
+ 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)
+}
+
std::string FragmentShaderRGBATexRectVaryingAlpha::GetShaderString(
TexCoordPrecision precision) const {
return "#extension GL_ARB_texture_rectangle : require\n" +
« no previous file with comments | « cc/output/shader.h ('k') | cc/output/software_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698