Package io.flutter.embedding.engine.renderer

## 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 a `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

    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 this `FlutterRenderer` starts and stops painting pixels to an Android `View` hierarchy.
    `TextureRegistry.SurfaceTextureEntry` | `createSurfaceTexture()` | Creates and returns a new `SurfaceTexture` 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 this `FlutterRenderer` is painting pixels to an Android `View` hierarchy, false otherwise.
    `boolean` | `isSoftwareRenderingEnabled()` |
    `void` | `onTrimMemory​(int level)` | Callback invoked when memory is low.
    `TextureRegistry.SurfaceTextureEntry` | `registerSurfaceTexture​(SurfaceTexture surfaceTexture)` | Registers and returns a `SurfaceTexture` managed by the Flutter engine that is also made available to Flutter code.
    `void` | `removeIsDisplayingFlutterUiListener​(FlutterUiDisplayListener listener)` | Removes a listener added via `addIsDisplayingFlutterUiListener(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 given `surface` was created and is available for Flutter rendering.
    `void` | `stopRenderingToSurface()` | Notifies Flutter that a `surface` previously registered with `startRenderingToSurface(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 a `surface` previously registered with `startRenderingToSurface(Surface, boolean)` has changed size to the given `width` and `height`.
    `void` | `swapSurface​(Surface surface)` | Swaps the `Surface` used to render the current frame.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FlutterRenderer

          public FlutterRenderer​(@NonNull
                                 FlutterJNI flutterJNI)

  - ### Method Detail

    - #### isDisplayingFlutterUi

          public boolean isDisplayingFlutterUi()

      Returns true if this `FlutterRenderer` is painting pixels to an Android `View` hierarchy, false otherwise.

    - #### addIsDisplayingFlutterUiListener

          public void addIsDisplayingFlutterUiListener​(@NonNull
                                                       FlutterUiDisplayListener listener)

      Adds a listener that is invoked whenever this `FlutterRenderer` starts and stops painting pixels to an Android `View` hierarchy.

    - #### removeIsDisplayingFlutterUiListener

          public void removeIsDisplayingFlutterUiListener​(@NonNull
                                                          FlutterUiDisplayListener listener)

      Removes a listener added via `addIsDisplayingFlutterUiListener(FlutterUiDisplayListener)`.

    - #### createSurfaceTexture

          public TextureRegistry.SurfaceTextureEntry createSurfaceTexture()

      Creates and returns a new `SurfaceTexture` managed by the Flutter engine that is also made available to Flutter code.
      Specified by:
        `createSurfaceTexture` in interface `TextureRegistry`
      Returns:
        A SurfaceTextureEntry.

    - #### registerSurfaceTexture

          public TextureRegistry.SurfaceTextureEntry registerSurfaceTexture​(@NonNull
                                                                            SurfaceTexture surfaceTexture)

      Registers and returns a `SurfaceTexture` managed by the Flutter engine that is also made available to Flutter code.
      Specified by:
        `registerSurfaceTexture` in interface `TextureRegistry`
      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 interface `TextureRegistry`

    - #### startRenderingToSurface

          public void startRenderingToSurface​(@NonNull
                                              Surface surface,
                                              boolean keepCurrentSurface)

      Notifies Flutter that the given `surface` 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` and `TextureView.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 the `Surface` used to render the current frame.

      In hybrid composition, the root surfaces changes from `SurfaceHolder.getSurface()` to `ImageReader.getSurface()` when a platform view is in the current frame.

    - #### surfaceChanged

          public void surfaceChanged​(int width,
                                     int height)

      Notifies Flutter that a `surface` previously registered with `startRenderingToSurface(Surface, boolean)` has changed size to the given `width` and `height`.

      See `SurfaceHolder.Callback` and `TextureView.SurfaceTextureListener`

    - #### stopRenderingToSurface

          public void stopRenderingToSurface()

      Notifies Flutter that a `surface` previously registered with `startRenderingToSurface(Surface, boolean)` has been destroyed and needs to be released and cleaned up on the Flutter side.

      See `SurfaceHolder.Callback` and `TextureView.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)