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

Unified Diff: cc/layers/video_layer_impl.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: 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
« no previous file with comments | « no previous file | cc/output/gl_renderer.cc » ('j') | cc/output/shader.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/video_layer_impl.cc
diff --git a/cc/layers/video_layer_impl.cc b/cc/layers/video_layer_impl.cc
index 5f18a768ca4dcf0c4b72767843ef7dc31eeccebc..0c43fe9396097cf5ee319eba3ffe5cc90935be98 100644
--- a/cc/layers/video_layer_impl.cc
+++ b/cc/layers/video_layer_impl.cc
@@ -188,6 +188,13 @@ void VideoLayerImpl::AppendQuads(RenderPass* render_pass,
const float tex_y_offset =
static_cast<float>(visible_rect.y()) / coded_size.height();
+ // Vertex shader should clamp to the visible rect, and then minus
+ // half a pixel (of the coded size) to account for bilinear filtering.
+ // This prevents sampling outside of the visible rect.
+ gfx::SizeF half_pixel(0.5f / coded_size.width(), 0.5f / coded_size.height());
+ gfx::SizeF clamp_size(tex_width_scale + tex_x_offset - half_pixel.width(),
+ tex_height_scale + tex_y_offset - half_pixel.height());
+
switch (frame_resource_type_) {
// TODO(danakj): Remove this, hide it in the hardware path.
case VideoFrameExternalResources::SOFTWARE_RESOURCE: {
@@ -230,16 +237,10 @@ void VideoLayerImpl::AppendQuads(RenderPass* render_pass,
YUVVideoDrawQuad* yuv_video_quad =
render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
yuv_video_quad->SetNew(
- shared_quad_state,
- quad_rect,
- opaque_rect,
- visible_quad_rect,
- tex_coord_rect,
- frame_resources_[0],
- frame_resources_[1],
+ shared_quad_state, quad_rect, opaque_rect, visible_quad_rect,
+ tex_coord_rect, clamp_size, frame_resources_[0], frame_resources_[1],
frame_resources_[2],
- frame_resources_.size() > 3 ? frame_resources_[3] : 0,
- color_space);
+ frame_resources_.size() > 3 ? frame_resources_[3] : 0, color_space);
break;
}
case VideoFrameExternalResources::RGB_RESOURCE: {
« no previous file with comments | « no previous file | cc/output/gl_renderer.cc » ('j') | cc/output/shader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698