Flutter Engine
The 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
5#import "flutter/shell/platform/darwin/ios/ios_surface.h"
6
7#import "flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h"
8#import "flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h"
9#import "flutter/shell/platform/darwin/ios/ios_surface_software.h"
10#include "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
11
13
14namespace flutter {
15
16std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> context,
17 const fml::scoped_nsobject<CALayer>& layer) {
18 FML_DCHECK(layer);
19 FML_DCHECK(context);
20
21 if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) {
22 if ([layer.get() isKindOfClass:[CAMetalLayer class]]) {
23 switch (context->GetBackend()) {
25 return std::make_unique<IOSSurfaceMetalSkia>(
26 fml::scoped_nsobject<CAMetalLayer>((CAMetalLayer*)layer.get()), // Metal layer
27 std::move(context) // context
28 );
29 break;
31 return std::make_unique<IOSSurfaceMetalImpeller>(
32 fml::scoped_nsobject<CAMetalLayer>((CAMetalLayer*)layer.get()), // Metal layer
33 std::move(context) // context
34 );
35 }
36 }
37 }
38
39 return std::make_unique<IOSSurfaceSoftware>(layer, // layer
40 std::move(context) // context
41 );
42}
43
44IOSSurface::IOSSurface(std::shared_ptr<IOSContext> ios_context)
45 : ios_context_(std::move(ios_context)) {
46 FML_DCHECK(ios_context_);
47}
48
49IOSSurface::~IOSSurface() = default;
50
51std::shared_ptr<IOSContext> IOSSurface::GetContext() const {
52 return ios_context_;
53}
54
55} // namespace flutter
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, const fml::scoped_nsobject< CALayer > &layer)
IOSSurface(std::shared_ptr< IOSContext > ios_context)
std::shared_ptr< IOSContext > GetContext() const
T get() const __attribute((ns_returns_not_retained))
#define FML_DCHECK(condition)
Definition logging.h:103
Definition ref_ptr.h:256
#define METAL_IOS_VERSION_BASELINE