Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplememt HTMLCanvasElement.toBlob #25091
Comments
|
It looks like this needs us to add a new task source, then queue a task on it that calls a callback with the result of file-encoding the bitmap. I see that the specification includes the file encode step happening "in parallel" but outside the task itself; are we better off moving that step into the task to keep the code simple, or actually running the PNG encoder in a parallel thread to make it faster? |
|
We could potentially do the PNG encode in the canvas thread? |
|
Note that the choice of which pixels to encode is synchronous; whatever thread we do it on, it needs to behave as though we extracted the bitmap at the time the original call was made, not later. |
https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-toblob and https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-todataurl look like they have the hard parts in common, and blobs exist, so this seems very possible.
WPT html/webappapis/dynamic-markup-insertion/opening-the-input-stream/tasks.window.js happens to incidentally test the task-queuing behavior of this.