Flutter Engine
The Flutter Engine
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 "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
7
8#include "flutter/fml/logging.h"
9#include "flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h"
10#include "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h"
11#include "flutter/shell/platform/darwin/ios/ios_context_software.h"
12
14
15namespace flutter {
16
17IOSContext::IOSContext() = default;
18
19IOSContext::~IOSContext() = default;
20
21std::unique_ptr<IOSContext> IOSContext::Create(
24 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch) {
25 switch (api) {
28 << "Software rendering is incompatible with Impeller.\n"
29 "Software rendering may have been automatically selected when running on a simulator "
30 "in an environment that does not support Metal. Enabling GPU pass through in your "
31 "environment may fix this. If that is not possible, then disable Impeller.";
32 return std::make_unique<IOSContextSoftware>();
34 switch (backend) {
36#if !SLIMPELLER
37 return std::make_unique<IOSContextMetalSkia>();
38#else // !SLIMPELLER
39 FML_LOG(FATAL) << "Impeller opt-out unavailable.";
40 return nullptr;
41#endif // !SLIMPELLER
43 return std::make_unique<IOSContextMetalImpeller>(is_gpu_disabled_sync_switch);
44 }
45 default:
46 break;
47 }
48 FML_CHECK(false);
49 return nullptr;
50}
51
54}
55
56std::shared_ptr<impeller::Context> IOSContext::GetImpellerContext() const {
57 return nullptr;
58}
59
60} // namespace flutter
const char * backend
virtual std::shared_ptr< impeller::Context > GetImpellerContext() const
Definition: ios_context.mm:56
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:21
virtual ~IOSContext()
Collects the context object. This must happen on the thread on which this object was created.
virtual IOSRenderingBackend GetBackend() const
Get the rendering backend used by this context.
Definition: ios_context.mm:52
#define FATAL(error)
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_CHECK(condition)
Definition: logging.h:85