Flutter Engine
The Flutter Engine
FlutterDarwinContextMetalSkia.h
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#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_FLUTTERDARWINCONTEXTMETALSKIA_H_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_FLUTTERDARWINCONTEXTMETALSKIA_H_
7
8#if !SLIMPELLER
9
10#import <CoreVideo/CVMetalTextureCache.h>
11#import <Foundation/Foundation.h>
12#import <Metal/Metal.h>
13
14#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h"
15#import "flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.h"
17
19
20/**
21 * Provides skia GrContexts that are shared between iOS and macOS embeddings.
22 */
23@interface FlutterDarwinContextMetalSkia : NSObject
24
25/**
26 * Initializes a FlutterDarwinContextMetalSkia with the system default MTLDevice and a new
27 * MTLCommandQueue.
28 */
29- (instancetype)initWithDefaultMTLDevice;
30
31/**
32 * Initializes a FlutterDarwinContextMetalSkia with provided MTLDevice and MTLCommandQueue.
33 */
34- (instancetype)initWithMTLDevice:(id<MTLDevice>)device
35 commandQueue:(id<MTLCommandQueue>)commandQueue;
36
37/**
38 * Creates an external texture with the specified ID and contents.
39 */
41 createExternalTextureWithIdentifier:(int64_t)textureID
42 texture:(NSObject<FlutterTexture>*)texture;
43
44/**
45 * Creates a GrDirectContext with the provided `MTLDevice` and `MTLCommandQueue`.
46 */
47+ (sk_sp<GrDirectContext>)createGrContext:(id<MTLDevice>)device
48 commandQueue:(id<MTLCommandQueue>)commandQueue;
49
50/**
51 * MTLDevice that is backing this context.s
52 */
53@property(nonatomic, readonly) id<MTLDevice> device;
54
55/**
56 * MTLCommandQueue that is acquired from the `device`. This queue is used both for rendering and
57 * resource related commands.
58 */
59@property(nonatomic, readonly) id<MTLCommandQueue> commandQueue;
60
61/**
62 * Skia GrContext that is used for rendering.
63 */
64@property(nonatomic, readonly) sk_sp<GrDirectContext> mainContext;
65
66/**
67 * Skia GrContext that is used for resources (uploading textures etc).
68 */
69@property(nonatomic, readonly) sk_sp<GrDirectContext> resourceContext;
70
71/*
72 * Texture cache for external textures.
73 */
74@property(nonatomic, readonly) CVMetalTextureCacheRef textureCache;
75
76@end
77
79
80#endif // !SLIMPELLER
81
82#endif // FLUTTER_SHELL_PLATFORM_DARWIN_GRAPHICS_FLUTTERDARWINCONTEXTMETALSKIA_H_
#define NS_ASSUME_NONNULL_BEGIN
Definition: FlutterMacros.h:19
#define NS_ASSUME_NONNULL_END
Definition: FlutterMacros.h:20
VkDevice device
Definition: main.cc:53