Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit dfd0f8b

Browse files
author
Yuncong Zhang
committed
Make Async.
1 parent 31187a0 commit dfd0f8b

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

Runtime/painting/image_stream.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -363,24 +363,15 @@ bool _hasFrameDurationPassed(TimeSpan timestamp) {
363363
}
364364

365365
void _decodeNextFrameAndSchedule() {
366-
this._codec.getNextFrame().Then(frame => {
367-
this._nextFrame = frame;
366+
var frame = this._codec.getNextFrame();
367+
this._nextFrame = frame;
368368

369-
if (this._codec.frameCount == 1) {
370-
this._emitFrame(new ImageInfo(image: this._nextFrame.image, scale: this._scale));
371-
return;
372-
}
369+
if (this._codec.frameCount == 1) {
370+
this._emitFrame(new ImageInfo(image: this._nextFrame.image, scale: this._scale));
371+
return;
372+
}
373373

374-
SchedulerBinding.instance.scheduleFrameCallback(this._handleAppFrame);
375-
},
376-
ex => {
377-
this.reportError(
378-
context: "resolving an image frame",
379-
exception: ex,
380-
informationCollector: this._informationCollector,
381-
silent: true
382-
);
383-
});
374+
SchedulerBinding.instance.scheduleFrameCallback(this._handleAppFrame);
384375
}
385376

386377
void _emitFrame(ImageInfo imageInfo) {

Runtime/ui/painting/codec.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class FrameInfo {
1212
public interface Codec : IDisposable {
1313
int frameCount { get; }
1414
int repetitionCount { get; }
15-
IPromise<FrameInfo> getNextFrame();
15+
FrameInfo getNextFrame();
1616
}
1717

1818
public class ImageCodec : Codec {
@@ -31,13 +31,13 @@ public int repetitionCount {
3131
get { return 0; }
3232
}
3333

34-
public IPromise<FrameInfo> getNextFrame() {
34+
public FrameInfo getNextFrame() {
3535
D.assert(this._image != null);
3636

37-
return Promise<FrameInfo>.Resolved(new FrameInfo {
37+
return new FrameInfo {
3838
duration = TimeSpan.Zero,
3939
image = this._image
40-
});
40+
};
4141
}
4242

4343
public void Dispose() {

Runtime/ui/painting/codec_gif.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ void _nextFrame() {
116116
}
117117
}
118118

119-
public IPromise<FrameInfo> getNextFrame() {
119+
public FrameInfo getNextFrame() {
120120
this._nextFrame();
121121
this._texture.LoadRawTextureData(this._frameData.gifFrame.bytes);
122122
this._texture.Apply();
123123
this._frameData.frameInfo = new FrameInfo() {
124124
image = this._image,
125125
duration = TimeSpan.FromMilliseconds(this._frameData.gifFrame.delay)
126126
};
127-
return Promise<FrameInfo>.Resolved(this._frameData.frameInfo);
127+
return this._frameData.frameInfo;
128128
}
129129

130130
public void Dispose() {

0 commit comments

Comments
 (0)