Skip to content

Commit

Permalink
Introduce mailbox-based version of VideoTextureBacking
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
Jonah Chin authored and Commit Bot committed Nov 11, 2020
1 parent e18cee6 commit 0c93bcb
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 126 deletions.
5 changes: 0 additions & 5 deletions cc/paint/paint_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,6 @@ 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())
Expand Down
6 changes: 3 additions & 3 deletions cc/paint/paint_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ class CC_PAINT_EXPORT PaintImage {
int src_x,
int src_y) const;

SkImageInfo GetSkImageInfo() const;
// Returned mailbox must not outlive this PaintImage.
gpu::Mailbox GetMailbox() const;

Id stable_id() const { return id_; }
const sk_sp<SkImage>& GetSkImage() const;
gpu::Mailbox GetMailbox() const;
SkImageInfo GetSkImageInfo() const;
AnimationType animation_type() const { return animation_type_; }
CompletionState completion_state() const { return completion_state_; }
bool is_multipart() const { return is_multipart_; }
Expand All @@ -262,7 +263,6 @@ 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 {
Expand Down
21 changes: 15 additions & 6 deletions cc/paint/paint_op_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1431,9 +1431,14 @@ void DrawImageOp::RasterWithFlags(const DrawImageOp* op,
canvas->scale(1.f / op->scale_adjustment.width(),
1.f / op->scale_adjustment.height());
}
auto sk_image = op->image.IsTextureBacked()
? op->image.GetAcceleratedSkImage()
: op->image.GetSwSkImage();
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();

canvas->drawImage(sk_image.get(), op->left, op->top, &paint);
return;
}
Expand Down Expand Up @@ -1505,9 +1510,13 @@ 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) {
auto sk_image = op->image.IsTextureBacked()
? op->image.GetAcceleratedSkImage()
: op->image.GetSwSkImage();
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();
c->drawImageRect(sk_image.get(), adjusted_src, op->dst, &p,
op->constraint);
});
Expand Down
5 changes: 3 additions & 2 deletions media/blink/webmediaplayer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1347,8 +1347,9 @@ 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())
return; // The context has been lost since and can't setup a GrContext.
DCHECK(
raster_context_provider_->ContextCapabilities().supports_oop_raster ||
raster_context_provider_->GrContext());
}
if (out_metadata && video_frame) {
// WebGL last-uploaded-frame-metadata API enabled. https://crbug.com/639174
Expand Down
Loading

0 comments on commit 0c93bcb

Please sign in to comment.