1 /* 2 * Copyright 2024 Autodesk, Inc. 3 * 4 * SPDX-License-Identifier: MIT 5 */ 6 7 #ifndef WSI_COMMON_METAL_LAYER_H 8 #define WSI_COMMON_METAL_LAYER_H 9 10 #include <stdint.h> 11 #include <stdbool.h> 12 13 #ifdef __OBJC__ 14 @class CAMetalLayer; 15 typedef unsigned long NSUInteger; 16 typedef enum MTLPixelFormat : NSUInteger MTLPixelFormat; 17 #else 18 typedef void CAMetalLayer; 19 typedef enum MTLPixelFormat : unsigned long 20 { 21 MTLPixelFormatBGRA8Unorm = 80, 22 MTLPixelFormatBGRA8Unorm_sRGB = 81, 23 MTLPixelFormatRGB10A2Unorm = 90, 24 MTLPixelFormatBGR10A2Unorm = 94, 25 MTLPixelFormatRGBA16Float = 115, 26 } MTLPixelFormat; 27 #endif 28 29 typedef void CAMetalDrawableBridged; 30 31 void 32 wsi_metal_layer_size(const CAMetalLayer *metal_layer, 33 uint32_t *width, uint32_t *height); 34 35 void 36 wsi_metal_layer_configure(const CAMetalLayer *metal_layer, 37 uint32_t width, uint32_t height, uint32_t image_count, 38 MTLPixelFormat format, bool enable_opaque, bool enable_immediate); 39 40 CAMetalDrawableBridged * 41 wsi_metal_layer_acquire_drawable(const CAMetalLayer *metal_layer); 42 43 struct wsi_metal_layer_blit_context; 44 45 struct wsi_metal_layer_blit_context * 46 wsi_create_metal_layer_blit_context(); 47 48 void 49 wsi_destroy_metal_layer_blit_context(struct wsi_metal_layer_blit_context *context); 50 51 void 52 wsi_metal_layer_blit_and_present(struct wsi_metal_layer_blit_context *context, 53 CAMetalDrawableBridged **drawable_ptr, void *buffer, 54 uint32_t width, uint32_t height, uint32_t row_pitch); 55 56 void 57 wsi_metal_layer_cancel_present(struct wsi_metal_layer_blit_context *context, 58 CAMetalDrawableBridged **drawable_ptr); 59 60 #endif // WSI_COMMON_METAL_LAYER_H 61