Debian Codegraph @

include/gpu/ganesh/gl/GrGLTypes.h

raw
1
2 /*
3 * Copyright 2015 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #ifndef GrGLTypes_DEFINED
10 #define GrGLTypes_DEFINED
11
12 #include "include/core/SkRefCnt.h"
13 #include "include/gpu/GpuTypes.h"
14 #include "include/gpu/ganesh/gl/GrGLConfig.h"
15
16 /**
17 * Classifies GL contexts by which standard they implement (currently as OpenGL vs. OpenGL ES).
18 */
19 enum GrGLStandard {
20 kNone_GrGLStandard,
21 kGL_GrGLStandard,
22 kGLES_GrGLStandard,
23 kWebGL_GrGLStandard,
24 };
25 static const int kGrGLStandardCnt = 4;
26
27 // The following allow certain interfaces to be turned off at compile time
28 // (for example, to lower code size).
29 #if SK_ASSUME_GL_ES
30 #define GR_IS_GR_GL(standard) false
31 #define GR_IS_GR_GL_ES(standard) true
32 #define GR_IS_GR_WEBGL(standard) false
33 #define SK_DISABLE_GL_INTERFACE 1
34 #define SK_DISABLE_WEBGL_INTERFACE 1
35 #elif SK_ASSUME_GL
36 #define GR_IS_GR_GL(standard) true
37 #define GR_IS_GR_GL_ES(standard) false
38 #define GR_IS_GR_WEBGL(standard) false
39 #define SK_DISABLE_GL_ES_INTERFACE 1
40 #define SK_DISABLE_WEBGL_INTERFACE 1
41 #elif SK_ASSUME_WEBGL
42 #define GR_IS_GR_GL(standard) false
43 #define GR_IS_GR_GL_ES(standard) false
44 #define GR_IS_GR_WEBGL(standard) true
45 #define SK_DISABLE_GL_ES_INTERFACE 1
46 #define SK_DISABLE_GL_INTERFACE 1
47 #else
48 #define GR_IS_GR_GL(standard) (kGL_GrGLStandard == standard)
49 #define GR_IS_GR_GL_ES(standard) (kGLES_GrGLStandard == standard)
50 #define GR_IS_GR_WEBGL(standard) (kWebGL_GrGLStandard == standard)
51 #endif
52
53 ///////////////////////////////////////////////////////////////////////////////
54
55 /**
56 * The supported GL formats represented as an enum. Actual support by GrContext depends on GL
57 * context version and extensions.
58 */
59 enum class GrGLFormat {
60 kUnknown,
61
62 kRGBA8,
63 kR8,
64 kALPHA8,
65 kLUMINANCE8,
66 kLUMINANCE8_ALPHA8,
67 kBGRA8,
68 kRGB565,
69 kRGBA16F,
70 kR16F,
71 kRGB8,
72 kRGBX8,
73 kRG8,
74 kRGB10_A2,
75 kRGBA4,
76 kSRGB8_ALPHA8,
77 kCOMPRESSED_ETC1_RGB8,
78 kCOMPRESSED_RGB8_ETC2,
79 kCOMPRESSED_RGB8_BC1,
80 kCOMPRESSED_RGBA8_BC1,
81 kR16,
82 kRG16,
83 kRGBA16,
84 kRG16F,
85 kLUMINANCE16F,
86
87 kLastColorFormat = kLUMINANCE16F,
88
89 // Depth/Stencil formats
90 kSTENCIL_INDEX8,
91 kSTENCIL_INDEX16,
92 kDEPTH24_STENCIL8,
93
94 kLast = kDEPTH24_STENCIL8
95 };
96
97 ///////////////////////////////////////////////////////////////////////////////
98 /**
99 * Declares typedefs for all the GL functions used in GrGLInterface
100 */
101
102 typedef unsigned int GrGLenum;
103 typedef unsigned char GrGLboolean;
104 typedef unsigned int GrGLbitfield;
105 typedef signed char GrGLbyte;
106 typedef char GrGLchar;
107 typedef short GrGLshort;
108 typedef int GrGLint;
109 typedef int GrGLsizei;
110 typedef int64_t GrGLint64;
111 typedef unsigned char GrGLubyte;
112 typedef unsigned short GrGLushort;
113 typedef unsigned int GrGLuint;
114 typedef uint64_t GrGLuint64;
115 typedef unsigned short int GrGLhalf;
116 typedef float GrGLfloat;
117 typedef float GrGLclampf;
118 typedef double GrGLdouble;
119 typedef double GrGLclampd;
120 typedef void GrGLvoid;
121 #ifdef _WIN64
122 typedef signed long long int GrGLintptr;
123 typedef signed long long int GrGLsizeiptr;
124 #else
125 typedef signed long int GrGLintptr;
126 typedef signed long int GrGLsizeiptr;
127 #endif
128 typedef void* GrGLeglImage;
129 typedef struct __GLsync* GrGLsync;
130
131 struct GrGLDrawArraysIndirectCommand {
132 GrGLuint fCount;
133 GrGLuint fInstanceCount;
134 GrGLuint fFirst;
135 GrGLuint fBaseInstance; // Requires EXT_base_instance on ES.
136 };
137
138 // static_asserts must have messages in this file because its included in C++14 client code.
139 static_assert(16 == sizeof(GrGLDrawArraysIndirectCommand), "");
140
141 struct GrGLDrawElementsIndirectCommand {
142 GrGLuint fCount;
143 GrGLuint fInstanceCount;
144 GrGLuint fFirstIndex;
145 GrGLuint fBaseVertex;
146 GrGLuint fBaseInstance; // Requires EXT_base_instance on ES.
147 };
148
149 static_assert(20 == sizeof(GrGLDrawElementsIndirectCommand), "");
150
151 /**
152 * KHR_debug
153 */
154 typedef void (GR_GL_FUNCTION_TYPE* GRGLDEBUGPROC)(GrGLenum source,
155 GrGLenum type,
156 GrGLuint id,
157 GrGLenum severity,
158 GrGLsizei length,
159 const GrGLchar* message,
160 const void* userParam);
161
162 /**
163 * EGL types.
164 */
165 typedef void* GrEGLImage;
166 typedef void* GrEGLDisplay;
167 typedef void* GrEGLContext;
168 typedef void* GrEGLClientBuffer;
169 typedef unsigned int GrEGLenum;
170 typedef int32_t GrEGLint;
171 typedef unsigned int GrEGLBoolean;
172
173 ///////////////////////////////////////////////////////////////////////////////
174 /**
175 * Types for interacting with GL resources created externally to Skia. GrBackendObjects for GL
176 * textures are really const GrGLTexture*. The fFormat here should be a sized, internal format
177 * for the texture. We will try to use the sized format if the GL Context supports it, otherwise
178 * we will internally fall back to using the base internal formats.
179 */
180 struct GrGLTextureInfo {
181 GrGLenum fTarget;
182 GrGLuint fID;
183 GrGLenum fFormat = 0;
184 skgpu::Protected fProtected = skgpu::Protected::kNo;
185
186 bool operator==(const GrGLTextureInfo& that) const {
187 return fTarget == that.fTarget &&
188 fID == that.fID &&
189 fFormat == that.fFormat &&
190 fProtected == that.fProtected;
191 }
192
193 bool isProtected() const { return fProtected == skgpu::Protected::kYes; }
194 };
195
196 struct GrGLFramebufferInfo {
197 GrGLuint fFBOID;
198 GrGLenum fFormat = 0;
199 skgpu::Protected fProtected = skgpu::Protected::kNo;
200
201 bool operator==(const GrGLFramebufferInfo& that) const {
202 return fFBOID == that.fFBOID &&
203 fFormat == that.fFormat &&
204 fProtected == that.fProtected;
205 }
206
207 bool isProtected() const { return fProtected == skgpu::Protected::kYes; }
208 };
209
210 struct GrGLSurfaceInfo {
211 uint32_t fSampleCount = 1;
212 uint32_t fLevelCount = 0;
213 skgpu::Protected fProtected = skgpu::Protected::kNo;
214
215 GrGLenum fTarget = 0;
216 GrGLenum fFormat = 0;
217 };
218
219 #endif