Commit 93f4ddb1 authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Migrate PaintCanvasVideoRenderer to shared images

This CL ensures:
- VideoFrame mailboxes are imported using the
  CreateAndTexStorage2DSharedImage API if they are shared images, and
  that the Begin/EndSharedImageAccessDirect scope are properly used.
- Intermediate copies are allocated as shared images instead of
  internally to skia.

The cache is modified to track the mailbox for the source texture,
rather than a SkImage, to be able to import it into multiple contexts.
Also the cached shared image is reused if possible (same context
provider, same size) to reflect equivalent skia optimizations (SkImage
pooling).

Note: this CL doesn't cover PrepareVideoFrameForWebGL, used for the
(still experimental) WEBGL_video_texture extension, which requires a
fairly significant refactoring all the way to WebGL bindings to support
shared image.

Bug: 882547
Change-Id: I77b374526f3617db0fd936ffa5b71885e2c8fab3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1616978
Commit-Queue: Antoine Labour <piman@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Auto-Submit: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680021}
parent a02ac85b
......@@ -17,6 +17,7 @@
#include "cc/paint/paint_canvas.h"
#include "cc/paint/paint_flags.h"
#include "cc/paint/paint_image.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "media/base/media_export.h"
#include "media/base/timestamp_constants.h"
#include "media/base/video_frame.h"
......@@ -198,14 +199,22 @@ class MEDIA_EXPORT PaintCanvasVideoRenderer {
// to the visible size of the VideoFrame. Its contents are generated lazily.
cc::PaintImage paint_image;
// A SkImage that contain the source texture for |paint_image|. This can be
// either the source VideoFrame's texture (if wraps_video_frame_texture is
// true) or a newly allocated texture (if wraps_video_frame_texture is
// false) if a copy or conversion was necessary.
// The context provider used to generate |source_mailbox| and
// |source_texture|. This is only set if the VideoFrame was texture-backed.
scoped_refptr<viz::ContextProvider> context_provider;
// The mailbox for the source texture. This can be either the source
// VideoFrame's texture (if |wraps_video_frame_texture| is true) or a newly
// allocated shared image (if |wraps_video_frame_texture| is false) if a
// copy or conversion was necessary.
// This is only set if the VideoFrame was texture-backed.
gpu::Mailbox source_mailbox;
// The texture ID created when importing |source_mailbox|.
// This is only set if the VideoFrame was texture-backed.
sk_sp<SkImage> source_image;
uint32_t source_texture = 0;
// The allocated size of |source_image|.
// The allocated size of |source_mailbox|.
// This is only set if the VideoFrame was texture-backed.
gfx::Size coded_size;
......@@ -214,8 +223,8 @@ class MEDIA_EXPORT PaintCanvasVideoRenderer {
// This is only set if the VideoFrame was texture-backed.
gfx::Rect visible_rect;
// Whether |source_image| directly points to a texture of the VideoFrame
// (if true), or to an allocated texture (if false).
// Whether |source_mailbox| directly points to a texture of the VideoFrame
// (if true), or to an allocated shared image (if false).
bool wraps_video_frame_texture = false;
};
......
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