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