This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Initial support for images in Skwasm #42019
Merged
auto-submit
merged 11 commits into
flutter-team-archive:main
from
eyebrowsoffire:skwasm_image
May 16, 2023
+1,120
−218
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e212cd1
Initial pass at picture to image.
eyebrowsoffire 7f8db30
Added a unit test and a fix.
eyebrowsoffire 85fe346
Add support for image shaders and binding to fragment shaders.
eyebrowsoffire 7f56e89
Add test for image shader.
eyebrowsoffire 1122814
Partway through image rasterization.
eyebrowsoffire 0544f10
Implement toByteData on images.
eyebrowsoffire fcec0ae
Image from pixel data.
eyebrowsoffire 7009a83
Update licenses golden.
eyebrowsoffire 4a2f1e5
Add support for rgbaFloat32 pixel format.
eyebrowsoffire fb6c2a6
Addressed more of Yegor's comments.
eyebrowsoffire 36f988b
Merge branch 'main' into skwasm_image
eyebrowsoffire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
48 changes: 48 additions & 0 deletions
48
lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_image.dart
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| @DefaultAsset('skwasm') | ||
| library skwasm_impl; | ||
|
|
||
| import 'dart:ffi'; | ||
|
|
||
| import 'package:ui/src/engine/skwasm/skwasm_impl.dart'; | ||
|
|
||
| final class RawImage extends Opaque {} | ||
| typedef ImageHandle = Pointer<RawImage>; | ||
|
|
||
| @Native<ImageHandle Function( | ||
| PictureHandle, | ||
| Int32, | ||
| Int32, | ||
| )>(symbol: 'image_createFromPicture', isLeaf: true) | ||
| external ImageHandle imageCreateFromPicture( | ||
| PictureHandle handle, | ||
| int width, | ||
| int height, | ||
| ); | ||
|
|
||
| @Native<ImageHandle Function( | ||
| SkDataHandle, | ||
| Int, | ||
| Int, | ||
| Bool, | ||
| Size | ||
| )>(symbol: 'image_createFromPixels', isLeaf: true) | ||
| external ImageHandle imageCreateFromPixels( | ||
| SkDataHandle pixelData, | ||
| int width, | ||
| int height, | ||
| bool isBgra, | ||
| int rowByteCount, | ||
| ); | ||
|
|
||
| @Native<Void Function(ImageHandle)>(symbol: 'image_dispose', isLeaf: true) | ||
| external void imageDispose(ImageHandle handle); | ||
|
|
||
| @Native<Int Function(ImageHandle)>(symbol: 'image_getWidth', isLeaf: true) | ||
| external int imageGetWidth(ImageHandle handle); | ||
|
|
||
| @Native<Int Function(ImageHandle)>(symbol: 'image_getHeight', isLeaf: true) | ||
| external int imageGetHeight(ImageHandle handle); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a bool sufficient to express all pixel formats we have? https://api.flutter.dev/flutter/dart-ui/PixelFormat.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we just have the two formats in web:
So I figured it was simpler to pass a bool for now. We can change it to an enum later if we have more than two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that looks like a bug.
PixelFormatis part ofdart:ui, which is expected to be identical across all platforms.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added support for it in Skwasm, but it's still not supported in all the renderers and the bitmap creation code path. I filed flutter/flutter#126895 as a follow-on.