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 and Description
    --- | ---
    `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.SurfaceTextureEntry`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FlutterRenderer(FlutterJNI flutterJNI)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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` 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` | `removeIsDisplayingFlutterUiListener(FlutterUiDisplayListener listener)` Removes a listener added via `addIsDisplayingFlutterUiListener(FlutterUiDisplayListener)`.
    `void` | `setAccessibilityFeatures(int flags)`
    `void` | `setSemanticsEnabled(boolean enabled)`
    `void` | `setViewportMetrics(FlutterRenderer.ViewportMetrics viewportMetrics)`
    `void` | `startRenderingToSurface(Surface surface)` 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)` 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)` 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` that is also made available to Flutter code.
      Specified by:
        `createSurfaceTexture` in interface `TextureRegistry`
      Returns:
        A SurfaceTextureEntry.

    - #### startRenderingToSurface

          public void startRenderingToSurface(@NonNull
                                              Surface surface)

      Notifies Flutter that the given `surface` was created and is available for Flutter rendering.

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

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

    - #### 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)