| Flutter iOS Embedder |

ios_context.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
5 #include "flutter/shell/platform/darwin/ios/ios_context.h"
6 #include <memory>
7 #include "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
8
9 #include "flutter/fml/logging.h"
10 #include "flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h"
11 #include "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h"
12 #include "flutter/shell/platform/darwin/ios/ios_context_noop.h"
13 #include "flutter/shell/platform/darwin/ios/ios_context_software.h"
14
15 FLUTTER_ASSERT_ARC
16
17 namespace flutter {
18
19 IOSContext::IOSContext() = default;
20
21 IOSContext::~IOSContext() = default;
22
23 std::unique_ptr<IOSContext> IOSContext::Create(
24 IOSRenderingAPI api,
25 IOSRenderingBackend backend,
26 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch) {
27 switch (api) {
28 case IOSRenderingAPI::kSoftware:
29 if (backend == IOSRenderingBackend::kImpeller) {
30 FML_LOG(IMPORTANT)
31 << "Software rendering is incompatible with Impeller.\n"
32 "Software rendering may have been automatically selected when running on a "
33 "simulator "
34 "in an environment that does not support Metal. Enabling GPU passthrough in your "
35 "environment may fix this.";
36 return std::make_unique<IOSContextNoop>();
37 }
38 return std::make_unique<IOSContextSoftware>();
39 case IOSRenderingAPI::kMetal:
40 switch (backend) {
41 case IOSRenderingBackend::kSkia:
42 #if !SLIMPELLER
43 return std::make_unique<IOSContextMetalSkia>();
44 #else // !SLIMPELLER
45 FML_LOG(FATAL) << "Impeller opt-out unavailable.";
46 return nullptr;
47 #endif // !SLIMPELLER
48 case IOSRenderingBackend::kImpeller:
49 return std::make_unique<IOSContextMetalImpeller>(is_gpu_disabled_sync_switch);
50 }
51 default:
52 break;
53 }
54 FML_CHECK(false);
55 return nullptr;
56 }
57
58 IOSRenderingBackend IOSContext::GetBackend() const {
59 // Overridden by Impeller subclasses.
60 return IOSRenderingBackend::kSkia;
61 }
62
63 std::shared_ptr<impeller::Context> IOSContext::GetImpellerContext() const {
64 return nullptr;
65 }
66
67 std::shared_ptr<impeller::AiksContext> IOSContext::GetAiksContext() const {
68 return nullptr;
69 }
70
71 } // namespace flutter
flutter::IOSRenderingBackend::kSkia
@ kSkia
flutter::IOSContext::~IOSContext
virtual ~IOSContext()
Collects the context object. This must happen on the thread on which this object was created.
ios_context_noop.h
ios_context_metal_impeller.h
ios_context_metal_skia.h
flutter::IOSRenderingBackend
IOSRenderingBackend
Definition: rendering_api_selection.h:19
flutter::IOSContext::GetAiksContext
virtual std::shared_ptr< impeller::AiksContext > GetAiksContext() const
Definition: ios_context.mm:67
flutter::IOSRenderingBackend::kImpeller
@ kImpeller
flutter
Definition: accessibility_bridge.h:27
flutter::IOSRenderingAPI
IOSRenderingAPI
Definition: rendering_api_selection.h:14
flutter::IOSContext::GetBackend
virtual IOSRenderingBackend GetBackend() const
Get the rendering backend used by this context.
Definition: ios_context.mm:58
flutter::IOSRenderingAPI::kMetal
@ kMetal
rendering_api_selection.h
ios_context_software.h
flutter::IOSContext::IOSContext
IOSContext()
ios_context.h
flutter::IOSRenderingAPI::kSoftware
@ kSoftware
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
flutter::IOSContext::Create
static std::unique_ptr< IOSContext > Create(IOSRenderingAPI api, IOSRenderingBackend backend, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
Create an iOS context object capable of creating the on-screen and off-screen GPU context for use by ...
Definition: ios_context.mm:23
flutter::IOSContext::GetImpellerContext
virtual std::shared_ptr< impeller::Context > GetImpellerContext() const
Definition: ios_context.mm:63