Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Issue 1355333005: Implement Asynchronous image encoding for Canvas.toBlob (Closed)

Created:
5 years, 3 months ago by xlai (Olivia)
Modified:
5 years ago
CC:
blink-reviews, kinuko+fileapi, nhiroki, tzik
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Implement Asynchronous image encoding for Canvas.toBlob Main thread creates a new thread to carry out the computation-intensive asynchronous image encoding operation. Afterwards the encoded image is passed back to the main thread to create blob and invoke user callback. Empty blob is passed to user callback in the senarios when the canvas has zero pixels or when the image encoding fails. This code review issue continues from the previous issue at https://codereview.chromium.org/1331443009/ before the blink and chromium are merged. BUG=523414 BUG=67587 Committed: https://crrev.com/9dcdf861954dd8294faf3eefde89ea228f99c322 Cr-Commit-Position: refs/heads/master@{#350910}

Patch Set 1 #

Patch Set 2 : Static Variables! #

Total comments: 1

Patch Set 3 : simplified race layout test; use DEFINE_STATIC_LOCAL #

Total comments: 1

Patch Set 4 : change according to feedback #

Total comments: 1

Patch Set 5 : Change async func to static so no need worry if canvas instance does not live long enough #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+227 lines, -28 lines) Patch
A third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-toDataURL-race-imageEncoder-jpeg.html View 1 2 1 chunk +21 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-toDataURL-race-imageEncoder-jpeg-expected.txt View 1 2 1 chunk +10 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-toDataURL-race-imageEncoder-png.html View 1 2 1 chunk +21 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-toDataURL-race-imageEncoder-png-expected.txt View 1 2 1 chunk +10 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-toDataURL-race-imageEncoder-webp.html View 1 2 1 chunk +21 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-toDataURL-race-imageEncoder-webp-expected.txt View 1 2 1 chunk +10 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-toBlob-toDataURL-race.js View 1 2 1 chunk +70 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/fileapi/File.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/fileapi/File.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/html/HTMLCanvasElement.h View 1 2 3 4 5 chunks +9 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp View 1 2 3 4 6 chunks +45 lines, -16 lines 1 comment Download
M third_party/WebKit/Source/platform/graphics/ImageBuffer.h View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp View 1 2 2 chunks +6 lines, -6 lines 0 comments Download

Messages

Total messages: 20 (6 generated)
xlai (Olivia)
5 years, 3 months ago (2015-09-24 20:01:08 UTC) #2
Justin Novosad
https://codereview.chromium.org/1355333005/diff/20001/third_party/WebKit/Source/core/html/HTMLCanvasElement.h File third_party/WebKit/Source/core/html/HTMLCanvasElement.h (right): https://codereview.chromium.org/1355333005/diff/20001/third_party/WebKit/Source/core/html/HTMLCanvasElement.h#newcode83 third_party/WebKit/Source/core/html/HTMLCanvasElement.h:83: static PassOwnPtr<WebThread> getToBlobThreadInstance(); This is not a proper use ...
5 years, 3 months ago (2015-09-24 20:51:31 UTC) #3
xlai (Olivia)
This time, I use DEFINE_STATIC_LOCAL for the static variable s_toBlobThread. There is no need to ...
5 years, 2 months ago (2015-09-25 16:40:18 UTC) #4
Justin Novosad
https://codereview.chromium.org/1355333005/diff/40001/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp File third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp (right): https://codereview.chromium.org/1355333005/diff/40001/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp#newcode142 third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp:142: return s_toBlobThread; Returning an "OwnPtr<WebThread>&" is not appropriate. The ...
5 years, 2 months ago (2015-09-25 16:47:34 UTC) #5
Justin Novosad
Why is there a third_party/WebKit/LayoutTests/platform/linux/fast/canvas/canvas-toBlob-toDataURL-race-imageEncoder-png-expected.png ?
5 years, 2 months ago (2015-09-25 16:49:25 UTC) #6
xlai (Olivia)
removed the expected.png file and changed the code accordingly.
5 years, 2 months ago (2015-09-25 18:46:33 UTC) #7
Justin Novosad
lgtm with nit https://codereview.chromium.org/1355333005/diff/60001/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp File third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp (right): https://codereview.chromium.org/1355333005/diff/60001/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp#newcode570 third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp:570: Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, threadSafeBind(&HTMLCanvasElement::createBlobAndCall, AllowCrossThreadAccess(this), encodedImage.release(), mimeType, AllowCrossThreadAccess(callback))); ...
5 years, 2 months ago (2015-09-25 18:57:10 UTC) #8
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1355333005/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1355333005/80001
5 years, 2 months ago (2015-09-25 19:16:40 UTC) #10
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years, 2 months ago (2015-09-25 20:54:02 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1355333005/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1355333005/80001
5 years, 2 months ago (2015-09-25 20:55:33 UTC) #15
commit-bot: I haz the power
Committed patchset #5 (id:80001)
5 years, 2 months ago (2015-09-25 21:05:34 UTC) #16
commit-bot: I haz the power
Patchset 5 (id:??) landed as https://crrev.com/9dcdf861954dd8294faf3eefde89ea228f99c322 Cr-Commit-Position: refs/heads/master@{#350910}
5 years, 2 months ago (2015-09-25 21:06:37 UTC) #17
yosin_UTC9
https://codereview.chromium.org/1355333005/diff/80001/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp File third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp (right): https://codereview.chromium.org/1355333005/diff/80001/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp#newcode534 third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp:534: String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double& quality, SourceDrawingBuffer sourceBuffer) ...
5 years ago (2015-12-03 02:50:41 UTC) #19
Justin Novosad
5 years ago (2015-12-03 03:20:16 UTC) #20
Message was sent while issue was closed.
On 2015/12/03 02:50:41, Yosi_back_on_Jan_5 wrote:
>
https://codereview.chromium.org/1355333005/diff/80001/third_party/WebKit/Sour...
> File third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp (right):
> 
>
https://codereview.chromium.org/1355333005/diff/80001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp:534: String
> HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double&
> quality, SourceDrawingBuffer sourceBuffer) const
> Just curiosity, why don't you use |double quality|?

Ah, I missed it.

Powered by Google App Engine
This is Rietveld 408576698