1 /* 2 * Copyright 2021 Google LLC 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 skgpu_graphite_MtlTypes_DEFINED 9 #define skgpu_graphite_MtlTypes_DEFINED 10 11 #include "include/gpu/graphite/GraphiteTypes.h" 12 #include "include/ports/SkCFObject.h" 13 14 /////////////////////////////////////////////////////////////////////////////// 15 16 #ifdef __APPLE__ 17 18 #include <CoreFoundation/CoreFoundation.h> 19 #include <TargetConditionals.h> 20 21 #if TARGET_OS_SIMULATOR 22 #define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(13.0)) 23 #else // TARGET_OS_SIMULATOR 24 #define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(8.0)) 25 #endif // TARGET_OS_SIMULATOR 26 27 #endif // __APPLE__ 28 29 30 namespace skgpu::graphite { 31 32 /** 33 * Declares typedefs for Metal types used in Graphite cpp code 34 */ 35 using MtlPixelFormat = unsigned int; 36 using MtlTextureUsage = unsigned int; 37 using MtlStorageMode = unsigned int; 38 using MtlHandle = const void*; 39 40 struct MtlTextureInfo { 41 uint32_t fSampleCount = 1; 42 skgpu::Mipmapped fMipmapped = skgpu::Mipmapped::kNo; 43 44 // Since we aren't in an Obj-C header we can't directly use Mtl types here. Each of these can 45 // cast to their mapped Mtl types list below. 46 MtlPixelFormat fFormat = 0; // MTLPixelFormat fFormat = MTLPixelFormatInvalid; 47 MtlTextureUsage fUsage = 0; // MTLTextureUsage fUsage = MTLTextureUsageUnknown; 48 MtlStorageMode fStorageMode = 0; // MTLStorageMode fStorageMode = MTLStorageModeShared; 49 bool fFramebufferOnly = false; 50 51 MtlTextureInfo() = default; 52 MtlTextureInfo(MtlHandle mtlTexture); MtlTextureInfoMtlTextureInfo53 MtlTextureInfo(uint32_t sampleCount, 54 skgpu::Mipmapped mipmapped, 55 MtlPixelFormat format, 56 MtlTextureUsage usage, 57 MtlStorageMode storageMode, 58 bool framebufferOnly) 59 : fSampleCount(sampleCount) 60 , fMipmapped(mipmapped) 61 , fFormat(format) 62 , fUsage(usage) 63 , fStorageMode(storageMode) 64 , fFramebufferOnly(framebufferOnly) {} 65 }; 66 67 } // namespace skgpu::graphite 68 69 #endif // skgpu_graphite_MtlTypes_DEFINED 70