• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
11 #include "include/gpu/GrTypes.h"
12 #include "include/ports/SkCFObject.h"
13 
14 /**
15  * Declares typedefs for Metal types used in Ganesh cpp code
16  */
17 using GrMTLPixelFormat = unsigned int;
18 using GrMTLTextureUsage = unsigned int;
19 using GrMTLStorageMode = unsigned int;
20 using GrMTLHandle = const void*;
21 
22 ///////////////////////////////////////////////////////////////////////////////
23 
24 #ifdef __APPLE__
25 
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 
34 /**
35  * Types for interacting with Metal resources created externally to Skia.
36  * This is used by GrBackendObjects.
37  */
38 struct GrMtlTextureInfo {
39 public:
GrMtlTextureInfoGrMtlTextureInfo40     GrMtlTextureInfo() {}
41 
42     sk_cfp<GrMTLHandle> fTexture;
43 
44     bool operator==(const GrMtlTextureInfo& that) const {
45         return fTexture == that.fTexture;
46     }
47 };
48 
49 struct 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 
61 #endif
62 
63 #endif
64