| 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
16 IOSContextMetalImpeller::IOSContextMetalImpeller(
17 const std::shared_ptr<const fml::SyncSwitch>& is_gpu_disabled_sync_switch)
18 : darwin_context_metal_impeller_(
19 [[FlutterDarwinContextMetalImpeller alloc] init:is_gpu_disabled_sync_switch]) {
20 if (darwin_context_metal_impeller_.context) {
21 aiks_context_ = std::make_shared<impeller::AiksContext>(
22 darwin_context_metal_impeller_.context, impeller::TypographerContextSkia::Make());
23 }
24 }
25
26 IOSContextMetalImpeller::~IOSContextMetalImpeller() = default;
27
28 IOSRenderingBackend IOSContextMetalImpeller::GetBackend() const {
29 return IOSRenderingBackend::kImpeller;
30 }
31
32 sk_sp<GrDirectContext> IOSContextMetalImpeller::GetMainContext() const {
33 return nullptr;
34 }
35
36 sk_sp<GrDirectContext> IOSContextMetalImpeller::GetResourceContext() const {
37 return nullptr;
38 }
39
40 // |IOSContext|
41 sk_sp<GrDirectContext> IOSContextMetalImpeller::CreateResourceContext() {
42 return nullptr;
43 }
44
45 // |IOSContext|
46 std::shared_ptr<impeller::Context> IOSContextMetalImpeller::GetImpellerContext() const {
47 return darwin_context_metal_impeller_.context;
48 }
49
50 // |IOSContext|
51 std::shared_ptr<impeller::AiksContext> IOSContextMetalImpeller::GetAiksContext() const {
52 return aiks_context_;
53 }
54
55 // |IOSContext|
56 std::unique_ptr<GLContextResult> IOSContextMetalImpeller::MakeCurrent() {
57 // This only makes sense for contexts that need to be bound to a specific thread.
58 return std::make_unique<GLContextDefaultResult>(true);
59 }
60
61 // |IOSContext|
62 std::unique_ptr<Texture> IOSContextMetalImpeller::CreateExternalTexture(
63 int64_t texture_id,
64 NSObject<FlutterTexture>* texture) {
65 return std::make_unique<IOSExternalTextureMetal>([darwin_context_metal_impeller_
66 createExternalTextureWithIdentifier:texture_id
67 texture:texture]);
68 }
69
70 } // namespace flutter
flutter::IOSContextMetalImpeller::~IOSContextMetalImpeller
~IOSContextMetalImpeller()
ios_context_metal_impeller.h
flutter::IOSContextMetalImpeller::GetResourceContext
sk_sp< GrDirectContext > GetResourceContext() const
flutter::IOSContextMetalImpeller::GetMainContext
sk_sp< GrDirectContext > GetMainContext() const override
Accessor for the Skia context associated with IOSSurfaces and the raster thread.
flutter::IOSRenderingBackend
IOSRenderingBackend
Definition: rendering_api_selection.h:19
flutter::IOSRenderingBackend::kImpeller
@ kImpeller
flutter
Definition: accessibility_bridge.h:27
ios_external_texture_metal.h
flutter::IOSContextMetalImpeller::IOSContextMetalImpeller
IOSContextMetalImpeller(const std::shared_ptr< const fml::SyncSwitch > &is_gpu_disabled_sync_switch)
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
flutter::IOSContextMetalImpeller::GetBackend
IOSRenderingBackend GetBackend() const override
Get the rendering backend used by this context.