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 
8 
10 
11 #if SHELL_ENABLE_METAL
14 #endif // SHELL_ENABLE_METAL
15 
16 namespace flutter {
17 
18 std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> context,
19  const fml::scoped_nsobject<CALayer>& layer) {
20  FML_DCHECK(layer);
21  FML_DCHECK(context);
22 
23 #if SHELL_ENABLE_METAL
24  if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) {
25  if ([layer.get() isKindOfClass:[CAMetalLayer class]]) {
26  switch (context->GetBackend()) {
28  return std::make_unique<IOSSurfaceMetalSkia>(
29  fml::scoped_nsobject<CAMetalLayer>(
30  reinterpret_cast<CAMetalLayer*>([layer.get() retain])), // Metal layer
31  std::move(context) // context
32  );
33  break;
35  return std::make_unique<IOSSurfaceMetalImpeller>(
36  fml::scoped_nsobject<CAMetalLayer>(
37  reinterpret_cast<CAMetalLayer*>([layer.get() retain])), // Metal layer
38  std::move(context) // context
39  );
40  }
41  }
42  }
43 #endif // SHELL_ENABLE_METAL
44 
45  return std::make_unique<IOSSurfaceSoftware>(layer, // layer
46  std::move(context) // context
47  );
48 }
49 
50 IOSSurface::IOSSurface(std::shared_ptr<IOSContext> ios_context)
51  : ios_context_(std::move(ios_context)) {
52  FML_DCHECK(ios_context_);
53 }
54 
55 IOSSurface::~IOSSurface() = default;
56 
57 std::shared_ptr<IOSContext> IOSSurface::GetContext() const {
58  return ios_context_;
59 }
60 
61 } // 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:50
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:57
flutter::IOSSurface::Create
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, const fml::scoped_nsobject< CALayer > &layer)
Definition: ios_surface.mm:18
flutter::IOSSurface::~IOSSurface
virtual ~IOSSurface()