| 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/ios/ios_surface_metal_impeller.h"
10 #import "flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h"
11 #import "flutter/shell/platform/darwin/ios/ios_surface_noop.h"
12 #import "flutter/shell/platform/darwin/ios/ios_surface_software.h"
13 #include "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
14
15 FLUTTER_ASSERT_ARC
16
17 namespace flutter {
18
19 std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> context,
20 CALayer* layer) {
21 FML_DCHECK(layer);
22 FML_DCHECK(context);
23
24 if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) {
25 if ([layer isKindOfClass:[CAMetalLayer class]]) {
26 switch (context->GetBackend()) {
27 case IOSRenderingBackend::kSkia:
28 #if !SLIMPELLER
29 return std::make_unique<IOSSurfaceMetalSkia>(
30 static_cast<CAMetalLayer*>(layer), // Metal layer
31 std::move(context) // context
32 );
33 #else // !SLIMPELLER
34 FML_LOG(FATAL) << "Impeller opt-out unavailable.";
35 return nullptr;
36 #endif // !SLIMPELLER
37 break;
38 case IOSRenderingBackend::kImpeller:
39 return std::make_unique<IOSSurfaceMetalImpeller>(
40 static_cast<CAMetalLayer*>(layer), // Metal layer
41 std::move(context) // context
42 );
43 }
44 }
45 }
46 if (context->GetBackend() == IOSRenderingBackend::kImpeller) {
47 return std::make_unique<IOSSurfaceNoop>(std::move(context));
48 }
49
50 return std::make_unique<IOSSurfaceSoftware>(layer, // layer
51 std::move(context) // context
52 );
53 }
54
55 IOSSurface::IOSSurface(std::shared_ptr<IOSContext> ios_context)
56 : ios_context_(std::move(ios_context)) {
57 FML_DCHECK(ios_context_);
58 }
59
60 IOSSurface::~IOSSurface() = default;
61
62 std::shared_ptr<IOSContext> IOSSurface::GetContext() const {
63 return ios_context_;
64 }
65
66 } // namespace flutter
flutter::IOSSurface::IOSSurface
IOSSurface(std::shared_ptr< IOSContext > ios_context)
Definition: ios_surface.mm:55
flutter::IOSSurface::Create
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, CALayer *layer)
Definition: ios_surface.mm:19
flutter::IOSSurface::~IOSSurface
virtual ~IOSSurface()
flutter::IOSSurface::GetContext
std::shared_ptr< IOSContext > GetContext() const
Definition: ios_surface.mm:62
ios_surface.h
ios_surface_metal_impeller.h
ios_surface_metal_skia.h
ios_surface_noop.h
ios_surface_software.h
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
flutter
Definition: accessibility_bridge.h:27
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