feat(web): use softbuffer to draw into the canvas #191
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cc @ngirot-devolutions
Instead of copying and sending image buffers to JavaScript, the WASM module now draws into the canvas by itself.
This removes some overhead associated with the previous approach and open the door for further optimizations.
In order to achieve good performance, the newest API of
[email protected]
is used: the "owned buffer" that can be written into by us with direct access andpresent_with_damage
to apply partial updates.The presentation itself is currently not yet "no-copy" in the case of the web backend because the current API of
softbuffer
is expecting a pixel buffer in the BGRX format while the underlying canvas can only takes RGBA pixels. There is an open issue for this.There was a bug with the
present_with_damage
implementation for the web backend.I fixed the issue and opened a PR to upstream the patch: rust-windowing/softbuffer#150
The cargo dependency patch will be removed once the fix is published on crates.io.
Issue: ARC-164