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