|
|
|
|
|
|
this._cache.Clear(); |
|
|
|
this._pendingImages.Clear(); |
|
|
|
this._currentSizeBytes = 0; |
|
|
|
|
|
|
|
|
|
|
|
this._lruKeys.Clear(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
this._lruKeys.Remove(image.node); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
public ImageStreamCompleter putIfAbsent(object key, Func<ImageStreamCompleter> loader, ImageErrorListener onError = null) { |
|
|
|
public ImageStreamCompleter putIfAbsent(object key, Func<ImageStreamCompleter> loader, |
|
|
|
ImageErrorListener onError = null) { |
|
|
|
D.assert(key != null); |
|
|
|
D.assert(loader != null); |
|
|
|
|
|
|
|
|
|
|
void listener(ImageInfo info, bool syncCall) { |
|
|
|
int imageSize = info?.image == null ? 0 : info.image.height * info.image.width * 4; |
|
|
|
_CachedImage cachedImage = new _CachedImage(result, imageSize); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._currentSizeBytes += imageSize; |
|
|
|
|
|
|
|
if (this._pendingImages.TryGetValue(key, out var loadedPendingImage)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
D.assert(!this._cache.ContainsKey(key)); |
|
|
|
this._cache[key] = cachedImage; |
|
|
|
cachedImage.node = this._lruKeys.AddLast(key); |
|
|
|
|
|
|
this.completer = completer; |
|
|
|
this.sizeBytes = sizeBytes; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ImageStreamCompleter completer; |
|
|
|
public int sizeBytes; |
|
|
|
public LinkedListNode<object> node; |
|
|
|