Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implememt HTMLCanvasElement.toBlob #25091

Open
pshaughn opened this issue Dec 4, 2019 · 3 comments
Open

Implememt HTMLCanvasElement.toBlob #25091

pshaughn opened this issue Dec 4, 2019 · 3 comments

Comments

@pshaughn
Copy link
Member

@pshaughn pshaughn commented Dec 4, 2019

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.

@pshaughn
Copy link
Member Author

@pshaughn pshaughn commented Jan 28, 2020

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?

@jdm
Copy link
Member

@jdm jdm commented Jan 28, 2020

We could potentially do the PNG encode in the canvas thread?

@pshaughn
Copy link
Member Author

@pshaughn pshaughn commented Feb 15, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.