]> git.cworth.org Git - apitrace/blob - specs/eglapi.py
59610eb89420a3ac2a9e3e59427ff23bcf323648
[apitrace] / specs / eglapi.py
1 ##########################################################################
2 #
3 # Copyright 2011 LunarG, Inc.
4 # All Rights Reserved.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24 ##########################################################################/
25
26 """EGL API description."""
27
28
29 from stdapi import *
30 from gltypes import *
31 from eglenum import *
32
33 EGLNativeDisplayType = Opaque("EGLNativeDisplayType")
34 EGLNativeWindowType = Opaque("EGLNativeWindowType")
35 EGLNativePixmapType = Opaque("EGLNativePixmapType")
36
37 EGLDisplay = Opaque("EGLDisplay")
38 EGLConfig = Opaque("EGLConfig")
39 EGLContext = Opaque("EGLContext")
40 EGLSurface = Opaque("EGLSurface")
41
42 EGLClientBuffer = Opaque("EGLClientBuffer")
43
44 EGLBoolean = Enum("EGLBoolean", [
45     "EGL_FALSE",
46     "EGL_TRUE",
47 ])
48
49 EGLint = Alias("EGLint", Int32)
50
51 # an alias of EGLenum
52 EGLint_enum = Alias("EGLint", EGLenum)
53 EGLattrib = EGLint_enum
54
55 # EGL_KHR_image_base
56 EGLImageKHR = Opaque("EGLImageKHR")
57
58 # EGL_KHR_reusable_sync
59 EGLSyncKHR = Opaque("EGLSyncKHR")
60 EGLTimeKHR = Alias("EGLTimeKHR", UInt64)
61
62 # EGL_NV_sync
63 EGLSyncNV = Alias("EGLSyncNV", EGLSyncKHR)
64 EGLTimeNV = Alias("EGLTimeNV", EGLTimeKHR)
65
66 # EGL_HI_clientpixmap
67 EGLClientPixmapHI = Struct("struct EGLClientPixmapHI", [
68   (OpaquePointer(Void), "pData"),
69   (EGLint, "iWidth"),
70   (EGLint, "iHeight"),
71   (EGLint, "iStride"),
72 ])
73
74 # EGL_NV_system_time
75 EGLuint64NV = Alias("EGLuint64NV", UInt64)
76
77 eglapi = Module("EGL")
78
79 EGLAttribList = Array(Const(EGLattrib), "_AttribPairList_size(attrib_list, EGL_NONE)")
80
81 EGLSurfaceFlags = Flags(Int, [
82     'EGL_MULTISAMPLE_RESOLVE_BOX_BIT',
83     'EGL_PBUFFER_BIT',
84     'EGL_PIXMAP_BIT',
85     'EGL_SWAP_BEHAVIOR_PRESERVED_BIT',
86     'EGL_VG_ALPHA_FORMAT_PRE_BIT',
87     'EGL_VG_COLORSPACE_LINEAR_BIT',
88     'EGL_WINDOW_BIT'
89 ])
90
91 EGLConformantFlags = Flags(Int, ['EGL_OPENGL_BIT','EGL_OPENGL_ES_BIT', 'EGL_OPENGL_ES2_BIT', 'EGL_OPENVG_BIT',])
92
93 EGLConfigAttribs = AttribArray(EGLenum, [
94     ('EGL_ALPHA_MASK_SIZE', UInt),
95     ('EGL_ALPHA_SIZE', UInt),
96     ('EGL_BIND_TO_TEXTURE_RGB', EGLBoolean),
97     ('EGL_BIND_TO_TEXTURE_RGBA', EGLBoolean),
98     ('EGL_BLUE_SIZE', UInt),
99     ('EGL_BUFFER_SIZE', UInt),
100     ('EGL_COLOR_BUFFER_TYPE', FakeEnum(Int, ['EGL_RGB_BUFFER', 'EGL_LUMINANCE_BUFFER'])),
101     ('EGL_CONFIG_CAVEAT', FakeEnum(Int, ['EGL_DONT_CARE', 'EGL_NONE', 'EGL_SLOW_CONFIG', 'EGL_NON_CONFORMANT_CONFIG'])),
102     ('EGL_CONFIG_ID', Int),
103     ('EGL_CONFORMANT', EGLConformantFlags),
104     ('EGL_DEPTH_SIZE', Int),
105     ('EGL_GREEN_SIZE', UInt),
106     ('EGL_LEVEL', Int),
107     ('EGL_LUMINANCE_SIZE', UInt),
108     ('EGL_MATCH_NATIVE_PIXMAP', Int),
109     ('EGL_NATIVE_RENDERABLE', FakeEnum(Int, ['EGL_DONT_CARE', 'EGL_TRUE', 'EGL_FALSE'])),
110     ('EGL_MAX_SWAP_INTERVAL', Int),
111     ('EGL_MIN_SWAP_INTERVAL', Int),
112     ('EGL_RED_SIZE', UInt),
113     ('EGL_SAMPLE_BUFFERS', Int),
114     ('EGL_SAMPLES', Int),
115     ('EGL_STENCIL_SIZE', UInt),
116     ('EGL_RENDERABLE_TYPE', EGLConformantFlags),
117     ('EGL_SURFACE_TYPE', EGLSurfaceFlags),
118     ('EGL_TRANSPARENT_TYPE', FakeEnum(Int, ['EGL_NONE', 'EGL_TRANSPARENT_RGB'])),
119     ('EGL_TRANSPARENT_RED_VALUE', Int),
120     ('EGL_TRANSPARENT_GREEN_VALUE', Int),
121     ('EGL_TRANSPARENT_BLUE_VALUE ', Int)
122 ])
123
124 EGLVGAlphaFormat = FakeEnum(Int, ['EGL_VG_ALPHA_FORMAT_NONPRE', 'EGL_VG_ALPHA_FORMAT_PRE'])
125 EGLVGColorspace = FakeEnum(Int, ['EGL_VG_COLORSPACE_sRGB', 'EGL_VG_COLORSPACE_LINEAR'])
126 EGLTextureFormat = FakeEnum(Int, ['EGL_NO_TEXTURE', 'EGL_TEXTURE_RGB', 'EGL_TEXTURE_RGBA'])
127 EGLTextureTarget = FakeEnum(Int, ['EGL_TEXTURE_2D', 'EGL_NO_TEXTURE' ])
128
129 EGLWindowsSurfaceAttribs = AttribArray(EGLenum, [
130     ('EGL_RENDER_BUFFER', FakeEnum(Int, ['EGL_SINGLE_BUFFER', 'EGL_BACK_BUFFER'])),
131     ('EGL_VG_ALPHA_FORMAT', EGLVGAlphaFormat),
132     ('EGL_VG_COLORSPACE', EGLVGColorspace)
133 ])
134
135 EGLPixmapSurfaceAttribs = AttribArray(EGLenum, [
136     ('EGL_VG_ALPHA_FORMAT', EGLVGAlphaFormat),
137     ('EGL_VG_COLORSPACE', EGLVGColorspace)
138 ])
139
140 EGLPbufferAttribs = AttribArray(EGLenum, [
141     ('EGL_HEIGHT', Int),
142     ('EGL_LARGEST_PBUFFER', EGLBoolean),
143     ('EGL_MIPMAP_TEXTURE', UInt),
144     ('EGL_TEXTURE_FORMAT', EGLTextureFormat),
145     ('EGL_TEXTURE_TARGET', EGLTextureTarget),
146     ('EGL_VG_ALPHA_FORMAT', EGLVGAlphaFormat),
147     ('EGL_VG_COLORSPACE', EGLVGColorspace),
148     ('EGL_WIDTH', Int)
149 ])
150
151 EGLPbufferFromClientBufferAttribs = AttribArray(EGLenum, [
152     ('EGL_MIPMAP_TEXTURE', EGLBoolean),
153     ('EGL_TEXTURE_FORMAT', EGLTextureFormat),
154     ('EGL_TEXTURE_TARGET', EGLTextureTarget)
155 ])
156
157 EGLDrmImageMesaAttribs = AttribArray(EGLenum, [
158     ('EGL_DRM_BUFFER_FORMAT_MESA', FakeEnum(Int, ['EGL_DRM_BUFFER_FORMAT_ARGB32_MESA'])),
159     ('EGL_DRM_BUFFER_USE_MESA', Flags(Int, ['EGL_DRM_BUFFER_USE_SCANOUT_MESA', 'EGL_DRM_BUFFER_USE_SHARE_MESA']))
160 ])
161
162 EGLProc = Opaque("__eglMustCastToProperFunctionPointerType")
163
164 def GlFunction(*args, **kwargs):
165     kwargs.setdefault('call', 'GL_APIENTRY')
166     return Function(*args, **kwargs)
167
168 eglapi.addFunctions([
169     # EGL 1.4
170     Function(EGLint_enum, "eglGetError", [], sideeffects=False),
171
172     Function(EGLDisplay, "eglGetDisplay", [(EGLNativeDisplayType, "display_id")]),
173     Function(EGLBoolean, "eglInitialize", [(EGLDisplay, "dpy"), Out(Pointer(EGLint), "major"), Out(Pointer(EGLint), "minor")]),
174     Function(EGLBoolean, "eglTerminate", [(EGLDisplay, "dpy")]),
175
176     Function(ConstCString, "eglQueryString", [(EGLDisplay, "dpy"), (EGLint_enum, "name")], sideeffects=False),
177
178     Function(EGLBoolean, "eglGetConfigs", [(EGLDisplay, "dpy"), (Array(EGLConfig, "config_size"), "configs"), (EGLint, "config_size"), Out(Pointer(EGLint), "num_config")]),
179     Function(EGLBoolean, "eglChooseConfig", [(EGLDisplay, "dpy"), (EGLConfigAttribs, "attrib_list"), (Array(EGLConfig, "config_size"), "configs"), (EGLint, "config_size"), Out(Pointer(EGLint), "num_config")]),
180     Function(EGLBoolean, "eglGetConfigAttrib", [(EGLDisplay, "dpy"), (EGLConfig, "config"), (EGLattrib, "attribute"), Out(Pointer(EGLint), "value")], sideeffects=False),
181
182     Function(EGLSurface, "eglCreateWindowSurface", [(EGLDisplay, "dpy"), (EGLConfig, "config"), (EGLNativeWindowType, "win"), (EGLWindowsSurfaceAttribs, "attrib_list")]),
183     Function(EGLSurface, "eglCreatePbufferSurface", [(EGLDisplay, "dpy"), (EGLConfig, "config"), (EGLPbufferAttribs, "attrib_list")]),
184     Function(EGLSurface, "eglCreatePixmapSurface", [(EGLDisplay, "dpy"), (EGLConfig, "config"), (EGLNativePixmapType, "pixmap"), (EGLPixmapSurfaceAttribs, "attrib_list")]),
185     Function(EGLBoolean, "eglDestroySurface", [(EGLDisplay, "dpy"), (EGLSurface, "surface")]),
186     Function(EGLBoolean, "eglQuerySurface", [(EGLDisplay, "dpy"), (EGLSurface, "surface"), (EGLattrib, "attribute"), Out(Pointer(EGLint), "value")], sideeffects=False),
187
188     Function(EGLBoolean, "eglBindAPI", [(EGLenum, "api")]),
189     Function(EGLenum, "eglQueryAPI", [], sideeffects=False),
190
191     Function(EGLBoolean, "eglWaitClient", []),
192
193     Function(EGLBoolean, "eglReleaseThread", []),
194
195     Function(EGLSurface, "eglCreatePbufferFromClientBuffer", [(EGLDisplay, "dpy"), (EGLenum, "buftype"), (EGLClientBuffer, "buffer"), (EGLConfig, "config"), (EGLPbufferFromClientBufferAttribs, "attrib_list")]),
196
197     Function(EGLBoolean, "eglSurfaceAttrib", [(EGLDisplay, "dpy"), (EGLSurface, "surface"), (EGLattrib, "attribute"), (EGLint, "value")]),
198     Function(EGLBoolean, "eglBindTexImage", [(EGLDisplay, "dpy"), (EGLSurface, "surface"), (EGLattrib, "buffer")]),
199     Function(EGLBoolean, "eglReleaseTexImage", [(EGLDisplay, "dpy"), (EGLSurface, "surface"), (EGLattrib, "buffer")]),
200
201     Function(EGLBoolean, "eglSwapInterval", [(EGLDisplay, "dpy"), (EGLint, "interval")]),
202
203     Function(EGLContext, "eglCreateContext", [(EGLDisplay, "dpy"), (EGLConfig, "config"), (EGLContext, "share_context"), (AttribArray(EGLenum, [('EGL_CONTEXT_CLIENT_VERSION', Int)]), "attrib_list")]),
204     Function(EGLBoolean, "eglDestroyContext", [(EGLDisplay, "dpy"), (EGLContext, "ctx")]),
205     Function(EGLBoolean, "eglMakeCurrent", [(EGLDisplay, "dpy"), (EGLSurface, "draw"), (EGLSurface, "read"), (EGLContext, "ctx")]),
206
207     Function(EGLContext, "eglGetCurrentContext", [], sideeffects=False),
208     Function(EGLSurface, "eglGetCurrentSurface", [(EGLattrib, "readdraw")], sideeffects=False),
209     Function(EGLDisplay, "eglGetCurrentDisplay", [], sideeffects=False),
210
211     Function(EGLBoolean, "eglQueryContext", [(EGLDisplay, "dpy"), (EGLContext, "ctx"), (EGLattrib, "attribute"), Out(Pointer(EGLint), "value")], sideeffects=False),
212
213     Function(EGLBoolean, "eglWaitGL", []),
214     Function(EGLBoolean, "eglWaitNative", [(EGLattrib, "engine")]),
215     Function(EGLBoolean, "eglSwapBuffers", [(EGLDisplay, "dpy"), (EGLSurface, "surface")]),
216     Function(EGLBoolean, "eglCopyBuffers", [(EGLDisplay, "dpy"), (EGLSurface, "surface"), (EGLNativePixmapType, "target")]),
217
218     Function(EGLProc, "eglGetProcAddress", [(ConstCString, "procname")]),
219
220     # EGL_KHR_lock_surface
221     # EGL_KHR_lock_surface2
222     Function(EGLBoolean, "eglLockSurfaceKHR", [(EGLDisplay, "display"), (EGLSurface, "surface"), (EGLAttribList, "attrib_list")]),
223     Function(EGLBoolean, "eglUnlockSurfaceKHR", [(EGLDisplay, "display"), (EGLSurface, "surface")]),
224
225     # EGL_KHR_image_base
226     Function(EGLImageKHR, "eglCreateImageKHR", [(EGLDisplay, "dpy"), (EGLContext, "ctx"), (EGLenum, "target"), (EGLClientBuffer, "buffer"), (AttribArray(EGLenum, [('EGL_IMAGE_PRESERVED_KHR', EGLBoolean)]), "attrib_list")]),
227     Function(EGLBoolean, "eglDestroyImageKHR", [(EGLDisplay, "dpy"), (EGLImageKHR, "image")]),
228
229     # EGL_KHR_fence_sync
230     # EGL_KHR_reusable_sync
231     Function(EGLSyncKHR, "eglCreateSyncKHR", [(EGLDisplay, "dpy"), (EGLenum, "type"), (EGLAttribList, "attrib_list")]),
232     Function(EGLBoolean, "eglDestroySyncKHR", [(EGLDisplay, "dpy"), (EGLSyncKHR, "sync")]),
233     Function(EGLint, "eglClientWaitSyncKHR", [(EGLDisplay, "dpy"), (EGLSyncKHR, "sync"), (EGLint, "flags"), (EGLTimeKHR, "timeout")]),
234     Function(EGLBoolean, "eglSignalSyncKHR", [(EGLDisplay, "dpy"), (EGLSyncKHR, "sync"), (EGLenum, "mode")]),
235     Function(EGLBoolean, "eglGetSyncAttribKHR", [(EGLDisplay, "dpy"), (EGLSyncKHR, "sync"), (EGLattrib, "attribute"), Out(Pointer(EGLint), "value")], sideeffects=False),
236
237     # EGL_NV_sync
238     Function(EGLSyncNV, "eglCreateFenceSyncNV", [(EGLDisplay, "dpy"), (EGLenum, "condition"), (EGLAttribList, "attrib_list")]),
239     Function(EGLBoolean, "eglDestroySyncNV", [(EGLSyncNV, "sync")]),
240     Function(EGLBoolean, "eglFenceNV", [(EGLSyncNV, "sync")]),
241     Function(EGLint, "eglClientWaitSyncNV", [(EGLSyncNV, "sync"), (EGLint, "flags"), (EGLTimeNV, "timeout")]),
242     Function(EGLBoolean, "eglSignalSyncNV", [(EGLSyncNV, "sync"), (EGLenum, "mode")]),
243     Function(EGLBoolean, "eglGetSyncAttribNV", [(EGLSyncNV, "sync"), (EGLattrib, "attribute"), Out(Pointer(EGLint), "value")], sideeffects=False),
244
245     # EGL_HI_clientpixmap
246     Function(EGLSurface, "eglCreatePixmapSurfaceHI", [(EGLDisplay, "dpy"), (EGLConfig, "config"), (Pointer(EGLClientPixmapHI), "pixmap")]),
247
248     # EGL_MESA_drm_image
249     Function(EGLImageKHR, "eglCreateDRMImageMESA", [(EGLDisplay, "dpy"), (EGLDrmImageMesaAttribs, "attrib_list")]),
250     Function(EGLBoolean, "eglExportDRMImageMESA", [(EGLDisplay, "dpy"), (EGLImageKHR, "image"), Out(Pointer(EGLint), "name"), Out(Pointer(EGLint), "handle"), Out(Pointer(EGLint), "stride")]),
251
252     # EGL_NV_post_sub_buffer
253     Function(EGLBoolean, "eglPostSubBufferNV", [(EGLDisplay, "dpy"), (EGLSurface, "surface"), (EGLint, "x"), (EGLint, "y"), (EGLint, "width"), (EGLint, "height")]),
254
255     # EGL_ANGLE_query_surface_pointer
256     Function(EGLBoolean, "eglQuerySurfacePointerANGLE", [(EGLDisplay, "dpy"), (EGLSurface, "surface"), (EGLattrib, "attribute"), Out(Pointer(OpaquePointer(Void)), "value")], sideeffects=False),
257
258     # EGL_NV_system_time
259     Function(EGLuint64NV, "eglGetSystemTimeFrequencyNV", [], sideeffects=False),
260     Function(EGLuint64NV, "eglGetSystemTimeNV", [], sideeffects=False),
261
262     # GL_OES_EGL_image
263     GlFunction(Void, "glEGLImageTargetTexture2DOES", [(GLenum, "target"), (EGLImageKHR, "image")]),
264     GlFunction(Void, "glEGLImageTargetRenderbufferStorageOES", [(GLenum, "target"), (EGLImageKHR, "image")]),
265 ])