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

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

Issue 1008493002: Increase YUV video clamping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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
« no previous file with comments | « cc/layers/video_layer_impl.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; 1952 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock;
1953 if (use_alpha_plane) { 1953 if (use_alpha_plane) {
1954 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( 1954 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
1955 resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR)); 1955 resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR));
1956 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target()); 1956 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target());
1957 } 1957 }
1958 1958
1959 int matrix_location = -1; 1959 int matrix_location = -1;
1960 int tex_scale_location = -1; 1960 int tex_scale_location = -1;
1961 int tex_offset_location = -1; 1961 int tex_offset_location = -1;
1962 int clamp_rect_location = -1; 1962 int ya_clamp_rect_location = -1;
1963 int uv_clamp_rect_location = -1;
1963 int y_texture_location = -1; 1964 int y_texture_location = -1;
1964 int u_texture_location = -1; 1965 int u_texture_location = -1;
1965 int v_texture_location = -1; 1966 int v_texture_location = -1;
1966 int a_texture_location = -1; 1967 int a_texture_location = -1;
1967 int yuv_matrix_location = -1; 1968 int yuv_matrix_location = -1;
1968 int yuv_adj_location = -1; 1969 int yuv_adj_location = -1;
1969 int alpha_location = -1; 1970 int alpha_location = -1;
1970 if (use_alpha_plane) { 1971 if (use_alpha_plane) {
1971 const VideoYUVAProgram* program = GetVideoYUVAProgram(tex_coord_precision); 1972 const VideoYUVAProgram* program = GetVideoYUVAProgram(tex_coord_precision);
1972 DCHECK(program && (program->initialized() || IsContextLost())); 1973 DCHECK(program && (program->initialized() || IsContextLost()));
1973 SetUseProgram(program->program()); 1974 SetUseProgram(program->program());
1974 matrix_location = program->vertex_shader().matrix_location(); 1975 matrix_location = program->vertex_shader().matrix_location();
1975 tex_scale_location = program->vertex_shader().tex_scale_location(); 1976 tex_scale_location = program->vertex_shader().tex_scale_location();
1976 tex_offset_location = program->vertex_shader().tex_offset_location(); 1977 tex_offset_location = program->vertex_shader().tex_offset_location();
1977 y_texture_location = program->fragment_shader().y_texture_location(); 1978 y_texture_location = program->fragment_shader().y_texture_location();
1978 u_texture_location = program->fragment_shader().u_texture_location(); 1979 u_texture_location = program->fragment_shader().u_texture_location();
1979 v_texture_location = program->fragment_shader().v_texture_location(); 1980 v_texture_location = program->fragment_shader().v_texture_location();
1980 a_texture_location = program->fragment_shader().a_texture_location(); 1981 a_texture_location = program->fragment_shader().a_texture_location();
1981 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); 1982 yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
1982 yuv_adj_location = program->fragment_shader().yuv_adj_location(); 1983 yuv_adj_location = program->fragment_shader().yuv_adj_location();
1983 clamp_rect_location = program->fragment_shader().clamp_rect_location(); 1984 ya_clamp_rect_location =
1985 program->fragment_shader().ya_clamp_rect_location();
1986 uv_clamp_rect_location =
1987 program->fragment_shader().uv_clamp_rect_location();
1984 alpha_location = program->fragment_shader().alpha_location(); 1988 alpha_location = program->fragment_shader().alpha_location();
1985 } else { 1989 } else {
1986 const VideoYUVProgram* program = GetVideoYUVProgram(tex_coord_precision); 1990 const VideoYUVProgram* program = GetVideoYUVProgram(tex_coord_precision);
1987 DCHECK(program && (program->initialized() || IsContextLost())); 1991 DCHECK(program && (program->initialized() || IsContextLost()));
1988 SetUseProgram(program->program()); 1992 SetUseProgram(program->program());
1989 matrix_location = program->vertex_shader().matrix_location(); 1993 matrix_location = program->vertex_shader().matrix_location();
1990 tex_scale_location = program->vertex_shader().tex_scale_location(); 1994 tex_scale_location = program->vertex_shader().tex_scale_location();
1991 tex_offset_location = program->vertex_shader().tex_offset_location(); 1995 tex_offset_location = program->vertex_shader().tex_offset_location();
1992 y_texture_location = program->fragment_shader().y_texture_location(); 1996 y_texture_location = program->fragment_shader().y_texture_location();
1993 u_texture_location = program->fragment_shader().u_texture_location(); 1997 u_texture_location = program->fragment_shader().u_texture_location();
1994 v_texture_location = program->fragment_shader().v_texture_location(); 1998 v_texture_location = program->fragment_shader().v_texture_location();
1995 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); 1999 yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
1996 yuv_adj_location = program->fragment_shader().yuv_adj_location(); 2000 yuv_adj_location = program->fragment_shader().yuv_adj_location();
1997 clamp_rect_location = program->fragment_shader().clamp_rect_location(); 2001 ya_clamp_rect_location =
2002 program->fragment_shader().ya_clamp_rect_location();
2003 uv_clamp_rect_location =
2004 program->fragment_shader().uv_clamp_rect_location();
1998 alpha_location = program->fragment_shader().alpha_location(); 2005 alpha_location = program->fragment_shader().alpha_location();
1999 } 2006 }
2000 2007
2001 GLC(gl_, 2008 GLC(gl_,
2002 gl_->Uniform2f(tex_scale_location, 2009 gl_->Uniform2f(tex_scale_location,
2003 quad->tex_coord_rect.width(), 2010 quad->tex_coord_rect.width(),
2004 quad->tex_coord_rect.height())); 2011 quad->tex_coord_rect.height()));
2005 GLC(gl_, 2012 GLC(gl_,
2006 gl_->Uniform2f(tex_offset_location, 2013 gl_->Uniform2f(tex_offset_location,
2007 quad->tex_coord_rect.x(), 2014 quad->tex_coord_rect.x(),
2008 quad->tex_coord_rect.y())); 2015 quad->tex_coord_rect.y()));
2009 // Clamping to half a texel inside the tex coord rect prevents bilinear 2016 // Clamping to half a texel inside the tex coord rect prevents bilinear
2010 // filtering from filtering outside the tex coord rect. 2017 // filtering from filtering outside the tex coord rect.
2011 gfx::RectF clamp_rect(quad->tex_coord_rect); 2018 gfx::RectF ya_clamp_rect(quad->tex_coord_rect);
2012 // Special case: empty texture size implies no clamping. 2019 // Special case: empty texture size implies no clamping.
2013 if (!quad->tex_size.IsEmpty()) { 2020 if (!quad->ya_tex_size.IsEmpty()) {
2014 clamp_rect.Inset(0.5f / quad->tex_size.width(), 2021 ya_clamp_rect.Inset(0.5f / quad->ya_tex_size.width(),
2015 0.5f / quad->tex_size.height()); 2022 0.5f / quad->ya_tex_size.height());
2016 } 2023 }
2017 GLC(gl_, gl_->Uniform4f(clamp_rect_location, clamp_rect.x(), clamp_rect.y(), 2024 gfx::RectF uv_clamp_rect(quad->tex_coord_rect);
2018 clamp_rect.right(), clamp_rect.bottom())); 2025 if (!quad->uv_tex_size.IsEmpty()) {
2026 uv_clamp_rect.Inset(0.5f / quad->uv_tex_size.width(),
2027 0.5f / quad->uv_tex_size.height());
2028 }
2029 GLC(gl_, gl_->Uniform4f(ya_clamp_rect_location, ya_clamp_rect.x(),
2030 ya_clamp_rect.y(), ya_clamp_rect.right(),
2031 ya_clamp_rect.bottom()));
2032 GLC(gl_, gl_->Uniform4f(uv_clamp_rect_location, uv_clamp_rect.x(),
2033 uv_clamp_rect.y(), uv_clamp_rect.right(),
2034 uv_clamp_rect.bottom()));
2019 2035
2020 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); 2036 GLC(gl_, gl_->Uniform1i(y_texture_location, 1));
2021 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); 2037 GLC(gl_, gl_->Uniform1i(u_texture_location, 2));
2022 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); 2038 GLC(gl_, gl_->Uniform1i(v_texture_location, 3));
2023 if (use_alpha_plane) 2039 if (use_alpha_plane)
2024 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); 2040 GLC(gl_, gl_->Uniform1i(a_texture_location, 4));
2025 2041
2026 // These values are magic numbers that are used in the transformation from YUV 2042 // These values are magic numbers that are used in the transformation from YUV
2027 // to RGB color values. They are taken from the following webpage: 2043 // to RGB color values. They are taken from the following webpage:
2028 // http://www.fourcc.org/fccyvrgb.php 2044 // http://www.fourcc.org/fccyvrgb.php
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
3522 context_support_->ScheduleOverlayPlane( 3538 context_support_->ScheduleOverlayPlane(
3523 overlay.plane_z_order, 3539 overlay.plane_z_order,
3524 overlay.transform, 3540 overlay.transform,
3525 pending_overlay_resources_.back()->texture_id(), 3541 pending_overlay_resources_.back()->texture_id(),
3526 overlay.display_rect, 3542 overlay.display_rect,
3527 overlay.uv_rect); 3543 overlay.uv_rect);
3528 } 3544 }
3529 } 3545 }
3530 3546
3531 } // namespace cc 3547 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/video_layer_impl.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698