Unverified Commit b4f4ece4 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

Remove `ImageProvider.load`, `DecoderCallback` and...

Remove `ImageProvider.load`, `DecoderCallback` and `PaintingBinding.instantiateImageCodec` (#132679)

~The failing plugin tests should pass once
https://github.com/flutter/packages/pull/4725 lands and rolls into
flutter/flutter~

google tests are migrated.

Part of https://github.com/flutter/flutter/issues/133171

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
parent 74ccd1d5
...@@ -13,6 +13,9 @@ import 'debug.dart'; ...@@ -13,6 +13,9 @@ import 'debug.dart';
import 'image_provider.dart' as image_provider; import 'image_provider.dart' as image_provider;
import 'image_stream.dart'; import 'image_stream.dart';
// Method signature for _loadAsync decode callbacks.
typedef _SimpleDecoderCallback = Future<ui.Codec> Function(ui.ImmutableBuffer buffer);
/// The dart:io implementation of [image_provider.NetworkImage]. /// The dart:io implementation of [image_provider.NetworkImage].
@immutable @immutable
class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkImage> implements image_provider.NetworkImage { class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkImage> implements image_provider.NetworkImage {
...@@ -35,25 +38,6 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm ...@@ -35,25 +38,6 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
return SynchronousFuture<NetworkImage>(this); return SynchronousFuture<NetworkImage>(this);
} }
@override
ImageStreamCompleter load(image_provider.NetworkImage key, image_provider.DecoderCallback decode) {
// Ownership of this controller is handed off to [_loadAsync]; it is that
// method's responsibility to close the controller's stream when the image
// has been loaded or an error is thrown.
final StreamController<ImageChunkEvent> chunkEvents = StreamController<ImageChunkEvent>();
return MultiFrameImageStreamCompleter(
codec: _loadAsync(key as NetworkImage, chunkEvents, decodeDeprecated: decode),
chunkEvents: chunkEvents.stream,
scale: key.scale,
debugLabel: key.url,
informationCollector: () => <DiagnosticsNode>[
DiagnosticsProperty<image_provider.ImageProvider>('Image provider', this),
DiagnosticsProperty<image_provider.NetworkImage>('Image key', key),
],
);
}
@override @override
ImageStreamCompleter loadBuffer(image_provider.NetworkImage key, image_provider.DecoderBufferCallback decode) { ImageStreamCompleter loadBuffer(image_provider.NetworkImage key, image_provider.DecoderBufferCallback decode) {
// Ownership of this controller is handed off to [_loadAsync]; it is that // Ownership of this controller is handed off to [_loadAsync]; it is that
...@@ -62,7 +46,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm ...@@ -62,7 +46,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
final StreamController<ImageChunkEvent> chunkEvents = StreamController<ImageChunkEvent>(); final StreamController<ImageChunkEvent> chunkEvents = StreamController<ImageChunkEvent>();
return MultiFrameImageStreamCompleter( return MultiFrameImageStreamCompleter(
codec: _loadAsync(key as NetworkImage, chunkEvents, decodeBufferDeprecated: decode), codec: _loadAsync(key as NetworkImage, chunkEvents, decode: decode),
chunkEvents: chunkEvents.stream, chunkEvents: chunkEvents.stream,
scale: key.scale, scale: key.scale,
debugLabel: key.url, debugLabel: key.url,
...@@ -112,9 +96,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm ...@@ -112,9 +96,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
Future<ui.Codec> _loadAsync( Future<ui.Codec> _loadAsync(
NetworkImage key, NetworkImage key,
StreamController<ImageChunkEvent> chunkEvents, { StreamController<ImageChunkEvent> chunkEvents, {
image_provider.ImageDecoderCallback? decode, required _SimpleDecoderCallback decode,
image_provider.DecoderBufferCallback? decodeBufferDeprecated,
image_provider.DecoderCallback? decodeDeprecated,
}) async { }) async {
try { try {
assert(key == this); assert(key == this);
...@@ -148,16 +130,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm ...@@ -148,16 +130,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
throw Exception('NetworkImage is an empty file: $resolved'); throw Exception('NetworkImage is an empty file: $resolved');
} }
if (decode != null) { return decode(await ui.ImmutableBuffer.fromUint8List(bytes));
final ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
return decode(buffer);
} else if (decodeBufferDeprecated != null) {
final ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
return decodeBufferDeprecated(buffer);
} else {
assert(decodeDeprecated != null);
return decodeDeprecated!(bytes);
}
} catch (e) { } catch (e) {
// Depending on where the exception was thrown, the image cache may not // Depending on where the exception was thrown, the image cache may not
// have had a chance to track the key in the cache at all. // have had a chance to track the key in the cache at all.
......
...@@ -15,6 +15,9 @@ import 'image_stream.dart'; ...@@ -15,6 +15,9 @@ import 'image_stream.dart';
/// Creates a type for an overridable factory function for testing purposes. /// Creates a type for an overridable factory function for testing purposes.
typedef HttpRequestFactory = web.XMLHttpRequest Function(); typedef HttpRequestFactory = web.XMLHttpRequest Function();
// Method signature for _loadAsync decode callbacks.
typedef _SimpleDecoderCallback = Future<ui.Codec> Function(ui.ImmutableBuffer buffer);
/// Default HTTP client. /// Default HTTP client.
web.XMLHttpRequest _httpClient() { web.XMLHttpRequest _httpClient() {
return web.XMLHttpRequest(); return web.XMLHttpRequest();
...@@ -54,23 +57,6 @@ class NetworkImage ...@@ -54,23 +57,6 @@ class NetworkImage
return SynchronousFuture<NetworkImage>(this); return SynchronousFuture<NetworkImage>(this);
} }
@override
ImageStreamCompleter load(image_provider.NetworkImage key, image_provider.DecoderCallback decode) {
// Ownership of this controller is handed off to [_loadAsync]; it is that
// method's responsibility to close the controller's stream when the image
// has been loaded or an error is thrown.
final StreamController<ImageChunkEvent> chunkEvents =
StreamController<ImageChunkEvent>();
return MultiFrameImageStreamCompleter(
chunkEvents: chunkEvents.stream,
codec: _loadAsync(key as NetworkImage, null, null, decode, chunkEvents),
scale: key.scale,
debugLabel: key.url,
informationCollector: _imageStreamInformationCollector(key),
);
}
@override @override
ImageStreamCompleter loadBuffer(image_provider.NetworkImage key, image_provider.DecoderBufferCallback decode) { ImageStreamCompleter loadBuffer(image_provider.NetworkImage key, image_provider.DecoderBufferCallback decode) {
// Ownership of this controller is handed off to [_loadAsync]; it is that // Ownership of this controller is handed off to [_loadAsync]; it is that
...@@ -81,7 +67,7 @@ class NetworkImage ...@@ -81,7 +67,7 @@ class NetworkImage
return MultiFrameImageStreamCompleter( return MultiFrameImageStreamCompleter(
chunkEvents: chunkEvents.stream, chunkEvents: chunkEvents.stream,
codec: _loadAsync(key as NetworkImage, null, decode, null, chunkEvents), codec: _loadAsync(key as NetworkImage, decode, chunkEvents),
scale: key.scale, scale: key.scale,
debugLabel: key.url, debugLabel: key.url,
informationCollector: _imageStreamInformationCollector(key), informationCollector: _imageStreamInformationCollector(key),
...@@ -97,7 +83,7 @@ class NetworkImage ...@@ -97,7 +83,7 @@ class NetworkImage
return MultiFrameImageStreamCompleter( return MultiFrameImageStreamCompleter(
chunkEvents: chunkEvents.stream, chunkEvents: chunkEvents.stream,
codec: _loadAsync(key as NetworkImage, decode, null, null, chunkEvents), codec: _loadAsync(key as NetworkImage, decode, chunkEvents),
scale: key.scale, scale: key.scale,
debugLabel: key.url, debugLabel: key.url,
informationCollector: _imageStreamInformationCollector(key), informationCollector: _imageStreamInformationCollector(key),
...@@ -121,9 +107,7 @@ class NetworkImage ...@@ -121,9 +107,7 @@ class NetworkImage
// directly in place of the typical `instantiateImageCodec` method. // directly in place of the typical `instantiateImageCodec` method.
Future<ui.Codec> _loadAsync( Future<ui.Codec> _loadAsync(
NetworkImage key, NetworkImage key,
image_provider.ImageDecoderCallback? decode, _SimpleDecoderCallback decode,
image_provider.DecoderBufferCallback? decodeBufferDeprecated,
image_provider.DecoderCallback? decodeDeprecated,
StreamController<ImageChunkEvent> chunkEvents, StreamController<ImageChunkEvent> chunkEvents,
) async { ) async {
assert(key == this); assert(key == this);
...@@ -178,17 +162,7 @@ class NetworkImage ...@@ -178,17 +162,7 @@ class NetworkImage
throw image_provider.NetworkImageLoadException( throw image_provider.NetworkImageLoadException(
statusCode: request.status, uri: resolved); statusCode: request.status, uri: resolved);
} }
return decode(await ui.ImmutableBuffer.fromUint8List(bytes));
if (decode != null) {
final ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
return decode(buffer);
} else if (decodeBufferDeprecated != null) {
final ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
return decodeBufferDeprecated(buffer);
} else {
assert(decodeDeprecated != null);
return decodeDeprecated!(bytes);
}
} else { } else {
// This API only exists in the web engine implementation and is not // This API only exists in the web engine implementation and is not
// contained in the analyzer summary for Flutter. // contained in the analyzer summary for Flutter.
......
...@@ -78,47 +78,6 @@ mixin PaintingBinding on BindingBase, ServicesBinding { ...@@ -78,47 +78,6 @@ mixin PaintingBinding on BindingBase, ServicesBinding {
@protected @protected
ImageCache createImageCache() => ImageCache(); ImageCache createImageCache() => ImageCache();
/// Calls through to [dart:ui.instantiateImageCodec] from [ImageCache].
///
/// This method is deprecated. use [instantiateImageCodecFromBuffer] with an
/// [ImmutableBuffer] instance instead of this method.
///
/// The `cacheWidth` and `cacheHeight` parameters, when specified, indicate
/// the size to decode the image to.
///
/// Both `cacheWidth` and `cacheHeight` must be positive values greater than
/// or equal to 1, or null. It is valid to specify only one of `cacheWidth`
/// and `cacheHeight` with the other remaining null, in which case the omitted
/// dimension will be scaled to maintain the aspect ratio of the original
/// dimensions. When both are null or omitted, the image will be decoded at
/// its native resolution.
///
/// The `allowUpscaling` parameter determines whether the `cacheWidth` or
/// `cacheHeight` parameters are clamped to the intrinsic width and height of
/// the original image. By default, the dimensions are clamped to avoid
/// unnecessary memory usage for images. Callers that wish to display an image
/// above its native resolution should prefer scaling the canvas the image is
/// drawn into.
@Deprecated(
'Use instantiateImageCodecWithSize with an ImmutableBuffer instance instead. '
'This feature was deprecated after v2.13.0-1.0.pre.',
)
Future<ui.Codec> instantiateImageCodec(
Uint8List bytes, {
int? cacheWidth,
int? cacheHeight,
bool allowUpscaling = false,
}) {
assert(cacheWidth == null || cacheWidth > 0);
assert(cacheHeight == null || cacheHeight > 0);
return ui.instantiateImageCodec(
bytes,
targetWidth: cacheWidth,
targetHeight: cacheHeight,
allowUpscaling: allowUpscaling,
);
}
/// Calls through to [dart:ui.instantiateImageCodecFromBuffer] from [ImageCache]. /// Calls through to [dart:ui.instantiateImageCodecFromBuffer] from [ImageCache].
/// ///
/// The [buffer] parameter should be an [ui.ImmutableBuffer] instance which can /// The [buffer] parameter should be an [ui.ImmutableBuffer] instance which can
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:ui' as ui show Codec, FrameInfo, Image; import 'dart:ui' as ui show Codec, FrameInfo, Image, ImmutableBuffer;
import 'binding.dart'; import 'binding.dart';
...@@ -17,10 +17,11 @@ import 'binding.dart'; ...@@ -17,10 +17,11 @@ import 'binding.dart';
/// [instantiateImageCodec] if support for animated images is necessary. /// [instantiateImageCodec] if support for animated images is necessary.
/// ///
/// This function differs from [ui.decodeImageFromList] in that it defers to /// This function differs from [ui.decodeImageFromList] in that it defers to
/// [PaintingBinding.instantiateImageCodec], and therefore can be mocked in /// [PaintingBinding.instantiateImageCodecWithSize], and therefore can be mocked
/// tests. /// in tests.
Future<ui.Image> decodeImageFromList(Uint8List bytes) async { Future<ui.Image> decodeImageFromList(Uint8List bytes) async {
final ui.Codec codec = await PaintingBinding.instance.instantiateImageCodec(bytes); final ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
final ui.Codec codec = await PaintingBinding.instance.instantiateImageCodecWithSize(buffer);
final ui.FrameInfo frameInfo = await codec.getNextFrame(); final ui.FrameInfo frameInfo = await codec.getNextFrame();
return frameInfo.image; return frameInfo.image;
} }
...@@ -63,7 +63,7 @@ class ScrollAwareImageProvider<T extends Object> extends ImageProvider<T> { ...@@ -63,7 +63,7 @@ class ScrollAwareImageProvider<T extends Object> extends ImageProvider<T> {
/// been resolved. /// been resolved.
final DisposableBuildContext context; final DisposableBuildContext context;
/// The wrapped image provider to delegate [obtainKey] and [load] to. /// The wrapped image provider to delegate [obtainKey] and [loadImage] to.
final ImageProvider<T> imageProvider; final ImageProvider<T> imageProvider;
@override @override
...@@ -105,9 +105,6 @@ class ScrollAwareImageProvider<T extends Object> extends ImageProvider<T> { ...@@ -105,9 +105,6 @@ class ScrollAwareImageProvider<T extends Object> extends ImageProvider<T> {
imageProvider.resolveStreamForKey(configuration, stream, key, handleError); imageProvider.resolveStreamForKey(configuration, stream, key, handleError);
} }
@override
ImageStreamCompleter load(T key, DecoderCallback decode) => imageProvider.load(key, decode);
@override @override
ImageStreamCompleter loadBuffer(T key, DecoderBufferCallback decode) => imageProvider.loadBuffer(key, decode); ImageStreamCompleter loadBuffer(T key, DecoderBufferCallback decode) => imageProvider.loadBuffer(key, decode);
......
...@@ -3556,7 +3556,7 @@ class DelayedImageProvider extends ImageProvider<DelayedImageProvider> { ...@@ -3556,7 +3556,7 @@ class DelayedImageProvider extends ImageProvider<DelayedImageProvider> {
} }
@override @override
ImageStreamCompleter load(DelayedImageProvider key, DecoderCallback decode) { ImageStreamCompleter loadImage(DelayedImageProvider key, ImageDecoderCallback decode) {
return OneFrameImageStreamCompleter(_completer.future); return OneFrameImageStreamCompleter(_completer.future);
} }
...@@ -3592,7 +3592,7 @@ class _TestImageProvider extends ImageProvider<Object> { ...@@ -3592,7 +3592,7 @@ class _TestImageProvider extends ImageProvider<Object> {
} }
@override @override
ImageStreamCompleter load(Object key, DecoderCallback decode) { ImageStreamCompleter loadImage(Object key, ImageDecoderCallback decode) {
_loadCallCount += 1; _loadCallCount += 1;
return _streamCompleter; return _streamCompleter;
} }
......
...@@ -34,7 +34,7 @@ class SynchronousTestImageProvider extends ImageProvider<int> { ...@@ -34,7 +34,7 @@ class SynchronousTestImageProvider extends ImageProvider<int> {
} }
@override @override
ImageStreamCompleter load(int key, DecoderCallback decode) { ImageStreamCompleter loadImage(int key, ImageDecoderCallback decode) {
return OneFrameImageStreamCompleter( return OneFrameImageStreamCompleter(
SynchronousFuture<ImageInfo>(TestImageInfo(key, image: image)), SynchronousFuture<ImageInfo>(TestImageInfo(key, image: image)),
); );
...@@ -52,7 +52,7 @@ class SynchronousErrorTestImageProvider extends ImageProvider<int> { ...@@ -52,7 +52,7 @@ class SynchronousErrorTestImageProvider extends ImageProvider<int> {
} }
@override @override
ImageStreamCompleter load(int key, DecoderCallback decode) { ImageStreamCompleter loadImage(int key, ImageDecoderCallback decode) {
throw throwable; throw throwable;
} }
} }
...@@ -68,7 +68,7 @@ class AsyncTestImageProvider extends ImageProvider<int> { ...@@ -68,7 +68,7 @@ class AsyncTestImageProvider extends ImageProvider<int> {
} }
@override @override
ImageStreamCompleter load(int key, DecoderCallback decode) { ImageStreamCompleter loadImage(int key, ImageDecoderCallback decode) {
return OneFrameImageStreamCompleter( return OneFrameImageStreamCompleter(
Future<ImageInfo>.value(TestImageInfo(key, image: image)), Future<ImageInfo>.value(TestImageInfo(key, image: image)),
); );
...@@ -88,7 +88,7 @@ class DelayedImageProvider extends ImageProvider<DelayedImageProvider> { ...@@ -88,7 +88,7 @@ class DelayedImageProvider extends ImageProvider<DelayedImageProvider> {
} }
@override @override
ImageStreamCompleter load(DelayedImageProvider key, DecoderCallback decode) { ImageStreamCompleter loadImage(DelayedImageProvider key, ImageDecoderCallback decode) {
return OneFrameImageStreamCompleter(_completer.future); return OneFrameImageStreamCompleter(_completer.future);
} }
...@@ -111,7 +111,7 @@ class MultiFrameImageProvider extends ImageProvider<MultiFrameImageProvider> { ...@@ -111,7 +111,7 @@ class MultiFrameImageProvider extends ImageProvider<MultiFrameImageProvider> {
} }
@override @override
ImageStreamCompleter load(MultiFrameImageProvider key, DecoderCallback decode) { ImageStreamCompleter loadImage(MultiFrameImageProvider key, ImageDecoderCallback decode) {
return completer; return completer;
} }
......
...@@ -25,7 +25,7 @@ class FakeImageProvider extends ImageProvider<FakeImageProvider> { ...@@ -25,7 +25,7 @@ class FakeImageProvider extends ImageProvider<FakeImageProvider> {
} }
@override @override
ImageStreamCompleter load(FakeImageProvider key, DecoderCallback decode) { ImageStreamCompleter loadImage(FakeImageProvider key, ImageDecoderCallback decode) {
assert(key == this); assert(key == this);
return MultiFrameImageStreamCompleter( return MultiFrameImageStreamCompleter(
codec: SynchronousFuture<ui.Codec>(_codec), codec: SynchronousFuture<ui.Codec>(_codec),
......
...@@ -28,11 +28,6 @@ class TestImageProvider extends ImageProvider<TestImageProvider> { ...@@ -28,11 +28,6 @@ class TestImageProvider extends ImageProvider<TestImageProvider> {
super.resolveStreamForKey(config, stream, key, handleError); super.resolveStreamForKey(config, stream, key, handleError);
} }
@override
ImageStreamCompleter load(TestImageProvider key, DecoderCallback decode) {
throw UnsupportedError('Use ImageProvider.loadImage instead.');
}
@override @override
ImageStreamCompleter loadBuffer(TestImageProvider key, DecoderBufferCallback decode) { ImageStreamCompleter loadBuffer(TestImageProvider key, DecoderBufferCallback decode) {
throw UnsupportedError('Use ImageProvider.loadImage instead.'); throw UnsupportedError('Use ImageProvider.loadImage instead.');
......
...@@ -54,7 +54,7 @@ class TestImageProvider extends ImageProvider<int> { ...@@ -54,7 +54,7 @@ class TestImageProvider extends ImageProvider<int> {
} }
@override @override
ImageStreamCompleter load(int key, DecoderCallback decode) { ImageStreamCompleter loadImage(int key, ImageDecoderCallback decode) {
return OneFrameImageStreamCompleter( return OneFrameImageStreamCompleter(
SynchronousFuture<ImageInfo>(TestImageInfo(imageValue, image: image.clone())), SynchronousFuture<ImageInfo>(TestImageInfo(imageValue, image: image.clone())),
); );
...@@ -68,7 +68,7 @@ class FailingTestImageProvider extends TestImageProvider { ...@@ -68,7 +68,7 @@ class FailingTestImageProvider extends TestImageProvider {
const FailingTestImageProvider(super.key, super.imageValue, { required super.image }); const FailingTestImageProvider(super.key, super.imageValue, { required super.image });
@override @override
ImageStreamCompleter load(int key, DecoderCallback decode) { ImageStreamCompleter loadImage(int key, ImageDecoderCallback decode) {
return OneFrameImageStreamCompleter(Future<ImageInfo>.sync(() => Future<ImageInfo>.error('loading failed!'))); return OneFrameImageStreamCompleter(Future<ImageInfo>.sync(() => Future<ImageInfo>.error('loading failed!')));
} }
} }
...@@ -95,11 +95,6 @@ class ErrorImageProvider extends ImageProvider<ErrorImageProvider> { ...@@ -95,11 +95,6 @@ class ErrorImageProvider extends ImageProvider<ErrorImageProvider> {
throw Error(); throw Error();
} }
@override
ImageStreamCompleter load(ErrorImageProvider key, DecoderCallback decode) {
throw Error();
}
@override @override
Future<ErrorImageProvider> obtainKey(ImageConfiguration configuration) { Future<ErrorImageProvider> obtainKey(ImageConfiguration configuration) {
return SynchronousFuture<ErrorImageProvider>(this); return SynchronousFuture<ErrorImageProvider>(this);
...@@ -121,11 +116,6 @@ class ObtainKeyErrorImageProvider extends ImageProvider<ObtainKeyErrorImageProvi ...@@ -121,11 +116,6 @@ class ObtainKeyErrorImageProvider extends ImageProvider<ObtainKeyErrorImageProvi
Future<ObtainKeyErrorImageProvider> obtainKey(ImageConfiguration configuration) { Future<ObtainKeyErrorImageProvider> obtainKey(ImageConfiguration configuration) {
throw Error(); throw Error();
} }
@override
ImageStreamCompleter load(ObtainKeyErrorImageProvider key, DecoderCallback decode) {
throw UnimplementedError();
}
} }
class LoadErrorImageProvider extends ImageProvider<LoadErrorImageProvider> { class LoadErrorImageProvider extends ImageProvider<LoadErrorImageProvider> {
...@@ -143,16 +133,11 @@ class LoadErrorImageProvider extends ImageProvider<LoadErrorImageProvider> { ...@@ -143,16 +133,11 @@ class LoadErrorImageProvider extends ImageProvider<LoadErrorImageProvider> {
Future<LoadErrorImageProvider> obtainKey(ImageConfiguration configuration) { Future<LoadErrorImageProvider> obtainKey(ImageConfiguration configuration) {
return SynchronousFuture<LoadErrorImageProvider>(this); return SynchronousFuture<LoadErrorImageProvider>(this);
} }
@override
ImageStreamCompleter load(LoadErrorImageProvider key, DecoderCallback decode) {
throw UnimplementedError();
}
} }
class LoadErrorCompleterImageProvider extends ImageProvider<LoadErrorCompleterImageProvider> { class LoadErrorCompleterImageProvider extends ImageProvider<LoadErrorCompleterImageProvider> {
@override @override
ImageStreamCompleter load(LoadErrorCompleterImageProvider key, DecoderCallback decode) { ImageStreamCompleter loadImage(LoadErrorCompleterImageProvider key, ImageDecoderCallback decode) {
final Completer<ImageInfo> completer = Completer<ImageInfo>.sync(); final Completer<ImageInfo> completer = Completer<ImageInfo>.sync();
completer.completeError(Error()); completer.completeError(Error());
return OneFrameImageStreamCompleter(completer.future); return OneFrameImageStreamCompleter(completer.future);
......
...@@ -14,9 +14,9 @@ class PaintingBindingSpy extends BindingBase with SchedulerBinding, ServicesBind ...@@ -14,9 +14,9 @@ class PaintingBindingSpy extends BindingBase with SchedulerBinding, ServicesBind
int get instantiateImageCodecCalledCount => counter; int get instantiateImageCodecCalledCount => counter;
@override @override
Future<ui.Codec> instantiateImageCodec(Uint8List list, {int? cacheWidth, int? cacheHeight, bool allowUpscaling = false}) { Future<ui.Codec> instantiateImageCodecWithSize(ui.ImmutableBuffer buffer, { ui.TargetImageSizeCallback? getTargetSize }) {
counter++; counter++;
return ui.instantiateImageCodec(list); return ui.instantiateImageCodecWithSize(buffer, getTargetSize: getTargetSize);
} }
@override @override
......
...@@ -156,7 +156,7 @@ class TestImageProvider extends ImageProvider<TestImageProvider> { ...@@ -156,7 +156,7 @@ class TestImageProvider extends ImageProvider<TestImageProvider> {
} }
@override @override
ImageStreamCompleter load(TestImageProvider key, DecoderCallback decode) { ImageStreamCompleter loadImage(TestImageProvider key, ImageDecoderCallback decode) {
return OneFrameImageStreamCompleter( return OneFrameImageStreamCompleter(
SynchronousFuture<ImageInfo>(ImageInfo(image: image)), SynchronousFuture<ImageInfo>(ImageInfo(image: image)),
); );
......
...@@ -25,7 +25,7 @@ class TestImageProvider extends ImageProvider<TestImageProvider> { ...@@ -25,7 +25,7 @@ class TestImageProvider extends ImageProvider<TestImageProvider> {
} }
@override @override
ImageStreamCompleter load(TestImageProvider key, DecoderCallback decode) { ImageStreamCompleter loadImage(TestImageProvider key, ImageDecoderCallback decode) {
return OneFrameImageStreamCompleter( return OneFrameImageStreamCompleter(
future.then<ImageInfo>((void value) => ImageInfo(image: image)), future.then<ImageInfo>((void value) => ImageInfo(image: image)),
); );
......
...@@ -58,7 +58,7 @@ class LoadTestImageProvider extends ImageProvider<Object> { ...@@ -58,7 +58,7 @@ class LoadTestImageProvider extends ImageProvider<Object> {
} }
@override @override
ImageStreamCompleter load(Object key, DecoderCallback decode) { ImageStreamCompleter loadImage(Object key, ImageDecoderCallback decode) {
throw UnimplementedError(); throw UnimplementedError();
} }
} }
......
...@@ -137,7 +137,7 @@ class _TestImageProvider extends ImageProvider<Object> { ...@@ -137,7 +137,7 @@ class _TestImageProvider extends ImageProvider<Object> {
} }
@override @override
ImageStreamCompleter load(Object key, DecoderCallback decode) { ImageStreamCompleter loadImage(Object key, ImageDecoderCallback decode) {
_loadCallCount += 1; _loadCallCount += 1;
return _streamCompleter; return _streamCompleter;
} }
......
...@@ -19,7 +19,7 @@ class TestImageProvider extends ImageProvider<TestImageProvider> { ...@@ -19,7 +19,7 @@ class TestImageProvider extends ImageProvider<TestImageProvider> {
} }
@override @override
ImageStreamCompleter load(TestImageProvider key, DecoderCallback decode) { ImageStreamCompleter loadImage(TestImageProvider key, ImageDecoderCallback decode) {
return OneFrameImageStreamCompleter( return OneFrameImageStreamCompleter(
SynchronousFuture<ImageInfo>(ImageInfo(image: image)), SynchronousFuture<ImageInfo>(ImageInfo(image: image)),
); );
......
...@@ -2083,7 +2083,7 @@ class _TestImageProvider extends ImageProvider<Object> { ...@@ -2083,7 +2083,7 @@ class _TestImageProvider extends ImageProvider<Object> {
} }
@override @override
ImageStreamCompleter load(Object key, DecoderCallback decode) { ImageStreamCompleter loadImage(Object key, ImageDecoderCallback decode) {
_loadCallCount += 1; _loadCallCount += 1;
return _streamCompleter; return _streamCompleter;
} }
...@@ -2198,7 +2198,7 @@ class _FailingImageProvider extends ImageProvider<int> { ...@@ -2198,7 +2198,7 @@ class _FailingImageProvider extends ImageProvider<int> {
} }
@override @override
ImageStreamCompleter load(int key, DecoderCallback decode) { ImageStreamCompleter loadImage(int key, ImageDecoderCallback decode) {
if (failOnLoad) { if (failOnLoad) {
throw throws; throw throws;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment