| Flutter iOS Embedder |

ios_context_metal_skia.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 #if !SLIMPELLER
6
7 #import "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h"
8
9 #include "flutter/common/graphics/persistent_cache.h"
10 #include "flutter/fml/logging.h"
11 #import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h"
12 #import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h"
13 #include "third_party/skia/include/gpu/GrContextOptions.h"
14
15 FLUTTER_ASSERT_ARC
16
17 namespace flutter {
18
19 IOSContextMetalSkia::IOSContextMetalSkia() {
20 darwin_context_metal_ = fml::scoped_nsobject<FlutterDarwinContextMetalSkia>{
21 [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice]};
22 }
23
24 IOSContextMetalSkia::~IOSContextMetalSkia() = default;
25
26 fml::scoped_nsobject<FlutterDarwinContextMetalSkia> IOSContextMetalSkia::GetDarwinContext() const {
27 return darwin_context_metal_;
28 }
29
30 IOSRenderingBackend IOSContextMetalSkia::GetBackend() const {
31 return IOSRenderingBackend::kSkia;
32 }
33
34 sk_sp<GrDirectContext> IOSContextMetalSkia::GetMainContext() const {
35 return darwin_context_metal_.get().mainContext;
36 }
37
38 sk_sp<GrDirectContext> IOSContextMetalSkia::GetResourceContext() const {
39 return darwin_context_metal_.get().resourceContext;
40 }
41
42 // |IOSContext|
43 sk_sp<GrDirectContext> IOSContextMetalSkia::CreateResourceContext() {
44 return darwin_context_metal_.get().resourceContext;
45 }
46
47 // |IOSContext|
48 std::unique_ptr<GLContextResult> IOSContextMetalSkia::MakeCurrent() {
49 // This only makes sense for context 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> IOSContextMetalSkia::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_ createExternalTextureWithIdentifier:texture_id texture:texture]});
60 }
61
62 } // namespace flutter
63
64 #endif // !SLIMPELLER
flutter::IOSRenderingBackend::kSkia
@ kSkia
flutter::IOSContextMetalSkia::GetResourceContext
sk_sp< GrDirectContext > GetResourceContext() const
Definition: ios_context_metal_skia.mm:38
flutter::IOSContextMetalSkia::GetMainContext
sk_sp< GrDirectContext > GetMainContext() const override
Accessor for the Skia context associated with IOSSurfaces and the raster thread.
Definition: ios_context_metal_skia.mm:34
flutter::IOSContextMetalSkia::GetBackend
IOSRenderingBackend GetBackend() const override
Get the rendering backend used by this context.
Definition: ios_context_metal_skia.mm:30
flutter::IOSContextMetalSkia::GetDarwinContext
fml::scoped_nsobject< FlutterDarwinContextMetalSkia > GetDarwinContext() const
Definition: ios_context_metal_skia.mm:26
ios_context_metal_skia.h
flutter::IOSRenderingBackend
IOSRenderingBackend
Definition: rendering_api_selection.h:19
flutter
Definition: accessibility_bridge.h:28
ios_external_texture_metal.h
flutter::IOSContextMetalSkia::IOSContextMetalSkia
IOSContextMetalSkia()
Definition: ios_context_metal_skia.mm:19
flutter::IOSContextMetalSkia::~IOSContextMetalSkia
~IOSContextMetalSkia()
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13