FlutterTexture.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2013 The Flutter Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef FLUTTER_FLUTTERTEXTURE_H_
  5. #define FLUTTER_FLUTTERTEXTURE_H_
  6. #import <CoreMedia/CoreMedia.h>
  7. #import <Foundation/Foundation.h>
  8. #include "FlutterMacros.h"
  9. NS_ASSUME_NONNULL_BEGIN
  10. FLUTTER_EXPORT
  11. /**
  12. * Represents a texture that can be shared with Flutter.
  13. *
  14. * See also: https://github.com/flutter/plugins/tree/master/packages/camera
  15. */
  16. @protocol FlutterTexture <NSObject>
  17. /** Copy the contents of the texture into a `CVPixelBuffer`. */
  18. - (CVPixelBufferRef _Nullable)copyPixelBuffer;
  19. /**
  20. * Called when the texture is unregistered.
  21. *
  22. * Called on the raster thread.
  23. */
  24. @optional
  25. - (void)onTextureUnregistered:(NSObject<FlutterTexture>*)texture;
  26. @end
  27. FLUTTER_EXPORT
  28. /**
  29. * A collection of registered `FlutterTexture`'s.
  30. */
  31. @protocol FlutterTextureRegistry <NSObject>
  32. /**
  33. * Registers a `FlutterTexture` for usage in Flutter and returns an id that can be used to reference
  34. * that texture when calling into Flutter with channels. Textures must be registered on the
  35. * platform thread.
  36. */
  37. - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture;
  38. /**
  39. * Notifies Flutter that the content of the previously registered texture has been updated.
  40. *
  41. * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread.
  42. */
  43. - (void)textureFrameAvailable:(int64_t)textureId;
  44. /**
  45. * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures
  46. * must be unregistered on the the platform thread.
  47. *
  48. * @param textureId The result that was previously returned from `registerTexture:`.
  49. */
  50. - (void)unregisterTexture:(int64_t)textureId;
  51. @end
  52. NS_ASSUME_NONNULL_END
  53. #endif // FLUTTER_FLUTTERTEXTURE_H_