Skip to content

for the embedder, allow backing stores to be EGL window surfaces #58363

Closed
flutter-team-archive/engine
#43683

Description

@ardera

Hello,
right now, it's very hard to integrate flutter with DRM hardware planes, i.e. get the flutter engine to render each flutter layer into its own hardware-composited DRM plane. It's not impossible, it seems, but it's very hacky and basically requires you to implement your own double buffering.

It'd be much easier if I could get the engine to just render each flutter layer into its own drawing surface (EGLSurface).

The way it works right now

Right now I'm using FBOs as "pseudo"-offscreen render targets. Each FBO has a renderbuffer as a color attachment that is actually an EGLImage. That EGLImage was created using the EGL_MESA_drm_image extension and has a drm fb associated with it that can be scanned out.

If you want it to be double buffered, you'd need to create two renderbuffers per FBO and swap the fbo-attached renderbuffer after eglSwapBuffers.

Use case

Easier / better hardware composition for embedders. For example, this allows me to use omxplayer as a video_player implementation on the Raspberry Pi, which is way faster than using textures to display the video.

Proposal

  • add a new FlutterOpenGLTargetType, maybe kFlutterOpenGLTargetTypeSurface.
  • add a new struct FlutterOpenGLSurface that has an opaque handle to be used by user-defined callbacks inside it.
  • add this struct to the union inside FlutterOpenGLBackingStore
  • add a new (or modify existing) callback to be called on the rendering thread that takes the mentioned opaque handle and makes the associated surface (and some rendering context) current.

FlutterOpenGLSurface could look like this:

typedef struct {
  void *user_data;
} FlutterOpenGLSurface;

The whole thing doesn't even need to have the Surface name in it, for example kFlutterOpenGLTargetTypeSurface could also be called kFlutterOpenGLTargetTypeGenericCallback, since (I think) surfaces are an EGL-thing and the user could do anything they want inside that callback, not just making a surface current.

Activity

  1. added
    engineflutter/engine related. See also e: labels.
    P3Issues that are less important to the Flutter project
    on Jun 1, 2020
  2. xiaowei-guan commented on Jun 2, 2021

    @xiaowei-guan
    Contributor
  3. github-actions commented on Aug 22, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions