Kitedesk fork of github.com/rustdesk-org/flutter_texture_rgba_renderer (Apache-2.0, upstream 42797e0f). Branch kd/b212-texture-leak: Linux texture lifetime fixes (B212).
Find a file
2023-02-17 00:55:21 -08:00
.github/workflows opt: readme 2023-02-17 14:06:30 +08:00
.vscode feat: init repo 2023-02-16 15:03:12 +08:00
example add: macos impl 2023-02-17 00:55:21 -08:00
lib feat: init repo 2023-02-16 15:03:12 +08:00
linux opt: hardware accleration texture on Linux 2023-02-16 16:30:11 +08:00
macos add: macos impl 2023-02-17 00:55:21 -08:00
test fix: test file 2023-02-16 16:37:20 +08:00
windows fix: add copy on windows 2023-02-17 14:34:38 +08:00
.gitignore feat: init repo 2023-02-16 15:03:12 +08:00
.metadata feat: init repo 2023-02-16 15:03:12 +08:00
analysis_options.yaml feat: init repo 2023-02-16 15:03:12 +08:00
CHANGELOG.md opt: readme 2023-02-17 14:06:30 +08:00
LICENSE feat: init repo 2023-02-16 15:03:12 +08:00
pubspec.yaml bump: 0.0.3 2023-02-17 11:54:26 +08:00
README.md opt: readme 2023-02-17 14:06:30 +08:00

Texture Rgba Renderer

A texture helper which brings a high level api to handle RGBA data. No frame copy required, and with full hardware acceleration.

Pub Version FOSSA Status

Platform Support

The plugin aims to provide opengl impl for the texture, which bring a better performance instead of FFI + CustomPainter.

  • Linux
  • Windows (No gpu acceleration yet due to the limitation of Flutter.)
// The available texture variants.
// Only PixelBufferTexture is currently implemented.
// Other variants are expected to be added in the future.
typedef std::variant<PixelBufferTexture, GpuSurfaceTexture> TextureVariant;
  • MacOS (not implemented yet.)

Getting Started

Create a texture by calling createTexture.

_textureRgbaRendererPlugin.createTexture(key).then((textureId) {
      if (textureId != -1) {
        debugPrint("Texture register success, textureId=$textureId");
        setState(() {
          this.textureId = textureId;
        });
      } else {
        return;
      }
    });

Transfer rgba data by calling onRgba.

data = mockPicture(width, height);
final res = await _textureRgbaRendererPlugin.onRgba(key, data!, height, width);
if (!res) {
    debugPrint("WARN: render failed");
}

Close a texture by calling closeTexture.

if (key != -1) {
    _textureRgbaRendererPlugin.closeTexture(key);
}

Check the example for details.

API

class TextureRgbaRenderer {

  /// Create a texture with unique identifier [key].
  /// 
  /// @return a texture id which can be used with
  /// ```dart
  /// Texture(textureId: textureId)
  /// ```
  Future<int> createTexture(int key) {
    return TextureRgbaRendererPlatform.instance.createTexture(key); 
  }

  /// Close a texture with unique identifier [key].
  /// 
  /// @return a boolean to indicate whether the operation is sucessfully executed.
  Future<bool> closeTexture(int key) {
    return TextureRgbaRendererPlatform.instance.closeTexture(key); 
  }

  /// Provide the rgba data to the texture.
  Future<bool> onRgba(int key, Uint8List data, int height, int width) {
     return TextureRgbaRendererPlatform.instance.onRgba(key, data, height, width); 
  }
}

Thanks

License

FOSSA Status