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_MtlGraphiteTypes_DEFINED 9 #define skgpu_graphite_MtlGraphiteTypes_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), tvos(13.0)) 23 #else // TARGET_OS_SIMULATOR 24 #define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(8.0), tvos(9.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 39 struct MtlTextureInfo { 40 uint32_t fSampleCount = 1; 41 skgpu::Mipmapped fMipmapped = skgpu::Mipmapped::kNo; 42 43 // Since we aren't in an Obj-C header we can't directly use Mtl types here. Each of these can 44 // cast to their mapped Mtl types list below. 45 MtlPixelFormat fFormat = 0; // MTLPixelFormat fFormat = MTLPixelFormatInvalid; 46 MtlTextureUsage fUsage = 0; // MTLTextureUsage fUsage = MTLTextureUsageUnknown; 47 MtlStorageMode fStorageMode = 0; // MTLStorageMode fStorageMode = MTLStorageModeShared; 48 bool fFramebufferOnly = false; 49 50 MtlTextureInfo() = default; 51 MtlTextureInfo(CFTypeRef mtlTexture); MtlTextureInfoMtlTextureInfo52 MtlTextureInfo(uint32_t sampleCount, 53 skgpu::Mipmapped mipmapped, 54 MtlPixelFormat format, 55 MtlTextureUsage usage, 56 MtlStorageMode storageMode, 57 bool framebufferOnly) 58 : fSampleCount(sampleCount) 59 , fMipmapped(mipmapped) 60 , fFormat(format) 61 , fUsage(usage) 62 , fStorageMode(storageMode) 63 , fFramebufferOnly(framebufferOnly) {} 64 }; 65 66 } // namespace skgpu::graphite 67 68 #endif // skgpu_graphite_MtlGraphiteTypes_DEFINED 69