Commit 9794f876 authored by Nathan Zabriskie's avatar Nathan Zabriskie Committed by Commit Bot

Update CanvasResourceProvider::WritePixels to work with OOPR

Currently CanvasResourceProvider::WritePixels writes directly to
SkCanvas but this won't work with OOPR Canvas which won't have access to
Skia in the renderer process. This CL adds an override for
CanvasResourceProviderSharedImage which checks for OOP support and calls
RasterInterface::WritePixels if it's in use.

Bug: 1063725
Change-Id: Ib2ebfe48c3c5b837caf242b1e64c926287072b00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2239763Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Commit-Queue: Nathan Zabriskie <nazabris@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#777253}
parent 3f86fb2f
...@@ -422,12 +422,14 @@ bool Canvas2DLayerBridge::WritePixels(const SkImageInfo& orig_info, ...@@ -422,12 +422,14 @@ bool Canvas2DLayerBridge::WritePixels(const SkImageInfo& orig_info,
if (!GetOrCreateResourceProvider()) if (!GetOrCreateResourceProvider())
return false; return false;
} }
last_record_tainted_by_write_pixels_ = true;
have_recorded_draw_commands_ = false; have_recorded_draw_commands_ = false;
ResourceProvider()->WritePixels(orig_info, pixels, row_bytes, x, y); bool wrote_pixels =
return true; ResourceProvider()->WritePixels(orig_info, pixels, row_bytes, x, y);
if (wrote_pixels)
last_record_tainted_by_write_pixels_ = true;
return wrote_pixels;
} }
void Canvas2DLayerBridge::SkipQueuedDrawCommands() { void Canvas2DLayerBridge::SkipQueuedDrawCommands() {
......
...@@ -238,6 +238,26 @@ class CanvasResourceProviderSharedImage : public CanvasResourceProvider { ...@@ -238,6 +238,26 @@ class CanvasResourceProviderSharedImage : public CanvasResourceProvider {
return resource()->TextureTarget(); return resource()->TextureTarget();
} }
bool WritePixels(const SkImageInfo& orig_info,
const void* pixels,
size_t row_bytes,
int x,
int y) override {
if (!use_oop_rasterization_) {
return CanvasResourceProvider::WritePixels(orig_info, pixels, row_bytes,
x, y);
}
TRACE_EVENT0("blink", "CanvasResourceProviderSharedImage::WritePixels");
if (IsGpuContextLost())
return false;
RasterInterface()->WritePixels(
GetBackingMailboxForOverwrite(kOrderingBarrier), x, y,
GetBackingTextureTarget(), row_bytes, orig_info, pixels);
return true;
}
scoped_refptr<CanvasResource> CreateResource() final { scoped_refptr<CanvasResource> CreateResource() final {
TRACE_EVENT0("blink", "CanvasResourceProviderSharedImage::CreateResource"); TRACE_EVENT0("blink", "CanvasResourceProviderSharedImage::CreateResource");
if (IsGpuContextLost()) if (IsGpuContextLost())
......
...@@ -178,11 +178,11 @@ class PLATFORM_EXPORT CanvasResourceProvider ...@@ -178,11 +178,11 @@ class PLATFORM_EXPORT CanvasResourceProvider
SkSurface* GetSkSurface() const; SkSurface* GetSkSurface() const;
bool IsGpuContextLost() const; bool IsGpuContextLost() const;
bool WritePixels(const SkImageInfo& orig_info, virtual bool WritePixels(const SkImageInfo& orig_info,
const void* pixels, const void* pixels,
size_t row_bytes, size_t row_bytes,
int x, int x,
int y); int y);
virtual gpu::Mailbox GetBackingMailboxForOverwrite( virtual gpu::Mailbox GetBackingMailboxForOverwrite(
MailboxSyncMode sync_mode) { MailboxSyncMode sync_mode) {
......
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