Class FlutterRenderer
- java.lang.Object
-
- io.flutter.embedding.engine.renderer.FlutterRenderer
-
- All Implemented Interfaces:
TextureRegistry
public class FlutterRenderer extends Object implements TextureRegistry
Represents the rendering responsibilities of aFlutterEngine
.FlutterRenderer
works in tandem with a providedRenderSurface
to paint Flutter pixels to an AndroidView
hierarchy.FlutterRenderer
manages textures for rendering, and forwards some Java calls to native Flutter code via JNI. The correspondingRenderSurface
provides the AndroidSurface
that this renderer paints.FlutterSurfaceView
andFlutterTextureView
are implementations ofRenderSurface
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FlutterRenderer.DisplayFeature
Description of a physical feature on the display.static class
FlutterRenderer.DisplayFeatureState
State of the display feature.static class
FlutterRenderer.DisplayFeatureType
Types of display features that can appear on the viewport.static class
FlutterRenderer.ViewportMetrics
Mutable data structure that holds all viewport metrics properties that Flutter cares about.-
Nested classes/interfaces inherited from interface io.flutter.view.TextureRegistry
TextureRegistry.OnFrameConsumedListener, TextureRegistry.OnTrimMemoryListener, TextureRegistry.SurfaceTextureEntry
-
-
Constructor Summary
Constructors Constructor Description FlutterRenderer(FlutterJNI flutterJNI)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIsDisplayingFlutterUiListener(FlutterUiDisplayListener listener)
Adds a listener that is invoked whenever thisFlutterRenderer
starts and stops painting pixels to an AndroidView
hierarchy.TextureRegistry.SurfaceTextureEntry
createSurfaceTexture()
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 id, int action, ByteBuffer args, int argsPosition)
Bitmap
getBitmap()
boolean
isDisplayingFlutterUi()
Returns true if thisFlutterRenderer
is painting pixels to an AndroidView
hierarchy, false otherwise.boolean
isSoftwareRenderingEnabled()
void
onTrimMemory(int level)
Callback invoked when memory is low.TextureRegistry.SurfaceTextureEntry
registerSurfaceTexture(SurfaceTexture surfaceTexture)
Registers and returns aSurfaceTexture
managed by the Flutter engine that is also made available to Flutter code.void
removeIsDisplayingFlutterUiListener(FlutterUiDisplayListener listener)
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 keepCurrentSurface)
Notifies Flutter that the givensurface
was created and is available for Flutter rendering.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.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.
-
-
-
Constructor Detail
-
FlutterRenderer
public FlutterRenderer(@NonNull FlutterJNI flutterJNI)
-
-
Method Detail
-
isDisplayingFlutterUi
public boolean isDisplayingFlutterUi()
Returns true if thisFlutterRenderer
is painting pixels to an AndroidView
hierarchy, false otherwise.
-
addIsDisplayingFlutterUiListener
public void addIsDisplayingFlutterUiListener(@NonNull FlutterUiDisplayListener listener)
Adds a listener that is invoked whenever thisFlutterRenderer
starts and stops painting pixels to an AndroidView
hierarchy.
-
removeIsDisplayingFlutterUiListener
public void removeIsDisplayingFlutterUiListener(@NonNull FlutterUiDisplayListener listener)
Removes a listener added viaaddIsDisplayingFlutterUiListener(FlutterUiDisplayListener)
.
-
createSurfaceTexture
public TextureRegistry.SurfaceTextureEntry 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
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.
-
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
public void startRenderingToSurface(@NonNull Surface surface, boolean keepCurrentSurface)
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.keepCurrentSurface
- True if the current active surface should not be released.
-
swapSurface
public void swapSurface(@NonNull Surface surface)
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
public void setViewportMetrics(@NonNull FlutterRenderer.ViewportMetrics viewportMetrics)
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
public Bitmap getBitmap()
-
dispatchPointerDataPacket
public void dispatchPointerDataPacket(@NonNull ByteBuffer buffer, int position)
-
isSoftwareRenderingEnabled
public boolean isSoftwareRenderingEnabled()
-
setAccessibilityFeatures
public void setAccessibilityFeatures(int flags)
-
setSemanticsEnabled
public void setSemanticsEnabled(boolean enabled)
-
dispatchSemanticsAction
public void dispatchSemanticsAction(int id, int action, @Nullable ByteBuffer args, int argsPosition)
-
-