| Index: cc/output/gl_renderer.cc
|
| diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
|
| index 59bb170c17de233ad7fd41c17ec0818435a0048d..c4da201f492f2baf090eb867ae6598752d1fb5d8 100644
|
| --- a/cc/output/gl_renderer.cc
|
| +++ b/cc/output/gl_renderer.cc
|
| @@ -2181,10 +2181,7 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
|
| quad->v_plane_resource_id() == quad->u_plane_resource_id()
|
| ? UV_TEXTURE_MODE_UV
|
| : UV_TEXTURE_MODE_U_V;
|
| - ColorConversionMode color_conversion_mode =
|
| - base::FeatureList::IsEnabled(media::kVideoColorManagement)
|
| - ? COLOR_CONVERSION_MODE_LUT_FROM_YUV
|
| - : COLOR_CONVERSION_MODE_NONE;
|
| + bool use_lut = base::FeatureList::IsEnabled(media::kVideoColorManagement);
|
| ResourceProvider::ScopedSamplerGL y_plane_lock(
|
| resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR);
|
| ResourceProvider::ScopedSamplerGL u_plane_lock(
|
| @@ -2212,7 +2209,7 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
|
|
|
| const Program* program = GetProgram(
|
| ProgramKey::YUVVideo(tex_coord_precision, sampler, alpha_texture_mode,
|
| - uv_texture_mode, color_conversion_mode));
|
| + uv_texture_mode, use_lut));
|
| DCHECK(program && (program->initialized() || IsContextLost()));
|
| SetUseProgram(program->program());
|
|
|
| @@ -2279,7 +2276,7 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
|
| if (alpha_texture_mode == YUV_HAS_ALPHA_TEXTURE)
|
| gl_->Uniform1i(program->a_texture_location(), 4);
|
|
|
| - if (color_conversion_mode == COLOR_CONVERSION_MODE_LUT_FROM_YUV) {
|
| + if (use_lut) {
|
| ColorLUTCache::LUT lut = color_lut_cache_.GetLUT(quad->video_color_space,
|
| frame->device_color_space);
|
| gl_->ActiveTexture(GL_TEXTURE5);
|
| @@ -2296,9 +2293,30 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
|
| ComputeYUVToRGBMatrices(quad->color_space, quad->bits_per_channel,
|
| quad->resource_multiplier, quad->resource_offset,
|
| yuv_to_rgb_multiplied, yuv_adjust_with_offset);
|
| - gl_->UniformMatrix3fv(program->yuv_matrix_location(), 1, 0,
|
| - yuv_to_rgb_multiplied);
|
| - gl_->Uniform3fv(program->yuv_adj_location(), 1, yuv_adjust_with_offset);
|
| + DCHECK_NE(program->color_matrix_location(), -1);
|
| + DCHECK_NE(program->color_offset_location(), -1);
|
| +
|
| + float matrix[16];
|
| + SkMatrix44 m;
|
| + for (int i = 0; i < 4; ++i) {
|
| + for (int j = 0; j < 4; ++j) {
|
| + float x;
|
| + if (i == 3 && j == 3) {
|
| + x = 1.0f;
|
| + } else if (i == 3 || j == 3) {
|
| + x = 0.0f;
|
| + } else {
|
| + x = yuv_to_rgb_multiplied[i * 3 + j];
|
| + }
|
| + m.set(j, i, x);
|
| + matrix[i * 4 + j] = x;
|
| + }
|
| + }
|
| + SkVector4 v(yuv_adjust_with_offset[0], yuv_adjust_with_offset[1],
|
| + yuv_adjust_with_offset[2], 0.0f);
|
| + v = m * v;
|
| + gl_->UniformMatrix4fv(program->color_matrix_location(), 1, false, matrix);
|
| + gl_->Uniform4fv(program->color_offset_location(), 1, v.fData);
|
| }
|
|
|
| // The transform and vertex data are used to figure out the extents that the
|
|
|