Flutter Engine
The Flutter Engine
GrMtlTypesPriv.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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 GrMtlTypesPriv_DEFINED
9#define GrMtlTypesPriv_DEFINED
10
11#include "include/gpu/GrTypes.h"
13
14///////////////////////////////////////////////////////////////////////////////
15
16#ifdef __APPLE__
17
18#include <TargetConditionals.h>
19
20#if defined(SK_BUILD_FOR_MAC)
21#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 130000
22#define GR_METAL_SDK_VERSION 300
23#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
24#define GR_METAL_SDK_VERSION 240
25#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
26#define GR_METAL_SDK_VERSION 230
27#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
28#define GR_METAL_SDK_VERSION 220
29#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
30#define GR_METAL_SDK_VERSION 210
31#else
32#error Must use at least 10.14 SDK to build Metal backend for MacOS
33#endif
34#else
35#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000 || __TV_OS_VERSION_MAX_ALLOWED >= 160000
36#define GR_METAL_SDK_VERSION 300
37#elif __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 || __TV_OS_VERSION_MAX_ALLOWED >= 150000
38#define GR_METAL_SDK_VERSION 240
39#elif __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 || __TV_OS_VERSION_MAX_ALLOWED >= 140000
40#define GR_METAL_SDK_VERSION 230
41#elif __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 || __TV_OS_VERSION_MAX_ALLOWED >= 130000
42#define GR_METAL_SDK_VERSION 220
43#elif __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000 || __TV_OS_VERSION_MAX_ALLOWED >= 120000
44#define GR_METAL_SDK_VERSION 210
45#else
46#error Must use at least 12.00 SDK to build Metal backend for iOS
47#endif
48#endif
49
50#if __has_feature(objc_arc) && __has_attribute(objc_externally_retained)
51#define GR_NORETAIN __attribute__((objc_externally_retained))
52#define GR_NORETAIN_BEGIN \
53 _Pragma("clang attribute push (__attribute__((objc_externally_retained)), apply_to=any(function,objc_method))")
54#define GR_NORETAIN_END _Pragma("clang attribute pop")
55#else
56#define GR_NORETAIN
57#define GR_NORETAIN_BEGIN
58#define GR_NORETAIN_END
59#endif
60
61struct GrMtlTextureSpec {
62 GrMtlTextureSpec()
63 : fFormat(0)
64 , fUsage(0)
65 , fStorageMode(0) {}
66 GrMtlTextureSpec(const GrMtlSurfaceInfo& info)
67 : fFormat(info.fFormat)
68 , fUsage(info.fUsage)
69 , fStorageMode(info.fStorageMode) {}
70
71 GrMTLPixelFormat fFormat;
72 GrMTLTextureUsage fUsage;
73 GrMTLStorageMode fStorageMode;
74};
75
76GrMtlSurfaceInfo GrMtlTextureSpecToSurfaceInfo(const GrMtlTextureSpec& mtlSpec,
77 uint32_t sampleCount,
78 uint32_t levelCount,
79 skgpu::Protected isProtected);
80
81#endif // __APPLE__
82
83#endif // GrMtlTypesPriv_DEFINED
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
GrMtlSurfaceInfo GrMtlTextureSpecToSurfaceInfo(const GrMtlTextureSpec &mtlSpec, uint32_t sampleCount, uint32_t levelCount, GrProtected isProtected)
unsigned int GrMTLStorageMode
Definition: GrMtlTypes.h:19
unsigned int GrMTLPixelFormat
Definition: GrMtlTypes.h:17
unsigned int GrMTLTextureUsage
Definition: GrMtlTypes.h:18
Protected
Definition: GpuTypes.h:61