Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: cc/output/gl_renderer.cc

Issue 2738713003: color: Ensure that VideoResourceUpdater give consistent colors (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 break; 2073 break;
2074 case YUVVideoDrawQuad::JPEG: 2074 case YUVVideoDrawQuad::JPEG:
2075 src_color_space = gfx::ColorSpace::CreateJpeg(); 2075 src_color_space = gfx::ColorSpace::CreateJpeg();
2076 break; 2076 break;
2077 } 2077 }
2078 } 2078 }
2079 // Invalid or unspecified color spaces should be treated as REC709. 2079 // Invalid or unspecified color spaces should be treated as REC709.
2080 if (!src_color_space.IsValid()) 2080 if (!src_color_space.IsValid())
2081 src_color_space = gfx::ColorSpace::CreateREC709(); 2081 src_color_space = gfx::ColorSpace::CreateREC709();
2082 2082
2083 // The source color space should never be RGB.
2084 DCHECK_NE(src_color_space, src_color_space.GetAsFullRangeRGB());
2085
2083 ResourceProvider::ScopedSamplerGL y_plane_lock( 2086 ResourceProvider::ScopedSamplerGL y_plane_lock(
2084 resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR); 2087 resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR);
2088 if (base::FeatureList::IsEnabled(media::kVideoColorManagement))
2089 DCHECK_EQ(src_color_space, y_plane_lock.color_space());
2085 ResourceProvider::ScopedSamplerGL u_plane_lock( 2090 ResourceProvider::ScopedSamplerGL u_plane_lock(
2086 resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_LINEAR); 2091 resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_LINEAR);
2087 DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target()); 2092 DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target());
2093 DCHECK_EQ(y_plane_lock.color_space(), u_plane_lock.color_space());
2088 // TODO(jbauman): Use base::Optional when available. 2094 // TODO(jbauman): Use base::Optional when available.
2089 std::unique_ptr<ResourceProvider::ScopedSamplerGL> v_plane_lock; 2095 std::unique_ptr<ResourceProvider::ScopedSamplerGL> v_plane_lock;
2090 2096
2091 if (uv_texture_mode == UV_TEXTURE_MODE_U_V) { 2097 if (uv_texture_mode == UV_TEXTURE_MODE_U_V) {
2092 v_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( 2098 v_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
2093 resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3, 2099 resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3,
2094 GL_LINEAR)); 2100 GL_LINEAR));
2095 DCHECK_EQ(y_plane_lock.target(), v_plane_lock->target()); 2101 DCHECK_EQ(y_plane_lock.target(), v_plane_lock->target());
2102 DCHECK_EQ(y_plane_lock.color_space(), v_plane_lock->color_space());
2096 } 2103 }
2097 std::unique_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; 2104 std::unique_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock;
2098 if (alpha_texture_mode == YUV_HAS_ALPHA_TEXTURE) { 2105 if (alpha_texture_mode == YUV_HAS_ALPHA_TEXTURE) {
2099 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( 2106 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
2100 resource_provider_, quad->a_plane_resource_id(), GL_TEXTURE4, 2107 resource_provider_, quad->a_plane_resource_id(), GL_TEXTURE4,
2101 GL_LINEAR)); 2108 GL_LINEAR));
2102 DCHECK_EQ(y_plane_lock.target(), a_plane_lock->target()); 2109 DCHECK_EQ(y_plane_lock.target(), a_plane_lock->target());
2103 } 2110 }
2104 2111
2105 // All planes must have the same sampler type. 2112 // All planes must have the same sampler type.
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
2983 } 2990 }
2984 2991
2985 void GLRenderer::SetUseProgram(const ProgramKey& program_key, 2992 void GLRenderer::SetUseProgram(const ProgramKey& program_key,
2986 const gfx::ColorSpace& src_color_space) { 2993 const gfx::ColorSpace& src_color_space) {
2987 // Ensure that we do not apply any color conversion unless the color correct 2994 // Ensure that we do not apply any color conversion unless the color correct
2988 // rendering flag has been specified. This is because media mailboxes will 2995 // rendering flag has been specified. This is because media mailboxes will
2989 // provide YUV color spaces despite YUV to RGB conversion already having been 2996 // provide YUV color spaces despite YUV to RGB conversion already having been
2990 // performed. 2997 // performed.
2991 // TODO(ccameron): Ensure that media mailboxes be accurate. 2998 // TODO(ccameron): Ensure that media mailboxes be accurate.
2992 // https://crbug.com/699243 2999 // https://crbug.com/699243
3000 // The source color space for non-YUV draw quads should always be full-range
hubbe 2017/03/13 17:53:45 I can think of cases when we might not want this c
ccameron 2017/03/13 22:16:55 Yes, hopefully soon we'll be able to then up the D
3001 // RGB.
3002 DCHECK_EQ(src_color_space, src_color_space.GetAsFullRangeRGB());
2993 if (settings_->enable_color_correct_rendering) { 3003 if (settings_->enable_color_correct_rendering) {
2994 SetUseProgram(program_key, src_color_space, 3004 SetUseProgram(program_key, src_color_space,
2995 current_frame()->current_render_pass->color_space); 3005 current_frame()->current_render_pass->color_space);
2996 } else { 3006 } else {
2997 SetUseProgram(program_key, gfx::ColorSpace(), gfx::ColorSpace()); 3007 SetUseProgram(program_key, gfx::ColorSpace(), gfx::ColorSpace());
2998 } 3008 }
2999 } 3009 }
3000 3010
3001 void GLRenderer::SetUseProgram(const ProgramKey& program_key_no_color, 3011 void GLRenderer::SetUseProgram(const ProgramKey& program_key_no_color,
3002 const gfx::ColorSpace& src_color_space, 3012 const gfx::ColorSpace& src_color_space,
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
3513 return; 3523 return;
3514 3524
3515 // Report GPU overdraw as a percentage of |max_result|. 3525 // Report GPU overdraw as a percentage of |max_result|.
3516 TRACE_COUNTER1( 3526 TRACE_COUNTER1(
3517 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3527 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3518 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3528 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3519 max_result); 3529 max_result);
3520 } 3530 }
3521 3531
3522 } // namespace cc 3532 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/video_resource_updater.h » ('j') | cc/resources/video_resource_updater.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698