// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SHELL_PLATFORM_DARWIN_GRAPHICS_DARWIN_CONTEXT_METAL_H_ #define SHELL_PLATFORM_DARWIN_GRAPHICS_DARWIN_CONTEXT_METAL_H_ #import #import #import #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" #import "flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextureMetal.h" #include "third_party/skia/include/gpu/GrDirectContext.h" NS_ASSUME_NONNULL_BEGIN /** * Provides skia GrContexts that are shared between iOS and macOS embeddings. */ @interface FlutterDarwinContextMetal : NSObject /** * Initializes a FlutterDarwinContextMetal with the system default MTLDevice and a new * MTLCommandQueue. */ - (instancetype)initWithDefaultMTLDevice; /** * Initializes a FlutterDarwinContextMetal with provided MTLDevice and MTLCommandQueue. */ - (instancetype)initWithMTLDevice:(id)device commandQueue:(id)commandQueue; /** * Creates an external texture with the specified ID and contents. */ - (FlutterDarwinExternalTextureMetal*) createExternalTextureWithIdentifier:(int64_t)textureID texture:(NSObject*)texture; /** * MTLDevice that is backing this context.s */ @property(nonatomic, readonly) id device; /** * MTLCommandQueue that is acquired from the `device`. This queue is used both for rendering and * resource related commands. */ @property(nonatomic, readonly) id commandQueue; /** * Skia GrContext that is used for rendering. */ @property(nonatomic, readonly) sk_sp mainContext; /** * Skia GrContext that is used for resources (uploading textures etc). */ @property(nonatomic, readonly) sk_sp resourceContext; /* * Texture cache for external textures. */ @property(nonatomic, readonly) CVMetalTextureCacheRef textureCache; @end NS_ASSUME_NONNULL_END #endif // SHELL_PLATFORM_DARWIN_GRAPHICS_DARWIN_CONTEXT_METAL_H_