blob: 2e108e1110923daee7d8fcfe1805ee6215ba8721 [file] [log] [blame]
Brian Salomonf391d0f2018-12-14 09:18:50 -05001/*
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
Greg Daniel01f278c2020-06-12 16:58:17 -040011#include "include/core/SkImage.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "include/gpu/mtl/GrMtlTypes.h"
Brian Salomonf391d0f2018-12-14 09:18:50 -050013
Greg Daniel01f278c2020-06-12 16:58:17 -040014class GrBackendFormat;
15
Brian Salomonf391d0f2018-12-14 09:18:50 -050016// Utilities that can be used from cpp files (rather than .mm).
17
18GrMTLPixelFormat GrGetMTLPixelFormatFromMtlTextureInfo(const GrMtlTextureInfo&);
19
Greg Daniel0eca74c2020-10-01 13:46:00 -040020size_t GrMtlBackendFormatBytesPerBlock(const GrBackendFormat& format);
21
Greg Daniela7f69c22020-10-07 13:04:15 -040022int GrMtlBackendFormatStencilBits(const GrBackendFormat& format);
23
Brian Salomondc8fcdb2020-03-26 16:45:05 -040024uint32_t GrMtlFormatChannels(GrMTLPixelFormat);
25
Greg Daniel01f278c2020-06-12 16:58:17 -040026SkImage::CompressionType GrMtlBackendFormatToCompressionType(const GrBackendFormat& format);
27
Brian Salomon8e0aa442020-09-30 13:50:18 -040028/**
29 * Gets the sample count of a texture held by GrMtlTextureInfo or zero if the texture is nil.
30 */
31int GrMtlTextureInfoSampleCount(const GrMtlTextureInfo&);
32
Robert Phillips8e54a6e2020-08-17 14:31:02 -040033#if defined(SK_DEBUG) || GR_TEST_UTILS
Robert Phillipsbac46722019-08-01 15:09:17 -040034const char* GrMtlFormatToStr(GrMTLPixelFormat mtlFormat);
Robert Phillips9a30ee02020-04-29 08:58:39 -040035bool GrMtlFormatIsBGRA8(GrMTLPixelFormat mtlFormat);
Robert Phillipsbac46722019-08-01 15:09:17 -040036#endif
Brian Salomonf391d0f2018-12-14 09:18:50 -050037
38#endif