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
Drop last usages of Dart_New from engine #16838
Merged
Merged
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
cca233e
experiment
dnfield 3296a12
some layers and scene
dnfield d444f64
more layers, path
dnfield 09d5a99
paths, images, more layers
dnfield ad4a654
start paragraph, fix images,drop frame_info
dnfield 670aaa1
merge
dnfield 027ce42
merge more
dnfield 25106df
remove usage of Dart_New for paragraph/libtxt
dnfield 6971c40
merge
dnfield 658783b
merge
dnfield 600ff75
format
dnfield 9af252e
format
dnfield 6bcb7df
Merge branch 'paragraph_faster' into picture_dart
dnfield 3f72ff2
The last bits
dnfield 58778cc
more dead code
dnfield 33cc2e5
review, fixes, tests
dnfield 61c2ae7
Merge branch 'paragraph_faster' into picture_dart
dnfield 8f8eb80
more permissive test
dnfield cbd7568
more permissive test
dnfield b648364
epsillon for top
dnfield 016351f
semantics
dnfield b8e6f8b
merge
dnfield 7709586
format again
dnfield be4a042
Merge remote-tracking branch 'upstream/master' into picture_dart
dnfield e001c35
more foramt
dnfield 0252872
retain canvas image
dnfield bf2fb5f
Merge remote-tracking branch 'upstream/master' into picture_dart
dnfield e519e56
cleanup, retain handles, fix toImage
dnfield 9619a78
review
dnfield b3c7687
Merge remote-tracking branch 'upstream/master' into picture_dart
dnfield cd55995
remove debug logging, unneeded includes
dnfield 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1639,22 +1639,19 @@ typedef ImageDecoderCallback = void Function(Image result); | |
| /// | ||
| /// To obtain an instance of the [FrameInfo] interface, see | ||
| /// [Codec.getNextFrame]. | ||
| @pragma('vm:entry-point') | ||
| class FrameInfo extends NativeFieldWrapperClass2 { | ||
| class FrameInfo { | ||
| /// This class is created by the engine, and should not be instantiated | ||
| /// or extended directly. | ||
| /// | ||
| /// To obtain an instance of the [FrameInfo] interface, see | ||
| /// [Codec.getNextFrame]. | ||
| @pragma('vm:entry-point') | ||
| FrameInfo._(); | ||
| FrameInfo._(int durationMilliseconds, this.image) : duration = Duration(milliseconds: durationMilliseconds); | ||
|
|
||
| /// The duration this frame should be shown. | ||
| Duration get duration => Duration(milliseconds: _durationMillis); | ||
| int get _durationMillis native 'FrameInfo_durationMillis'; | ||
| final Duration duration; | ||
|
|
||
| /// The [Image] object for this frame. | ||
| Image get image native 'FrameInfo_image'; | ||
| final Image image; | ||
| } | ||
|
|
||
| /// A handle to an image codec. | ||
|
|
@@ -1684,21 +1681,34 @@ class Codec extends NativeFieldWrapperClass2 { | |
| /// * -1 for infinity repetitions. | ||
| int get repetitionCount native 'Codec_repetitionCount'; | ||
|
|
||
| FrameInfo _cachedFrame; | ||
|
|
||
| /// Fetches the next animation frame. | ||
| /// | ||
| /// Wraps back to the first frame after returning the last frame. | ||
| /// | ||
| /// The returned future can complete with an error if the decoding has failed. | ||
| Future<FrameInfo> getNextFrame() { | ||
| return _futurize(_getNextFrame); | ||
| Future<FrameInfo> getNextFrame() async { | ||
| if (_cachedFrame != null && frameCount == 1) { | ||
| return _cachedFrame; | ||
| } | ||
| final Image image = Image._(); | ||
| print('About to call _futureize with image'); | ||
| final int durationMilliseconds = await _futurize((_Callback<int> callback) => _getNextFrame(image, callback)); | ||
| print(image); | ||
| return _cachedFrame = FrameInfo._(durationMilliseconds, image); | ||
|
||
| } | ||
|
|
||
| /// Returns an error message on failure, null on success. | ||
| String _getNextFrame(_Callback<FrameInfo> callback) native 'Codec_getNextFrame'; | ||
| String _getNextFrame(Image outImage, _Callback<int> callback) native 'Codec_getNextFrame'; | ||
|
|
||
| /// Release the resources used by this object. The object is no longer usable | ||
| /// after this method is called. | ||
| void dispose() native 'Codec_dispose'; | ||
| void dispose() { | ||
| _cachedFrame = null; | ||
| _dispose(); | ||
| } | ||
| void _dispose() native 'Codec_dispose'; | ||
| } | ||
|
|
||
| /// Instantiates an image codec [Codec] object. | ||
|
|
@@ -1718,10 +1728,12 @@ class Codec extends NativeFieldWrapperClass2 { | |
| Future<Codec> instantiateImageCodec(Uint8List list, { | ||
| int targetWidth, | ||
| int targetHeight, | ||
| }) { | ||
| return _futurize( | ||
| (_Callback<Codec> callback) => _instantiateImageCodec(list, callback, null, targetWidth ?? _kDoNotResizeDimension, targetHeight ?? _kDoNotResizeDimension) | ||
| ); | ||
| }) async { | ||
| final Codec codec = Codec._(); | ||
| await _futurize((_Callback<bool> callback) { | ||
| return _instantiateImageCodec(codec, list, callback, null, targetWidth ?? _kDoNotResizeDimension, targetHeight ?? _kDoNotResizeDimension); | ||
| }); | ||
| return codec; | ||
| } | ||
|
|
||
| /// Instantiates a [Codec] object for an image binary data. | ||
|
|
@@ -1735,7 +1747,7 @@ Future<Codec> instantiateImageCodec(Uint8List list, { | |
| /// If both are equal to [_kDoNotResizeDimension], then the image maintains its real size. | ||
| /// | ||
| /// Returns an error message if the instantiation has failed, null otherwise. | ||
| String _instantiateImageCodec(Uint8List list, _Callback<Codec> callback, _ImageInfo imageInfo, int targetWidth, int targetHeight) | ||
| String _instantiateImageCodec(Codec outCodec, Uint8List list, _Callback<bool> callback, _ImageInfo imageInfo, int targetWidth, int targetHeight) | ||
| native 'instantiateImageCodec'; | ||
|
|
||
| /// Loads a single image frame from a byte array into an [Image] object. | ||
|
|
@@ -1776,11 +1788,12 @@ void decodeImageFromPixels( | |
| {int rowBytes, int targetWidth, int targetHeight} | ||
| ) { | ||
| final _ImageInfo imageInfo = _ImageInfo(width, height, format.index, rowBytes); | ||
| final Future<Codec> codecFuture = _futurize( | ||
| (_Callback<Codec> callback) => _instantiateImageCodec(pixels, callback, imageInfo, targetWidth ?? _kDoNotResizeDimension, targetHeight ?? _kDoNotResizeDimension) | ||
| ); | ||
| codecFuture.then((Codec codec) => codec.getNextFrame()) | ||
| .then((FrameInfo frameInfo) => callback(frameInfo.image)); | ||
| final Codec codec = Codec._(); | ||
| _futurize( | ||
| (_Callback<bool> callback) => _instantiateImageCodec(codec, pixels, callback, imageInfo, targetWidth ?? _kDoNotResizeDimension, targetHeight ?? _kDoNotResizeDimension) | ||
| ).then((bool _) { | ||
| codec.getNextFrame().then((FrameInfo frameInfo) => callback(frameInfo.image)); | ||
| }); | ||
| } | ||
|
|
||
| /// Determines the winding rule that decides how the interior of a [Path] is | ||
|
|
@@ -4125,15 +4138,17 @@ class Picture extends NativeFieldWrapperClass2 { | |
| /// | ||
| /// Although the image is returned synchronously, the picture is actually | ||
| /// rasterized the first time the image is drawn and then cached. | ||
| Future<Image> toImage(int width, int height) { | ||
| Future<Image> toImage(int width, int height) async { | ||
| if (width <= 0 || height <= 0) | ||
| throw Exception('Invalid image dimensions.'); | ||
| return _futurize( | ||
| (_Callback<Image> callback) => _toImage(width, height, callback) | ||
| final Image image = Image._(); | ||
| await _futurize( | ||
| (_Callback<bool> callback) => _toImage(image, width, height, callback) | ||
| ); | ||
| return image; | ||
| } | ||
|
|
||
| String _toImage(int width, int height, _Callback<Image> callback) native 'Picture_toImage'; | ||
| String _toImage(Image outImage, int width, int height, _Callback<bool> callback) native 'Picture_toImage'; | ||
|
|
||
| /// Release the resources used by this object. The object is no longer usable | ||
| /// after this method is called. | ||
|
|
||
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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.
Did you mean to leave this debug logging here?
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.
Removed. Thanks for catching this, this would've caused actual confusion for users haha