Add ICU message format support
[chromium-blink-merge.git] / ui / gl / gl_bindings.h
blob983ba7f31c1573c415152d272a066eee6dac06aa
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_UNPACK_COMPLETED_CHROMIUM 0x6005
130 #define GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM 0x6006
132 // GL_CHROMIUM_sync_query
133 #define GL_COMMANDS_COMPLETED_CHROMIUM 0x84F7
135 // GL_CHROMIUM_gpu_memory_buffer_image
136 #define GL_MAP_CHROMIUM 0x78F1
137 #define GL_SCANOUT_CHROMIUM 0x78F2
139 // GL_CHROMIUM_yuv_420_image
140 #define GL_RGB_YUV_420_CHROMIUM 0x78FA
142 // GL_CHROMIUM_schedule_overlay_plane
143 #define GL_OVERLAY_TRANSFORM_NONE_CHROMIUM 0x9245
144 #define GL_OVERLAY_TRANSFORM_FLIP_HORIZONTAL_CHROMIUM 0x9246
145 #define GL_OVERLAY_TRANSFORM_FLIP_VERTICAL_CHROMIUM 0x9247
146 #define GL_OVERLAY_TRANSFORM_ROTATE_90_CHROMIUM 0x9248
147 #define GL_OVERLAY_TRANSFORM_ROTATE_180_CHROMIUM 0x9249
148 #define GL_OVERLAY_TRANSFORM_ROTATE_270_CHROMIUM 0x924A
150 // GL_CHROMIUM_subscribe_uniforms
151 #define GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM 0x924B
152 #define GL_MOUSE_POSITION_CHROMIUM 0x924C
154 // GL_OES_texure_3D
155 #define GL_SAMPLER_3D_OES 0x8B5F
157 // GL_OES_depth24
158 #define GL_DEPTH_COMPONENT24_OES 0x81A6
160 // GL_OES_depth32
161 #define GL_DEPTH_COMPONENT32_OES 0x81A7
163 // GL_OES_packed_depth_stencil
164 #ifndef GL_DEPTH24_STENCIL8_OES
165 #define GL_DEPTH24_STENCIL8_OES 0x88F0
166 #endif
168 #ifndef GL_DEPTH24_STENCIL8
169 #define GL_DEPTH24_STENCIL8 0x88F0
170 #endif
172 // GL_OES_compressed_ETC1_RGB8_texture
173 #define GL_ETC1_RGB8_OES 0x8D64
175 // GL_AMD_compressed_ATC_texture
176 #define GL_ATC_RGB_AMD 0x8C92
177 #define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
178 #define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
180 // GL_IMG_texture_compression_pvrtc
181 #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
182 #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
183 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
184 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
186 // GL_OES_vertex_array_object
187 #define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
189 // GL_CHROMIUM_pixel_transfer_buffer_object
190 #define GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM 0x78EC
191 #define GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM 0x78ED
192 #define GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM 0x78EE
193 #define GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM 0x78EF
195 /* GL_EXT_discard_framebuffer */
196 #ifndef GL_EXT_discard_framebuffer
197 #define GL_COLOR_EXT 0x1800
198 #define GL_DEPTH_EXT 0x1801
199 #define GL_STENCIL_EXT 0x1802
200 #endif
202 // GL_EXT_sRGB
203 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
205 // GL_ARB_get_program_binary
206 #define PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
207 // GL_OES_get_program_binary
208 #define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
209 #define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
210 #define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
212 #ifndef GL_EXT_multisampled_render_to_texture
213 #define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
214 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
215 #define GL_MAX_SAMPLES_EXT 0x8D57
216 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
217 #endif
219 #ifndef GL_IMG_multisampled_render_to_texture
220 #define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
221 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
222 #define GL_MAX_SAMPLES_IMG 0x9135
223 #define GL_TEXTURE_SAMPLES_IMG 0x9136
224 #endif
226 #ifndef GL_CHROMIUM_path_rendering
227 #define GL_CHROMIUM_path_rendering 1
228 // These match the corresponding values in NV_path_rendering
229 // extension, eg tokens with CHROMIUM replaced with NV.
230 #define GL_PATH_MODELVIEW_MATRIX_CHROMIUM 0x0BA6
231 #define GL_PATH_PROJECTION_MATRIX_CHROMIUM 0x0BA7
232 #define GL_PATH_MODELVIEW_CHROMIUM 0x1700
233 #define GL_PATH_PROJECTION_CHROMIUM 0x1701
234 #define GL_FLAT_CHROMIUM 0x1D00
235 #define GL_CLOSE_PATH_CHROMIUM 0x00
236 #define GL_MOVE_TO_CHROMIUM 0x02
237 #define GL_LINE_TO_CHROMIUM 0x04
238 #define GL_QUADRATIC_CURVE_TO_CHROMIUM 0x0A
239 #define GL_CUBIC_CURVE_TO_CHROMIUM 0x0C
240 #define GL_CONIC_CURVE_TO_CHROMIUM 0x1A
241 #define GL_PATH_STROKE_WIDTH_CHROMIUM 0x9075
242 #define GL_PATH_END_CAPS_CHROMIUM 0x9076
243 #define GL_PATH_JOIN_STYLE_CHROMIUM 0x9079
244 #define GL_PATH_MITER_LIMIT_CHROMIUM 0x907a
245 #define GL_PATH_STROKE_BOUND_CHROMIUM 0x9086
246 #define GL_COUNT_UP_CHROMIUM 0x9088
247 #define GL_COUNT_DOWN_CHROMIUM 0x9089
248 #define GL_CONVEX_HULL_CHROMIUM 0x908B
249 #define GL_BOUNDING_BOX_CHROMIUM 0x908D
250 #define GL_SQUARE_CHROMIUM 0x90a3
251 #define GL_ROUND_CHROMIUM 0x90a4
252 #define GL_BEVEL_CHROMIUM 0x90a6
253 #define GL_MITER_REVERT_CHROMIUM 0x90a7
254 #define GL_PATH_STENCIL_FUNC_CHROMIUM 0x90B7
255 #define GL_PATH_STENCIL_REF_CHROMIUM 0x90B8
256 #define GL_PATH_STENCIL_VALUE_MASK_CHROMIUM 0x90B9
257 #endif
259 #ifndef GL_KHR_blend_equation_advanced
260 #define GL_KHR_blend_equation_advanced 1
261 #define GL_COLORBURN_KHR 0x929A
262 #define GL_COLORDODGE_KHR 0x9299
263 #define GL_DARKEN_KHR 0x9297
264 #define GL_DIFFERENCE_KHR 0x929E
265 #define GL_EXCLUSION_KHR 0x92A0
266 #define GL_HARDLIGHT_KHR 0x929B
267 #define GL_HSL_COLOR_KHR 0x92AF
268 #define GL_HSL_HUE_KHR 0x92AD
269 #define GL_HSL_LUMINOSITY_KHR 0x92B0
270 #define GL_HSL_SATURATION_KHR 0x92AE
271 #define GL_LIGHTEN_KHR 0x9298
272 #define GL_MULTIPLY_KHR 0x9294
273 #define GL_OVERLAY_KHR 0x9296
274 #define GL_SCREEN_KHR 0x9295
275 #define GL_SOFTLIGHT_KHR 0x929C
276 #endif /* GL_KHR_blend_equation_advanced */
278 #ifndef GL_KHR_blend_equation_advanced_coherent
279 #define GL_KHR_blend_equation_advanced_coherent 1
280 #define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285
281 #endif /* GL_KHR_blend_equation_advanced_coherent */
283 #ifndef GL_EXT_disjoint_timer_query
284 #define GL_EXT_disjoint_timer_query 1
285 #define GL_QUERY_COUNTER_BITS_EXT 0x8864
286 #define GL_TIME_ELAPSED_EXT 0x88BF
287 #define GL_TIMESTAMP_EXT 0x8E28
288 #define GL_GPU_DISJOINT_EXT 0x8FBB
289 #endif
291 #ifndef GL_KHR_robustness
292 #define GL_KHR_robustness 1
293 #define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3
294 #define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252
295 #define GL_GUILTY_CONTEXT_RESET_KHR 0x8253
296 #define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254
297 #define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255
298 #define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256
299 #define GL_NO_RESET_NOTIFICATION_KHR 0x8261
300 #define GL_CONTEXT_LOST_KHR 0x0507
301 #endif /* GL_KHR_robustness */
303 #ifndef GL_EXT_texture_rg
304 #define GL_EXT_texture_rg 1
305 #define GL_RED_EXT 0x1903
306 #define GL_RG_EXT 0x8227
307 #define GL_R8_EXT 0x8229
308 #define GL_RG8_EXT 0x822B
309 #endif /* GL_EXT_texture_rg */
311 #define GL_GLEXT_PROTOTYPES 1
313 #if defined(OS_WIN)
314 #define GL_BINDING_CALL WINAPI
315 #else
316 #define GL_BINDING_CALL
317 #endif
319 #define GL_SERVICE_LOG(args) DLOG(INFO) << args;
320 #if defined(NDEBUG)
321 #define GL_SERVICE_LOG_CODE_BLOCK(code)
322 #else
323 #define GL_SERVICE_LOG_CODE_BLOCK(code) code
324 #endif
326 // Forward declare OSMesa types.
327 typedef struct osmesa_context *OSMesaContext;
328 typedef void (*OSMESAproc)();
330 // Forward declare EGL types.
331 typedef uint64 EGLuint64CHROMIUM;
333 #include "gl_bindings_autogen_gl.h"
334 #include "gl_bindings_autogen_osmesa.h"
336 #if defined(OS_WIN)
337 #include "gl_bindings_autogen_egl.h"
338 #include "gl_bindings_autogen_wgl.h"
339 #elif defined(USE_X11)
340 #include "gl_bindings_autogen_egl.h"
341 #include "gl_bindings_autogen_glx.h"
342 #elif defined(USE_OZONE)
343 #include "gl_bindings_autogen_egl.h"
344 #elif defined(OS_ANDROID)
345 #include "gl_bindings_autogen_egl.h"
346 #endif
348 namespace gfx {
350 struct GL_EXPORT DriverGL {
351 void InitializeStaticBindings();
352 void InitializeCustomDynamicBindings(GLContext* context);
353 void InitializeDebugBindings();
354 void InitializeNullDrawBindings();
355 // TODO(danakj): Remove this when all test suites are using null-draw.
356 bool HasInitializedNullDrawBindings();
357 bool SetNullDrawBindingsEnabled(bool enabled);
358 void ClearBindings();
360 ProcsGL fn;
361 ProcsGL orig_fn;
362 ProcsGL debug_fn;
363 ExtensionsGL ext;
364 bool null_draw_bindings_enabled;
366 private:
367 void InitializeDynamicBindings(GLContext* context);
370 struct GL_EXPORT DriverOSMESA {
371 void InitializeStaticBindings();
372 void InitializeExtensionBindings();
373 void InitializeDebugBindings();
374 void ClearBindings();
376 ProcsOSMESA fn;
377 ProcsOSMESA debug_fn;
378 ExtensionsOSMESA ext;
380 private:
381 static std::string GetPlatformExtensions();
384 #if defined(OS_WIN)
385 struct GL_EXPORT DriverWGL {
386 void InitializeStaticBindings();
387 void InitializeExtensionBindings();
388 void InitializeDebugBindings();
389 void ClearBindings();
391 ProcsWGL fn;
392 ProcsWGL debug_fn;
393 ExtensionsWGL ext;
395 private:
396 static std::string GetPlatformExtensions();
398 #endif
400 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || defined(USE_OZONE)
401 struct GL_EXPORT DriverEGL {
402 void InitializeStaticBindings();
403 void InitializeExtensionBindings();
404 void InitializeDebugBindings();
405 void ClearBindings();
407 ProcsEGL fn;
408 ProcsEGL debug_fn;
409 ExtensionsEGL ext;
411 static std::string GetPlatformExtensions();
412 static std::string GetClientExtensions();
414 #endif
416 #if defined(USE_X11)
417 struct GL_EXPORT DriverGLX {
418 void InitializeStaticBindings();
419 void InitializeExtensionBindings();
420 void InitializeDebugBindings();
421 void ClearBindings();
423 ProcsGLX fn;
424 ProcsGLX debug_fn;
425 ExtensionsGLX ext;
427 private:
428 static std::string GetPlatformExtensions();
430 #endif
432 // This #define is here to support autogenerated code.
433 #define g_current_gl_context g_current_gl_context_tls->Get()
434 GL_EXPORT extern base::ThreadLocalPointer<GLApi>* g_current_gl_context_tls;
436 GL_EXPORT extern OSMESAApi* g_current_osmesa_context;
437 GL_EXPORT extern DriverGL g_driver_gl;
438 GL_EXPORT extern DriverOSMESA g_driver_osmesa;
440 #if defined(OS_WIN)
442 GL_EXPORT extern EGLApi* g_current_egl_context;
443 GL_EXPORT extern WGLApi* g_current_wgl_context;
444 GL_EXPORT extern DriverEGL g_driver_egl;
445 GL_EXPORT extern DriverWGL g_driver_wgl;
447 #elif defined(USE_X11)
449 GL_EXPORT extern EGLApi* g_current_egl_context;
450 GL_EXPORT extern GLXApi* g_current_glx_context;
451 GL_EXPORT extern DriverEGL g_driver_egl;
452 GL_EXPORT extern DriverGLX g_driver_glx;
454 #elif defined(USE_OZONE)
456 GL_EXPORT extern EGLApi* g_current_egl_context;
457 GL_EXPORT extern DriverEGL g_driver_egl;
459 #elif defined(OS_ANDROID)
461 GL_EXPORT extern EGLApi* g_current_egl_context;
462 GL_EXPORT extern DriverEGL g_driver_egl;
464 #endif
466 } // namespace gfx
468 #endif // UI_GL_GL_BINDINGS_H_