Package limn.video
Class VideoSurfaces
java.lang.Object
limn.video.VideoSurfaces
Video-surface facade + install-at-startup SPI (the same inversion as the image, audio and 3D
facades): a neutral entry point here, the device implementation installed by the backend. One
provider, unlike
Videos's ordered list of decoders: a surface is created by whichever
backend owns the window being rendered, and there is nothing for a second one to claim.
VideoSurface surface = VideoSurfaces.create(); // once, while the widget is alive
// ... per picture, inside the frame that draws it:
surface.upload(frame);
canvas.drawSurface(surface, x, y, width, height);
create() must run on the UI thread inside a frame, because the surface belongs to the
GL context of the window rendering it. Installation and the availability probe are safe from any
thread.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBackend-supplied factory, installed at startup. -
Method Summary
Modifier and TypeMethodDescriptionstatic VideoSurfacecreate()Creates a surface for the window being rendered.static voidinstall(VideoSurfaces.Provider newProvider) Installs the backend's provider.static booleanstatic voiduninstall(VideoSurfaces.Provider expected) Removes the provider if it is stillexpected, so a late teardown cannot clear a newer one.
-
Method Details
-
install
Installs the backend's provider. Called once at startup, before any surface is created. -
uninstall
Removes the provider if it is stillexpected, so a late teardown cannot clear a newer one. -
isAvailable
public static boolean isAvailable()- Returns:
- whether a backend provider is installed (false when running headless)
-
create
Creates a surface for the window being rendered. The caller owns it and must release it: a surface holds a picture's worth of device memory, and a stream that opens one per playback and never releases it leaks that much per playback. Release it from inside a frame withVideoSurface.dispose(), or from a widget being detached withScene.disposeLater(limn.graphics.GpuSurface), which defers it to one.- Throws:
IllegalStateException- if no backend provider is installed, if the calling thread is not the UI thread, or if no frame is being rendered
-