present method

  1. @override
GpuPresentStatus present(
  1. CommandBuffer commandBuffer
)
override

Publishes this frame as the current image for the surface.

The commandBuffer must be the command buffer that contains the final writes to colorTexture. Call this method after recording those writes and before submitting commandBuffer.

Calling this method does not submit commandBuffer. It registers the frame with commandBuffer so the surface can use command buffer completion to decide when this texture can be considered for reuse.

You must submit commandBuffer for the presented frame to be rendered. Until it is submitted, GpuImageSurface.currentImage will not contain this frame's contents, and the backing texture remains unavailable for future frames. If a frame is presented but its command buffer is never submitted, the next GpuImageSurface.acquireNextFrame throws a StateError.

The published image is available from GpuImageSurface.currentImage.

Implementation

@override
GpuPresentStatus present(CommandBuffer commandBuffer) {
  if (!_isActive) {
    throw StateError(
      'GpuSurfaceFrame has already been presented or discarded.',
    );
  }
  _surface._presentFrame(this, commandBuffer);
  _isActive = false;
  colorTexture._valid = false;
  return GpuPresentStatus.success;
}