Flutter iOS Embedder
ios_context_metal_impeller.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 "flutter/impeller/entity/mtl/entity_shaders.h"
9 #include "impeller/display_list/aiks_context.h"
10 #include "impeller/typographer/backends/skia/typographer_context_skia.h"
11 
13 
14 namespace flutter {
15 namespace {
16 impeller::Flags SettingsToFlags(const Settings& settings) {
17  return impeller::Flags{
18  .use_sdfs = settings.impeller_use_sdfs,
19  };
20 }
21 } // namespace
22 
24  const Settings& settings,
25  const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch)
26  : darwin_context_metal_impeller_([[FlutterDarwinContextMetalImpeller alloc]
27  init:SettingsToFlags(settings)
28  gpuDisabledSyncSwitch:is_gpu_disabled_sync_switch]) {
29  if (darwin_context_metal_impeller_.context) {
30  aiks_context_ = std::make_shared<impeller::AiksContext>(
31  darwin_context_metal_impeller_.context, impeller::TypographerContextSkia::Make());
32  }
33 }
34 
35 IOSContextMetalImpeller::~IOSContextMetalImpeller() = default;
36 
37 // |IOSContext|
38 std::shared_ptr<impeller::Context> IOSContextMetalImpeller::GetImpellerContext() const {
39  return darwin_context_metal_impeller_.context;
40 }
41 
42 // |IOSContext|
43 std::shared_ptr<impeller::AiksContext> IOSContextMetalImpeller::GetAiksContext() const {
44  return aiks_context_;
45 }
46 
47 // |IOSContext|
48 std::unique_ptr<Texture> IOSContextMetalImpeller::CreateExternalTexture(
49  int64_t texture_id,
50  NSObject<FlutterTexture>* texture) {
51  return std::make_unique<IOSExternalTextureMetal>([darwin_context_metal_impeller_
52  createExternalTextureWithIdentifier:texture_id
53  texture:texture]);
54 }
55 
56 } // namespace flutter
IOSContextMetalImpeller(const Settings &settings, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
int64_t texture_id