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

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

Powered by Google App Engine
This is Rietveld 408576698