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