// Modified by the Kitedesk fork (2026, B212/B252): closeTexture ownership. import 'dart:typed_data'; export './texture_rgba_ffi.dart' show Native; import 'texture_rgba_renderer_platform_interface.dart'; class TextureRgbaRenderer { /// Create a texture with unique [key]. /// /// @return a texture id which can be used with /// ```dart /// Texture(textureId: textureId) /// ``` Future createTexture(int key) { return TextureRgbaRendererPlatform.instance.createTexture(key); } /// Close a texture with unique identifier [key]. /// /// Pass [recycle] = true only when nothing calls `onRgba` with the pointer /// from [getTexturePtr] any more. On Linux the texture is then kept for the /// next [createTexture] of the same window (Kitedesk fork, B212). /// On Windows it may be destroyed only after the engine finishes unregistering /// it. Without [recycle], Windows retains its closed identity for the process /// lifetime so late raw-pointer frames cannot reach freed or reused memory; /// its frame buffers are freed after unregistering (Kitedesk fork, B252). /// Other platforms ignore [recycle]. /// /// @return a boolean to indicate whether the operation is sucessfully executed. Future closeTexture(int key, {bool recycle = false}) { return TextureRgbaRendererPlatform.instance .closeTexture(key, recycle: recycle); } /// Provide the rgba data to the texture. Future onRgba( int key, Uint8List data, int height, int width, int strideAlign) { return TextureRgbaRendererPlatform.instance .onRgba(key, data, height, width, strideAlign); } Future getTexturePtr(int key) { return TextureRgbaRendererPlatform.instance.getTexturePtr(key); } }