1 /* 2 * Copyright 2022 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 skgpu_MtlMemoryAllocator_DEFINED 9 #define skgpu_MtlMemoryAllocator_DEFINED 10 11 #ifdef __APPLE__ 12 13 #ifdef __OBJC__ 14 #import <Metal/Metal.h> 15 #endif 16 17 namespace skgpu { 18 19 // interface classes for the GPU memory allocator 20 class MtlAlloc : public SkRefCnt { 21 public: 22 ~MtlAlloc() override = default; 23 }; 24 25 #ifdef __OBJC__ 26 class MtlMemoryAllocator : public SkRefCnt { 27 public: 28 virtual id<MTLBuffer> newBufferWithLength(NSUInteger length, MTLResourceOptions options, 29 sk_sp<MtlAlloc>* allocation) = 0; 30 virtual id<MTLTexture> newTextureWithDescriptor(MTLTextureDescriptor* texDesc, 31 sk_sp<MtlAlloc>* allocation) = 0; 32 }; 33 #endif 34 35 } // namespace skgpu 36 37 #endif // __APPLE__ 38 39 #endif // skgpu_MtlMemoryAllocator_DEFINED 40