Update V8 to version 4.7.47.
[chromium-blink-merge.git] / ui / gl / gl_bindings.h
blob09725985b28a72f097f3cb67fc3a2a874adf3df9
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 #define GL_UNPACK_COLORSPACE_CONVERSION_CHROMIUM 0x9243
74 #define GL_BIND_GENERATES_RESOURCE_CHROMIUM 0x9244
76 // GL_CHROMIUM_gpu_memory_manager
77 #define GL_TEXTURE_POOL_CHROMIUM 0x6000
78 #define GL_TEXTURE_POOL_MANAGED_CHROMIUM 0x6001
79 #define GL_TEXTURE_POOL_UNMANAGED_CHROMIUM 0x6002
81 // GL_ANGLE_pack_reverse_row_order
82 #define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
84 // GL_ANGLE_texture_usage
85 #define GL_TEXTURE_USAGE_ANGLE 0x93A2
86 #define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3
88 // GL_EXT_texture_storage
89 #define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
90 #define GL_ALPHA8_EXT 0x803C
91 #define GL_LUMINANCE8_EXT 0x8040
92 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045
93 #define GL_RGBA32F_EXT 0x8814
94 #define GL_RGB32F_EXT 0x8815
95 #define GL_ALPHA32F_EXT 0x8816
96 #define GL_LUMINANCE32F_EXT 0x8818
97 #define GL_LUMINANCE_ALPHA32F_EXT 0x8819
98 #define GL_RGBA16F_EXT 0x881A
99 #define GL_RGB16F_EXT 0x881B
100 #define GL_RG16F_EXT 0x822F
101 #define GL_R16F_EXT 0x822D
102 #define GL_ALPHA16F_EXT 0x881C
103 #define GL_LUMINANCE16F_EXT 0x881E
104 #define GL_LUMINANCE_ALPHA16F_EXT 0x881F
105 #define GL_R32F_EXT 0x822E
106 #define GL_RG32F_EXT 0x8230
107 #define GL_BGRA8_EXT 0x93A1
109 // GL_ANGLE_instanced_arrays
110 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
112 // GL_EXT_occlusion_query_boolean
113 #define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
114 #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
115 #define GL_CURRENT_QUERY_EXT 0x8865
116 #define GL_QUERY_RESULT_EXT 0x8866
117 #define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
119 // GL_CHROMIUM_command_buffer_query
120 #define GL_COMMANDS_ISSUED_CHROMIUM 0x6004
122 /* GL_CHROMIUM_get_error_query */
123 #define GL_GET_ERROR_QUERY_CHROMIUM 0x6003
125 /* GL_CHROMIUM_command_buffer_latency_query */
126 #define GL_LATENCY_QUERY_CHROMIUM 0x6007
128 /* GL_CHROMIUM_async_pixel_transfers */
129 #define GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM 0x6006
131 // GL_CHROMIUM_sync_query
132 #define GL_COMMANDS_COMPLETED_CHROMIUM 0x84F7
134 // GL_CHROMIUM_gpu_memory_buffer_image
135 #define GL_MAP_CHROMIUM 0x78F1
136 #define GL_SCANOUT_CHROMIUM 0x78F2
138 // GL_CHROMIUM_yuv_420_image
139 #define GL_RGB_YUV_420_CHROMIUM 0x78FA
141 // GL_CHROMIUM_ycbcr_422_image
142 #define GL_RGB_YCBCR_422_CHROMIUM 0x78FB
144 // GL_CHROMIUM_schedule_overlay_plane
145 #define GL_OVERLAY_TRANSFORM_NONE_CHROMIUM 0x9245
146 #define GL_OVERLAY_TRANSFORM_FLIP_HORIZONTAL_CHROMIUM 0x9246
147 #define GL_OVERLAY_TRANSFORM_FLIP_VERTICAL_CHROMIUM 0x9247
148 #define GL_OVERLAY_TRANSFORM_ROTATE_90_CHROMIUM 0x9248
149 #define GL_OVERLAY_TRANSFORM_ROTATE_180_CHROMIUM 0x9249
150 #define GL_OVERLAY_TRANSFORM_ROTATE_270_CHROMIUM 0x924A
152 // GL_CHROMIUM_subscribe_uniforms
153 #define GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM 0x924B
154 #define GL_MOUSE_POSITION_CHROMIUM 0x924C
156 // GL_OES_texure_3D
157 #define GL_SAMPLER_3D_OES 0x8B5F
159 // GL_OES_depth24
160 #define GL_DEPTH_COMPONENT24_OES 0x81A6
162 // GL_OES_depth32
163 #define GL_DEPTH_COMPONENT32_OES 0x81A7
165 // GL_OES_packed_depth_stencil
166 #ifndef GL_DEPTH24_STENCIL8_OES
167 #define GL_DEPTH24_STENCIL8_OES 0x88F0
168 #endif
170 #ifndef GL_DEPTH24_STENCIL8
171 #define GL_DEPTH24_STENCIL8 0x88F0
172 #endif
174 // GL_OES_compressed_ETC1_RGB8_texture
175 #define GL_ETC1_RGB8_OES 0x8D64
177 // GL_AMD_compressed_ATC_texture
178 #define GL_ATC_RGB_AMD 0x8C92
179 #define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
180 #define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
182 // GL_IMG_texture_compression_pvrtc
183 #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
184 #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
185 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
186 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
188 // GL_OES_vertex_array_object
189 #define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
191 // GL_CHROMIUM_pixel_transfer_buffer_object
192 #define GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM 0x78EC
193 #define GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM 0x78ED
194 #define GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM 0x78EE
195 #define GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM 0x78EF
197 /* GL_EXT_discard_framebuffer */
198 #ifndef GL_EXT_discard_framebuffer
199 #define GL_COLOR_EXT 0x1800
200 #define GL_DEPTH_EXT 0x1801
201 #define GL_STENCIL_EXT 0x1802
202 #endif
204 // GL_EXT_sRGB
205 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
207 // GL_ARB_get_program_binary
208 #define PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
209 // GL_OES_get_program_binary
210 #define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
211 #define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
212 #define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
214 #ifndef GL_EXT_multisampled_render_to_texture
215 #define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
216 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
217 #define GL_MAX_SAMPLES_EXT 0x8D57
218 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
219 #endif
221 #ifndef GL_IMG_multisampled_render_to_texture
222 #define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
223 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
224 #define GL_MAX_SAMPLES_IMG 0x9135
225 #define GL_TEXTURE_SAMPLES_IMG 0x9136
226 #endif
228 #ifndef GL_CHROMIUM_path_rendering
229 #define GL_CHROMIUM_path_rendering 1
230 // These match the corresponding values in NV_path_rendering
231 // extension, eg tokens with CHROMIUM replaced with NV.
232 #define GL_PATH_MODELVIEW_MATRIX_CHROMIUM 0x0BA6
233 #define GL_PATH_PROJECTION_MATRIX_CHROMIUM 0x0BA7
234 #define GL_PATH_MODELVIEW_CHROMIUM 0x1700
235 #define GL_PATH_PROJECTION_CHROMIUM 0x1701
236 #define GL_FLAT_CHROMIUM 0x1D00
237 #define GL_CLOSE_PATH_CHROMIUM 0x00
238 #define GL_MOVE_TO_CHROMIUM 0x02
239 #define GL_LINE_TO_CHROMIUM 0x04
240 #define GL_QUADRATIC_CURVE_TO_CHROMIUM 0x0A
241 #define GL_CUBIC_CURVE_TO_CHROMIUM 0x0C
242 #define GL_CONIC_CURVE_TO_CHROMIUM 0x1A
243 #define GL_PATH_STROKE_WIDTH_CHROMIUM 0x9075
244 #define GL_PATH_END_CAPS_CHROMIUM 0x9076
245 #define GL_PATH_JOIN_STYLE_CHROMIUM 0x9079
246 #define GL_PATH_MITER_LIMIT_CHROMIUM 0x907a
247 #define GL_PATH_STROKE_BOUND_CHROMIUM 0x9086
248 #define GL_COUNT_UP_CHROMIUM 0x9088
249 #define GL_COUNT_DOWN_CHROMIUM 0x9089
250 #define GL_CONVEX_HULL_CHROMIUM 0x908B
251 #define GL_BOUNDING_BOX_CHROMIUM 0x908D
252 #define GL_SQUARE_CHROMIUM 0x90a3
253 #define GL_ROUND_CHROMIUM 0x90a4
254 #define GL_BEVEL_CHROMIUM 0x90a6
255 #define GL_MITER_REVERT_CHROMIUM 0x90a7
256 #define GL_PATH_STENCIL_FUNC_CHROMIUM 0x90B7
257 #define GL_PATH_STENCIL_REF_CHROMIUM 0x90B8
258 #define GL_PATH_STENCIL_VALUE_MASK_CHROMIUM 0x90B9
259 #endif
261 #ifndef GL_KHR_blend_equation_advanced
262 #define GL_KHR_blend_equation_advanced 1
263 #define GL_COLORBURN_KHR 0x929A
264 #define GL_COLORDODGE_KHR 0x9299
265 #define GL_DARKEN_KHR 0x9297
266 #define GL_DIFFERENCE_KHR 0x929E
267 #define GL_EXCLUSION_KHR 0x92A0
268 #define GL_HARDLIGHT_KHR 0x929B
269 #define GL_HSL_COLOR_KHR 0x92AF
270 #define GL_HSL_HUE_KHR 0x92AD
271 #define GL_HSL_LUMINOSITY_KHR 0x92B0
272 #define GL_HSL_SATURATION_KHR 0x92AE
273 #define GL_LIGHTEN_KHR 0x9298
274 #define GL_MULTIPLY_KHR 0x9294
275 #define GL_OVERLAY_KHR 0x9296
276 #define GL_SCREEN_KHR 0x9295
277 #define GL_SOFTLIGHT_KHR 0x929C
278 #endif /* GL_KHR_blend_equation_advanced */
280 #ifndef GL_KHR_blend_equation_advanced_coherent
281 #define GL_KHR_blend_equation_advanced_coherent 1
282 #define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285
283 #endif /* GL_KHR_blend_equation_advanced_coherent */
285 #ifndef GL_EXT_disjoint_timer_query
286 #define GL_EXT_disjoint_timer_query 1
287 #define GL_QUERY_COUNTER_BITS_EXT 0x8864
288 #define GL_TIME_ELAPSED_EXT 0x88BF
289 #define GL_TIMESTAMP_EXT 0x8E28
290 #define GL_GPU_DISJOINT_EXT 0x8FBB
291 #endif
293 #ifndef GL_KHR_robustness
294 #define GL_KHR_robustness 1
295 #define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3
296 #define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252
297 #define GL_GUILTY_CONTEXT_RESET_KHR 0x8253
298 #define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254
299 #define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255
300 #define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256
301 #define GL_NO_RESET_NOTIFICATION_KHR 0x8261
302 #define GL_CONTEXT_LOST_KHR 0x0507
303 #endif /* GL_KHR_robustness */
305 #ifndef GL_EXT_texture_rg
306 #define GL_EXT_texture_rg 1
307 #define GL_RED_EXT 0x1903
308 #define GL_RG_EXT 0x8227
309 #define GL_R8_EXT 0x8229
310 #define GL_RG8_EXT 0x822B
311 #endif /* GL_EXT_texture_rg */
313 #define GL_GLEXT_PROTOTYPES 1
315 #if defined(OS_WIN)
316 #define GL_BINDING_CALL WINAPI
317 #else
318 #define GL_BINDING_CALL
319 #endif
321 #define GL_SERVICE_LOG(args) DLOG(INFO) << args;
322 #if defined(NDEBUG)
323 #define GL_SERVICE_LOG_CODE_BLOCK(code)
324 #else
325 #define GL_SERVICE_LOG_CODE_BLOCK(code) code
326 #endif
328 // Forward declare OSMesa types.
329 typedef struct osmesa_context *OSMesaContext;
330 typedef void (*OSMESAproc)();
332 // Forward declare EGL types.
333 typedef uint64 EGLuint64CHROMIUM;
335 #include "gl_bindings_autogen_gl.h"
336 #include "gl_bindings_autogen_osmesa.h"
338 #if defined(OS_WIN)
339 #include "gl_bindings_autogen_egl.h"
340 #include "gl_bindings_autogen_wgl.h"
341 #elif defined(USE_X11)
342 #include "gl_bindings_autogen_egl.h"
343 #include "gl_bindings_autogen_glx.h"
344 #elif defined(USE_OZONE)
345 #include "gl_bindings_autogen_egl.h"
346 #elif defined(OS_ANDROID)
347 #include "gl_bindings_autogen_egl.h"
348 #endif
350 namespace gfx {
352 struct GL_EXPORT DriverGL {
353 void InitializeStaticBindings();
354 void InitializeCustomDynamicBindings(GLContext* context);
355 void InitializeDebugBindings();
356 void InitializeNullDrawBindings();
357 // TODO(danakj): Remove this when all test suites are using null-draw.
358 bool HasInitializedNullDrawBindings();
359 bool SetNullDrawBindingsEnabled(bool enabled);
360 void ClearBindings();
362 ProcsGL fn;
363 ProcsGL orig_fn;
364 ProcsGL debug_fn;
365 ExtensionsGL ext;
366 bool null_draw_bindings_enabled;
368 private:
369 void InitializeDynamicBindings(GLContext* context);
372 struct GL_EXPORT DriverOSMESA {
373 void InitializeStaticBindings();
374 void InitializeExtensionBindings();
375 void InitializeDebugBindings();
376 void ClearBindings();
378 ProcsOSMESA fn;
379 ProcsOSMESA debug_fn;
380 ExtensionsOSMESA ext;
382 private:
383 static std::string GetPlatformExtensions();
386 #if defined(OS_WIN)
387 struct GL_EXPORT DriverWGL {
388 void InitializeStaticBindings();
389 void InitializeExtensionBindings();
390 void InitializeDebugBindings();
391 void ClearBindings();
393 ProcsWGL fn;
394 ProcsWGL debug_fn;
395 ExtensionsWGL ext;
397 private:
398 static std::string GetPlatformExtensions();
400 #endif
402 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || defined(USE_OZONE)
403 struct GL_EXPORT DriverEGL {
404 void InitializeStaticBindings();
405 void InitializeExtensionBindings();
406 void InitializeDebugBindings();
407 void ClearBindings();
409 ProcsEGL fn;
410 ProcsEGL debug_fn;
411 ExtensionsEGL ext;
413 static std::string GetPlatformExtensions();
414 static std::string GetClientExtensions();
416 #endif
418 #if defined(USE_X11)
419 struct GL_EXPORT DriverGLX {
420 void InitializeStaticBindings();
421 void InitializeExtensionBindings();
422 void InitializeDebugBindings();
423 void ClearBindings();
425 ProcsGLX fn;
426 ProcsGLX debug_fn;
427 ExtensionsGLX ext;
429 private:
430 static std::string GetPlatformExtensions();
432 #endif
434 // This #define is here to support autogenerated code.
435 #define g_current_gl_context g_current_gl_context_tls->Get()
436 GL_EXPORT extern base::ThreadLocalPointer<GLApi>* g_current_gl_context_tls;
438 GL_EXPORT extern OSMESAApi* g_current_osmesa_context;
439 GL_EXPORT extern DriverGL g_driver_gl;
440 GL_EXPORT extern DriverOSMESA g_driver_osmesa;
442 #if defined(OS_WIN)
444 GL_EXPORT extern EGLApi* g_current_egl_context;
445 GL_EXPORT extern WGLApi* g_current_wgl_context;
446 GL_EXPORT extern DriverEGL g_driver_egl;
447 GL_EXPORT extern DriverWGL g_driver_wgl;
449 #elif defined(USE_X11)
451 GL_EXPORT extern EGLApi* g_current_egl_context;
452 GL_EXPORT extern GLXApi* g_current_glx_context;
453 GL_EXPORT extern DriverEGL g_driver_egl;
454 GL_EXPORT extern DriverGLX g_driver_glx;
456 #elif defined(USE_OZONE)
458 GL_EXPORT extern EGLApi* g_current_egl_context;
459 GL_EXPORT extern DriverEGL g_driver_egl;
461 #elif defined(OS_ANDROID)
463 GL_EXPORT extern EGLApi* g_current_egl_context;
464 GL_EXPORT extern DriverEGL g_driver_egl;
466 #endif
468 } // namespace gfx
470 #endif // UI_GL_GL_BINDINGS_H_