| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/shader.h" | 5 #include "cc/output/shader.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 float u_unsigned = TextureLookup(u_texture, uv_clamped).x; | 2230 float u_unsigned = TextureLookup(u_texture, uv_clamped).x; |
| 2231 float v_unsigned = TextureLookup(v_texture, uv_clamped).x; | 2231 float v_unsigned = TextureLookup(v_texture, uv_clamped).x; |
| 2232 float a_raw = TextureLookup(a_texture, ya_clamped).x; | 2232 float a_raw = TextureLookup(a_texture, ya_clamped).x; |
| 2233 vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj; | 2233 vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj; |
| 2234 vec3 rgb = yuv_matrix * yuv; | 2234 vec3 rgb = yuv_matrix * yuv; |
| 2235 gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw); | 2235 gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw); |
| 2236 } | 2236 } |
| 2237 }); | 2237 }); |
| 2238 } | 2238 } |
| 2239 | 2239 |
| 2240 std::string FragmentShaderYVideo::GetShaderString( |
| 2241 TexCoordPrecision precision, |
| 2242 SamplerType sampler) const { |
| 2243 return FRAGMENT_SHADER(GetShaderHead(), GetShaderBody()); |
| 2244 } |
| 2245 |
| 2246 std::string FragmentShaderYVideo::GetShaderHead() { |
| 2247 return SHADER0([]() { |
| 2248 precision mediump float; |
| 2249 varying TexCoordPrecision vec2 v_texCoord; |
| 2250 uniform SamplerType s_texture; |
| 2251 }); |
| 2252 } |
| 2253 |
| 2254 std::string FragmentShaderYVideo::GetShaderBody() { |
| 2255 return SHADER0([]() { |
| 2256 void main() { |
| 2257 gl_FragColor = TextureLookup(s_texture, v_texCoord); |
| 2258 } |
| 2259 }); |
| 2260 } |
| 2261 |
| 2240 FragmentShaderColor::FragmentShaderColor() : color_location_(-1) { | 2262 FragmentShaderColor::FragmentShaderColor() : color_location_(-1) { |
| 2241 } | 2263 } |
| 2242 | 2264 |
| 2243 void FragmentShaderColor::Init(GLES2Interface* context, | 2265 void FragmentShaderColor::Init(GLES2Interface* context, |
| 2244 unsigned program, | 2266 unsigned program, |
| 2245 int* base_uniform_index) { | 2267 int* base_uniform_index) { |
| 2246 static const char* uniforms[] = { | 2268 static const char* uniforms[] = { |
| 2247 "color", | 2269 "color", |
| 2248 }; | 2270 }; |
| 2249 int locations[arraysize(uniforms)]; | 2271 int locations[arraysize(uniforms)]; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2313 void main() { | 2335 void main() { |
| 2314 vec4 d4 = min(edge_dist[0], edge_dist[1]); | 2336 vec4 d4 = min(edge_dist[0], edge_dist[1]); |
| 2315 vec2 d2 = min(d4.xz, d4.yw); | 2337 vec2 d2 = min(d4.xz, d4.yw); |
| 2316 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); | 2338 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); |
| 2317 gl_FragColor = color * aa; | 2339 gl_FragColor = color * aa; |
| 2318 } | 2340 } |
| 2319 }); | 2341 }); |
| 2320 } | 2342 } |
| 2321 | 2343 |
| 2322 } // namespace cc | 2344 } // namespace cc |
| OLD | NEW |