Can I get a Flutter surface texture with Flutter FFI?

815 Views Asked by At

This is part of the code for a Flutter plugin that uses a Flutter texture to render something with OpenGL

private FlutterVideoPlugin(Registrar registrar, MethodChannel channel) {
    this.registrar = registrar;
    this.channel = channel;
    this.textures = registrar.textures();
}

@Override
public void onMethodCall(MethodCall call, Result notSafeResult) {
    final AnyThreadResult result = new AnyThreadResult(notSafeResult);
    if (call.method.equals("createVideoRenderer")) {
        TextureRegistry.SurfaceTextureEntry entry = textures.createSurfaceTexture();
        //do anything with the texture

As you see, it uses a Flutter methodCall.

Is it possible to do the same thing but with FFI in C++? I'd not like to rely on onMethodCall, it's gotta be either FFI or Flutter method calls, because I think that FFI does everything in a different way, something like that.

However, since the Flutter engine and specially the Texture part is written in Java, it looks like I need some java code. The problem is that FFI and java don't mix. It looks like I either have to use onMethodCall for everything in my app, or FFI, but FFI does not seem to have support for getting textures

1

There are 1 best solutions below

0
On

There is an open issue: Consider exposing plugin APIs for use via FFI #110353

Discussion on the issue refers specifically to the Texture Registry so I believe the answer is no (for now).