acquireNextFrame method

  1. @override
GpuImageSurfaceFrame acquireNextFrame()
override

Acquires a color texture that can be used as the final render target.

The returned GpuImageSurfaceFrame owns the write lease for its GpuSurfaceFrame.colorTexture. Renderers should write their final color result into that texture and then call GpuSurfaceFrame.present.

The surface will not return a backing texture that is still the current image, is waiting on producer GPU work, or is still referenced by Flutter. If no retained backing texture is available, the surface allocates another one.

Implementation

@override
GpuImageSurfaceFrame acquireNextFrame() {
  _checkPreviousPresentSubmitted();
  final Texture texture = Texture._surface(
    _gpuContext,
    _format,
    _width,
    _height,
  );
  final int textureIndex = _acquireNextFrame(texture);
  if (textureIndex < 0) {
    throw Exception('Failed to acquire a Flutter GPU surface frame.');
  }
  texture._valid = true;
  return GpuImageSurfaceFrame._(this, textureIndex, texture);
}