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

Unified Diff: cc/output/gl_renderer.cc

Issue 1852923002: Enable sampling from DXGI NV12 formats in GLRenderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 47b851fee26b2ac43b2e891ed959317d4690a157..fd886e28edbf461bc206af33ce4b7ee42c286da7 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -1965,15 +1965,23 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
quad->shared_quad_state->visible_quad_layer_rect.bottom_right());
bool use_alpha_plane = quad->a_plane_resource_id() != 0;
+ bool use_nv12 = quad->v_plane_resource_id() == quad->u_plane_resource_id();
+
+ if (use_nv12 && use_alpha_plane)
+ return;
danakj 2016/04/11 23:28:28 do you mean dcheck?
ResourceProvider::ScopedSamplerGL y_plane_lock(
resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR);
ResourceProvider::ScopedSamplerGL u_plane_lock(
resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_LINEAR);
DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target());
- ResourceProvider::ScopedSamplerGL v_plane_lock(
- resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3, GL_LINEAR);
- DCHECK_EQ(y_plane_lock.target(), v_plane_lock.target());
+ scoped_ptr<ResourceProvider::ScopedSamplerGL> v_plane_lock;
danakj 2016/04/11 23:28:28 TODO to use base::Optional, no need for mallocs he
+ if (!use_nv12) {
+ v_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
+ resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3,
+ GL_LINEAR));
+ DCHECK_EQ(y_plane_lock.target(), v_plane_lock->target());
+ }
scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock;
if (use_alpha_plane) {
a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL(
@@ -2020,7 +2028,7 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
uv_clamp_rect_location =
program->fragment_shader().uv_clamp_rect_location();
alpha_location = program->fragment_shader().alpha_location();
- } else {
+ } else if (!use_nv12) {
const VideoYUVProgram* program =
GetVideoYUVProgram(tex_coord_precision, sampler);
DCHECK(program && (program->initialized() || IsContextLost()));
@@ -2040,6 +2048,25 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
uv_clamp_rect_location =
program->fragment_shader().uv_clamp_rect_location();
alpha_location = program->fragment_shader().alpha_location();
+ } else {
+ const VideoNV12Program* program =
+ GetVideoNV12Program(tex_coord_precision, sampler);
+ DCHECK(program && (program->initialized() || IsContextLost()));
+ SetUseProgram(program->program());
+ matrix_location = program->vertex_shader().matrix_location();
+ ya_tex_scale_location = program->vertex_shader().ya_tex_scale_location();
+ ya_tex_offset_location = program->vertex_shader().ya_tex_offset_location();
+ uv_tex_scale_location = program->vertex_shader().uv_tex_scale_location();
+ uv_tex_offset_location = program->vertex_shader().uv_tex_offset_location();
+ y_texture_location = program->fragment_shader().y_texture_location();
+ u_texture_location = program->fragment_shader().uv_texture_location();
+ yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
+ yuv_adj_location = program->fragment_shader().yuv_adj_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();
}
gfx::SizeF ya_tex_scale(1.0f, 1.0f);
@@ -2095,7 +2122,8 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
gl_->Uniform1i(y_texture_location, 1);
gl_->Uniform1i(u_texture_location, 2);
- gl_->Uniform1i(v_texture_location, 3);
+ if (!use_nv12)
+ gl_->Uniform1i(v_texture_location, 3);
if (use_alpha_plane)
gl_->Uniform1i(a_texture_location, 4);
@@ -3407,6 +3435,22 @@ const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram(
return program;
}
+const GLRenderer::VideoNV12Program* GLRenderer::GetVideoNV12Program(
danakj 2016/04/11 23:28:28 This program should be tested in our unit tests th
+ TexCoordPrecision precision,
+ SamplerType sampler) {
+ DCHECK_GE(precision, 0);
+ DCHECK_LE(precision, LAST_TEX_COORD_PRECISION);
+ DCHECK_GE(sampler, 0);
+ DCHECK_LE(sampler, LAST_SAMPLER_TYPE);
+ VideoNV12Program* program = &video_nv12_program_[precision][sampler];
+ if (!program->initialized()) {
+ TRACE_EVENT0("cc", "GLRenderer::videoNV12Program::initialize");
+ program->Initialize(output_surface_->context_provider(), precision,
+ sampler);
+ }
+ return program;
+}
+
const GLRenderer::VideoYUVAProgram* GLRenderer::GetVideoYUVAProgram(
TexCoordPrecision precision,
SamplerType sampler) {
@@ -3460,6 +3504,7 @@ void GLRenderer::CleanupSharedObjects() {
video_yuv_program_[i][j].Cleanup(gl_);
video_yuva_program_[i][j].Cleanup(gl_);
+ video_nv12_program_[i][j].Cleanup(gl_);
}
for (int j = 0; j <= LAST_BLEND_MODE; j++) {
render_pass_program_[i][j].Cleanup(gl_);
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/shader.h » ('j') | cc/output/shader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698