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 
6 
7 #include <memory>
8 
14 
16 
17 namespace flutter {
18 
19 std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> context,
20  const fml::scoped_nsobject<CALayer>& layer) {
21  FML_DCHECK(layer);
22  FML_DCHECK(context);
23 
24  if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) {
25  if ([layer.get() isKindOfClass:[CAMetalLayer class]]) {
26  switch (context->GetBackend()) {
28 #if !SLIMPELLER
29  return std::make_unique<IOSSurfaceMetalSkia>(
30  fml::scoped_nsobject<CAMetalLayer>((CAMetalLayer*)layer.get()), // 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;
39  return std::make_unique<IOSSurfaceMetalImpeller>(
40  fml::scoped_nsobject<CAMetalLayer>((CAMetalLayer*)layer.get()), // 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::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:55
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:62
flutter::IOSSurface::Create
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, const fml::scoped_nsobject< CALayer > &layer)
Definition: ios_surface.mm:19
flutter::IOSSurface::~IOSSurface
virtual ~IOSSurface()
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
ios_surface_noop.h