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 {
87 NSNumber* enableWideGamut =
88 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTEnableWideGamut"];
89 if (enableWideGamut != nil) {
95 - (BOOL)enableFlutterGPU {
96 NSNumber* enableFlutterGPU =
97 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTEnableFlutterGPU"];
98 if (enableFlutterGPU != nil) {
99 return enableFlutterGPU.boolValue;
104 - (NSString*)assetsPath {
110 NSBundle* assetBundle = _dartBundle ?: [NSBundle mainBundle];
111 NSString* flutterAssetsName = [assetBundle objectForInfoDictionaryKey:@"FLTAssetsPath"];
112 if (flutterAssetsName == nil) {
113 flutterAssetsName =
@"flutter_assets";
115 NSString* path = [assetBundle pathForResource:flutterAssetsName ofType:@""];
117 NSLog(
@"Failed to find path for \"%@\
"", flutterAssetsName);
122 - (NSString*)ICUDataPath {
127 NSString* path = [[NSBundle bundleForClass:[
self class]] pathForResource:kICUBundlePath
135 + (NSString*)flutterAssetsNameWithBundle:(NSBundle*)bundle {
140 bundle = [NSBundle mainBundle];
142 NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"];
143 if (flutterAssetsName == nil) {
144 flutterAssetsName =
@"Contents/Frameworks/App.framework/Resources/flutter_assets";
146 return flutterAssetsName;
149 + (NSString*)lookupKeyForAsset:(NSString*)asset {
150 return [
self lookupKeyForAsset:asset fromBundle:nil];
153 + (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle {
154 NSString* flutterAssetsName = [
FlutterDartProject flutterAssetsNameWithBundle:bundle];
155 return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset];
158 + (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package {
159 return [
self lookupKeyForAsset:asset fromPackage:package fromBundle:nil];
162 + (NSString*)lookupKeyForAsset:(NSString*)asset
163 fromPackage:(NSString*)package
164 fromBundle:(nullable NSBundle*)bundle {
165 return [
self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset]
169 + (NSString*)defaultBundleIdentifier {
static NSString *const kAppBundleIdentifier
static NSString *const kICUBundlePath
static BOOL DoesHardwareSupportWideGamut()
NSBundle * FLTFrameworkBundleWithIdentifier(NSString *flutterFrameworkBundleID)