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