feat(ext/canvas): enhance createImageBitmap
specification compliance
#25517
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.
Feature
basic support for decoding image format
jpeg
,png
,gif
,bmp
,ico
,webp
issues for supporting AVIF
The AVIF image format is supported by all browsers today.
However, the standardization of sniffing mime type seems to have hard going.
supportcolorSpace
forImageData
There can convert color space fromsrgb
todisplay-p3
withcreateImageBitmap
.This was a misunderstanding on my part, so I reverted it.
The conversion using the
ImageData
colorSpace option was probably the responsibility ofCanvasRenderingContext2D
.I've left the implementation commented out as it may be useful as a reference for implementing
CanvasRenderingContext2D
orOffscreenCanvasRenderingContext2D
.support
colorSpaceConversion
optionThe specifications are not particularly clear about the implementation details, and I had a hard time understanding its behavior, but I eventually do reverse engineering the results of wpt and implemented it to be consistent with those results.
port to Rust
To simplify code, almost logic moved to Rust side.
added a simple architecture document for README
It is basically based on the
image
implementation, and I wrote roughly how you can handle data effectively.performance impact
I was curious to see if the increased amount of Rust code, especially static dispatch, was affecting the bootstrap time of the runtime.
I'm not very confident about the suitability of this benchmark.
bootstrap
API benchmark
extra
The benchmarks below are for when the argument to
op_create_image_bitmap
is a struct except for the first argument ofbuf
.It seems that serializing the argument to
op
as a struct has a fairly large impact on performance.This may apply to things other than
op_create_image_bitmap
as well.plans for enhancement in another PRs
improve performance
There is known to that processing image is a cpu-bound task. So,
op_create_image_bitmap
will be async fn and consider to be data-parallelism with usingrayon
.align error message