| Flutter macOS Embedder |

FlutterTexture.h
Go to the documentation of this file.
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
5 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_HEADERS_FLUTTERTEXTURE_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_HEADERS_FLUTTERTEXTURE_H_
7
8 #import <CoreMedia/CoreMedia.h>
9 #import <Foundation/Foundation.h>
10
11 #import "FlutterMacros.h"
12
13 NS_ASSUME_NONNULL_BEGIN
14
15 FLUTTER_DARWIN_EXPORT
16 /**
17 * Represents a texture that can be shared with Flutter.
18 *
19 * See also: https://github.com/flutter/plugins/tree/master/packages/camera
20 */
21 @protocol FlutterTexture <NSObject>
22 /**
23 * Copy the contents of the texture into a `CVPixelBuffer`.
24 *
25 * The type of the pixel buffer is one of the following:
26 * - `kCVPixelFormatType_32BGRA`
27 * - `kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange`
28 * - `kCVPixelFormatType_420YpCbCr8BiPlanarFullRange`
29 */
30 - (CVPixelBufferRef _Nullable)copyPixelBuffer;
31
32 /**
33 * Called when the texture is unregistered.
34 *
35 * Called on the raster thread.
36 */
37 @optional
38 - (void)onTextureUnregistered:(NSObject<FlutterTexture>*)texture;
39 @end
40
41 FLUTTER_DARWIN_EXPORT
42 /**
43 * A collection of registered `FlutterTexture`'s.
44 */
45 @protocol FlutterTextureRegistry <NSObject>
46 /**
47 * Registers a `FlutterTexture` for usage in Flutter and returns an id that can be used to reference
48 * that texture when calling into Flutter with channels. Textures must be registered on the
49 * platform thread. On success returns the pointer to the registered texture, else returns 0.
50 */
51 - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture;
52 /**
53 * Notifies Flutter that the content of the previously registered texture has been updated.
54 *
55 * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread.
56 */
57 - (void)textureFrameAvailable:(int64_t)textureId;
58 /**
59 * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures
60 * must be unregistered on the platform thread.
61 *
62 * @param textureId The result that was previously returned from `registerTexture:`.
63 */
64 - (void)unregisterTexture:(int64_t)textureId;
65 @end
66
67 NS_ASSUME_NONNULL_END
68
69 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_HEADERS_FLUTTERTEXTURE_H_
FlutterMacros.h
NS_ASSUME_NONNULL_BEGIN
#define NS_ASSUME_NONNULL_BEGIN
Definition: FlutterMacros.h:19
NS_ASSUME_NONNULL_END
#define NS_ASSUME_NONNULL_END
Definition: FlutterMacros.h:20
FLUTTER_DARWIN_EXPORT
#define FLUTTER_DARWIN_EXPORT
Definition: FlutterMacros.h:14
FlutterTexture-p
Definition: FlutterTexture.h:21
-[FlutterTexture-p copyPixelBuffer]
CVPixelBufferRef _Nullable copyPixelBuffer()
FlutterTextureRegistry-p
Definition: FlutterTexture.h:45