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

Unified Diff: cc/output/gl_renderer.cc

Issue 881963002: Clamp YUV videos to their visible size in the shader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test, fix bugs Created 5 years, 11 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
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index f2029f3a50d60dd1db9d4e65015c310ebe783a28..f53ab0db06205e1fe13c8ccebca0f16681169cbc 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -1832,6 +1832,7 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
int matrix_location = -1;
int tex_scale_location = -1;
int tex_offset_location = -1;
+ int clamp_rect_location = -1;
int y_texture_location = -1;
int u_texture_location = -1;
int v_texture_location = -1;
@@ -1852,6 +1853,7 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
a_texture_location = program->fragment_shader().a_texture_location();
yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
yuv_adj_location = program->fragment_shader().yuv_adj_location();
+ clamp_rect_location = program->fragment_shader().clamp_rect_location();
alpha_location = program->fragment_shader().alpha_location();
} else {
const VideoYUVProgram* program = GetVideoYUVProgram(tex_coord_precision);
@@ -1865,6 +1867,7 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
v_texture_location = program->fragment_shader().v_texture_location();
yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
yuv_adj_location = program->fragment_shader().yuv_adj_location();
+ clamp_rect_location = program->fragment_shader().clamp_rect_location();
alpha_location = program->fragment_shader().alpha_location();
}
@@ -1876,6 +1879,14 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
gl_->Uniform2f(tex_offset_location,
quad->tex_coord_rect.x(),
quad->tex_coord_rect.y()));
+ // Clamping to half a texel inside the tex coord rect prevents bilinear
+ // filtering from filtering outside the tex coord rect.
+ gfx::RectF clamp_rect(quad->tex_coord_rect);
+ clamp_rect.Inset(0.5f / quad->tex_size.width(),
+ 0.5f / quad->tex_size.height());
+ GLC(gl_, gl_->Uniform4f(clamp_rect_location, clamp_rect.x(), clamp_rect.y(),
+ clamp_rect.right(), clamp_rect.bottom()));
+
GLC(gl_, gl_->Uniform1i(y_texture_location, 1));
GLC(gl_, gl_->Uniform1i(u_texture_location, 2));
GLC(gl_, gl_->Uniform1i(v_texture_location, 3));

Powered by Google App Engine
This is Rietveld 408576698