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

Commit a054c47

Browse files
author
Yuncong Zhang
committed
Fix gif not animating problem.
1 parent 3f950f9 commit a054c47

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Runtime/flow/raster_cache.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,26 @@ static bool _canRasterizePicture(Picture picture) {
213213
return false;
214214
}
215215

216+
foreach (DrawCmd drawCmd in picture.drawCmds) {
217+
switch (drawCmd) {
218+
case DrawImage cmd: {
219+
if (cmd.image.isDynamic)
220+
return false;
221+
break;
222+
}
223+
case DrawImageNine cmd: {
224+
if (cmd.image.isDynamic)
225+
return false;
226+
break;
227+
}
228+
case DrawImageRect cmd: {
229+
if (cmd.image.isDynamic)
230+
return false;
231+
break;
232+
}
233+
}
234+
}
235+
216236
return true;
217237
}
218238

Runtime/ui/painting/codec_gif.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ IEnumerator _startDecoding() {
6060
if (this._texture == null) {
6161
this._texture = new Texture2D(this._width, this._height, TextureFormat.BGRA32, false);
6262
this._texture.hideFlags = HideFlags.HideAndDontSave;
63-
this._image = new Image(this._texture);
63+
this._image = new Image(this._texture, isDynamic: true);
6464
this._frameData.frameInfo.image = this._image;
6565
}
6666
this._frameData.gifFrame = this._decoder.currentFrame;

Runtime/ui/painting/image.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ public class Image : IEquatable<Image>, IDisposable {
88
Texture _texture;
99
readonly bool _noDispose;
1010
readonly bool _isAsset;
11+
readonly bool _isDynamic;
1112
AssetBundle _bundle;
1213

13-
public Image(Texture texture, bool noDispose = false, bool isAsset = false, AssetBundle bundle = null) {
14+
public Image(Texture texture, bool noDispose = false, bool isAsset = false, AssetBundle bundle = null, bool isDynamic = false) {
1415
D.assert(!noDispose || !isAsset && bundle == null);
1516
D.assert(isAsset || bundle == null);
1617

1718
this._texture = texture;
1819
this._noDispose = noDispose;
1920
this._isAsset = isAsset;
2021
this._bundle = bundle;
22+
this._isDynamic = isDynamic;
2123
}
2224

2325
public int width {
@@ -32,6 +34,10 @@ public Texture texture {
3234
get { return this._texture; }
3335
}
3436

37+
public bool isDynamic {
38+
get { return this._isDynamic; }
39+
}
40+
3541
~Image() {
3642
this._dispose(true);
3743
}

0 commit comments

Comments
 (0)