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

Unified Diff: cc/output/gl_renderer.cc

Issue 2400033004: cc: custom bilinear filtering for YUV quad.
Patch Set: fix SAMPLER_TYPE_2D_RECT logic Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 0bb2d6966970448c181df25965fdef3e3753383f..0a3e68ed655f89354e73efeefb2ff8fd6966ff88 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -2206,24 +2206,25 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
base::FeatureList::IsEnabled(media::kVideoColorManagement);
DCHECK(!(use_nv12 && use_alpha_plane));
+ // GL_LINEAR cannot be used because |u_plane| is sub-sampled.
ResourceProvider::ScopedSamplerGL y_plane_lock(
- resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR);
+ resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_NEAREST);
ResourceProvider::ScopedSamplerGL u_plane_lock(
- resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_LINEAR);
+ resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_NEAREST);
DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target());
// TODO(jbauman): Use base::Optional when available.
std::unique_ptr<ResourceProvider::ScopedSamplerGL> v_plane_lock;
if (!use_nv12) {
v_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3,
- GL_LINEAR));
+ GL_NEAREST));
DCHECK_EQ(y_plane_lock.target(), v_plane_lock->target());
}
std::unique_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock;
if (use_alpha_plane) {
a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
resource_provider_, quad->a_plane_resource_id(), GL_TEXTURE4,
- GL_LINEAR));
+ GL_NEAREST));
DCHECK_EQ(y_plane_lock.target(), a_plane_lock->target());
}
@@ -2235,6 +2236,8 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
int ya_tex_offset_location = -1;
int uv_tex_scale_location = -1;
int uv_tex_offset_location = -1;
+ int ya_size_location = -1;
+ int uv_subsampling_factor_location = -1;
int ya_clamp_rect_location = -1;
int uv_clamp_rect_location = -1;
int y_texture_location = -1;
@@ -2265,6 +2268,9 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
lut_texture_location = program->fragment_shader().lut_texture_location();
yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
yuv_adj_location = program->fragment_shader().yuv_adj_location();
+ ya_size_location = program->fragment_shader().ya_size_location();
+ uv_subsampling_factor_location =
+ program->fragment_shader().uv_subsampling_factor_location();
ya_clamp_rect_location = program->fragment_shader().ya_clamp_rect_location();
uv_clamp_rect_location = program->fragment_shader().uv_clamp_rect_location();
alpha_location = program->fragment_shader().alpha_location();
@@ -2276,12 +2282,21 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
gfx::SizeF ya_tex_scale(1.0f, 1.0f);
gfx::SizeF uv_tex_scale(1.0f, 1.0f);
if (sampler != SAMPLER_TYPE_2D_RECT) {
+ DCHECK_NE(-1, ya_size_location);
+ gl_->Uniform2f(ya_size_location, quad->ya_tex_size.width(),
+ quad->ya_tex_size.height());
+
DCHECK(!quad->ya_tex_size.IsEmpty());
DCHECK(!quad->uv_tex_size.IsEmpty());
ya_tex_scale = gfx::SizeF(1.0f / quad->ya_tex_size.width(),
1.0f / quad->ya_tex_size.height());
uv_tex_scale = gfx::SizeF(1.0f / quad->uv_tex_size.width(),
1.0f / quad->uv_tex_size.height());
+ } else {
+ DCHECK_NE(-1, uv_subsampling_factor_location);
+ gl_->Uniform2f(uv_subsampling_factor_location,
+ quad->uv_tex_size.width() / quad->ya_tex_size.width(),
+ quad->uv_tex_size.height() / quad->ya_tex_size.height());
}
float ya_vertex_tex_translate_x =
@@ -3632,8 +3647,8 @@ const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram(
[use_color_lut];
if (!program->initialized()) {
TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize");
- program->mutable_fragment_shader()->SetFeatures(use_alpha_plane, use_nv12,
- use_color_lut);
+ program->mutable_fragment_shader()->SetFeatures(sampler, use_alpha_plane,
+ use_nv12, use_color_lut);
program->Initialize(output_surface_->context_provider(), precision,
sampler);
}
« no previous file with comments | « no previous file | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698