readback method

  1. @override
Future<ByteData> readback(
  1. TextureHandle texture, {
  2. ScreenRect? region,
})
override

Refuses what the contract refuses, records the rest, and answers zeros unless answerReadback says otherwise. A whole texture outside readbackFormats is "converted" to zeros of its size, and recorded as a readback of all of it.

Implementation

@override
Future<ByteData> readback(TextureHandle texture, {ScreenRect? region}) {
  final resolved = readbackConverts(texture, region: region)
      ? ScreenRect.of(texture)
      : readbackRegionOf(texture, region);
  readbacks.add((texture: texture, region: resolved));
  final answer = answerReadback;
  return Future<ByteData>.value(
    answer == null
        ? ByteData(resolved.width * resolved.height * 4)
        : answer(texture, resolved),
  );
}