New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 787039 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Feature

Blocking:
issue 634542
issue 785389
issue 826878



Sign in to add a comment

Refactor CanvasAsyncBlobCreator to use StaticBitmapImage

Project Member Reported by zakerinasab@chromium.org, Nov 20 2017

Issue description

HTMLCanvasElement and OffscreenCanvas toDataURL() and toBlob() functions essentially work as follows:

- make a snapshot,
- create an ImageData from snapshot, 
- send the ImageData to CanvasAsyncBlobCreator for encoding. 

However, CanvasAsyncBlobCreator is now using Skia encoders, which means we can remove the intermediate snapshot to ImageData conversion. By refactoring CanvasAsyncBlobCreator to do so, we gain a couple of benefits: the color information is plumbed automatically, the code gets significantly simplified, and we save memory and CPU cycles by removing ImageData from the pipeline. 

 
Comment by junov@:

One thing to be careful about: There are cases where the encode is delegated to a background thread.  SkImages that are on the gpu cannot be accessed from a separate thread.  The simplest solution I can think of is to hold the image as a RefPtr<StaticBitmapImage> instead of a raw SkImage.  That way, you can just call StaticBitmapImage::Transfer before posting the encoding task to another thread.  That should be all you need to do.  If the image is accelerated, Transfer() will put the resource into a texture mailbox. Then, on the encoder thread, when you call PaintImageForCurrentFrame() as you would to obtain an SkImage, the mailbox will be automatically consumed under the hood.  This also has the advantage of pushing the blocking GPU readback operation onto the background thread.
Summary: Refactor CanvasAsyncBlobCreator to use StaticBitmapImage (was: Refactor CanvasAsyncBlobCreator() to use StaticBitmapImage)
Blocking: 634542
Project Member

Comment 4 by bugdroid1@chromium.org, Dec 5 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6e0ab6ae54cc837abd96024dae5595a8d299e7b8

commit 6e0ab6ae54cc837abd96024dae5595a8d299e7b8
Author: Reza.Zakerinasab <zakerinasab@chromium.org>
Date: Tue Dec 05 16:37:10 2017

Refactor CanvasAsyncBlobCreator to use StaticBitmapImage

This change refactors CanvasAsyncBlobCreator to remove the intermediate
ImageData object and use StaticBitmapImage directly.

Bug:  787039 
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I8b49cfc455a50a06a83ebc3dc3c6f418346be4db
Reviewed-on: https://chromium-review.googlesource.com/780279
Commit-Queue: Mohammad Reza Zakerinasab <zakerinasab@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Olivia Lai <xlai@chromium.org>
Reviewed-by: Justin Novosad <junov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521715}
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/core/html/HTMLCanvasElement.h
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.h
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreatorTest.cpp
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
[modify] https://crrev.com/6e0ab6ae54cc837abd96024dae5595a8d299e7b8/third_party/WebKit/Source/platform/graphics/ImageBuffer.h

Status: Fixed (was: Assigned)

Comment 6 by kbr@chromium.org, Apr 2 2018

Blocking: 826878

Sign in to add a comment