1 /* 2 * Copyright 2018 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 GrMtlCppUtil_DEFINED 9 #define GrMtlCppUtil_DEFINED 10 11 #include "include/core/SkImage.h" 12 #include "include/gpu/mtl/GrMtlTypes.h" 13 #include "include/private/GrTypesPriv.h" 14 15 class GrBackendFormat; 16 17 // Utilities that can be used from cpp files (rather than .mm). 18 19 GrMTLPixelFormat GrGetMTLPixelFormatFromMtlTextureInfo(const GrMtlTextureInfo&); 20 21 size_t GrMtlBackendFormatBytesPerBlock(const GrBackendFormat& format); 22 23 int GrMtlBackendFormatStencilBits(const GrBackendFormat& format); 24 25 uint32_t GrMtlFormatChannels(GrMTLPixelFormat); 26 27 GrColorFormatDesc GrMtlFormatDesc(GrMTLPixelFormat); 28 29 SkImage::CompressionType GrMtlBackendFormatToCompressionType(const GrBackendFormat& format); 30 31 /** 32 * Gets the sample count of a texture held by GrMtlTextureInfo or zero if the texture is nil. 33 */ 34 int GrMtlTextureInfoSampleCount(const GrMtlTextureInfo&); 35 36 #if defined(SK_DEBUG) || GR_TEST_UTILS 37 const char* GrMtlFormatToStr(GrMTLPixelFormat mtlFormat); 38 bool GrMtlFormatIsBGRA8(GrMTLPixelFormat mtlFormat); 39 #endif 40 41 #endif 42