Package limn.backend

Interface GpuRenderer


public interface GpuRenderer
GPU rendering entry point for one window. Hands out the high-level Canvas that widgets draw through; implementations own every GL call. Nothing above the backend module may touch OpenGL.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    default void
    Schedules a capture of this frame to a PNG file, creating the parent directories if they are missing.
    void
    Schedules a capture of this frame: after the frame callback returns and all batched geometry is flushed to the framebuffer (and before the buffer swap), the pixels are read back and handed to sink.
    void
    clear(float red, float green, float blue, float alpha)
    Clears the framebuffer to the given non-premultiplied RGBA color (0–1).
    default void
    clear(Color color)
     
  • Method Details

    • canvas

      Canvas canvas()
      Returns:
      the canvas for the current frame, only valid while inside a FrameCallback
    • clear

      void clear(float red, float green, float blue, float alpha)
      Clears the framebuffer to the given non-premultiplied RGBA color (0–1).
    • clear

      default void clear(Color color)
    • captureFramebuffer

      void captureFramebuffer(Consumer<Image> sink)
      Schedules a capture of this frame: after the frame callback returns and all batched geometry is flushed to the framebuffer (and before the buffer swap), the pixels are read back and handed to sink. This is the basis of the --screenshot verification mode, and the way an application gets what a window is showing without writing a file. Must be called from inside a FrameCallback; sink runs on the UI thread, still inside that frame, before the swap.

      The image is display-referred already: a window's framebuffer holds what the composite produced, sRGB-encoded, tonemapped if anything in the frame needed it. The wrong edit this prevents is applying a display transform to it, which would tonemap the frame a second time; that transform belongs to ReadableSurface, whose subject is an offscreen target that has not been through the composite.

      Alpha is straight and the rows are top-down, as Image requires, whatever the underlying graphics API's own conventions are. The read is a synchronous GPU stall by construction; it is the point where the CPU waits for the frame it just submitted.

    • captureFramebuffer

      default void captureFramebuffer(Path pngFile)
      Schedules a capture of this frame to a PNG file, creating the parent directories if they are missing.

      Deliberately a thin default over captureFramebuffer(Consumer) plus Images.save(limn.graphics.Image, limn.graphics.ImageEncodeOptions, java.nio.file.Path): the toolkit has exactly one PNG writer, and a renderer that grew its own would be a second one that drifts.