| 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 #include "flutter/impeller/entity/mtl/entity_shaders.h"
7 #import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h"
8
9 namespace flutter {
10
11 IOSContextMetalImpeller::IOSContextMetalImpeller(
12 std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch)
13 : IOSContext(MsaaSampleCount::kFour),
14 darwin_context_metal_impeller_(fml::scoped_nsobject<FlutterDarwinContextMetalImpeller>{
15 [[FlutterDarwinContextMetalImpeller alloc]
16 init:std::move(is_gpu_disabled_sync_switch)]}) {}
17
18 IOSContextMetalImpeller::~IOSContextMetalImpeller() = default;
19
20 fml::scoped_nsobject<FlutterDarwinContextMetalSkia> IOSContextMetalImpeller::GetDarwinContext()
21 const {
22 return fml::scoped_nsobject<FlutterDarwinContextMetalSkia>{};
23 }
24
25 IOSRenderingBackend IOSContextMetalImpeller::GetBackend() const {
26 return IOSRenderingBackend::kImpeller;
27 }
28
29 sk_sp<GrDirectContext> IOSContextMetalImpeller::GetMainContext() const {
30 return nullptr;
31 }
32
33 sk_sp<GrDirectContext> IOSContextMetalImpeller::GetResourceContext() const {
34 return nullptr;
35 }
36
37 // |IOSContext|
38 sk_sp<GrDirectContext> IOSContextMetalImpeller::CreateResourceContext() {
39 return nullptr;
40 }
41
42 // |IOSContext|
43 std::shared_ptr<impeller::Context> IOSContextMetalImpeller::GetImpellerContext() const {
44 return darwin_context_metal_impeller_.get().context;
45 }
46
47 // |IOSContext|
48 std::unique_ptr<GLContextResult> IOSContextMetalImpeller::MakeCurrent() {
49 // This only makes sense for contexts that need to be bound to a specific thread.
50 return std::make_unique<GLContextDefaultResult>(true);
51 }
52
53 // |IOSContext|
54 std::unique_ptr<Texture> IOSContextMetalImpeller::CreateExternalTexture(
55 int64_t texture_id,
56 fml::scoped_nsobject<NSObject<FlutterTexture>> texture) {
57 return std::make_unique<IOSExternalTextureMetal>(
58 fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{
59 [[darwin_context_metal_impeller_ createExternalTextureWithIdentifier:texture_id
60 texture:texture] retain]});
61 }
62
63 } // 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::IOSContextMetalImpeller::GetDarwinContext
fml::scoped_nsobject< FlutterDarwinContextMetalSkia > GetDarwinContext() const
flutter::IOSContextMetalImpeller::IOSContextMetalImpeller
IOSContextMetalImpeller(std::shared_ptr< const fml::SyncSwitch > is_gpu_disabled_sync_switch)
flutter::IOSRenderingBackend
IOSRenderingBackend
Definition: rendering_api_selection.h:19
flutter::IOSRenderingBackend::kImpeller
@ kImpeller
flutter
Definition: accessibility_bridge.h:28
ios_external_texture_metal.h
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24
flutter::IOSContextMetalImpeller::GetBackend
IOSRenderingBackend GetBackend() const override
Get the rendering backend used by this context.