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