Flutter Engine
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_gl.h"
8 #import "flutter/shell/platform/darwin/ios/ios_surface_software.h"
9 
10 #include "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
11 
12 #if SHELL_ENABLE_METAL
13 #import "flutter/shell/platform/darwin/ios/ios_surface_metal.h"
14 #endif // SHELL_ENABLE_METAL
15 
16 namespace flutter {
17 
18 std::unique_ptr<IOSSurface> IOSSurface::Create(std::shared_ptr<IOSContext> context,
20  FML_DCHECK(layer);
21  FML_DCHECK(context);
22 
23  if ([layer.get() isKindOfClass:[CAEAGLLayer class]]) {
24  return std::make_unique<IOSSurfaceGL>(
26  reinterpret_cast<CAEAGLLayer*>([layer.get() retain])), // EAGL layer
27  std::move(context) // context
28  );
29  }
30 
31 #if SHELL_ENABLE_METAL
32  if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) {
33  if ([layer.get() isKindOfClass:[CAMetalLayer class]]) {
34  return std::make_unique<IOSSurfaceMetal>(
36  reinterpret_cast<CAMetalLayer*>([layer.get() retain])), // Metal layer
37  std::move(context) // context
38  );
39  }
40  }
41 #endif // SHELL_ENABLE_METAL
42 
43  return std::make_unique<IOSSurfaceSoftware>(std::move(layer), // layer
44  std::move(context) // context
45  );
46 }
47 
48 IOSSurface::IOSSurface(std::shared_ptr<IOSContext> ios_context)
49  : ios_context_(std::move(ios_context)) {
50  FML_DCHECK(ios_context_);
51 }
52 
53 IOSSurface::~IOSSurface() = default;
54 
55 std::shared_ptr<IOSContext> IOSSurface::GetContext() const {
56  return ios_context_;
57 }
58 
59 } // namespace flutter
std::shared_ptr< IOSContext > GetContext() const
Definition: ios_surface.mm:55
#define FML_DCHECK(condition)
Definition: logging.h:86
Definition: ref_ptr.h:252
#define METAL_IOS_VERSION_BASELINE
IOSSurface(std::shared_ptr< IOSContext > ios_context)
Definition: ios_surface.mm:48
static std::unique_ptr< IOSSurface > Create(std::shared_ptr< IOSContext > context, fml::scoped_nsobject< CALayer > layer)
Definition: ios_surface.mm:18