10 #import <Metal/Metal.h>
17 static BOOL result = NO;
18 static dispatch_once_t once_token = 0;
19 dispatch_once(&once_token, ^{
20 id<MTLDevice> device = MTLCreateSystemDefaultDevice();
24 result = [device supportsFamily:MTLGPUFamilyApple3];
30 #pragma mark - Private interface declaration.
36 + (NSString*)flutterAssetsNameWithBundle:(NSBundle*)bundle;
40 NSBundle* _dartBundle;
45 - (instancetype)init {
46 return [
self initWithPrecompiledDartBundle:nil];
49 - (instancetype)initWithPrecompiledDartBundle:(NSBundle*)bundle {
51 NSAssert(
self,
@"Super init cannot be nil");
54 if (_dartBundle == nil) {
56 _dartBundle = [NSBundle bundleWithURL:[NSBundle.mainBundle.privateFrameworksURL
57 URLByAppendingPathComponent:@"App.framework"]];
59 if (!_dartBundle.isLoaded) {
62 _dartEntrypointArguments = [[NSProcessInfo processInfo] arguments];
64 _dartEntrypointArguments = [_dartEntrypointArguments
65 subarrayWithRange:NSMakeRange(1, _dartEntrypointArguments.count - 1)];
69 - (instancetype)initWithAssetsPath:(NSString*)assets ICUDataPath:(NSString*)icuPath {
71 NSAssert(
self,
@"Super init cannot be nil");
77 - (BOOL)enableImpeller {
78 NSNumber* enableImpeller =
79 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTEnableImpeller"];
80 if (enableImpeller != nil) {
81 return enableImpeller.boolValue;
86 - (BOOL)enableWideGamut {
90 - (BOOL)enableFlutterGPU {
91 NSNumber* enableFlutterGPU =
92 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTEnableFlutterGPU"];
93 if (enableFlutterGPU != nil) {
94 return enableFlutterGPU.boolValue;
103 - (NSString*)assetsPath {
109 NSBundle* assetBundle = _dartBundle ?: [NSBundle mainBundle];
110 NSString* flutterAssetsName = [assetBundle objectForInfoDictionaryKey:@"FLTAssetsPath"];
111 if (flutterAssetsName == nil) {
112 flutterAssetsName =
@"flutter_assets";
114 NSString* path = [assetBundle pathForResource:flutterAssetsName ofType:@""];
116 NSLog(
@"Failed to find path for \"%@\
"", flutterAssetsName);
121 - (NSString*)ICUDataPath {
126 NSString* path = [[NSBundle bundleForClass:[
self class]] pathForResource:kICUBundlePath
134 + (NSString*)flutterAssetsNameWithBundle:(NSBundle*)bundle {
139 bundle = [NSBundle mainBundle];
141 NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"];
142 if (flutterAssetsName == nil) {
143 flutterAssetsName =
@"Contents/Frameworks/App.framework/Resources/flutter_assets";
145 return flutterAssetsName;
148 + (NSString*)lookupKeyForAsset:(NSString*)asset {
149 return [
self lookupKeyForAsset:asset fromBundle:nil];
152 + (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle {
153 NSString* flutterAssetsName = [
FlutterDartProject flutterAssetsNameWithBundle:bundle];
154 return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset];
157 + (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package {
158 return [
self lookupKeyForAsset:asset fromPackage:package fromBundle:nil];
161 + (NSString*)lookupKeyForAsset:(NSString*)asset
162 fromPackage:(NSString*)package
163 fromBundle:(nullable NSBundle*)bundle {
164 return [
self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset]
168 + (NSString*)defaultBundleIdentifier {
static NSString *const kAppBundleIdentifier
static NSString *const kICUBundlePath
static BOOL DoesHardwareSupportWideGamut()
NSBundle * FLTFrameworkBundleWithIdentifier(NSString *flutterFrameworkBundleID)