1 /* 2 * Copyright 2024 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_MtlGraphiteTypesUtils_DEFINED 9 #define skgpu_graphite_MtlGraphiteTypesUtils_DEFINED 10 11 #include "include/core/SkTypes.h" 12 13 #include "include/gpu/graphite/BackendTexture.h" 14 #include "include/gpu/graphite/TextureInfo.h" 15 #include "include/private/base/SkAPI.h" 16 17 #import <CoreFoundation/CoreFoundation.h> 18 19 namespace skgpu::graphite { 20 21 struct SK_API MtlTextureInfo; 22 23 namespace TextureInfos { 24 SK_API TextureInfo MakeMetal(const MtlTextureInfo&); 25 SK_API TextureInfo MakeMetal(CFTypeRef mtlTexture); 26 27 SK_API bool GetMtlTextureInfo(const TextureInfo&, MtlTextureInfo*); 28 } // namespace TextureInfos 29 30 namespace BackendTextures { 31 // The BackendTexture will not call retain or release on the passed in CFTypeRef. Thus the 32 // client must keep the CFTypeRef valid until they are no longer using the BackendTexture. 33 SK_API BackendTexture MakeMetal(SkISize dimensions, CFTypeRef mtlTexture); 34 35 SK_API CFTypeRef GetMtlTexture(const BackendTexture&); 36 } // namespace BackendTextures 37 38 namespace BackendSemaphores { 39 // TODO(b/286088355) Determine creator's responsibility for setting refcnt. 40 SK_API BackendSemaphore MakeMetal(CFTypeRef mtlEvent, uint64_t value); 41 42 SK_API CFTypeRef GetMtlEvent(const BackendSemaphore&); 43 SK_API uint64_t GetMtlValue(const BackendSemaphore&); 44 } // namespace BackendSemaphores 45 46 } // namespace skgpu::graphite 47 48 #endif // skgpu_graphite_MtlGraphiteTypesUtils_DEFINED 49