DevTools: kill codeschool extension from whitelist
[chromium-blink-merge.git] / ui / gl / gl_bindings.h
blob55432fa816069baa4b970e6797b943836b5f0f6c
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_GL_GL_BINDINGS_H_
6 #define UI_GL_GL_BINDINGS_H_
8 #include <string>
10 // Includes the platform independent and platform dependent GL headers.
11 // Only include this in cc files. It pulls in system headers, including
12 // the X11 headers on linux, which define all kinds of macros that are
13 // liable to cause conflicts.
15 #include <GL/gl.h>
16 #include <GL/glext.h>
17 #include <EGL/egl.h>
18 #include <EGL/eglext.h>
20 #include "base/logging.h"
21 #include "base/threading/thread_local.h"
22 #include "build/build_config.h"
23 #include "ui/gl/gl_export.h"
25 // The standard OpenGL native extension headers are also included.
26 #if defined(OS_WIN)
27 #include <GL/wglext.h>
28 #elif defined(OS_MACOSX)
29 #include <OpenGL/OpenGL.h>
30 #elif defined(USE_X11)
31 #include <GL/glx.h>
32 #include <GL/glxext.h>
34 // Undefine some macros defined by X headers. This is why this file should only
35 // be included in .cc files.
36 #undef Bool
37 #undef None
38 #undef Status
39 #endif
42 // GLES2 defines not part of Desktop GL
43 // Shader Precision-Specified Types
44 #define GL_LOW_FLOAT 0x8DF0
45 #define GL_MEDIUM_FLOAT 0x8DF1
46 #define GL_HIGH_FLOAT 0x8DF2
47 #define GL_LOW_INT 0x8DF3
48 #define GL_MEDIUM_INT 0x8DF4
49 #define GL_HIGH_INT 0x8DF5
50 #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
51 #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
52 #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
53 #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
54 #define GL_MAX_VARYING_VECTORS 0x8DFC
55 #define GL_SHADER_BINARY_FORMATS 0x8DF8
56 #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
57 #define GL_SHADER_COMPILER 0x8DFA
58 #define GL_RGB565 0x8D62
59 #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
60 #define GL_RGB8_OES 0x8051
61 #define GL_RGBA8_OES 0x8058
62 #define GL_HALF_FLOAT_OES 0x8D61
64 // GL_OES_EGL_image_external
65 #define GL_TEXTURE_EXTERNAL_OES 0x8D65
66 #define GL_SAMPLER_EXTERNAL_OES 0x8D66
67 #define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
68 #define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
70 // GL_ANGLE_translated_shader_source
71 #define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
73 // GL_CHROMIUM_flipy
74 #define GL_UNPACK_FLIP_Y_CHROMIUM 0x9240
76 #define GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM 0x9241
77 #define GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM 0x9242
78 #define GL_UNPACK_COLORSPACE_CONVERSION_CHROMIUM 0x9243
79 #define GL_BIND_GENERATES_RESOURCE_CHROMIUM 0x9244
81 // GL_CHROMIUM_gpu_memory_manager
82 #define GL_TEXTURE_POOL_CHROMIUM 0x6000
83 #define GL_TEXTURE_POOL_MANAGED_CHROMIUM 0x6001
84 #define GL_TEXTURE_POOL_UNMANAGED_CHROMIUM 0x6002
86 // GL_ANGLE_pack_reverse_row_order
87 #define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
89 // GL_ANGLE_texture_usage
90 #define GL_TEXTURE_USAGE_ANGLE 0x93A2
91 #define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3
93 // GL_EXT_texture_storage
94 #define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
95 #define GL_ALPHA8_EXT 0x803C
96 #define GL_LUMINANCE8_EXT 0x8040
97 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045
98 #define GL_RGBA32F_EXT 0x8814
99 #define GL_RGB32F_EXT 0x8815
100 #define GL_ALPHA32F_EXT 0x8816
101 #define GL_LUMINANCE32F_EXT 0x8818
102 #define GL_LUMINANCE_ALPHA32F_EXT 0x8819
103 #define GL_RGBA16F_EXT 0x881A
104 #define GL_RGB16F_EXT 0x881B
105 #define GL_RG16F_EXT 0x822F
106 #define GL_R16F_EXT 0x822D
107 #define GL_ALPHA16F_EXT 0x881C
108 #define GL_LUMINANCE16F_EXT 0x881E
109 #define GL_LUMINANCE_ALPHA16F_EXT 0x881F
110 #define GL_R32F_EXT 0x822E
111 #define GL_RG32F_EXT 0x8230
112 #define GL_BGRA8_EXT 0x93A1
114 // GL_ANGLE_instanced_arrays
115 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
117 // GL_EXT_occlusion_query_boolean
118 #define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
119 #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
120 #define GL_CURRENT_QUERY_EXT 0x8865
121 #define GL_QUERY_RESULT_EXT 0x8866
122 #define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
124 // GL_CHROMIUM_command_buffer_query
125 #define GL_COMMANDS_ISSUED_CHROMIUM 0x6004
127 /* GL_CHROMIUM_get_error_query */
128 #define GL_GET_ERROR_QUERY_CHROMIUM 0x6003
130 /* GL_CHROMIUM_command_buffer_latency_query */
131 #define GL_LATENCY_QUERY_CHROMIUM 0x6007
133 /* GL_CHROMIUM_async_pixel_transfers */
134 #define GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM 0x6005
135 #define GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM 0x6006
137 // GL_CHROMIUM_sync_query
138 #define GL_COMMANDS_COMPLETED_CHROMIUM 0x84F7
140 // GL_CHROMIUM_gpu_memory_buffer_image
141 #define GL_MAP_CHROMIUM 0x78F1
142 #define GL_SCANOUT_CHROMIUM 0x78F2
144 // GL_CHROMIUM_yuv_420_image
145 #define GL_RGB_YUV_420_CHROMIUM 0x78FA
147 // GL_CHROMIUM_schedule_overlay_plane
148 #define GL_OVERLAY_TRANSFORM_NONE_CHROMIUM 0x9245
149 #define GL_OVERLAY_TRANSFORM_FLIP_HORIZONTAL_CHROMIUM 0x9246
150 #define GL_OVERLAY_TRANSFORM_FLIP_VERTICAL_CHROMIUM 0x9247
151 #define GL_OVERLAY_TRANSFORM_ROTATE_90_CHROMIUM 0x9248
152 #define GL_OVERLAY_TRANSFORM_ROTATE_180_CHROMIUM 0x9249
153 #define GL_OVERLAY_TRANSFORM_ROTATE_270_CHROMIUM 0x924A
155 // GL_CHROMIUM_subscribe_uniforms
156 #define GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM 0x924B
157 #define GL_MOUSE_POSITION_CHROMIUM 0x924C
159 // GL_OES_texure_3D
160 #define GL_SAMPLER_3D_OES 0x8B5F
162 // GL_OES_depth24
163 #define GL_DEPTH_COMPONENT24_OES 0x81A6
165 // GL_OES_depth32
166 #define GL_DEPTH_COMPONENT32_OES 0x81A7
168 // GL_OES_packed_depth_stencil
169 #ifndef GL_DEPTH24_STENCIL8_OES
170 #define GL_DEPTH24_STENCIL8_OES 0x88F0
171 #endif
173 #ifndef GL_DEPTH24_STENCIL8
174 #define GL_DEPTH24_STENCIL8 0x88F0
175 #endif
177 // GL_OES_compressed_ETC1_RGB8_texture
178 #define GL_ETC1_RGB8_OES 0x8D64
180 // GL_AMD_compressed_ATC_texture
181 #define GL_ATC_RGB_AMD 0x8C92
182 #define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
183 #define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
185 // GL_IMG_texture_compression_pvrtc
186 #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
187 #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
188 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
189 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
191 // GL_OES_vertex_array_object
192 #define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
194 // GL_CHROMIUM_pixel_transfer_buffer_object
195 #define GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM 0x78EC
196 #define GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM 0x78ED
197 #define GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM 0x78EE
198 #define GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM 0x78EF
200 /* GL_EXT_discard_framebuffer */
201 #ifndef GL_EXT_discard_framebuffer
202 #define GL_COLOR_EXT 0x1800
203 #define GL_DEPTH_EXT 0x1801
204 #define GL_STENCIL_EXT 0x1802
205 #endif
207 // GL_EXT_sRGB
208 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
210 // GL_ARB_get_program_binary
211 #define PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
212 // GL_OES_get_program_binary
213 #define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
214 #define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
215 #define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
217 #ifndef GL_EXT_multisampled_render_to_texture
218 #define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
219 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
220 #define GL_MAX_SAMPLES_EXT 0x8D57
221 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
222 #endif
224 #ifndef GL_IMG_multisampled_render_to_texture
225 #define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
226 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
227 #define GL_MAX_SAMPLES_IMG 0x9135
228 #define GL_TEXTURE_SAMPLES_IMG 0x9136
229 #endif
231 #ifndef GL_CHROMIUM_path_rendering
232 // These match the corresponding values in NV_path_rendering
233 // extension, eg tokens with CHROMIUM replaced with NV.
234 #define GL_PATH_MODELVIEW_MATRIX_CHROMIUM 0x0BA6
235 #define GL_PATH_PROJECTION_MATRIX_CHROMIUM 0x0BA7
236 #define GL_PATH_MODELVIEW_CHROMIUM 0x1700
237 #define GL_PATH_PROJECTION_CHROMIUM 0x1701
238 #endif
240 #ifndef GL_KHR_blend_equation_advanced
241 #define GL_KHR_blend_equation_advanced 1
242 #define GL_COLORBURN_KHR 0x929A
243 #define GL_COLORDODGE_KHR 0x9299
244 #define GL_DARKEN_KHR 0x9297
245 #define GL_DIFFERENCE_KHR 0x929E
246 #define GL_EXCLUSION_KHR 0x92A0
247 #define GL_HARDLIGHT_KHR 0x929B
248 #define GL_HSL_COLOR_KHR 0x92AF
249 #define GL_HSL_HUE_KHR 0x92AD
250 #define GL_HSL_LUMINOSITY_KHR 0x92B0
251 #define GL_HSL_SATURATION_KHR 0x92AE
252 #define GL_LIGHTEN_KHR 0x9298
253 #define GL_MULTIPLY_KHR 0x9294
254 #define GL_OVERLAY_KHR 0x9296
255 #define GL_SCREEN_KHR 0x9295
256 #define GL_SOFTLIGHT_KHR 0x929C
257 #endif /* GL_KHR_blend_equation_advanced */
259 #ifndef GL_KHR_blend_equation_advanced_coherent
260 #define GL_KHR_blend_equation_advanced_coherent 1
261 #define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285
262 #endif /* GL_KHR_blend_equation_advanced_coherent */
264 #ifndef GL_EXT_disjoint_timer_query
265 #define GL_EXT_disjoint_timer_query 1
266 #define GL_QUERY_COUNTER_BITS_EXT 0x8864
267 #define GL_TIME_ELAPSED_EXT 0x88BF
268 #define GL_TIMESTAMP_EXT 0x8E28
269 #define GL_GPU_DISJOINT_EXT 0x8FBB
270 #endif
272 #ifndef GL_KHR_robustness
273 #define GL_KHR_robustness 1
274 #define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3
275 #define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252
276 #define GL_GUILTY_CONTEXT_RESET_KHR 0x8253
277 #define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254
278 #define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255
279 #define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256
280 #define GL_NO_RESET_NOTIFICATION_KHR 0x8261
281 #define GL_CONTEXT_LOST_KHR 0x0507
282 #endif /* GL_KHR_robustness */
284 #ifndef GL_EXT_texture_rg
285 #define GL_EXT_texture_rg 1
286 #define GL_RED_EXT 0x1903
287 #define GL_RG_EXT 0x8227
288 #define GL_R8_EXT 0x8229
289 #define GL_RG8_EXT 0x822B
290 #endif /* GL_EXT_texture_rg */
292 #define GL_GLEXT_PROTOTYPES 1
294 #if defined(OS_WIN)
295 #define GL_BINDING_CALL WINAPI
296 #else
297 #define GL_BINDING_CALL
298 #endif
300 #define GL_SERVICE_LOG(args) DLOG(INFO) << args;
301 #if defined(NDEBUG)
302 #define GL_SERVICE_LOG_CODE_BLOCK(code)
303 #else
304 #define GL_SERVICE_LOG_CODE_BLOCK(code) code
305 #endif
307 // Forward declare OSMesa types.
308 typedef struct osmesa_context *OSMesaContext;
309 typedef void (*OSMESAproc)();
311 // Forward declare EGL types.
312 typedef uint64 EGLuint64CHROMIUM;
314 #include "gl_bindings_autogen_gl.h"
315 #include "gl_bindings_autogen_osmesa.h"
317 #if defined(OS_WIN)
318 #include "gl_bindings_autogen_egl.h"
319 #include "gl_bindings_autogen_wgl.h"
320 #elif defined(USE_X11)
321 #include "gl_bindings_autogen_egl.h"
322 #include "gl_bindings_autogen_glx.h"
323 #elif defined(USE_OZONE)
324 #include "gl_bindings_autogen_egl.h"
325 #elif defined(OS_ANDROID)
326 #include "gl_bindings_autogen_egl.h"
327 #endif
329 namespace gfx {
331 struct GL_EXPORT DriverGL {
332 void InitializeStaticBindings();
333 void InitializeCustomDynamicBindings(GLContext* context);
334 void InitializeDebugBindings();
335 void InitializeNullDrawBindings();
336 // TODO(danakj): Remove this when all test suites are using null-draw.
337 bool HasInitializedNullDrawBindings();
338 bool SetNullDrawBindingsEnabled(bool enabled);
339 void ClearBindings();
341 ProcsGL fn;
342 ProcsGL orig_fn;
343 ProcsGL debug_fn;
344 ExtensionsGL ext;
345 bool null_draw_bindings_enabled;
347 private:
348 void InitializeDynamicBindings(GLContext* context);
351 struct GL_EXPORT DriverOSMESA {
352 void InitializeStaticBindings();
353 void InitializeDebugBindings();
354 void ClearBindings();
356 ProcsOSMESA fn;
357 ProcsOSMESA debug_fn;
358 ExtensionsOSMESA ext;
360 private:
361 static std::string GetPlatformExtensions();
364 #if defined(OS_WIN)
365 struct GL_EXPORT DriverWGL {
366 void InitializeStaticBindings();
367 void InitializeDebugBindings();
368 void ClearBindings();
370 ProcsWGL fn;
371 ProcsWGL debug_fn;
372 ExtensionsWGL ext;
374 private:
375 static std::string GetPlatformExtensions();
377 #endif
379 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || defined(USE_OZONE)
380 struct GL_EXPORT DriverEGL {
381 void InitializeStaticBindings();
382 void InitializeDebugBindings();
383 void ClearBindings();
385 ProcsEGL fn;
386 ProcsEGL debug_fn;
387 ExtensionsEGL ext;
389 private:
390 static std::string GetPlatformExtensions();
391 static std::string GetClientExtensions();
393 #endif
395 #if defined(USE_X11)
396 struct GL_EXPORT DriverGLX {
397 void InitializeStaticBindings();
398 void InitializeDebugBindings();
399 void ClearBindings();
401 ProcsGLX fn;
402 ProcsGLX debug_fn;
403 ExtensionsGLX ext;
405 private:
406 static std::string GetPlatformExtensions();
408 #endif
410 // This #define is here to support autogenerated code.
411 #define g_current_gl_context g_current_gl_context_tls->Get()
412 GL_EXPORT extern base::ThreadLocalPointer<GLApi>* g_current_gl_context_tls;
414 GL_EXPORT extern OSMESAApi* g_current_osmesa_context;
415 GL_EXPORT extern DriverGL g_driver_gl;
416 GL_EXPORT extern DriverOSMESA g_driver_osmesa;
418 #if defined(OS_WIN)
420 GL_EXPORT extern EGLApi* g_current_egl_context;
421 GL_EXPORT extern WGLApi* g_current_wgl_context;
422 GL_EXPORT extern DriverEGL g_driver_egl;
423 GL_EXPORT extern DriverWGL g_driver_wgl;
425 #elif defined(USE_X11)
427 GL_EXPORT extern EGLApi* g_current_egl_context;
428 GL_EXPORT extern GLXApi* g_current_glx_context;
429 GL_EXPORT extern DriverEGL g_driver_egl;
430 GL_EXPORT extern DriverGLX g_driver_glx;
432 #elif defined(USE_OZONE)
434 GL_EXPORT extern EGLApi* g_current_egl_context;
435 GL_EXPORT extern DriverEGL g_driver_egl;
437 #elif defined(OS_ANDROID)
439 GL_EXPORT extern EGLApi* g_current_egl_context;
440 GL_EXPORT extern DriverEGL g_driver_egl;
442 #endif
444 } // namespace gfx
446 #endif // UI_GL_GL_BINDINGS_H_