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  .antialiased_lines = settings.impeller_antialiased_lines,
19  .use_sdfs = settings.impeller_use_sdfs,
20  };
21 }
22 } // namespace
23 
25  const Settings& settings,
26  const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch)
27  : darwin_context_metal_impeller_([[FlutterDarwinContextMetalImpeller alloc]
28  init:SettingsToFlags(settings)
29  gpuDisabledSyncSwitch:is_gpu_disabled_sync_switch]) {
30  if (darwin_context_metal_impeller_.context) {
31  aiks_context_ = std::make_shared<impeller::AiksContext>(
32  darwin_context_metal_impeller_.context, impeller::TypographerContextSkia::Make());
33  }
34 }
35 
36 IOSContextMetalImpeller::~IOSContextMetalImpeller() = default;
37 
38 IOSRenderingBackend IOSContextMetalImpeller::GetBackend() const {
39  return IOSRenderingBackend::kImpeller;
40 }
41 
42 // |IOSContext|
43 std::shared_ptr<impeller::Context> IOSContextMetalImpeller::GetImpellerContext() const {
44  return darwin_context_metal_impeller_.context;
45 }
46 
47 // |IOSContext|
48 std::shared_ptr<impeller::AiksContext> IOSContextMetalImpeller::GetAiksContext() const {
49  return aiks_context_;
50 }
51 
52 // |IOSContext|
53 std::unique_ptr<Texture> IOSContextMetalImpeller::CreateExternalTexture(
54  int64_t texture_id,
55  NSObject<FlutterTexture>* texture) {
56  return std::make_unique<IOSExternalTextureMetal>([darwin_context_metal_impeller_
57  createExternalTextureWithIdentifier:texture_id
58  texture:texture]);
59 }
60 
61 } // namespace flutter
IOSContextMetalImpeller(const Settings &settings, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
int64_t texture_id