OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 2199 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
2200 gl_, &highp_threshold_cache_, highp_threshold_min_, | 2200 gl_, &highp_threshold_cache_, highp_threshold_min_, |
2201 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); | 2201 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); |
2202 | 2202 |
2203 bool use_alpha_plane = quad->a_plane_resource_id() != 0; | 2203 bool use_alpha_plane = quad->a_plane_resource_id() != 0; |
2204 bool use_nv12 = quad->v_plane_resource_id() == quad->u_plane_resource_id(); | 2204 bool use_nv12 = quad->v_plane_resource_id() == quad->u_plane_resource_id(); |
2205 bool use_color_lut = | 2205 bool use_color_lut = |
2206 base::FeatureList::IsEnabled(media::kVideoColorManagement); | 2206 base::FeatureList::IsEnabled(media::kVideoColorManagement); |
2207 DCHECK(!(use_nv12 && use_alpha_plane)); | 2207 DCHECK(!(use_nv12 && use_alpha_plane)); |
2208 | 2208 |
| 2209 FragmentShaderYUVVideo::HighbitTexture highbit_texture = |
| 2210 FragmentShaderYUVVideo::HIGHBIT_Y8; |
| 2211 if (quad->bits_per_channel > 8) { |
| 2212 // TODO(dshwang): the resource should know its format. crbug.com/624436 |
| 2213 ResourceFormat resource_format = |
| 2214 resource_provider_->GetResourceFormat(quad->y_plane_resource_id()); |
| 2215 if (resource_format == LUMINANCE_F16) { |
| 2216 highbit_texture = FragmentShaderYUVVideo::HIGHBIT_LUMINANCE_F16; |
| 2217 } else { |
| 2218 DCHECK(RG_88 == resource_format || RGBA_8888 == resource_format); |
| 2219 highbit_texture = FragmentShaderYUVVideo::HIGHBIT_RG88; |
| 2220 } |
| 2221 } |
| 2222 DCHECK_LE(YUVVideoDrawQuad::kMinBitsPerChannel, quad->bits_per_channel); |
| 2223 DCHECK_LE(quad->bits_per_channel, YUVVideoDrawQuad::kMaxBitsPerChannel); |
| 2224 GLenum filter = highbit_texture == FragmentShaderYUVVideo::HIGHBIT_RG88 |
| 2225 ? GL_NEAREST |
| 2226 : GL_LINEAR; |
| 2227 |
| 2228 // y_plane can be RG texture, so use manual bilinear shader. |
2209 ResourceProvider::ScopedSamplerGL y_plane_lock( | 2229 ResourceProvider::ScopedSamplerGL y_plane_lock( |
2210 resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR); | 2230 resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, filter); |
2211 ResourceProvider::ScopedSamplerGL u_plane_lock( | 2231 ResourceProvider::ScopedSamplerGL u_plane_lock( |
2212 resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_LINEAR); | 2232 resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, filter); |
2213 DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target()); | 2233 DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target()); |
2214 // TODO(jbauman): Use base::Optional when available. | 2234 // TODO(jbauman): Use base::Optional when available. |
2215 std::unique_ptr<ResourceProvider::ScopedSamplerGL> v_plane_lock; | 2235 std::unique_ptr<ResourceProvider::ScopedSamplerGL> v_plane_lock; |
2216 if (!use_nv12) { | 2236 if (!use_nv12) { |
2217 v_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( | 2237 v_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( |
2218 resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3, | 2238 resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3, filter)); |
2219 GL_LINEAR)); | |
2220 DCHECK_EQ(y_plane_lock.target(), v_plane_lock->target()); | 2239 DCHECK_EQ(y_plane_lock.target(), v_plane_lock->target()); |
| 2240 } else { |
| 2241 // |bits_per_channel| of PIXEL_FORMAT_NV12 is 8. |
| 2242 DCHECK_EQ(static_cast<GLenum>(GL_LINEAR), filter); |
2221 } | 2243 } |
2222 std::unique_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; | 2244 std::unique_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; |
2223 if (use_alpha_plane) { | 2245 if (use_alpha_plane) { |
2224 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( | 2246 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( |
2225 resource_provider_, quad->a_plane_resource_id(), GL_TEXTURE4, | 2247 resource_provider_, quad->a_plane_resource_id(), GL_TEXTURE4, |
2226 GL_LINEAR)); | 2248 GL_LINEAR)); |
2227 DCHECK_EQ(y_plane_lock.target(), a_plane_lock->target()); | 2249 DCHECK_EQ(y_plane_lock.target(), a_plane_lock->target()); |
| 2250 // |bits_per_channel| of PIXEL_FORMAT_YV12A is 8. |
| 2251 DCHECK_EQ(static_cast<GLenum>(GL_LINEAR), filter); |
2228 } | 2252 } |
2229 | 2253 |
2230 // All planes must have the same sampler type. | 2254 // All planes must have the same sampler type. |
2231 SamplerType sampler = SamplerTypeFromTextureTarget(y_plane_lock.target()); | 2255 SamplerType sampler = SamplerTypeFromTextureTarget(y_plane_lock.target()); |
2232 | 2256 |
2233 int matrix_location = -1; | 2257 int matrix_location = -1; |
2234 int ya_tex_scale_location = -1; | 2258 int ya_tex_scale_location = -1; |
2235 int ya_tex_offset_location = -1; | 2259 int ya_tex_offset_location = -1; |
2236 int uv_tex_scale_location = -1; | 2260 int uv_tex_scale_location = -1; |
2237 int uv_tex_offset_location = -1; | 2261 int uv_tex_offset_location = -1; |
| 2262 int ya_size_location = -1; |
| 2263 int uv_size_location = -1; |
2238 int ya_clamp_rect_location = -1; | 2264 int ya_clamp_rect_location = -1; |
2239 int uv_clamp_rect_location = -1; | 2265 int uv_clamp_rect_location = -1; |
2240 int y_texture_location = -1; | 2266 int y_texture_location = -1; |
2241 int u_texture_location = -1; | 2267 int u_texture_location = -1; |
2242 int v_texture_location = -1; | 2268 int v_texture_location = -1; |
2243 int uv_texture_location = -1; | 2269 int uv_texture_location = -1; |
2244 int a_texture_location = -1; | 2270 int a_texture_location = -1; |
2245 int lut_texture_location = -1; | 2271 int lut_texture_location = -1; |
2246 int yuv_matrix_location = -1; | 2272 int yuv_matrix_location = -1; |
2247 int yuv_adj_location = -1; | 2273 int yuv_adj_location = -1; |
2248 int alpha_location = -1; | 2274 int alpha_location = -1; |
2249 int resource_multiplier_location = -1; | 2275 int resource_multiplier_location = -1; |
2250 int resource_offset_location = -1; | 2276 int resource_offset_location = -1; |
2251 const VideoYUVProgram* program = GetVideoYUVProgram( | 2277 const VideoYUVProgram* program = |
2252 tex_coord_precision, sampler, use_alpha_plane, use_nv12, use_color_lut); | 2278 GetVideoYUVProgram(tex_coord_precision, sampler, use_alpha_plane, |
| 2279 use_nv12, use_color_lut, highbit_texture); |
2253 DCHECK(program && (program->initialized() || IsContextLost())); | 2280 DCHECK(program && (program->initialized() || IsContextLost())); |
2254 SetUseProgram(program->program()); | 2281 SetUseProgram(program->program()); |
2255 matrix_location = program->vertex_shader().matrix_location(); | 2282 matrix_location = program->vertex_shader().matrix_location(); |
2256 ya_tex_scale_location = program->vertex_shader().ya_tex_scale_location(); | 2283 ya_tex_scale_location = program->vertex_shader().ya_tex_scale_location(); |
2257 ya_tex_offset_location = program->vertex_shader().ya_tex_offset_location(); | 2284 ya_tex_offset_location = program->vertex_shader().ya_tex_offset_location(); |
2258 uv_tex_scale_location = program->vertex_shader().uv_tex_scale_location(); | 2285 uv_tex_scale_location = program->vertex_shader().uv_tex_scale_location(); |
2259 uv_tex_offset_location = program->vertex_shader().uv_tex_offset_location(); | 2286 uv_tex_offset_location = program->vertex_shader().uv_tex_offset_location(); |
2260 y_texture_location = program->fragment_shader().y_texture_location(); | 2287 y_texture_location = program->fragment_shader().y_texture_location(); |
2261 u_texture_location = program->fragment_shader().u_texture_location(); | 2288 u_texture_location = program->fragment_shader().u_texture_location(); |
2262 v_texture_location = program->fragment_shader().v_texture_location(); | 2289 v_texture_location = program->fragment_shader().v_texture_location(); |
2263 uv_texture_location = program->fragment_shader().uv_texture_location(); | 2290 uv_texture_location = program->fragment_shader().uv_texture_location(); |
2264 a_texture_location = program->fragment_shader().a_texture_location(); | 2291 a_texture_location = program->fragment_shader().a_texture_location(); |
2265 lut_texture_location = program->fragment_shader().lut_texture_location(); | 2292 lut_texture_location = program->fragment_shader().lut_texture_location(); |
2266 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); | 2293 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); |
2267 yuv_adj_location = program->fragment_shader().yuv_adj_location(); | 2294 yuv_adj_location = program->fragment_shader().yuv_adj_location(); |
| 2295 ya_size_location = program->fragment_shader().ya_size_location(); |
| 2296 uv_size_location = program->fragment_shader().uv_size_location(); |
2268 ya_clamp_rect_location = program->fragment_shader().ya_clamp_rect_location(); | 2297 ya_clamp_rect_location = program->fragment_shader().ya_clamp_rect_location(); |
2269 uv_clamp_rect_location = program->fragment_shader().uv_clamp_rect_location(); | 2298 uv_clamp_rect_location = program->fragment_shader().uv_clamp_rect_location(); |
2270 alpha_location = program->fragment_shader().alpha_location(); | 2299 alpha_location = program->fragment_shader().alpha_location(); |
2271 resource_multiplier_location = | 2300 resource_multiplier_location = |
2272 program->fragment_shader().resource_multiplier_location(); | 2301 program->fragment_shader().resource_multiplier_location(); |
2273 resource_offset_location = | 2302 resource_offset_location = |
2274 program->fragment_shader().resource_offset_location(); | 2303 program->fragment_shader().resource_offset_location(); |
2275 | 2304 |
2276 gfx::SizeF ya_tex_scale(1.0f, 1.0f); | 2305 gfx::SizeF ya_tex_scale(1.0f, 1.0f); |
2277 gfx::SizeF uv_tex_scale(1.0f, 1.0f); | 2306 gfx::SizeF uv_tex_scale(1.0f, 1.0f); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 gl_->Uniform1i(y_texture_location, 1); | 2356 gl_->Uniform1i(y_texture_location, 1); |
2328 if (use_nv12) { | 2357 if (use_nv12) { |
2329 gl_->Uniform1i(uv_texture_location, 2); | 2358 gl_->Uniform1i(uv_texture_location, 2); |
2330 } else { | 2359 } else { |
2331 gl_->Uniform1i(u_texture_location, 2); | 2360 gl_->Uniform1i(u_texture_location, 2); |
2332 gl_->Uniform1i(v_texture_location, 3); | 2361 gl_->Uniform1i(v_texture_location, 3); |
2333 } | 2362 } |
2334 if (use_alpha_plane) | 2363 if (use_alpha_plane) |
2335 gl_->Uniform1i(a_texture_location, 4); | 2364 gl_->Uniform1i(a_texture_location, 4); |
2336 | 2365 |
2337 // These values are magic numbers that are used in the transformation from YUV | 2366 float resource_multiplier = 1.f; |
2338 // to RGB color values. They are taken from the following webpage: | 2367 switch (highbit_texture) { |
2339 // http://www.fourcc.org/fccyvrgb.php | 2368 case FragmentShaderYUVVideo::HIGHBIT_Y8: |
2340 float yuv_to_rgb_rec601[9] = { | 2369 resource_multiplier = 1.f; |
2341 1.164f, 1.164f, 1.164f, 0.0f, -.391f, 2.018f, 1.596f, -.813f, 0.0f, | |
2342 }; | |
2343 float yuv_to_rgb_jpeg[9] = { | |
2344 1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414f, 0.0f, | |
2345 }; | |
2346 float yuv_to_rgb_rec709[9] = { | |
2347 1.164f, 1.164f, 1.164f, 0.0f, -0.213f, 2.112f, 1.793f, -0.533f, 0.0f, | |
2348 }; | |
2349 | |
2350 // They are used in the YUV to RGBA conversion formula: | |
2351 // Y - 16 : Gives 16 values of head and footroom for overshooting | |
2352 // U - 128 : Turns unsigned U into signed U [-128,127] | |
2353 // V - 128 : Turns unsigned V into signed V [-128,127] | |
2354 float yuv_adjust_constrained[3] = { | |
2355 -16.f, -128.f, -128.f, | |
2356 }; | |
2357 | |
2358 // Same as above, but without the head and footroom. | |
2359 float yuv_adjust_full[3] = { | |
2360 0.0f, -128.f, -128.f, | |
2361 }; | |
2362 | |
2363 float* yuv_to_rgb = NULL; | |
2364 float* yuv_adjust = NULL; | |
2365 | |
2366 switch (quad->color_space) { | |
2367 case YUVVideoDrawQuad::REC_601: | |
2368 yuv_to_rgb = yuv_to_rgb_rec601; | |
2369 yuv_adjust = yuv_adjust_constrained; | |
2370 break; | 2370 break; |
2371 case YUVVideoDrawQuad::REC_709: | 2371 case FragmentShaderYUVVideo::HIGHBIT_LUMINANCE_F16: |
2372 yuv_to_rgb = yuv_to_rgb_rec709; | 2372 resource_multiplier = quad->resource_multiplier; |
2373 yuv_adjust = yuv_adjust_constrained; | |
2374 break; | 2373 break; |
2375 case YUVVideoDrawQuad::JPEG: | 2374 case FragmentShaderYUVVideo::HIGHBIT_RG88: |
2376 yuv_to_rgb = yuv_to_rgb_jpeg; | 2375 // f(r, g) = normalized_float = ((g * 256 * 255) + r * 255) / 1023 |
2377 yuv_adjust = yuv_adjust_full; | 2376 // when |bits_per_channel| is 10 bit, and |r| and |g| is normalized. |
| 2377 resource_multiplier = 255.f / ((1 << quad->bits_per_channel) - 1); |
2378 break; | 2378 break; |
2379 } | 2379 } |
2380 | 2380 |
2381 float yuv_to_rgb_multiplied[9]; | 2381 if (use_color_lut) { |
2382 float yuv_adjust_with_offset[3]; | 2382 DCHECK_NE(-1, lut_texture_location); |
2383 | |
2384 // Formula according to BT.601-7 section 2.5.3. | |
2385 DCHECK_LE(YUVVideoDrawQuad::kMinBitsPerChannel, quad->bits_per_channel); | |
2386 DCHECK_LE(quad->bits_per_channel, YUVVideoDrawQuad::kMaxBitsPerChannel); | |
2387 float adjustment_multiplier = (1 << (quad->bits_per_channel - 8)) * 1.0f / | |
2388 ((1 << quad->bits_per_channel) - 1); | |
2389 | |
2390 for (int i = 0; i < 9; ++i) | |
2391 yuv_to_rgb_multiplied[i] = yuv_to_rgb[i] * quad->resource_multiplier; | |
2392 | |
2393 for (int i = 0; i < 3; ++i) { | |
2394 yuv_adjust_with_offset[i] = | |
2395 yuv_adjust[i] * adjustment_multiplier / quad->resource_multiplier - | |
2396 quad->resource_offset; | |
2397 } | |
2398 | |
2399 if (lut_texture_location != -1) { | |
2400 unsigned int lut_texture = color_lut_cache_.GetLUT( | 2383 unsigned int lut_texture = color_lut_cache_.GetLUT( |
2401 quad->video_color_space, output_surface_->device_color_space(), 32); | 2384 quad->video_color_space, output_surface_->device_color_space(), 32); |
2402 gl_->ActiveTexture(GL_TEXTURE5); | 2385 gl_->ActiveTexture(GL_TEXTURE5); |
2403 gl_->BindTexture(GL_TEXTURE_2D, lut_texture); | 2386 gl_->BindTexture(GL_TEXTURE_2D, lut_texture); |
2404 gl_->Uniform1i(lut_texture_location, 5); | 2387 gl_->Uniform1i(lut_texture_location, 5); |
2405 gl_->ActiveTexture(GL_TEXTURE0); | 2388 gl_->ActiveTexture(GL_TEXTURE0); |
| 2389 |
| 2390 if (highbit_texture == FragmentShaderYUVVideo::HIGHBIT_LUMINANCE_F16 || |
| 2391 highbit_texture == FragmentShaderYUVVideo::HIGHBIT_RG88) { |
| 2392 DCHECK_NE(-1, resource_multiplier_location); |
| 2393 gl_->Uniform1f(resource_multiplier_location, resource_multiplier); |
| 2394 } |
| 2395 if (highbit_texture == FragmentShaderYUVVideo::HIGHBIT_LUMINANCE_F16) { |
| 2396 DCHECK_NE(-1, resource_offset_location); |
| 2397 gl_->Uniform1f(resource_offset_location, quad->resource_offset); |
| 2398 } |
| 2399 } else { |
| 2400 DCHECK_NE(-1, yuv_matrix_location); |
| 2401 DCHECK_NE(-1, yuv_adj_location); |
| 2402 |
| 2403 // These values are magic numbers that are used in the transformation from |
| 2404 // YUV to RGB color values. They are taken from the following webpage: |
| 2405 // http://www.fourcc.org/fccyvrgb.php |
| 2406 float yuv_to_rgb_rec601[9] = { |
| 2407 1.164f, 1.164f, 1.164f, 0.0f, -.391f, 2.018f, 1.596f, -.813f, 0.0f, |
| 2408 }; |
| 2409 float yuv_to_rgb_jpeg[9] = { |
| 2410 1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414f, 0.0f, |
| 2411 }; |
| 2412 float yuv_to_rgb_rec709[9] = { |
| 2413 1.164f, 1.164f, 1.164f, 0.0f, -0.213f, 2.112f, 1.793f, -0.533f, 0.0f, |
| 2414 }; |
| 2415 |
| 2416 // They are used in the YUV to RGBA conversion formula: |
| 2417 // Y - 16 : Gives 16 values of head and footroom for overshooting |
| 2418 // U - 128 : Turns unsigned U into signed U [-128,127] |
| 2419 // V - 128 : Turns unsigned V into signed V [-128,127] |
| 2420 float yuv_adjust_constrained[3] = { |
| 2421 -16.f, -128.f, -128.f, |
| 2422 }; |
| 2423 |
| 2424 // Same as above, but without the head and footroom. |
| 2425 float yuv_adjust_full[3] = { |
| 2426 0.0f, -128.f, -128.f, |
| 2427 }; |
| 2428 |
| 2429 float* yuv_to_rgb = NULL; |
| 2430 float* yuv_adjust = NULL; |
| 2431 |
| 2432 switch (quad->color_space) { |
| 2433 case YUVVideoDrawQuad::REC_601: |
| 2434 yuv_to_rgb = yuv_to_rgb_rec601; |
| 2435 yuv_adjust = yuv_adjust_constrained; |
| 2436 break; |
| 2437 case YUVVideoDrawQuad::REC_709: |
| 2438 yuv_to_rgb = yuv_to_rgb_rec709; |
| 2439 yuv_adjust = yuv_adjust_constrained; |
| 2440 break; |
| 2441 case YUVVideoDrawQuad::JPEG: |
| 2442 yuv_to_rgb = yuv_to_rgb_jpeg; |
| 2443 yuv_adjust = yuv_adjust_full; |
| 2444 break; |
| 2445 } |
| 2446 |
| 2447 float yuv_to_rgb_multiplied[9]; |
| 2448 for (int i = 0; i < 9; ++i) |
| 2449 yuv_to_rgb_multiplied[i] = yuv_to_rgb[i] * resource_multiplier; |
| 2450 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb_multiplied); |
| 2451 |
| 2452 float yuv_adjust_with_offset[3]; |
| 2453 // Formula according to BT.601-7 section 2.5.3. |
| 2454 float adjustment_multiplier = (1 << (quad->bits_per_channel - 8)) * 1.0f / |
| 2455 ((1 << quad->bits_per_channel) - 1); |
| 2456 float resource_offset = 0.f; |
| 2457 if (highbit_texture == FragmentShaderYUVVideo::HIGHBIT_LUMINANCE_F16) |
| 2458 resource_offset = quad->resource_offset; |
| 2459 for (int i = 0; i < 3; ++i) { |
| 2460 yuv_adjust_with_offset[i] = |
| 2461 yuv_adjust[i] * adjustment_multiplier / resource_multiplier - |
| 2462 resource_offset; |
| 2463 } |
| 2464 |
| 2465 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust_with_offset); |
2406 } | 2466 } |
2407 | 2467 |
2408 if (resource_multiplier_location != -1) { | 2468 if (highbit_texture == FragmentShaderYUVVideo::HIGHBIT_RG88) { |
2409 gl_->Uniform1f(resource_multiplier_location, quad->resource_multiplier); | 2469 DCHECK_NE(-1, ya_size_location); |
2410 } | 2470 DCHECK_NE(-1, uv_size_location); |
2411 | 2471 gl_->Uniform2f(ya_size_location, quad->ya_tex_size.width(), |
2412 if (resource_offset_location != -1) { | 2472 quad->ya_tex_size.height()); |
2413 gl_->Uniform1f(resource_offset_location, quad->resource_offset); | 2473 gl_->Uniform2f(uv_size_location, quad->uv_tex_size.width(), |
| 2474 quad->uv_tex_size.height()); |
2414 } | 2475 } |
2415 | 2476 |
2416 // The transform and vertex data are used to figure out the extents that the | 2477 // The transform and vertex data are used to figure out the extents that the |
2417 // un-antialiased quad should have and which vertex this is and the float | 2478 // un-antialiased quad should have and which vertex this is and the float |
2418 // quad passed in via uniform is the actual geometry that gets used to draw | 2479 // quad passed in via uniform is the actual geometry that gets used to draw |
2419 // it. This is why this centered rect is used and not the original quad_rect. | 2480 // it. This is why this centered rect is used and not the original quad_rect. |
2420 auto tile_rect = gfx::RectF(quad->rect); | 2481 auto tile_rect = gfx::RectF(quad->rect); |
2421 if (yuv_matrix_location != -1) { | |
2422 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb_multiplied); | |
2423 } | |
2424 | |
2425 if (yuv_adj_location) { | |
2426 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust_with_offset); | |
2427 } | |
2428 | 2482 |
2429 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location); | 2483 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location); |
2430 if (!clip_region) { | 2484 if (!clip_region) { |
2431 DrawQuadGeometry(frame->projection_matrix, | 2485 DrawQuadGeometry(frame->projection_matrix, |
2432 quad->shared_quad_state->quad_to_target_transform, | 2486 quad->shared_quad_state->quad_to_target_transform, |
2433 tile_rect, matrix_location); | 2487 tile_rect, matrix_location); |
2434 } else { | 2488 } else { |
2435 float uvs[8] = {0}; | 2489 float uvs[8] = {0}; |
2436 GetScaledUVs(quad->visible_rect, clip_region, uvs); | 2490 GetScaledUVs(quad->visible_rect, clip_region, uvs); |
2437 gfx::QuadF region_quad = *clip_region; | 2491 gfx::QuadF region_quad = *clip_region; |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3618 sampler); | 3672 sampler); |
3619 } | 3673 } |
3620 return program; | 3674 return program; |
3621 } | 3675 } |
3622 | 3676 |
3623 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( | 3677 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( |
3624 TexCoordPrecision precision, | 3678 TexCoordPrecision precision, |
3625 SamplerType sampler, | 3679 SamplerType sampler, |
3626 bool use_alpha_plane, | 3680 bool use_alpha_plane, |
3627 bool use_nv12, | 3681 bool use_nv12, |
3628 bool use_color_lut) { | 3682 bool use_color_lut, |
| 3683 FragmentShaderYUVVideo::HighbitTexture highbit_texture) { |
3629 DCHECK_GE(precision, 0); | 3684 DCHECK_GE(precision, 0); |
3630 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3685 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
3631 DCHECK_GE(sampler, 0); | 3686 DCHECK_GE(sampler, 0); |
3632 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3687 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
3633 VideoYUVProgram* program = | 3688 VideoYUVProgram* program = |
3634 &video_yuv_program_[precision][sampler][use_alpha_plane][use_nv12] | 3689 &video_yuv_program_[precision][sampler][use_alpha_plane][use_nv12] |
3635 [use_color_lut]; | 3690 [use_color_lut][highbit_texture]; |
3636 if (!program->initialized()) { | 3691 if (!program->initialized()) { |
3637 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); | 3692 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); |
3638 program->mutable_fragment_shader()->SetFeatures(use_alpha_plane, use_nv12, | 3693 program->mutable_fragment_shader()->SetFeatures( |
3639 use_color_lut); | 3694 use_alpha_plane, use_nv12, use_color_lut, highbit_texture); |
3640 program->Initialize(output_surface_->context_provider(), precision, | 3695 program->Initialize(output_surface_->context_provider(), precision, |
3641 sampler); | 3696 sampler); |
3642 } | 3697 } |
3643 return program; | 3698 return program; |
3644 } | 3699 } |
3645 | 3700 |
3646 const GLRenderer::VideoStreamTextureProgram* | 3701 const GLRenderer::VideoStreamTextureProgram* |
3647 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { | 3702 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { |
3648 DCHECK_GE(precision, 0); | 3703 DCHECK_GE(precision, 0); |
3649 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3704 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
(...skipping 24 matching lines...) Expand all Loading... |
3674 render_pass_mask_program_[i][j][k][l].Cleanup(gl_); | 3729 render_pass_mask_program_[i][j][k][l].Cleanup(gl_); |
3675 render_pass_mask_program_aa_[i][j][k][l].Cleanup(gl_); | 3730 render_pass_mask_program_aa_[i][j][k][l].Cleanup(gl_); |
3676 render_pass_mask_color_matrix_program_aa_[i][j][k][l].Cleanup(gl_); | 3731 render_pass_mask_color_matrix_program_aa_[i][j][k][l].Cleanup(gl_); |
3677 render_pass_mask_color_matrix_program_[i][j][k][l].Cleanup(gl_); | 3732 render_pass_mask_color_matrix_program_[i][j][k][l].Cleanup(gl_); |
3678 } | 3733 } |
3679 } | 3734 } |
3680 | 3735 |
3681 for (int k = 0; k < 2; k++) { | 3736 for (int k = 0; k < 2; k++) { |
3682 for (int l = 0; l < 2; l++) { | 3737 for (int l = 0; l < 2; l++) { |
3683 for (int m = 0; m < 2; m++) { | 3738 for (int m = 0; m < 2; m++) { |
3684 video_yuv_program_[i][j][k][l][m].Cleanup(gl_); | 3739 for (int n = 0; n <= FragmentShaderYUVVideo::LAST_HIGHBIT_TEXTURE; |
| 3740 n++) { |
| 3741 video_yuv_program_[i][j][k][l][m][n].Cleanup(gl_); |
| 3742 } |
3685 } | 3743 } |
3686 } | 3744 } |
3687 } | 3745 } |
3688 } | 3746 } |
3689 for (int j = 0; j <= LAST_BLEND_MODE; j++) { | 3747 for (int j = 0; j <= LAST_BLEND_MODE; j++) { |
3690 render_pass_program_[i][j].Cleanup(gl_); | 3748 render_pass_program_[i][j].Cleanup(gl_); |
3691 render_pass_program_aa_[i][j].Cleanup(gl_); | 3749 render_pass_program_aa_[i][j].Cleanup(gl_); |
3692 render_pass_color_matrix_program_[i][j].Cleanup(gl_); | 3750 render_pass_color_matrix_program_[i][j].Cleanup(gl_); |
3693 render_pass_color_matrix_program_aa_[i][j].Cleanup(gl_); | 3751 render_pass_color_matrix_program_aa_[i][j].Cleanup(gl_); |
3694 } | 3752 } |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4035 | 4093 |
4036 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4094 gl_->ScheduleCALayerSharedStateCHROMIUM( |
4037 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4095 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
4038 sorting_context_id, gl_transform); | 4096 sorting_context_id, gl_transform); |
4039 gl_->ScheduleCALayerCHROMIUM( | 4097 gl_->ScheduleCALayerCHROMIUM( |
4040 texture_id, contents_rect, ca_layer_overlay->background_color, | 4098 texture_id, contents_rect, ca_layer_overlay->background_color, |
4041 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4099 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
4042 } | 4100 } |
4043 | 4101 |
4044 } // namespace cc | 4102 } // namespace cc |
OLD | NEW |