5#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h"
7#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
8#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTexture.h"
9#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"
10#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.h"
11#include "flutter/shell/platform/embedder/embedder.h"
13#pragma mark - Static callbacks that require the engine.
16 NSCAssert(NO,
@"The renderer config should not be used to get the next drawable.");
21 NSCAssert(NO,
@"The renderer config should not be used to present drawable.");
26 int64_t textureIdentifier,
31 return [
engine.
renderer populateTextureWithIdentifier:textureIdentifier
32 metalTexture:metalTexture];
35#pragma mark - FlutterRenderer implementation
41- (instancetype)initWithFlutterEngine:(nonnull
FlutterEngine*)flutterEngine {
42 self = [
super initWithDelegate:self engine:flutterEngine];
44 _device = MTLCreateSystemDefaultDevice();
46 NSLog(
@"Could not acquire Metal device.");
50 _commandQueue = [_device newCommandQueue];
52 NSLog(
@"Could not create Metal command queue.");
57 commandQueue:_commandQueue];
69 .get_next_drawable_callback =
71 .present_drawable_callback =
73 .external_texture_frame_callback =
79#pragma mark - Embedder callback implementations.
81- (
BOOL)populateTextureWithIdentifier:(int64_t)textureID
87#pragma mark - FlutterTextureRegistrar methods.
91 darwinMetalContext:_darwinMetalContext];
static bool OnAcquireExternalTexture(void *user_data, int64_t textureIdentifier, size_t width, size_t height, FlutterMetalExternalTexture *metalTexture)
static FlutterMetalTexture OnGetNextDrawable(void *user_data, const FlutterFrameInfo *frameInfo)
static bool OnPresentDrawable(void *user_data, const FlutterMetalTexture *texture)
bool(* FlutterMetalPresentCallback)(void *, const FlutterMetalTexture *)
const void * FlutterMetalDeviceHandle
Alias for id<MTLDevice>.
bool(* FlutterMetalTextureFrameCallback)(void *, int64_t, size_t, size_t, FlutterMetalExternalTexture *)
const void * FlutterMetalCommandQueueHandle
Alias for id<MTLCommandQueue>.
FlutterMetalTexture(* FlutterMetalTextureCallback)(void *, const FlutterFrameInfo *)
Callback for when a metal texture is requested.
FlutterRenderer * renderer
BOOL populateTexture:(nonnull FlutterMetalExternalTexture *metalTexture)