readPixels method

  1. @override
Future<ByteData?> readPixels(
  1. TextureHandle texture
)
override

The texture's pixels: premultiplied RGBA8, row-major from the top-left.

One layout, named, because the only thing anybody does with these is compare them against pixels that came from somewhere else — and two sides of a comparison that disagree about premultiplication differ on every translucent texel while looking identical on screen.

Separate from presenting a frame because it is a different question with a different cost. Presenting happens every frame and must be nearly free; reading back happens when something wants to look at what a pass wrote — the golden suite comparing a frame, the MRT probe checking that a second attachment was honoured — and is affordable on both backends precisely because it stops at CPU memory.

Null when the texture cannot be read: deviceTransient lives in tile memory, and there is nothing there to read once the pass has ended.

Implementation

@override
Future<ByteData?> readPixels(TextureHandle texture) {
  events.add(TraceReadPixels(_texture(texture)));
  return inner.readPixels(texture);
}