5e1581b9ce50efaccc1dd39c4b1a4afddd47acea
[mesa.git] / src / egl / main / eglapi.h
1 /**************************************************************************
2 *
3 * Copyright 2008 VMware, Inc.
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 #include "egltypedefs.h"
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /**
41 * A generic function ptr type
42 */
43 typedef void (*_EGLProc)(void);
44
45 struct wl_display;
46 struct mesa_glinterop_device_info;
47 struct mesa_glinterop_export_in;
48 struct mesa_glinterop_export_out;
49
50 /**
51 * The API dispatcher jumps through these functions
52 */
53 struct _egl_api
54 {
55 /* driver funcs */
56 EGLBoolean (*Initialize)(_EGLDriver *, _EGLDisplay *dpy);
57 EGLBoolean (*Terminate)(_EGLDriver *, _EGLDisplay *dpy);
58 const char *(*QueryDriverName)(_EGLDisplay *dpy);
59 char *(*QueryDriverConfig)(_EGLDisplay *dpy);
60
61 /* config funcs */
62 EGLBoolean (*GetConfigs)(_EGLDriver *drv, _EGLDisplay *dpy,
63 EGLConfig *configs, EGLint config_size,
64 EGLint *num_config);
65 EGLBoolean (*ChooseConfig)(_EGLDriver *drv, _EGLDisplay *dpy,
66 const EGLint *attrib_list, EGLConfig *configs,
67 EGLint config_size, EGLint *num_config);
68 EGLBoolean (*GetConfigAttrib)(_EGLDriver *drv, _EGLDisplay *dpy,
69 _EGLConfig *config, EGLint attribute,
70 EGLint *value);
71
72 /* context funcs */
73 _EGLContext *(*CreateContext)(_EGLDriver *drv, _EGLDisplay *dpy,
74 _EGLConfig *config, _EGLContext *share_list,
75 const EGLint *attrib_list);
76 EGLBoolean (*DestroyContext)(_EGLDriver *drv, _EGLDisplay *dpy,
77 _EGLContext *ctx);
78 /* this is the only function (other than Initialize) that may be called
79 * with an uninitialized display
80 */
81 EGLBoolean (*MakeCurrent)(_EGLDriver *drv, _EGLDisplay *dpy,
82 _EGLSurface *draw, _EGLSurface *read,
83 _EGLContext *ctx);
84 EGLBoolean (*QueryContext)(_EGLDriver *drv, _EGLDisplay *dpy,
85 _EGLContext *ctx, EGLint attribute,
86 EGLint *value);
87
88 /* surface funcs */
89 _EGLSurface *(*CreateWindowSurface)(_EGLDriver *drv, _EGLDisplay *dpy,
90 _EGLConfig *config, void *native_window,
91 const EGLint *attrib_list);
92 _EGLSurface *(*CreatePixmapSurface)(_EGLDriver *drv, _EGLDisplay *dpy,
93 _EGLConfig *config, void *native_pixmap,
94 const EGLint *attrib_list);
95 _EGLSurface *(*CreatePbufferSurface)(_EGLDriver *drv, _EGLDisplay *dpy,
96 _EGLConfig *config,
97 const EGLint *attrib_list);
98 EGLBoolean (*DestroySurface)(_EGLDriver *drv, _EGLDisplay *dpy,
99 _EGLSurface *surface);
100 EGLBoolean (*QuerySurface)(_EGLDriver *drv, _EGLDisplay *dpy,
101 _EGLSurface *surface, EGLint attribute,
102 EGLint *value);
103 EGLBoolean (*SurfaceAttrib)(_EGLDriver *drv, _EGLDisplay *dpy,
104 _EGLSurface *surface, EGLint attribute,
105 EGLint value);
106 EGLBoolean (*BindTexImage)(_EGLDriver *drv, _EGLDisplay *dpy,
107 _EGLSurface *surface, EGLint buffer);
108 EGLBoolean (*ReleaseTexImage)(_EGLDriver *drv, _EGLDisplay *dpy,
109 _EGLSurface *surface, EGLint buffer);
110 EGLBoolean (*SwapInterval)(_EGLDriver *drv, _EGLDisplay *dpy,
111 _EGLSurface *surf, EGLint interval);
112 EGLBoolean (*SwapBuffers)(_EGLDriver *drv, _EGLDisplay *dpy,
113 _EGLSurface *draw);
114 EGLBoolean (*CopyBuffers)(_EGLDriver *drv, _EGLDisplay *dpy,
115 _EGLSurface *surface, void *native_pixmap_target);
116 EGLBoolean (*SetDamageRegion)(_EGLDriver *drv, _EGLDisplay *dpy,
117 _EGLSurface *surface, EGLint *rects, EGLint n_rects);
118
119 /* misc functions */
120 EGLBoolean (*WaitClient)(_EGLDriver *drv, _EGLDisplay *dpy,
121 _EGLContext *ctx);
122 EGLBoolean (*WaitNative)(_EGLDriver *drv, _EGLDisplay *dpy,
123 EGLint engine);
124
125 /* this function may be called from multiple threads at the same time */
126 _EGLProc (*GetProcAddress)(_EGLDriver *drv, const char *procname);
127
128 _EGLSurface *(*CreatePbufferFromClientBuffer)(_EGLDriver *drv,
129 _EGLDisplay *dpy,
130 EGLenum buftype,
131 EGLClientBuffer buffer,
132 _EGLConfig *config,
133 const EGLint *attrib_list);
134
135 _EGLImage *(*CreateImageKHR)(_EGLDriver *drv, _EGLDisplay *dpy,
136 _EGLContext *ctx, EGLenum target,
137 EGLClientBuffer buffer,
138 const EGLint *attr_list);
139 EGLBoolean (*DestroyImageKHR)(_EGLDriver *drv, _EGLDisplay *dpy,
140 _EGLImage *image);
141
142 _EGLSync *(*CreateSyncKHR)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum type,
143 const EGLAttrib *attrib_list);
144 EGLBoolean (*DestroySyncKHR)(_EGLDriver *drv, _EGLDisplay *dpy,
145 _EGLSync *sync);
146 EGLint (*ClientWaitSyncKHR)(_EGLDriver *drv, _EGLDisplay *dpy,
147 _EGLSync *sync, EGLint flags, EGLTime timeout);
148 EGLint (*WaitSyncKHR)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync);
149 EGLBoolean (*SignalSyncKHR)(_EGLDriver *drv, _EGLDisplay *dpy,
150 _EGLSync *sync, EGLenum mode);
151 EGLBoolean (*GetSyncAttrib)(_EGLDriver *drv, _EGLDisplay *dpy,
152 _EGLSync *sync, EGLint attribute,
153 EGLAttrib *value);
154 EGLint (*DupNativeFenceFDANDROID)(_EGLDriver *drv, _EGLDisplay *dpy,
155 _EGLSync *sync);
156
157 EGLBoolean (*SwapBuffersRegionNOK)(_EGLDriver *drv, _EGLDisplay *disp,
158 _EGLSurface *surf, EGLint numRects,
159 const EGLint *rects);
160
161 _EGLImage *(*CreateDRMImageMESA)(_EGLDriver *drv, _EGLDisplay *disp,
162 const EGLint *attr_list);
163 EGLBoolean (*ExportDRMImageMESA)(_EGLDriver *drv, _EGLDisplay *disp,
164 _EGLImage *img, EGLint *name,
165 EGLint *handle, EGLint *stride);
166
167 EGLBoolean (*BindWaylandDisplayWL)(_EGLDriver *drv, _EGLDisplay *disp,
168 struct wl_display *display);
169 EGLBoolean (*UnbindWaylandDisplayWL)(_EGLDriver *drv, _EGLDisplay *disp,
170 struct wl_display *display);
171 EGLBoolean (*QueryWaylandBufferWL)(_EGLDriver *drv, _EGLDisplay *displ,
172 struct wl_resource *buffer,
173 EGLint attribute, EGLint *value);
174
175 struct wl_buffer *(*CreateWaylandBufferFromImageWL)(_EGLDriver *drv,
176 _EGLDisplay *disp,
177 _EGLImage *img);
178
179 EGLBoolean (*SwapBuffersWithDamageEXT)(_EGLDriver *drv, _EGLDisplay *dpy,
180 _EGLSurface *surface,
181 const EGLint *rects, EGLint n_rects);
182
183 EGLBoolean (*PostSubBufferNV)(_EGLDriver *drv, _EGLDisplay *disp,
184 _EGLSurface *surface, EGLint x, EGLint y,
185 EGLint width, EGLint height);
186
187 EGLint (*QueryBufferAge)(_EGLDriver *drv,
188 _EGLDisplay *dpy, _EGLSurface *surface);
189 EGLBoolean (*GetSyncValuesCHROMIUM)(_EGLDisplay *dpy, _EGLSurface *surface,
190 EGLuint64KHR *ust, EGLuint64KHR *msc,
191 EGLuint64KHR *sbc);
192
193 EGLBoolean (*ExportDMABUFImageQueryMESA)(_EGLDriver *drv, _EGLDisplay *disp,
194 _EGLImage *img, EGLint *fourcc,
195 EGLint *nplanes,
196 EGLuint64KHR *modifiers);
197 EGLBoolean (*ExportDMABUFImageMESA)(_EGLDriver *drv, _EGLDisplay *disp,
198 _EGLImage *img, EGLint *fds,
199 EGLint *strides, EGLint *offsets);
200
201 int (*GLInteropQueryDeviceInfo)(_EGLDisplay *dpy, _EGLContext *ctx,
202 struct mesa_glinterop_device_info *out);
203 int (*GLInteropExportObject)(_EGLDisplay *dpy, _EGLContext *ctx,
204 struct mesa_glinterop_export_in *in,
205 struct mesa_glinterop_export_out *out);
206
207 EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDriver *drv, _EGLDisplay *dpy,
208 EGLint max_formats, EGLint *formats,
209 EGLint *num_formats);
210 EGLBoolean (*QueryDmaBufModifiersEXT) (_EGLDriver *drv, _EGLDisplay *dpy,
211 EGLint format, EGLint max_modifiers,
212 EGLuint64KHR *modifiers,
213 EGLBoolean *external_only,
214 EGLint *num_modifiers);
215
216 void (*SetBlobCacheFuncsANDROID) (_EGLDriver *drv, _EGLDisplay *dpy,
217 EGLSetBlobFuncANDROID set,
218 EGLGetBlobFuncANDROID get);
219 };
220
221 #ifdef __cplusplus
222 }
223 #endif
224
225 #endif /* EGLAPI_INCLUDED */