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