Commit 8dc4d905 authored by Jonah Chin's avatar Jonah Chin Committed by Chromium LUCI CQ

Revert "Introduce mailbox-based version of VideoTextureBacking"

This reverts commit 0c93bcb5.

Reason for revert: An earlier change is causing a canvas video issue.
This change depends on that change. Reverting both changes until the
bug is resolved. See crbug.com/1164407.

Original change's description:
> Introduce mailbox-based version of VideoTextureBacking
>
> This CL introduces an OOPR compatible version of VideoTextureBacking and
> updates PaintCanvasVideoRenderer::UpdateLastImage() to use this new
> version in the OOPR codepath.
>
> More details about overall PaintImage effort: crbug.com/1023259
> Info about the OOPR-Canvas2D project: crbug.com/1018894
>
> Bug: 1115217
> Change-Id: I4590cf16d6faef0e5575b0b4006ea88de89aa13d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419653
> Reviewed-by: Khushal <khushalsagar@chromium.org>
> Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
> Commit-Queue: Jonah Chin <jochin@microsoft.com>
> Cr-Commit-Position: refs/heads/master@{#826449}

TBR=dalecurtis@chromium.org,khushalsagar@chromium.org,jochin@microsoft.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1115217
Change-Id: I3b1d370e7048eee9d8885651ee0e68b342340b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623174Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarJonah Chin <jochin@microsoft.com>
Commit-Queue: Jonah Chin <jochin@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#842354}
parent 670336f2
......@@ -298,6 +298,11 @@ void PaintImage::FlushPendingSkiaOps() {
texture_backing_->FlushPendingSkiaOps();
}
bool PaintImage::HasExclusiveTextureAccess() const {
DCHECK(IsTextureBacked());
return texture_backing_->unique();
}
int PaintImage::width() const {
return paint_worklet_input_
? static_cast<int>(paint_worklet_input_->GetSize().width())
......
......@@ -239,11 +239,10 @@ class CC_PAINT_EXPORT PaintImage {
int src_x,
int src_y) const;
// Returned mailbox must not outlive this PaintImage.
gpu::Mailbox GetMailbox() const;
SkImageInfo GetSkImageInfo() const;
Id stable_id() const { return id_; }
SkImageInfo GetSkImageInfo() const;
gpu::Mailbox GetMailbox() const;
AnimationType animation_type() const { return animation_type_; }
CompletionState completion_state() const { return completion_state_; }
bool is_multipart() const { return is_multipart_; }
......@@ -266,6 +265,7 @@ class CC_PAINT_EXPORT PaintImage {
// Skia internally buffers commands and flushes them as necessary but there
// are some cases where we need to force a flush.
void FlushPendingSkiaOps();
bool HasExclusiveTextureAccess() const;
int width() const;
int height() const;
SkColorSpace* color_space() const {
......
......@@ -1515,14 +1515,9 @@ void DrawImageOp::RasterWithFlags(const DrawImageOp* op,
canvas->scale(1.f / op->scale_adjustment.width(),
1.f / op->scale_adjustment.height());
}
sk_sp<SkImage> sk_image;
if (op->image.IsTextureBacked()) {
sk_image = op->image.GetAcceleratedSkImage();
DCHECK(sk_image || !canvas->recordingContext());
}
if (!sk_image)
sk_image = op->image.GetSwSkImage();
auto sk_image = op->image.IsTextureBacked()
? op->image.GetAcceleratedSkImage()
: op->image.GetSwSkImage();
canvas->drawImage(sk_image.get(), op->left, op->top, &paint);
return;
}
......@@ -1594,13 +1589,9 @@ void DrawImageRectOp::RasterWithFlags(const DrawImageRectOp* op,
if (!params.image_provider) {
SkRect adjusted_src = AdjustSrcRectForScale(op->src, op->scale_adjustment);
flags->DrawToSk(canvas, [op, adjusted_src](SkCanvas* c, const SkPaint& p) {
sk_sp<SkImage> sk_image;
if (op->image.IsTextureBacked()) {
sk_image = op->image.GetAcceleratedSkImage();
DCHECK(sk_image || !c->recordingContext());
}
if (!sk_image)
sk_image = op->image.GetSwSkImage();
auto sk_image = op->image.IsTextureBacked()
? op->image.GetAcceleratedSkImage()
: op->image.GetSwSkImage();
c->drawImageRect(sk_image.get(), adjusted_src, op->dst, &p,
op->constraint);
});
......
......@@ -1351,10 +1351,8 @@ void WebMediaPlayerImpl::Paint(cc::PaintCanvas* canvas,
if (video_frame && video_frame->HasTextures()) {
if (!raster_context_provider_)
return; // Unable to get/create a shared main thread context.
if (!raster_context_provider_->GrContext() &&
!raster_context_provider_->ContextCapabilities().supports_oop_raster) {
return; // The context has been lost.
}
if (!raster_context_provider_->GrContext())
return; // The context has been lost since and can't setup a GrContext.
}
if (out_metadata && video_frame) {
// WebGL last-uploaded-frame-metadata API enabled. https://crbug.com/639174
......
......@@ -41,7 +41,6 @@ class RasterContextProvider;
}
namespace media {
class VideoTextureBacking;
// Handles rendering of VideoFrames to PaintCanvases.
class MEDIA_EXPORT PaintCanvasVideoRenderer {
......@@ -212,15 +211,22 @@ class MEDIA_EXPORT PaintCanvasVideoRenderer {
// to the visible size of the VideoFrame. Its contents are generated lazily.
cc::PaintImage paint_image;
// The backing for the source texture. This is also responsible for managing
// the lifetime of the texture.
sk_sp<VideoTextureBacking> texture_backing;
// The context provider used to generate |source_mailbox| and
// |source_texture|. This is only set if the VideoFrame was texture-backed.
scoped_refptr<viz::RasterContextProvider> raster_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 GL texture ID used in non-OOP code path.
// The texture ID created when importing |source_mailbox|.
// This is only set if the VideoFrame was texture-backed.
uint32_t source_texture = 0;
// The allocated size of VideoFrame texture.
// The allocated size of |source_mailbox|.
// This is only set if the VideoFrame was texture-backed.
gfx::Size coded_size;
......@@ -229,6 +235,10 @@ class MEDIA_EXPORT PaintCanvasVideoRenderer {
// This is only set if the VideoFrame was texture-backed.
gfx::Rect visible_rect;
// 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;
// Used to allow recycling of the previous shared image. This requires that
// no external users have access to this resource via SkImage. Returns true
// if the existing resource can be recycled.
......@@ -256,8 +266,6 @@ class MEDIA_EXPORT PaintCanvasVideoRenderer {
unsigned int type,
bool flip_y);
bool CacheBackingWrapsTexture() const;
base::Optional<Cache> cache_;
// If |cache_| is not used for a while, it's deleted to save memory.
......
......@@ -377,8 +377,8 @@ gpu::ContextSupport* ContextProviderCommandBuffer::ContextSupport() {
class GrDirectContext* ContextProviderCommandBuffer::GrContext() {
DCHECK(bind_tried_);
DCHECK_EQ(bind_result_, gpu::ContextResult::kSuccess);
if (!support_grcontext_ || !ContextSupport()->HasGrContextSupport())
return nullptr;
DCHECK(support_grcontext_);
DCHECK(ContextSupport()->HasGrContextSupport());
CheckValidThreadOrLockAcquired();
if (gr_context_)
......
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