fix(🐛): ImageBitmap alpha and options - #434
Merged
Merged
Conversation
Two snapshot-based suites covering createImageBitmap and copyExternalImageToTexture, with baselines validated against Chrome (yarn test:ref) and the dawn.node client (yarn test:node): - ImageBitmapAlpha.spec.ts: full matrix of premultiplyAlpha x destination premultipliedAlpha x flipY, over both the blob and the ArrayBuffer overload, plus exact-value checks where losslessness is guaranteed. The alpha baselines encode the reference integer conversion math; native platforms pass once straight-alpha support lands (issue #432 / PR #433). - ImageBitmapOptions.spec.ts: crop-rect overload, resizeWidth/Height, imageOrientation, and colorSpaceConversion (Display-P3 fixture generated by Chrome). Native currently ignores these options, so on iOS/Android each case asserts today's identity behavior and flips to the reference snapshot once the option is implemented. setup.ts: the node client polyfills now implement premultiplyAlpha, crop, bilinear resize, flipY orientation, close(), and alpha-aware copyExternalImageToTexture with the same integer math as the native ImageBitmap, so reference results can be generated and cross-checked locally. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…remultipliedAlpha createImageBitmap ignored the premultiplyAlpha option and copyExternalImageToTexture ignored the destination's premultipliedAlpha, so an ImageBitmap always came through premultiplied regardless of what was requested. This diverged from the web API and failed the new ImageBitmapAlpha suite on device. - Track the alpha representation on ImageData (premultiplied flag) and expose it on ImageBitmap. - Add a shared convertAlpha helper that matches the reference client's integer rounding, so native results stay bit-exact with dawn.node. - Parse premultiplyAlpha (from both the (source, options) and crop-rect overloads) and convert the decoded pixels to the requested representation before wrapping them in an ImageBitmap. - Convert to the destination's premultipliedAlpha (default false) in copyExternalImageToTexture, composing with the existing flipY. - Decode straight (non-premultiplied) RGBA on Apple via vImage so premultiplyAlpha "none" preserves the decoded bytes exactly; CGBitmapContext cannot target a non-premultiplied layout. Link Accelerate for vImage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 24, 2026
|
🎉 This PR is included in version 0.6.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes #432
Two snapshot-based suites covering createImageBitmap and copyExternalImageToTexture, with baselines validated against Chrome (yarn test:ref) and the dawn.node client (yarn test:node):
setup.ts: the node client polyfills now implement premultiplyAlpha, crop, bilinear resize, flipY orientation, close(), and alpha-aware copyExternalImageToTexture with the same integer math as the native ImageBitmap, so reference results can be generated and cross-checked locally.