Class SwapChain
- java.lang.Object
-
- com.google.android.filament.SwapChain
-
public class SwapChain extends java.lang.ObjectASwapChainrepresents an Operating System's native renderable surface.Typically it's a native window or a view. Because a
SwapChainis initialized from a native object, it is given to filament as anObject, which must be of the proper type for each platform filament is running on.SwapChain swapChain = engine.createSwapChain(nativeWindow);The
nativeWindowparameter above must be of type:Platform nativeWindow type Android SurfaceExamples
Android
A
Surfacecan be retrieved from aSurfaceVieworSurfaceHoldereasily usingSurfaceHolder.getSurface()and/orSurfaceView.getHolder().To use a
Textureviewas aSwapChain, it is necessary to first get itsSurfaceTexture, for instance usingSurfaceTextureListenerand then create aSurface:// using a TextureView.SurfaceTextureListener: public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { mSurface = new Surface(surfaceTexture); // mSurface can now be used with Engine.createSwapChain() }- See Also:
Engine
-
-
Field Summary
Fields Modifier and Type Field Description static longCONFIG_DEFAULTstatic longCONFIG_ENABLE_XCBIndicates that the native X11 window is an XCB window rather than an XLIB window.static longCONFIG_READABLEThis flag indicates that theSwapChainmay be used as a source surface for reading back render results.static longCONFIG_TRANSPARENTThis flag indicates that theSwapChainmust be allocated with an alpha-channel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetNativeObject()java.lang.ObjectgetNativeWindow()voidsetFrameCompletedCallback(java.lang.Object handler, java.lang.Runnable callback)FrameCompletedCallback is a callback function that notifies an application when a frame's contents have completed rendering on the GPU.
-
-
-
Field Detail
-
CONFIG_DEFAULT
public static final long CONFIG_DEFAULT
- See Also:
- Constant Field Values
-
CONFIG_TRANSPARENT
public static final long CONFIG_TRANSPARENT
This flag indicates that theSwapChainmust be allocated with an alpha-channel.- See Also:
- Constant Field Values
-
CONFIG_READABLE
public static final long CONFIG_READABLE
This flag indicates that theSwapChainmay be used as a source surface for reading back render results. This config must be set when creating anySwapChainthat will be used as the source for a blit operation.
-
CONFIG_ENABLE_XCB
public static final long CONFIG_ENABLE_XCB
Indicates that the native X11 window is an XCB window rather than an XLIB window. This is ignored on non-Linux platforms and in builds that support only one X11 API.- See Also:
- Constant Field Values
-
-
Method Detail
-
getNativeWindow
public java.lang.Object getNativeWindow()
- Returns:
- the native
ObjectthisSwapChainwas created from or null for a headless SwapChain.
-
setFrameCompletedCallback
public void setFrameCompletedCallback(@NonNull java.lang.Object handler, @NonNull java.lang.Runnable callback)FrameCompletedCallback is a callback function that notifies an application when a frame's contents have completed rendering on the GPU.Use setFrameCompletedCallback to set a callback on an individual SwapChain. Each time a frame completes GPU rendering, the callback will be called.
The FrameCompletedCallback is guaranteed to be called on the main Filament thread.
Warning: Only Filament's Metal backend supports frame callbacks. Other backends ignore the callback (which will never be called) and proceed normally.
- Parameters:
handler- AExecutor.callback- The Runnable callback to invoke.
-
getNativeObject
public long getNativeObject()
-
-