blob: f7a232e3c6ceaab8414b70c0ac7930033118b206 [file] [log] [blame]
Greg Danieleee51832017-07-28 11:31:19 -04001/*
2 * Copyright 2017 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 GrMtlTypes_DEFINED
9#define GrMtlTypes_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/gpu/GrTypes.h"
Jim Van Verth84294222019-06-07 13:10:50 -040012#include "include/ports/SkCFObject.h"
Jim Van Verthdac1e552019-05-31 09:10:55 -040013
Timothy Liang4e85e802018-06-28 16:37:18 -040014/**
15 * Declares typedefs for Metal types used in Ganesh cpp code
16 */
Greg Daniel84261652021-09-19 17:53:40 -040017using GrMTLPixelFormat = unsigned int;
18using GrMTLTextureUsage = unsigned int;
19using GrMTLStorageMode = unsigned int;
20using GrMTLHandle = const void*;
Timothy Liang4e85e802018-06-28 16:37:18 -040021
22///////////////////////////////////////////////////////////////////////////////
Jim Van Verthdac1e552019-05-31 09:10:55 -040023
Jim Van Verth45564262021-03-22 16:08:31 -040024#ifdef __APPLE__
Chinmay Garde13b6cf62020-04-22 17:48:18 -070025
26#include <TargetConditionals.h>
27
28#if TARGET_OS_SIMULATOR
29#define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(13.0))
30#else // TARGET_OS_SIMULATOR
31#define SK_API_AVAILABLE_CA_METAL_LAYER SK_API_AVAILABLE(macos(10.11), ios(8.0))
32#endif // TARGET_OS_SIMULATOR
33
Timothy Liang4e85e802018-06-28 16:37:18 -040034/**
Jim Van Verthdac1e552019-05-31 09:10:55 -040035 * Types for interacting with Metal resources created externally to Skia.
36 * This is used by GrBackendObjects.
Timothy Liang4e85e802018-06-28 16:37:18 -040037 */
38struct GrMtlTextureInfo {
39public:
Jim Van Verthdac1e552019-05-31 09:10:55 -040040 GrMtlTextureInfo() {}
41
Jim Van Verth45564262021-03-22 16:08:31 -040042 sk_cfp<GrMTLHandle> fTexture;
Timothy Liang4e85e802018-06-28 16:37:18 -040043
44 bool operator==(const GrMtlTextureInfo& that) const {
45 return fTexture == that.fTexture;
46 }
47};
Jim Van Verth9e640472020-11-19 12:59:06 -050048
Greg Daniel84261652021-09-19 17:53:40 -040049struct GrMtlSurfaceInfo {
50 uint32_t fSampleCount = 1;
51 uint32_t fLevelCount = 0;
52 GrProtected fProtected = GrProtected::kNo;
53
54 // Since we aren't in an Obj-C header we can't directly use Mtl types here. Each of these can
55 // cast to their mapped Mtl types list below.
56 GrMTLPixelFormat fFormat = 0; // MTLPixelFormat fFormat = MTLPixelFormatInvalid;
57 GrMTLTextureUsage fUsage = 0; // MTLTextureUsage fUsage = MTLTextureUsageUnknown;
58 GrMTLStorageMode fStorageMode = 0; // MTLStorageMode fStorageMode = MTLStorageModeShared;
59};
60
Jim Van Verth066ceb12019-08-28 14:35:55 -040061#endif
Greg Danieleee51832017-07-28 11:31:19 -040062
63#endif