Flutter Engine
 
Loading...
Searching...
No Matches
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
9#import "flutter/shell/platform/darwin/common/InternalFlutterSwiftCommon/InternalFlutterSwiftCommon.h"
13
15
16namespace flutter {
17
18std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> context,
19 CALayer* layer) {
20 FML_DCHECK(layer);
21 FML_DCHECK(context);
22
23 if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) {
24 if ([layer isKindOfClass:[CAMetalLayer class]]) {
25 switch (context->GetBackend()) {
27 [FlutterLogger logFatal:@"Impeller opt-out unavailable."];
28 return nullptr;
30 return std::make_unique<IOSSurfaceMetalImpeller>(
31 static_cast<CAMetalLayer*>(layer), // Metal layer
32 std::move(context) // context
33 );
34 }
35 }
36 }
37 return std::make_unique<IOSSurfaceNoop>(std::move(context));
38}
39
40IOSSurface::IOSSurface(std::shared_ptr<IOSContext> ios_context)
41 : ios_context_(std::move(ios_context)) {
42 FML_DCHECK(ios_context_);
43}
44
45IOSSurface::~IOSSurface() = default;
46
47std::shared_ptr<IOSContext> IOSSurface::GetContext() const {
48 return ios_context_;
49}
50
51} // namespace flutter
IOSSurface(std::shared_ptr< IOSContext > ios_context)
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, CALayer *layer)
std::shared_ptr< IOSContext > GetContext() const
#define FML_DCHECK(condition)
Definition logging.h:122
Definition ref_ptr.h:261
#define METAL_IOS_VERSION_BASELINE