Flutter iOS Embedder
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 
8 
9 #include "flutter/common/graphics/persistent_cache.h"
10 #include "flutter/fml/logging.h"
11 #import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h"
13 #include "third_party/skia/include/gpu/ganesh/GrContextOptions.h"
14 
16 
17 namespace flutter {
18 
20  darwin_context_metal_ = [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice];
21 }
22 
24 
25 FlutterDarwinContextMetalSkia* IOSContextMetalSkia::GetDarwinContext() const {
26  return darwin_context_metal_;
27 }
28 
31 }
32 
33 sk_sp<GrDirectContext> IOSContextMetalSkia::GetMainContext() const {
34  return darwin_context_metal_.mainContext;
35 }
36 
37 sk_sp<GrDirectContext> IOSContextMetalSkia::GetResourceContext() const {
38  return darwin_context_metal_.resourceContext;
39 }
40 
41 // |IOSContext|
42 sk_sp<GrDirectContext> IOSContextMetalSkia::CreateResourceContext() {
43  return darwin_context_metal_.resourceContext;
44 }
45 
46 // |IOSContext|
47 std::unique_ptr<GLContextResult> IOSContextMetalSkia::MakeCurrent() {
48  // This only makes sense for context that need to be bound to a specific thread.
49  return std::make_unique<GLContextDefaultResult>(true);
50 }
51 
52 // |IOSContext|
53 std::unique_ptr<Texture> IOSContextMetalSkia::CreateExternalTexture(
54  int64_t texture_id,
55  NSObject<FlutterTexture>* texture) {
56  return std::make_unique<IOSExternalTextureMetal>(
57  [darwin_context_metal_ createExternalTextureWithIdentifier:texture_id texture:texture]);
58 }
59 
60 } // namespace flutter
61 
62 #endif // !SLIMPELLER
IOSRenderingBackend GetBackend() const override
Get the rendering backend used by this context.
sk_sp< GrDirectContext > GetResourceContext() const
FlutterDarwinContextMetalSkia * GetDarwinContext() const
sk_sp< GrDirectContext > GetMainContext() const override
Accessor for the Skia context associated with IOSSurfaces and the raster thread.
int64_t texture_id