| Flutter iOS Embedder |

ios_surface.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 #import "flutter/shell/platform/darwin/ios/ios_surface.h"
6
7 #include <memory>
8
9 #import "flutter/shell/platform/darwin/common/InternalFlutterSwiftCommon/InternalFlutterSwiftCommon.h"
10 #import "flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h"
11 #import "flutter/shell/platform/darwin/ios/ios_surface_noop.h"
12 #include "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
13
14 FLUTTER_ASSERT_ARC
15
16 namespace flutter {
17
18 std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> context,
19 CALayer* layer) {
20 FML_DCHECK(layer);
21 FML_DCHECK(context);
22
23 if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) {
24 if ([layer isKindOfClass:[CAMetalLayer class]]) {
25 switch (context->GetBackend()) {
26 case IOSRenderingBackend::kSkia:
27 [FlutterLogger logFatal:@"Impeller opt-out unavailable."];
28 return nullptr;
29 case IOSRenderingBackend::kImpeller:
30 return std::make_unique<IOSSurfaceMetalImpeller>(
31 static_cast<CAMetalLayer*>(layer), // Metal layer
32 std::move(context) // context
33 );
34 }
35 }
36 }
37 return std::make_unique<IOSSurfaceNoop>(std::move(context));
38 }
39
40 IOSSurface::IOSSurface(std::shared_ptr<IOSContext> ios_context)
41 : ios_context_(std::move(ios_context)) {
42 FML_DCHECK(ios_context_);
43 }
44
45 IOSSurface::~IOSSurface() = default;
46
47 std::shared_ptr<IOSContext> IOSSurface::GetContext() const {
48 return ios_context_;
49 }
50
51 } // namespace flutter
flutter::IOSSurface::IOSSurface
IOSSurface(std::shared_ptr< IOSContext > ios_context)
Definition: ios_surface.mm:40
flutter::IOSSurface::Create
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, CALayer *layer)
Definition: ios_surface.mm:18
flutter::IOSSurface::~IOSSurface
virtual ~IOSSurface()
flutter::IOSSurface::GetContext
std::shared_ptr< IOSContext > GetContext() const
Definition: ios_surface.mm:47
ios_surface.h
ios_surface_metal_impeller.h
ios_surface_noop.h
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
flutter
Definition: accessibility_bridge.h:26
flutter::IOSRenderingBackend::kImpeller
@ kImpeller
flutter::IOSRenderingBackend::kSkia
@ kSkia
rendering_api_selection.h
METAL_IOS_VERSION_BASELINE
#define METAL_IOS_VERSION_BASELINE
Definition: rendering_api_selection.h:40