Class FlutterRenderer
- All Implemented Interfaces:
TextureRegistry
FlutterEngine
.
FlutterRenderer
works in tandem with a provided RenderSurface
to paint Flutter
pixels to an Android View
hierarchy.
FlutterRenderer
manages textures for rendering, and forwards some Java calls to native
Flutter code via JNI. The corresponding RenderSurface
provides the Android Surface
that this renderer paints.
FlutterSurfaceView
and FlutterTextureView
are implementations of RenderSurface
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Description of a physical feature on the display.static enum
State of the display feature.static enum
Types of display features that can appear on the viewport.static final class
Mutable data structure that holds all viewport metrics properties that Flutter cares about.Nested classes/interfaces inherited from interface io.flutter.view.TextureRegistry
TextureRegistry.GLTextureConsumer, TextureRegistry.ImageConsumer, TextureRegistry.ImageTextureEntry, TextureRegistry.OnFrameConsumedListener, TextureRegistry.OnTrimMemoryListener, TextureRegistry.SurfaceProducer, TextureRegistry.SurfaceTextureEntry, TextureRegistry.TextureEntry
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
Whether to disable clearing of the Surface used to render platform views.static boolean
Whether to always use GL textures forcreateSurfaceProducer()
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a listener that is invoked whenever thisFlutterRenderer
starts and stops painting pixels to an AndroidView
hierarchy.Creates and registers a texture managed by the Flutter engine.Creates and returns a new external textureTextureRegistry.SurfaceProducer
managed by the Flutter engine that is also made available to Flutter code.Creates and returns a newSurfaceTexture
managed by the Flutter engine that is also made available to Flutter code.void
dispatchPointerDataPacket
(ByteBuffer buffer, int position) void
dispatchSemanticsAction
(int nodeId, int action, ByteBuffer args, int argsPosition) boolean
Returns true if thisFlutterRenderer
is painting pixels to an AndroidView
hierarchy, false otherwise.boolean
void
onTrimMemory
(int level) Callback invoked when memory is low.registerSurfaceTexture
(SurfaceTexture surfaceTexture) Registers and returns aSurfaceTexture
managed by the Flutter engine that is also made available to Flutter code.void
Removes a listener added viaaddIsDisplayingFlutterUiListener(FlutterUiDisplayListener)
.void
setAccessibilityFeatures
(int flags) void
setSemanticsEnabled
(boolean enabled) void
setViewportMetrics
(FlutterRenderer.ViewportMetrics viewportMetrics) Notifies Flutter that the viewport metrics, e.g.void
startRenderingToSurface
(Surface surface, boolean onlySwap) Notifies Flutter that the givensurface
was created and is available for Flutter rendering.void
Notifies Flutter that asurface
previously registered withstartRenderingToSurface(Surface, boolean)
has been destroyed and needs to be released and cleaned up on the Flutter side.void
surfaceChanged
(int width, int height) Notifies Flutter that asurface
previously registered withstartRenderingToSurface(Surface, boolean)
has changed size to the givenwidth
andheight
.void
swapSurface
(Surface surface) Swaps theSurface
used to render the current frame.
-
Field Details
-
debugForceSurfaceProducerGlTextures
@VisibleForTesting public static boolean debugForceSurfaceProducerGlTexturesWhether to always use GL textures forcreateSurfaceProducer()
.This is a debug-only API intended for local development. For example, when using a newer Android device (that normally would use
FlutterRenderer.ImageReaderSurfaceProducer
, but wanting to test the OpenGLES/SurfaceTextureSurfaceProducer
code branch. This flag has undefined behavior if set to true while running in a Vulkan (Impeller) context. -
debugDisableSurfaceClear
@VisibleForTesting public static boolean debugDisableSurfaceClearWhether to disable clearing of the Surface used to render platform views.
-
-
Constructor Details
-
FlutterRenderer
-
-
Method Details
-
isDisplayingFlutterUi
public boolean isDisplayingFlutterUi()Returns true if thisFlutterRenderer
is painting pixels to an AndroidView
hierarchy, false otherwise. -
addIsDisplayingFlutterUiListener
Adds a listener that is invoked whenever thisFlutterRenderer
starts and stops painting pixels to an AndroidView
hierarchy. -
removeIsDisplayingFlutterUiListener
Removes a listener added viaaddIsDisplayingFlutterUiListener(FlutterUiDisplayListener)
. -
createSurfaceProducer
Creates and returns a new external textureTextureRegistry.SurfaceProducer
managed by the Flutter engine that is also made available to Flutter code.- Specified by:
createSurfaceProducer
in interfaceTextureRegistry
- Returns:
- A SurfaceProducer.
-
createSurfaceTexture
Creates and returns a newSurfaceTexture
managed by the Flutter engine that is also made available to Flutter code.- Specified by:
createSurfaceTexture
in interfaceTextureRegistry
- Returns:
- A SurfaceTextureEntry.
-
registerSurfaceTexture
@NonNull public TextureRegistry.SurfaceTextureEntry registerSurfaceTexture(@NonNull SurfaceTexture surfaceTexture) Registers and returns aSurfaceTexture
managed by the Flutter engine that is also made available to Flutter code.- Specified by:
registerSurfaceTexture
in interfaceTextureRegistry
- Returns:
- A SurfaceTextureEntry.
-
createImageTexture
Description copied from interface:TextureRegistry
Creates and registers a texture managed by the Flutter engine.- Specified by:
createImageTexture
in interfaceTextureRegistry
- Returns:
- a ImageTextureEntry.
-
onTrimMemory
public void onTrimMemory(int level) Description copied from interface:TextureRegistry
Callback invoked when memory is low.Invoke this from
Activity.onTrimMemory(int)
.- Specified by:
onTrimMemory
in interfaceTextureRegistry
-
startRenderingToSurface
Notifies Flutter that the givensurface
was created and is available for Flutter rendering.If called more than once, the current native resources are released. This can be undesired if the Engine expects to reuse this surface later. For example, this is true when platform views are displayed in a frame, and then removed in the next frame.
To avoid releasing the current surface resources, set
keepCurrentSurface
to true.See
SurfaceHolder.Callback
andTextureView.SurfaceTextureListener
- Parameters:
surface
- The render surface.onlySwap
- True if the current active surface should not be detached.
-
swapSurface
Swaps theSurface
used to render the current frame.In hybrid composition, the root surfaces changes from
SurfaceHolder.getSurface()
toImageReader.getSurface()
when a platform view is in the current frame. -
surfaceChanged
public void surfaceChanged(int width, int height) Notifies Flutter that asurface
previously registered withstartRenderingToSurface(Surface, boolean)
has changed size to the givenwidth
andheight
.See
SurfaceHolder.Callback
andTextureView.SurfaceTextureListener
-
stopRenderingToSurface
public void stopRenderingToSurface()Notifies Flutter that asurface
previously registered withstartRenderingToSurface(Surface, boolean)
has been destroyed and needs to be released and cleaned up on the Flutter side.See
SurfaceHolder.Callback
andTextureView.SurfaceTextureListener
-
setViewportMetrics
Notifies Flutter that the viewport metrics, e.g. window height and width, have changed.If the width, height, or devicePixelRatio are less than or equal to 0, this update is ignored.
- Parameters:
viewportMetrics
- The metrics to send to the Dart application.
-
getBitmap
-
dispatchPointerDataPacket
-
isSoftwareRenderingEnabled
public boolean isSoftwareRenderingEnabled() -
setAccessibilityFeatures
public void setAccessibilityFeatures(int flags) -
setSemanticsEnabled
public void setSemanticsEnabled(boolean enabled) -
dispatchSemanticsAction
public void dispatchSemanticsAction(int nodeId, int action, @Nullable ByteBuffer args, int argsPosition)
-