Chromium Code Reviews| Index: cc/output/shader.cc |
| diff --git a/cc/output/shader.cc b/cc/output/shader.cc |
| index fb12506fab3c6a5b82f087f7575297d358005a9d..f7f014d02d0956953ff0f20ac589762efbd4a09c 100644 |
| --- a/cc/output/shader.cc |
| +++ b/cc/output/shader.cc |
| @@ -2128,6 +2128,57 @@ std::string FragmentShaderYUVVideo::GetShaderString(TexCoordPrecision precision, |
| return FRAGMENT_SHADER(head, get_uv + get_alpha + main); |
| } |
| +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(sampler2D sampler, highp vec2 texCoord) { |
|
aleksandar.stojiljkovic
2016/07/15 12:29:06
custom bilinear filter used for RG88.
|
| + vec4 s1 = texture2D(sampler, texCoord); |
| + vec4 s2 = texture2D(sampler, texCoord + vec2(x_derivative, 0.)); |
| + vec4 s3 = texture2D(sampler, texCoord + vec2(0., y_derivative)); |
| + vec4 s4 = texture2D(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) { |
| } |