| 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
5 #import "flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h"
6
7 #include "flutter/impeller/entity/mtl/entity_shaders.h"
8 #import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h"
9 #include "impeller/display_list/aiks_context.h"
10 #include "impeller/typographer/backends/skia/typographer_context_skia.h"
11
12 FLUTTER_ASSERT_ARC
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 };
20 }
21 } // namespace
22
23 IOSContextMetalImpeller::IOSContextMetalImpeller(
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 IOSRenderingBackend IOSContextMetalImpeller::GetBackend() const {
38 return IOSRenderingBackend::kImpeller;
39 }
40
41 // |IOSContext|
42 std::shared_ptr<impeller::Context> IOSContextMetalImpeller::GetImpellerContext() const {
43 return darwin_context_metal_impeller_.context;
44 }
45
46 // |IOSContext|
47 std::shared_ptr<impeller::AiksContext> IOSContextMetalImpeller::GetAiksContext() const {
48 return aiks_context_;
49 }
50
51 // |IOSContext|
52 std::unique_ptr<Texture> IOSContextMetalImpeller::CreateExternalTexture(
53 int64_t texture_id,
54 NSObject<FlutterTexture>* texture) {
55 return std::make_unique<IOSExternalTextureMetal>([darwin_context_metal_impeller_
56 createExternalTextureWithIdentifier:texture_id
57 texture:texture]);
58 }
59
60 } // namespace flutter
flutter::IOSContextMetalImpeller::IOSContextMetalImpeller
IOSContextMetalImpeller(const Settings &settings, const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
ios_context_metal_impeller.h
ios_external_texture_metal.h
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
flutter
Definition: accessibility_bridge.h:26
flutter::IOSRenderingBackend
IOSRenderingBackend
Definition: rendering_api_selection.h:19
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24