blob: ed890f0d38b3f19a71d1e7f45cba5114d7cb82b8 [file]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package io.flutter.view;
import android.graphics.SurfaceTexture;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
// TODO(mattcarroll): re-evalute docs in this class and add nullability annotations.
/**
* Registry of backend textures used with a single {@link FlutterView} instance. Entries may be
* embedded into the Flutter view using the <a
* href="https://api.flutter.dev/flutter/widgets/Texture-class.html">Texture</a> widget.
*/
public interface TextureRegistry {
/**
* Creates and registers a SurfaceTexture managed by the Flutter engine.
*
* @return A SurfaceTextureEntry.
*/
@NonNull
SurfaceTextureEntry createSurfaceTexture();
/**
* Registers a SurfaceTexture managed by the Flutter engine.
*
* @return A SurfaceTextureEntry.
*/
@NonNull
SurfaceTextureEntry registerSurfaceTexture(@NonNull SurfaceTexture surfaceTexture);
/** A registry entry for a managed SurfaceTexture. */
interface SurfaceTextureEntry {
/** @return The managed SurfaceTexture. */
@NonNull
SurfaceTexture surfaceTexture();
/** @return The identity of this SurfaceTexture. */
long id();
/** Deregisters and releases this SurfaceTexture. */
void release();
/** Set a listener that will be notified when the most recent image has been consumed. */
default void setOnFrameConsumedListener(@Nullable OnFrameConsumedListener listener) {}
}
/** Listener invoked when the most recent image has been consumed. */
interface OnFrameConsumedListener {
/**
* This method will to be invoked when the most recent image from the image stream has been
* consumed.
*/
void onFrameConsumed();
}
}