| Index: cc/output/gl_renderer.cc
|
| diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
|
| index 6803b2ac1ee9500e5316efc39b93c19b9d2c73cd..d0835d1dbae5426873c7a17da4f81e01c39cf8a4 100644
|
| --- a/cc/output/gl_renderer.cc
|
| +++ b/cc/output/gl_renderer.cc
|
| @@ -545,6 +545,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;
|
| }
|
| }
|
|
|
| @@ -2323,6 +2326,64 @@ 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::ScopedSamplerGL lock(resource_provider_,
|
| + quad->resource_id(),
|
| + GL_NEAREST);
|
| + const SamplerType sampler = SamplerTypeFromTextureTarget(lock.target());
|
| + DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
|
| + gl_->BindTexture(lock.target(), lock.texture_id());
|
| +
|
| + // TODO(astojilj) TextureProgram could also be used - just remember to set
|
| + // varying v_alpha.
|
| + 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() } };
|
| + }
|
| + if (sampler == SAMPLER_TYPE_2D_RECT) {
|
| + // Un-normalize the texture coordiantes for rectangle targets.
|
| + gfx::Size texture_size = lock.texture_size();
|
| + 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);
|
| +
|
| + if (!clip_region) {
|
| + DrawQuadGeometry(frame, 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) {
|
| @@ -3555,6 +3616,22 @@ const GLRenderer::VideoYUVAProgram* GLRenderer::GetVideoYUVAProgram(
|
| 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);
|
| @@ -3606,6 +3683,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_);
|
|
|