1/**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
5 * Copyright 2010-2011 LunarG, Inc.
6 * All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
18 * of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 *
28 **************************************************************************/
29
30
31#ifndef EGLAPI_INCLUDED
32#define EGLAPI_INCLUDED
33
34/**
35 * A generic function ptr type
36 */
37typedef void (*_EGLProc)(void);
38
39
40/**
41 * Typedefs for all EGL API entrypoint functions.
42 */
43
44/* driver funcs */
45typedef EGLBoolean (*Initialize_t)(_EGLDriver *, _EGLDisplay *dpy);
46typedef EGLBoolean (*Terminate_t)(_EGLDriver *, _EGLDisplay *dpy);
47
48/* config funcs */
49typedef EGLBoolean (*GetConfigs_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
50typedef EGLBoolean (*ChooseConfig_t)(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
51typedef EGLBoolean (*GetConfigAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, EGLint attribute, EGLint *value);
52
53/* context funcs */
54typedef _EGLContext *(*CreateContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, _EGLContext *share_list, const EGLint *attrib_list);
55typedef EGLBoolean (*DestroyContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
56/* this is the only function (other than Initialize) that may be called with an uninitialized display */
57typedef EGLBoolean (*MakeCurrent_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx);
58typedef EGLBoolean (*QueryContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value);
59
60/* surface funcs */
61typedef _EGLSurface *(*CreateWindowSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, EGLNativeWindowType window, const EGLint *attrib_list);
62typedef _EGLSurface *(*CreatePixmapSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
63typedef _EGLSurface *(*CreatePbufferSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, const EGLint *attrib_list);
64typedef EGLBoolean (*DestroySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface);
65typedef EGLBoolean (*QuerySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint *value);
66typedef EGLBoolean (*SurfaceAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint value);
67typedef EGLBoolean (*BindTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer);
68typedef EGLBoolean (*ReleaseTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer);
69typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
70typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw);
71typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLNativePixmapType target);
72
73/* misc funcs */
74typedef const char *(*QueryString_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name);
75typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
76typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine);
77
78/* this function may be called from multiple threads at the same time */
79typedef _EGLProc (*GetProcAddress_t)(_EGLDriver *drv, const char *procname);
80
81
82
83#ifdef EGL_MESA_screen_surface
84typedef EGLBoolean (*ChooseModeMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
85typedef EGLBoolean (*GetModesMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode);
86typedef EGLBoolean (*GetModeAttribMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLMode *mode, EGLint attribute, EGLint *value);
87typedef EGLBoolean (*CopyContextMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *source, _EGLContext *dest, EGLint mask);
88typedef EGLBoolean (*GetScreensMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
89typedef _EGLSurface *(*CreateScreenSurfaceMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, const EGLint *attrib_list);
90typedef EGLBoolean (*ShowScreenSurfaceMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLSurface *surface, _EGLMode *mode);
91typedef EGLBoolean (*ScreenPositionMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, EGLint x, EGLint y);
92typedef EGLBoolean (*QueryScreenMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, EGLint attribute, EGLint *value);
93typedef EGLBoolean (*QueryScreenSurfaceMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLSurface **surface);
94typedef EGLBoolean (*QueryScreenModeMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLMode **mode);
95typedef const char * (*QueryModeStringMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLMode *mode);
96#endif /* EGL_MESA_screen_surface */
97
98
99typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum buftype, EGLClientBuffer buffer, _EGLConfig *config, const EGLint *attrib_list);
100
101
102typedef _EGLImage *(*CreateImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list);
103typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
104
105
106typedef _EGLSync *(*CreateSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum type, const EGLint *attrib_list);
107typedef EGLBoolean (*DestroySyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync);
108typedef EGLint (*ClientWaitSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLint flags, EGLTimeKHR timeout);
109typedef EGLBoolean (*SignalSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLenum mode);
110typedef EGLBoolean (*GetSyncAttribKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLint attribute, EGLint *value);
111
112
113#ifdef EGL_NOK_swap_region
114typedef EGLBoolean (*SwapBuffersRegionNOK_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint numRects, const EGLint *rects);
115#endif
116
117#ifdef EGL_MESA_drm_image
118typedef _EGLImage *(*CreateDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attr_list);
119typedef EGLBoolean (*ExportDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *name, EGLint *handle, EGLint *stride);
120#endif
121
122#ifdef EGL_WL_bind_wayland_display
123struct wl_display;
124typedef EGLBoolean (*BindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display);
125typedef EGLBoolean (*UnbindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display);
126typedef EGLBoolean (*QueryWaylandBufferWL_t)(_EGLDriver *drv, _EGLDisplay *displ, struct wl_buffer *buffer, EGLint attribute, EGLint *value);
127#endif
128
129typedef EGLBoolean (*PostSubBufferNV_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, EGLint x, EGLint y, EGLint width, EGLint height);
130
131/**
132 * The API dispatcher jumps through these functions
133 */
134struct _egl_api
135{
136   Initialize_t Initialize;
137   Terminate_t Terminate;
138
139   GetConfigs_t GetConfigs;
140   ChooseConfig_t ChooseConfig;
141   GetConfigAttrib_t GetConfigAttrib;
142
143   CreateContext_t CreateContext;
144   DestroyContext_t DestroyContext;
145   MakeCurrent_t MakeCurrent;
146   QueryContext_t QueryContext;
147
148   CreateWindowSurface_t CreateWindowSurface;
149   CreatePixmapSurface_t CreatePixmapSurface;
150   CreatePbufferSurface_t CreatePbufferSurface;
151   DestroySurface_t DestroySurface;
152   QuerySurface_t QuerySurface;
153   SurfaceAttrib_t SurfaceAttrib;
154   BindTexImage_t BindTexImage;
155   ReleaseTexImage_t ReleaseTexImage;
156   SwapInterval_t SwapInterval;
157   SwapBuffers_t SwapBuffers;
158   CopyBuffers_t CopyBuffers;
159
160   QueryString_t QueryString;
161   WaitClient_t WaitClient;
162   WaitNative_t WaitNative;
163   GetProcAddress_t GetProcAddress;
164
165#ifdef EGL_MESA_screen_surface
166   ChooseModeMESA_t ChooseModeMESA;
167   GetModesMESA_t GetModesMESA;
168   GetModeAttribMESA_t GetModeAttribMESA;
169   CopyContextMESA_t CopyContextMESA;
170   GetScreensMESA_t GetScreensMESA;
171   CreateScreenSurfaceMESA_t CreateScreenSurfaceMESA;
172   ShowScreenSurfaceMESA_t ShowScreenSurfaceMESA;
173   ScreenPositionMESA_t ScreenPositionMESA;
174   QueryScreenMESA_t QueryScreenMESA;
175   QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA;
176   QueryScreenModeMESA_t QueryScreenModeMESA;
177   QueryModeStringMESA_t QueryModeStringMESA;
178#endif /* EGL_MESA_screen_surface */
179
180   CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer;
181
182   CreateImageKHR_t CreateImageKHR;
183   DestroyImageKHR_t DestroyImageKHR;
184
185   CreateSyncKHR_t CreateSyncKHR;
186   DestroySyncKHR_t DestroySyncKHR;
187   ClientWaitSyncKHR_t ClientWaitSyncKHR;
188   SignalSyncKHR_t SignalSyncKHR;
189   GetSyncAttribKHR_t GetSyncAttribKHR;
190
191#ifdef EGL_NOK_swap_region
192   SwapBuffersRegionNOK_t SwapBuffersRegionNOK;
193#endif
194
195#ifdef EGL_MESA_drm_image
196   CreateDRMImageMESA_t CreateDRMImageMESA;
197   ExportDRMImageMESA_t ExportDRMImageMESA;
198#endif
199
200#ifdef EGL_WL_bind_wayland_display
201   BindWaylandDisplayWL_t BindWaylandDisplayWL;
202   UnbindWaylandDisplayWL_t UnbindWaylandDisplayWL;
203   QueryWaylandBufferWL_t QueryWaylandBufferWL;
204#endif
205
206   PostSubBufferNV_t PostSubBufferNV;
207};
208
209#endif /* EGLAPI_INCLUDED */
210