Index: cc/output/shader.cc |
diff --git a/cc/output/shader.cc b/cc/output/shader.cc |
index b5d163862d14e010aa19d5bcd083278366ed34b4..ed17163e7c7ffa5fff5c8217f1bd49028a526b7a 100644 |
--- a/cc/output/shader.cc |
+++ b/cc/output/shader.cc |
@@ -2176,6 +2176,58 @@ std::string FragmentShaderYUVVideo::GetShaderString(TexCoordPrecision precision, |
return FRAGMENT_SHADER(head, functions); |
} |
+FragmentShaderYVideo::FragmentShaderYVideo() |
+ : FragmentTexOpaqueBinding(), |
+ x_derivative_location_(-1), |
+ y_derivative_location_(-1) {} |
+ |
+void FragmentShaderYVideo::Init(GLES2Interface* context, |
+ unsigned program, |
+ int* base_uniform_index) { |
+ FragmentTexOpaqueBinding::Init(context, program, base_uniform_index); |
+ |
+ static const char* uniforms[] = {"x_derivative", "y_derivative"}; |
+ int locations[arraysize(uniforms)]; |
+ |
+ GetProgramUniformLocations(context, program, arraysize(uniforms), uniforms, |
+ locations, base_uniform_index); |
+ x_derivative_location_ = locations[0]; |
+ y_derivative_location_ = locations[1]; |
+} |
+ |
+std::string FragmentShaderYVideo::GetShaderString(TexCoordPrecision precision, |
+ SamplerType sampler) const { |
+ return FRAGMENT_SHADER(GetShaderHead(), GetShaderBody()); |
+} |
+ |
+std::string FragmentShaderYVideo::GetShaderHead() { |
+ return SHADER0([]() { |
+ precision mediump float; |
+ varying TexCoordPrecision vec2 v_texCoord; |
+ uniform SamplerType s_texture; |
+ uniform float x_derivative; |
+ uniform float y_derivative; |
+ }); |
+} |
+ |
+std::string FragmentShaderYVideo::GetShaderBody() { |
+ return SHADER0([]() { |
+ vec4 TextureLookupBilinear(SamplerType sampler, highp vec2 texCoord) { |
+ vec4 s1 = TextureLookup(sampler, texCoord); |
+ vec4 s2 = TextureLookup(sampler, texCoord + vec2(x_derivative, 0.)); |
+ vec4 s3 = TextureLookup(sampler, texCoord + vec2(0., y_derivative)); |
+ vec4 s4 = |
+ TextureLookup(sampler, texCoord + vec2(x_derivative, y_derivative)); |
+ vec2 f = fract(texCoord.xy / vec2(x_derivative, y_derivative)); |
+ return mix(mix(s1, s2, f.x), mix(s3, s4, f.x), f.y); |
+ } |
+ void main() { |
+ gl_FragColor = |
+ vec4(vec3(TextureLookupBilinear(s_texture, v_texCoord).g), 1.); |
+ } |
+ }); |
+} |
+ |
FragmentShaderColor::FragmentShaderColor() : color_location_(-1) { |
} |