Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
rendering_api_selection.mm
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
6
7#include <Foundation/Foundation.h>
8#include <Metal/Metal.h>
9#include <QuartzCore/CAEAGLLayer.h>
10#import <QuartzCore/CAMetalLayer.h>
11#import <TargetConditionals.h>
12
13#include "flutter/fml/logging.h"
14#import "flutter/shell/platform/darwin/common/InternalFlutterSwiftCommon/InternalFlutterSwiftCommon.h"
17
19
20namespace flutter {
21
23 bool ios_version_supports_metal = false;
24 if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) {
25 id<MTLDevice> device = MTLCreateSystemDefaultDevice();
26 ios_version_supports_metal = [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v3];
27 }
28 return ios_version_supports_metal;
29}
30
32 static bool should_use_metal = ShouldUseMetalRenderer();
33 if (should_use_metal) {
35 }
36
37 // When Metal isn't available we use Skia software rendering since it performs
38 // a little better than emulated OpenGL. Also, omitting an OpenGL backend
39 // reduces binary footprint.
40#if TARGET_OS_SIMULATOR
42#else
43 FML_CHECK(false) << "Metal may only be unavailable on simulators";
45#endif // TARGET_OS_SIMULATOR
46}
47
49 switch (rendering_api) {
51 return [CALayer class];
53 if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) {
54 if ([FlutterMetalLayer enabled]) {
55 return [FlutterMetalLayer class];
56 } else {
57 return [CAMetalLayer class];
58 }
59 }
60 FML_CHECK(false) << "Metal availability should already have been checked";
61 break;
62 default:
63 break;
64 }
65 FML_CHECK(false) << "Unknown client rendering API";
66 return [CALayer class];
67}
68
69} // namespace flutter
VkDevice device
Definition main.cc:69
#define FML_CHECK(condition)
Definition logging.h:104
bool ShouldUseMetalRenderer()
IOSRenderingAPI GetRenderingAPIForProcess()
Class GetCoreAnimationLayerClassForRenderingAPI(IOSRenderingAPI rendering_api)
#define METAL_IOS_VERSION_BASELINE