Commit c09dad4d authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Add PaintCanvasVideoRenderer tests and fix issue with implicit copy

Add a bunch of new tests to cover CopyVideoFrameTexturesToGLTexture and
Paint/Copy for when the source VideoFrame contains GPU textures.

This uncovered an issue where in one particular case the frame was
incorrectly cropped twice when copying a RGBA texture frame, which this
patch also fixes.

Bug: 969201
Change-Id: Id402a85840397522cd6b5c5e44bfe03abdc90f0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1697529
Auto-Submit: Antoine Labour <piman@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676617}
parent 785b4708
......@@ -307,6 +307,9 @@ sk_sp<SkImage> NewSkImageFromVideoFrameNative(
<< mailbox_holder.texture_target;
gpu::gles2::GLES2Interface* gl = context_provider->ContextGL();
gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData());
GLuint frame_texture =
gl->CreateAndConsumeTextureCHROMIUM(mailbox_holder.mailbox.name);
unsigned source_texture = 0;
gfx::ColorSpace color_space_for_skia;
*wrapped_video_frame_texture =
......@@ -314,9 +317,7 @@ sk_sp<SkImage> NewSkImageFromVideoFrameNative(
if (*wrapped_video_frame_texture) {
// Fast path where we can avoid a copy, by having last_image_ directly wrap
// the VideoFrame texture.
gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData());
source_texture =
gl->CreateAndConsumeTextureCHROMIUM(mailbox_holder.mailbox.name);
source_texture = frame_texture;
color_space_for_skia = video_frame->ColorSpace();
} else {
// TODO(dcastagna): At the moment Skia doesn't support targets different
......@@ -326,9 +327,9 @@ sk_sp<SkImage> NewSkImageFromVideoFrameNative(
gl->GenTextures(1, &source_texture);
DCHECK(source_texture);
gl->BindTexture(GL_TEXTURE_2D, source_texture);
PaintCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture(
gl, video_frame, GL_TEXTURE_2D, source_texture, GL_RGBA, GL_RGBA,
GL_UNSIGNED_BYTE, 0, false, false);
gl->CopyTextureCHROMIUM(frame_texture, 0, GL_TEXTURE_2D, source_texture, 0,
GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
gl->DeleteTextures(1, &frame_texture);
}
GrGLTextureInfo source_texture_info;
source_texture_info.fID = source_texture;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment