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

Unified Diff: cc/output/gl_renderer.cc

Issue 2121043002: 16 bpp video stream capture, render and WebGL usage - Realsense R200 & SR300 support. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 2 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 | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index ac68a08c62f622ed275cca567de070aa52845e20..ecf4dac925181dae49d0468b390ed6b4ccd727a4 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -599,6 +599,9 @@ void GLRenderer::DoDrawQuad(DrawingFrame* frame,
DrawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad),
clip_region);
break;
+ case DrawQuad::Y_VIDEO_CONTENT:
+ DrawYVideoQuad(frame, YVideoDrawQuad::MaterialCast(quad), clip_region);
+ break;
}
}
@@ -2453,6 +2456,65 @@ void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
}
}
+void GLRenderer::DrawYVideoQuad(const DrawingFrame* frame,
+ const YVideoDrawQuad* quad,
+ const gfx::QuadF* clip_region) {
+ SetBlendEnabled(quad->ShouldDrawWithBlending());
+ TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
+ gl_, &highp_threshold_cache_, highp_threshold_min_,
+ quad->shared_quad_state->visible_quad_layer_rect.bottom_right());
+
+ ResourceProvider::ScopedReadLockGL lock(resource_provider_,
+ quad->resource_id());
+ const SamplerType sampler = SamplerTypeFromTextureTarget(lock.target());
+ DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
+ gl_->BindTexture(lock.target(), lock.texture_id());
+
+ const VideoYProgram* program = GetVideoYProgram(tex_coord_precision, sampler);
+ DCHECK(program && (program->initialized() || IsContextLost()));
+ SetUseProgram(program->program());
+
+ // Set the uv-transform.
+ Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}};
+ if (!clip_region) {
+ gfx::PointF uv0 = quad->uv_top_left;
+ gfx::PointF uv1 = quad->uv_bottom_right;
+ uv_transform = {{uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y()}};
+ }
+ gfx::Size texture_size = lock.size();
+ if (sampler == SAMPLER_TYPE_2D_RECT) {
+ // Un-normalize the texture coordiantes for rectangle targets.
+ uv_transform.data[0] *= texture_size.width();
+ uv_transform.data[2] *= texture_size.width();
+ uv_transform.data[1] *= texture_size.height();
+ uv_transform.data[3] *= texture_size.height();
+ }
+ gl_->Uniform4fv(program->vertex_shader().tex_transform_location(), 1,
+ uv_transform.data);
+ gl_->Uniform1i(program->fragment_shader().sampler_location(), 0);
+ gl_->Uniform1f(program->fragment_shader().x_derivative_location(),
+ 1.f / (float)texture_size.width());
+ gl_->Uniform1f(program->fragment_shader().y_derivative_location(),
+ 1.f / (float)texture_size.height());
+
+ if (!clip_region) {
+ DrawQuadGeometry(frame->projection_matrix,
+ quad->shared_quad_state->quad_to_target_transform,
+ gfx::RectF(quad->rect),
+ program->vertex_shader().matrix_location());
+ } else {
+ gfx::QuadF region_quad(*clip_region);
+ region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height());
+ region_quad -= gfx::Vector2dF(0.5f, 0.5f);
+ float uvs[8] = {0};
+ GetScaledUVs(quad->visible_rect, clip_region, uvs);
+ DrawQuadGeometryClippedByQuadF(
+ frame, quad->shared_quad_state->quad_to_target_transform,
+ gfx::RectF(quad->rect), region_quad,
+ program->vertex_shader().matrix_location(), uvs);
+ }
+}
+
void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
const StreamVideoDrawQuad* quad,
const gfx::QuadF* clip_region) {
@@ -3652,6 +3714,22 @@ const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram(
return program;
}
+const GLRenderer::VideoYProgram* GLRenderer::GetVideoYProgram(
+ 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);
+ VideoYProgram* program = &video_y_program_[precision][sampler];
+ if (!program->initialized()) {
+ TRACE_EVENT0("cc", "GLRenderer::videoYProgram::initialize");
+ program->Initialize(output_surface_->context_provider(), precision,
+ sampler);
+ }
+ return program;
+}
+
const GLRenderer::VideoStreamTextureProgram*
GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) {
DCHECK_GE(precision, 0);
@@ -3707,6 +3785,7 @@ void GLRenderer::CleanupSharedObjects() {
nonpremultiplied_texture_program_[i][j].Cleanup(gl_);
texture_background_program_[i][j].Cleanup(gl_);
nonpremultiplied_texture_background_program_[i][j].Cleanup(gl_);
+ video_y_program_[i][j].Cleanup(gl_);
}
video_stream_texture_program_[i].Cleanup(gl_);
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698