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 
12 
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()) {
26  FML_LOG(FATAL) << "Impeller opt-out unavailable.";
27  return nullptr;
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
IOSSurface(std::shared_ptr< IOSContext > ios_context)
Definition: ios_surface.mm:39
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, CALayer *layer)
Definition: ios_surface.mm:17
std::shared_ptr< IOSContext > GetContext() const
Definition: ios_surface.mm:46
#define METAL_IOS_VERSION_BASELINE