7#import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h"
9#include "flutter/common/graphics/persistent_cache.h"
10#include "flutter/fml/logging.h"
11#include "flutter/shell/common/context_options.h"
12#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
22 id<MTLDevice>
device = MTLCreateSystemDefaultDevice();
26- (instancetype)initWithMTLDevice:(
id<MTLDevice>)device
27 commandQueue:(
id<MTLCommandQueue>)commandQueue {
44 [_commandQueue setLabel:@"Flutter Main Queue"];
46 CVReturn cvReturn = CVMetalTextureCacheCreate(kCFAllocatorDefault,
52 if (cvReturn != kCVReturnSuccess) {
60 _mainContext = [
self createGrContext];
61 _resourceContext = [
self createGrContext];
63 if (!_mainContext || !_resourceContext) {
70#if defined(FML_OS_IOS) || defined(FML_OS_IOS_SIM)
71 FML_LOG(IMPORTANT) <<
"Using the Skia rendering backend (Metal).";
74 _resourceContext->setResourceCacheLimit(0u);
80 const auto contextOptions =
82 id<MTLDevice>
device = _device;
88 commandQueue:(
id<MTLCommandQueue>)commandQueue {
89 const auto contextOptions =
94 backendContext.
fDevice.reset((__bridge_retained
void*)
device);
101 CFRelease(_textureCache);
106 createExternalTextureWithIdentifier:(int64_t)textureID
#define FML_DLOG(severity)
#define FML_LOG(severity)
sk_sp< GrDirectContext > createGrContext()
instancetype initWithMTLDevice:commandQueue:(id< MTLDevice > device,[commandQueue] id< MTLCommandQueue > commandQueue)
sk_sp< GrDirectContext > createGrContext:commandQueue:(id< MTLDevice > device,[commandQueue] id< MTLCommandQueue > commandQueue)
instancetype initWithDefaultMTLDevice()
id< MTLCommandQueue > commandQueue
SK_API sk_sp< GrDirectContext > MakeMetal(const GrMtlBackendContext &, const GrContextOptions &)
GrContextOptions MakeDefaultContextOptions(ContextType type, std::optional< GrBackendApi > api)
Initializes GrContextOptions with values suitable for Flutter. The options can be further tweaked bef...
@ kRender
The context is used to render to a texture or renderbuffer.
sk_cfp< GrMTLHandle > fDevice
sk_cfp< GrMTLHandle > fQueue