Greg Daniel | eee5183 | 2017-07-28 11:31:19 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrMtlTypes_DEFINED |
| 9 | #define GrMtlTypes_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/gpu/GrTypes.h" |
Jim Van Verth | 8429422 | 2019-06-07 13:10:50 -0400 | [diff] [blame] | 12 | #include "include/ports/SkCFObject.h" |
Jim Van Verth | dac1e55 | 2019-05-31 09:10:55 -0400 | [diff] [blame] | 13 | |
Timothy Liang | 4e85e80 | 2018-06-28 16:37:18 -0400 | [diff] [blame] | 14 | /** |
| 15 | * Declares typedefs for Metal types used in Ganesh cpp code |
| 16 | */ |
Greg Daniel | 8426165 | 2021-09-19 17:53:40 -0400 | [diff] [blame^] | 17 | using GrMTLPixelFormat = unsigned int; |
| 18 | using GrMTLTextureUsage = unsigned int; |
| 19 | using GrMTLStorageMode = unsigned int; |
| 20 | using GrMTLHandle = const void*; |
Timothy Liang | 4e85e80 | 2018-06-28 16:37:18 -0400 | [diff] [blame] | 21 | |
| 22 | /////////////////////////////////////////////////////////////////////////////// |
Jim Van Verth | dac1e55 | 2019-05-31 09:10:55 -0400 | [diff] [blame] | 23 | |
Jim Van Verth | 4556426 | 2021-03-22 16:08:31 -0400 | [diff] [blame] | 24 | #ifdef __APPLE__ |
Chinmay Garde | 13b6cf6 | 2020-04-22 17:48:18 -0700 | [diff] [blame] | 25 | |
| 26 | #include <TargetConditionals.h> |
| 27 | |
| 28 | #if TARGET_OS_SIMULATOR |
| 29 | #define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(13.0)) |
| 30 | #else // TARGET_OS_SIMULATOR |
| 31 | #define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(8.0)) |
| 32 | #endif // TARGET_OS_SIMULATOR |
| 33 | |
Timothy Liang | 4e85e80 | 2018-06-28 16:37:18 -0400 | [diff] [blame] | 34 | /** |
Jim Van Verth | dac1e55 | 2019-05-31 09:10:55 -0400 | [diff] [blame] | 35 | * Types for interacting with Metal resources created externally to Skia. |
| 36 | * This is used by GrBackendObjects. |
Timothy Liang | 4e85e80 | 2018-06-28 16:37:18 -0400 | [diff] [blame] | 37 | */ |
| 38 | struct GrMtlTextureInfo { |
| 39 | public: |
Jim Van Verth | dac1e55 | 2019-05-31 09:10:55 -0400 | [diff] [blame] | 40 | GrMtlTextureInfo() {} |
| 41 | |
Jim Van Verth | 4556426 | 2021-03-22 16:08:31 -0400 | [diff] [blame] | 42 | sk_cfp<GrMTLHandle> fTexture; |
Timothy Liang | 4e85e80 | 2018-06-28 16:37:18 -0400 | [diff] [blame] | 43 | |
| 44 | bool operator==(const GrMtlTextureInfo& that) const { |
| 45 | return fTexture == that.fTexture; |
| 46 | } |
| 47 | }; |
Jim Van Verth | 9e64047 | 2020-11-19 12:59:06 -0500 | [diff] [blame] | 48 | |
Greg Daniel | 8426165 | 2021-09-19 17:53:40 -0400 | [diff] [blame^] | 49 | struct GrMtlSurfaceInfo { |
| 50 | uint32_t fSampleCount = 1; |
| 51 | uint32_t fLevelCount = 0; |
| 52 | GrProtected fProtected = GrProtected::kNo; |
| 53 | |
| 54 | // Since we aren't in an Obj-C header we can't directly use Mtl types here. Each of these can |
| 55 | // cast to their mapped Mtl types list below. |
| 56 | GrMTLPixelFormat fFormat = 0; // MTLPixelFormat fFormat = MTLPixelFormatInvalid; |
| 57 | GrMTLTextureUsage fUsage = 0; // MTLTextureUsage fUsage = MTLTextureUsageUnknown; |
| 58 | GrMTLStorageMode fStorageMode = 0; // MTLStorageMode fStorageMode = MTLStorageModeShared; |
| 59 | }; |
| 60 | |
Jim Van Verth | 066ceb1 | 2019-08-28 14:35:55 -0400 | [diff] [blame] | 61 | #endif |
Greg Daniel | eee5183 | 2017-07-28 11:31:19 -0400 | [diff] [blame] | 62 | |
| 63 | #endif |