3 * Copyright 2015 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
9 #ifndef GrGLTypes_DEFINED
10 #define GrGLTypes_DEFINED
12 #include "include/core/SkRefCnt.h"
13 #include "include/gpu/gl/GrGLConfig.h"
16 * Classifies GL contexts by which standard they implement (currently as OpenGL vs. OpenGL ES).
24 static const int kGrGLStandardCnt = 4;
26 // The following allow certain interfaces to be turned off at compile time
27 // (for example, to lower code size).
29 #define GR_IS_GR_GL(standard) false
30 #define GR_IS_GR_GL_ES(standard) true
31 #define GR_IS_GR_WEBGL(standard) false
32 #define SK_DISABLE_GL_INTERFACE 1
33 #define SK_DISABLE_WEBGL_INTERFACE 1
35 #define GR_IS_GR_GL(standard) true
36 #define GR_IS_GR_GL_ES(standard) false
37 #define GR_IS_GR_WEBGL(standard) false
38 #define SK_DISABLE_GL_ES_INTERFACE 1
39 #define SK_DISABLE_WEBGL_INTERFACE 1
41 #define GR_IS_GR_GL(standard) false
42 #define GR_IS_GR_GL_ES(standard) false
43 #define GR_IS_GR_WEBGL(standard) true
44 #define SK_DISABLE_GL_ES_INTERFACE 1
45 #define SK_DISABLE_GL_INTERFACE 1
47 #define GR_IS_GR_GL(standard) (kGL_GrGLStandard == standard)
48 #define GR_IS_GR_GL_ES(standard) (kGLES_GrGLStandard == standard)
49 #define GR_IS_GR_WEBGL(standard) (kWebGL_GrGLStandard == standard)
52 ///////////////////////////////////////////////////////////////////////////////
55 * The supported GL formats represented as an enum. Actual support by GrContext depends on GL
56 * context version and extensions.
58 enum class GrGLFormat {
76 kCOMPRESSED_ETC1_RGB8,
77 kCOMPRESSED_RGB8_ETC2,
79 kCOMPRESSED_RGBA8_BC1,
86 kLastColorFormat = kLUMINANCE16F,
88 // Depth/Stencil formats
93 kLast = kDEPTH24_STENCIL8
96 ///////////////////////////////////////////////////////////////////////////////
98 * Declares typedefs for all the GL functions used in GrGLInterface
101 typedef unsigned int GrGLenum;
102 typedef unsigned char GrGLboolean;
103 typedef unsigned int GrGLbitfield;
104 typedef signed char GrGLbyte;
105 typedef char GrGLchar;
106 typedef short GrGLshort;
108 typedef int GrGLsizei;
109 typedef int64_t GrGLint64;
110 typedef unsigned char GrGLubyte;
111 typedef unsigned short GrGLushort;
112 typedef unsigned int GrGLuint;
113 typedef uint64_t GrGLuint64;
114 typedef unsigned short int GrGLhalf;
115 typedef float GrGLfloat;
116 typedef float GrGLclampf;
117 typedef double GrGLdouble;
118 typedef double GrGLclampd;
119 typedef void GrGLvoid;
121 typedef signed long long int GrGLintptr;
122 typedef signed long long int GrGLsizeiptr;
124 typedef signed long int GrGLintptr;
125 typedef signed long int GrGLsizeiptr;
127 typedef void* GrGLeglImage;
128 typedef struct __GLsync* GrGLsync;
130 struct GrGLDrawArraysIndirectCommand {
132 GrGLuint fInstanceCount;
134 GrGLuint fBaseInstance; // Requires EXT_base_instance on ES.
137 // static_asserts must have messages in this file because its included in C++14 client code.
138 static_assert(16 == sizeof(GrGLDrawArraysIndirectCommand), "");
140 struct GrGLDrawElementsIndirectCommand {
142 GrGLuint fInstanceCount;
143 GrGLuint fFirstIndex;
144 GrGLuint fBaseVertex;
145 GrGLuint fBaseInstance; // Requires EXT_base_instance on ES.
148 static_assert(20 == sizeof(GrGLDrawElementsIndirectCommand), "");
153 typedef void (GR_GL_FUNCTION_TYPE* GRGLDEBUGPROC)(GrGLenum source,
158 const GrGLchar* message,
159 const void* userParam);
164 typedef void* GrEGLImage;
165 typedef void* GrEGLDisplay;
166 typedef void* GrEGLContext;
167 typedef void* GrEGLClientBuffer;
168 typedef unsigned int GrEGLenum;
169 typedef int32_t GrEGLint;
170 typedef unsigned int GrEGLBoolean;
172 ///////////////////////////////////////////////////////////////////////////////
174 * Types for interacting with GL resources created externally to Skia. GrBackendObjects for GL
175 * textures are really const GrGLTexture*. The fFormat here should be a sized, internal format
176 * for the texture. We will try to use the sized format if the GL Context supports it, otherwise
177 * we will internally fall back to using the base internal formats.
179 struct GrGLTextureInfo {
182 GrGLenum fFormat = 0;
184 bool operator==(const GrGLTextureInfo& that) const {
185 return fTarget == that.fTarget && fID == that.fID && fFormat == that.fFormat;
189 struct GrGLFramebufferInfo {
191 GrGLenum fFormat = 0;
193 bool operator==(const GrGLFramebufferInfo& that) const {
194 return fFBOID == that.fFBOID && fFormat == that.fFormat;
198 struct GrGLSurfaceInfo {
199 uint32_t fSampleCount = 1;
200 uint32_t fLevelCount = 0;
201 GrProtected fProtected = GrProtected::kNo;
203 GrGLenum fTarget = 0;
204 GrGLenum fFormat = 0;