Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // main.cpp: DLL entry point and management of thread-local data. |
| 16 | |
| 17 | #include "main.h" |
| 18 | |
| 19 | #include "libEGL.hpp" |
| 20 | #include "Context.hpp" |
Nicolas Capens | 31c07a3 | 2017-06-13 23:44:13 -0400 | [diff] [blame] | 21 | #include "Surface.hpp" |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 22 | #include "Display.h" |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 23 | |
| 24 | #include "resource.h" |
| 25 | #include "Common/Thread.hpp" |
| 26 | #include "Common/SharedLibrary.hpp" |
| 27 | #include "common/debug.h" |
| 28 | |
| 29 | #include <EGL/eglext.h> |
| 30 | |
| 31 | static sw::Thread::LocalStorageKey currentTLS = TLS_OUT_OF_INDEXES; |
| 32 | |
| 33 | #if !defined(_MSC_VER) |
| 34 | #define CONSTRUCTOR __attribute__((constructor)) |
| 35 | #define DESTRUCTOR __attribute__((destructor)) |
| 36 | #else |
| 37 | #define CONSTRUCTOR |
| 38 | #define DESTRUCTOR |
| 39 | #endif |
| 40 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 41 | namespace egl |
| 42 | { |
David Rim | 10bcdb4 | 2018-04-06 17:48:41 +0900 | [diff] [blame] | 43 | void releaseCurrent(void *storage) |
| 44 | { |
| 45 | // This pthread destructor is called after the TLS is already reset to NULL, |
| 46 | // so we can't call EGL functions here to do the cleanup. |
| 47 | |
| 48 | Current *current = (Current*)storage; |
| 49 | |
| 50 | if(current) |
| 51 | { |
| 52 | if(current->drawSurface) |
| 53 | { |
| 54 | current->drawSurface->release(); |
| 55 | } |
| 56 | |
| 57 | if(current->readSurface) |
| 58 | { |
| 59 | current->readSurface->release(); |
| 60 | } |
| 61 | |
| 62 | if(current->context) |
| 63 | { |
| 64 | current->context->release(); |
| 65 | } |
| 66 | |
| 67 | free(current); |
| 68 | } |
| 69 | } |
| 70 | |
Nicolas Capens | 420b64d | 2017-07-07 17:01:16 -0400 | [diff] [blame] | 71 | Current *attachThread() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 72 | { |
| 73 | TRACE("()"); |
| 74 | |
Nicolas Capens | 420b64d | 2017-07-07 17:01:16 -0400 | [diff] [blame] | 75 | if(currentTLS == TLS_OUT_OF_INDEXES) |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 76 | { |
David Rim | 10bcdb4 | 2018-04-06 17:48:41 +0900 | [diff] [blame] | 77 | currentTLS = sw::Thread::allocateLocalStorageKey(releaseCurrent); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 78 | } |
Nicolas Capens | 420b64d | 2017-07-07 17:01:16 -0400 | [diff] [blame] | 79 | |
Nicolas Capens | 4ad365b | 2017-09-12 16:39:42 -0400 | [diff] [blame] | 80 | Current *current = (Current*)sw::Thread::allocateLocalStorage(currentTLS, sizeof(Current)); |
Nicolas Capens | 420b64d | 2017-07-07 17:01:16 -0400 | [diff] [blame] | 81 | |
| 82 | current->error = EGL_SUCCESS; |
| 83 | current->API = EGL_OPENGL_ES_API; |
| 84 | current->context = nullptr; |
| 85 | current->drawSurface = nullptr; |
| 86 | current->readSurface = nullptr; |
| 87 | |
| 88 | return current; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 89 | } |
| 90 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 91 | void detachThread() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 92 | { |
| 93 | TRACE("()"); |
| 94 | |
Nicolas Capens | cc5c7d9 | 2016-06-13 14:35:11 -0400 | [diff] [blame] | 95 | eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE); |
| 96 | |
Nicolas Capens | 4ad365b | 2017-09-12 16:39:42 -0400 | [diff] [blame] | 97 | sw::Thread::freeLocalStorage(currentTLS); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 98 | } |
| 99 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 100 | CONSTRUCTOR void attachProcess() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 101 | { |
| 102 | TRACE("()"); |
| 103 | |
| 104 | #if !defined(ANGLE_DISABLE_TRACE) && defined(TRACE_OUTPUT_FILE) |
| 105 | FILE *debug = fopen(TRACE_OUTPUT_FILE, "rt"); |
| 106 | |
| 107 | if(debug) |
| 108 | { |
| 109 | fclose(debug); |
| 110 | debug = fopen(TRACE_OUTPUT_FILE, "wt"); // Erase |
| 111 | fclose(debug); |
| 112 | } |
| 113 | #endif |
| 114 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 115 | attachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 116 | } |
| 117 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 118 | DESTRUCTOR void detachProcess() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 119 | { |
| 120 | TRACE("()"); |
| 121 | |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 122 | detachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 123 | sw::Thread::freeLocalStorageKey(currentTLS); |
| 124 | } |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 125 | } |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 126 | |
| 127 | #if defined(_WIN32) |
Alexis Hetu | 8e942eb | 2017-03-16 10:53:01 -0400 | [diff] [blame] | 128 | #ifdef DEBUGGER_WAIT_DIALOG |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 129 | static INT_PTR CALLBACK DebuggerWaitDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 130 | { |
| 131 | RECT rect; |
| 132 | |
| 133 | switch(uMsg) |
| 134 | { |
| 135 | case WM_INITDIALOG: |
| 136 | GetWindowRect(GetDesktopWindow(), &rect); |
| 137 | SetWindowPos(hwnd, HWND_TOP, rect.right / 2, rect.bottom / 2, 0, 0, SWP_NOSIZE); |
| 138 | SetTimer(hwnd, 1, 100, NULL); |
| 139 | return TRUE; |
| 140 | case WM_COMMAND: |
| 141 | if(LOWORD(wParam) == IDCANCEL) |
| 142 | { |
| 143 | EndDialog(hwnd, 0); |
| 144 | } |
| 145 | break; |
| 146 | case WM_TIMER: |
| 147 | if(IsDebuggerPresent()) |
| 148 | { |
| 149 | EndDialog(hwnd, 0); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | return FALSE; |
| 154 | } |
| 155 | |
| 156 | static void WaitForDebugger(HINSTANCE instance) |
| 157 | { |
| 158 | if(!IsDebuggerPresent()) |
| 159 | { |
| 160 | HRSRC dialog = FindResource(instance, MAKEINTRESOURCE(IDD_DIALOG1), RT_DIALOG); |
| 161 | DLGTEMPLATE *dialogTemplate = (DLGTEMPLATE*)LoadResource(instance, dialog); |
| 162 | DialogBoxIndirect(instance, dialogTemplate, NULL, DebuggerWaitDialogProc); |
| 163 | } |
| 164 | } |
Alexis Hetu | e97a31e | 2016-11-14 14:10:47 -0500 | [diff] [blame] | 165 | #endif |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 166 | |
| 167 | extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) |
| 168 | { |
| 169 | switch(reason) |
| 170 | { |
| 171 | case DLL_PROCESS_ATTACH: |
Alexis Hetu | 3818231 | 2017-03-16 11:46:16 -0400 | [diff] [blame] | 172 | #ifdef DEBUGGER_WAIT_DIALOG |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 173 | WaitForDebugger(instance); |
| 174 | #endif |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 175 | egl::attachProcess(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 176 | break; |
| 177 | case DLL_THREAD_ATTACH: |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 178 | egl::attachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 179 | break; |
| 180 | case DLL_THREAD_DETACH: |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 181 | egl::detachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 182 | break; |
| 183 | case DLL_PROCESS_DETACH: |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 184 | egl::detachProcess(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 185 | break; |
| 186 | default: |
| 187 | break; |
| 188 | } |
| 189 | |
| 190 | return TRUE; |
| 191 | } |
| 192 | #endif |
| 193 | |
| 194 | namespace egl |
| 195 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 196 | static Current *getCurrent(void) |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 197 | { |
| 198 | Current *current = (Current*)sw::Thread::getLocalStorage(currentTLS); |
| 199 | |
| 200 | if(!current) |
| 201 | { |
Nicolas Capens | 420b64d | 2017-07-07 17:01:16 -0400 | [diff] [blame] | 202 | current = attachThread(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 203 | } |
| 204 | |
Nicolas Capens | 420b64d | 2017-07-07 17:01:16 -0400 | [diff] [blame] | 205 | return current; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | void setCurrentError(EGLint error) |
| 209 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 210 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 211 | |
| 212 | current->error = error; |
| 213 | } |
| 214 | |
| 215 | EGLint getCurrentError() |
| 216 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 217 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 218 | |
| 219 | return current->error; |
| 220 | } |
| 221 | |
| 222 | void setCurrentAPI(EGLenum API) |
| 223 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 224 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 225 | |
| 226 | current->API = API; |
| 227 | } |
| 228 | |
| 229 | EGLenum getCurrentAPI() |
| 230 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 231 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 232 | |
| 233 | return current->API; |
| 234 | } |
| 235 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 236 | void setCurrentContext(egl::Context *ctx) |
| 237 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 238 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 239 | |
| 240 | if(ctx) |
| 241 | { |
| 242 | ctx->addRef(); |
| 243 | } |
| 244 | |
| 245 | if(current->context) |
| 246 | { |
| 247 | current->context->release(); |
| 248 | } |
| 249 | |
| 250 | current->context = ctx; |
| 251 | } |
| 252 | |
Nicolas Capens | 506cc5e | 2017-07-24 11:30:55 -0400 | [diff] [blame] | 253 | NO_SANITIZE_FUNCTION egl::Context *getCurrentContext() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 254 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 255 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 256 | |
| 257 | return current->context; |
| 258 | } |
| 259 | |
| 260 | void setCurrentDrawSurface(egl::Surface *surface) |
| 261 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 262 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 263 | |
| 264 | if(surface) |
| 265 | { |
| 266 | surface->addRef(); |
| 267 | } |
| 268 | |
| 269 | if(current->drawSurface) |
| 270 | { |
| 271 | current->drawSurface->release(); |
| 272 | } |
| 273 | |
| 274 | current->drawSurface = surface; |
| 275 | } |
| 276 | |
| 277 | egl::Surface *getCurrentDrawSurface() |
| 278 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 279 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 280 | |
| 281 | return current->drawSurface; |
| 282 | } |
| 283 | |
| 284 | void setCurrentReadSurface(egl::Surface *surface) |
| 285 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 286 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 287 | |
| 288 | if(surface) |
| 289 | { |
| 290 | surface->addRef(); |
| 291 | } |
| 292 | |
| 293 | if(current->readSurface) |
| 294 | { |
| 295 | current->readSurface->release(); |
| 296 | } |
| 297 | |
| 298 | current->readSurface = surface; |
| 299 | } |
| 300 | |
| 301 | egl::Surface *getCurrentReadSurface() |
| 302 | { |
Nicolas Capens | af93a42 | 2016-06-12 16:11:25 -0400 | [diff] [blame] | 303 | Current *current = getCurrent(); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 304 | |
| 305 | return current->readSurface; |
| 306 | } |
| 307 | |
| 308 | void error(EGLint errorCode) |
| 309 | { |
| 310 | egl::setCurrentError(errorCode); |
| 311 | |
| 312 | if(errorCode != EGL_SUCCESS) |
| 313 | { |
| 314 | switch(errorCode) |
| 315 | { |
| 316 | case EGL_NOT_INITIALIZED: TRACE("\t! Error generated: not initialized\n"); break; |
| 317 | case EGL_BAD_ACCESS: TRACE("\t! Error generated: bad access\n"); break; |
| 318 | case EGL_BAD_ALLOC: TRACE("\t! Error generated: bad alloc\n"); break; |
| 319 | case EGL_BAD_ATTRIBUTE: TRACE("\t! Error generated: bad attribute\n"); break; |
| 320 | case EGL_BAD_CONFIG: TRACE("\t! Error generated: bad config\n"); break; |
| 321 | case EGL_BAD_CONTEXT: TRACE("\t! Error generated: bad context\n"); break; |
| 322 | case EGL_BAD_CURRENT_SURFACE: TRACE("\t! Error generated: bad current surface\n"); break; |
| 323 | case EGL_BAD_DISPLAY: TRACE("\t! Error generated: bad display\n"); break; |
| 324 | case EGL_BAD_MATCH: TRACE("\t! Error generated: bad match\n"); break; |
| 325 | case EGL_BAD_NATIVE_PIXMAP: TRACE("\t! Error generated: bad native pixmap\n"); break; |
| 326 | case EGL_BAD_NATIVE_WINDOW: TRACE("\t! Error generated: bad native window\n"); break; |
| 327 | case EGL_BAD_PARAMETER: TRACE("\t! Error generated: bad parameter\n"); break; |
| 328 | case EGL_BAD_SURFACE: TRACE("\t! Error generated: bad surface\n"); break; |
| 329 | case EGL_CONTEXT_LOST: TRACE("\t! Error generated: context lost\n"); break; |
| 330 | default: TRACE("\t! Error generated: <0x%X>\n", errorCode); break; |
| 331 | } |
| 332 | } |
| 333 | } |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 334 | |
| 335 | sw::MutexLock *getDisplayLock(EGLDisplay dpy) |
| 336 | { |
| 337 | auto display = Display::get(dpy); |
| 338 | if (!display) return nullptr; |
| 339 | return display->getLock(); |
| 340 | } |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | namespace egl |
| 344 | { |
| 345 | EGLint GetError(void); |
| 346 | EGLDisplay GetDisplay(EGLNativeDisplayType display_id); |
| 347 | EGLBoolean Initialize(EGLDisplay dpy, EGLint *major, EGLint *minor); |
| 348 | EGLBoolean Terminate(EGLDisplay dpy); |
| 349 | const char *QueryString(EGLDisplay dpy, EGLint name); |
| 350 | EGLBoolean GetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
| 351 | EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
| 352 | EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); |
| 353 | EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType window, const EGLint *attrib_list); |
| 354 | EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); |
| 355 | EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); |
| 356 | EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface); |
| 357 | EGLBoolean QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); |
| 358 | EGLBoolean BindAPI(EGLenum api); |
| 359 | EGLenum QueryAPI(void); |
| 360 | EGLBoolean WaitClient(void); |
| 361 | EGLBoolean ReleaseThread(void); |
| 362 | EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); |
| 363 | EGLBoolean SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); |
| 364 | EGLBoolean BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); |
| 365 | EGLBoolean ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); |
| 366 | EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval); |
| 367 | EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); |
| 368 | EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx); |
| 369 | EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); |
| 370 | EGLContext GetCurrentContext(void); |
| 371 | EGLSurface GetCurrentSurface(EGLint readdraw); |
| 372 | EGLDisplay GetCurrentDisplay(void); |
| 373 | EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); |
| 374 | EGLBoolean WaitGL(void); |
| 375 | EGLBoolean WaitNative(EGLint engine); |
| 376 | EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface surface); |
| 377 | EGLBoolean CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); |
| 378 | EGLImageKHR CreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 379 | EGLImageKHR CreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 380 | EGLBoolean DestroyImageKHR(EGLDisplay dpy, EGLImageKHR image); |
| 381 | EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 382 | EGLDisplay GetPlatformDisplay(EGLenum platform, void *native_display, const EGLAttrib *attrib_list); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 383 | EGLSurface CreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 384 | EGLSurface CreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 385 | EGLSurface CreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 386 | EGLSurface CreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 387 | EGLSyncKHR CreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 388 | EGLSyncKHR CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 389 | EGLBoolean DestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync); |
| 390 | EGLint ClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); |
| 391 | EGLBoolean GetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 392 | EGLBoolean GetSyncAttrib(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLAttrib *value); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 393 | __eglMustCastToProperFunctionPointerType GetProcAddress(const char *procname); |
| 394 | } |
| 395 | |
| 396 | extern "C" |
| 397 | { |
| 398 | EGLAPI EGLint EGLAPIENTRY eglGetError(void) |
| 399 | { |
| 400 | return egl::GetError(); |
| 401 | } |
| 402 | |
| 403 | EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) |
| 404 | { |
| 405 | return egl::GetDisplay(display_id); |
| 406 | } |
| 407 | |
| 408 | EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) |
| 409 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 410 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 411 | return egl::Initialize(dpy, major, minor); |
| 412 | } |
| 413 | |
| 414 | EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) |
| 415 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 416 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 417 | return egl::Terminate(dpy); |
| 418 | } |
| 419 | |
| 420 | EGLAPI const char *EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) |
| 421 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 422 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 423 | return egl::QueryString(dpy, name); |
| 424 | } |
| 425 | |
| 426 | EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
| 427 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 428 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 429 | return egl::GetConfigs(dpy, configs, config_size, num_config); |
| 430 | } |
| 431 | |
| 432 | EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
| 433 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 434 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 435 | return egl::ChooseConfig(dpy, attrib_list, configs, config_size, num_config); |
| 436 | } |
| 437 | |
| 438 | EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) |
| 439 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 440 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 441 | return egl::GetConfigAttrib(dpy, config, attribute, value); |
| 442 | } |
| 443 | |
| 444 | EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType window, const EGLint *attrib_list) |
| 445 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 446 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 447 | return egl::CreateWindowSurface(dpy, config, window, attrib_list); |
| 448 | } |
| 449 | |
| 450 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) |
| 451 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 452 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 453 | return egl::CreatePbufferSurface(dpy, config, attrib_list); |
| 454 | } |
| 455 | |
| 456 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) |
| 457 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 458 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 459 | return egl::CreatePixmapSurface(dpy, config, pixmap, attrib_list); |
| 460 | } |
| 461 | |
| 462 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface) |
| 463 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 464 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 465 | return egl::DestroySurface(dpy, surface); |
| 466 | } |
| 467 | |
| 468 | EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) |
| 469 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 470 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 471 | return egl::QuerySurface(dpy, surface, attribute, value); |
| 472 | } |
| 473 | |
| 474 | EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api) |
| 475 | { |
| 476 | return egl::BindAPI(api); |
| 477 | } |
| 478 | |
| 479 | EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void) |
| 480 | { |
| 481 | return egl::QueryAPI(); |
| 482 | } |
| 483 | |
| 484 | EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void) |
| 485 | { |
| 486 | return egl::WaitClient(); |
| 487 | } |
| 488 | |
| 489 | EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) |
| 490 | { |
| 491 | return egl::ReleaseThread(); |
| 492 | } |
| 493 | |
| 494 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) |
| 495 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 496 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 497 | return egl::CreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list); |
| 498 | } |
| 499 | |
| 500 | EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) |
| 501 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 502 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 503 | return egl::SurfaceAttrib(dpy, surface, attribute, value); |
| 504 | } |
| 505 | |
| 506 | EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) |
| 507 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 508 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 509 | return egl::BindTexImage(dpy, surface, buffer); |
| 510 | } |
| 511 | |
| 512 | EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) |
| 513 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 514 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 515 | return egl::ReleaseTexImage(dpy, surface, buffer); |
| 516 | } |
| 517 | |
| 518 | EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) |
| 519 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 520 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 521 | return egl::SwapInterval(dpy, interval); |
| 522 | } |
| 523 | |
| 524 | EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) |
| 525 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 526 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 527 | return egl::CreateContext(dpy, config, share_context, attrib_list); |
| 528 | } |
| 529 | |
| 530 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx) |
| 531 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 532 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 533 | return egl::DestroyContext(dpy, ctx); |
| 534 | } |
| 535 | |
| 536 | EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) |
| 537 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 538 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 539 | return egl::MakeCurrent(dpy, draw, read, ctx); |
| 540 | } |
| 541 | |
| 542 | EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void) |
| 543 | { |
| 544 | return egl::GetCurrentContext(); |
| 545 | } |
| 546 | |
| 547 | EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) |
| 548 | { |
| 549 | return egl::GetCurrentSurface(readdraw); |
| 550 | } |
| 551 | |
| 552 | EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) |
| 553 | { |
| 554 | return egl::GetCurrentDisplay(); |
| 555 | } |
| 556 | |
| 557 | EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) |
| 558 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 559 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 560 | return egl::QueryContext(dpy, ctx, attribute, value); |
| 561 | } |
| 562 | |
| 563 | EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void) |
| 564 | { |
| 565 | return egl::WaitClient(); |
| 566 | } |
| 567 | |
| 568 | EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) |
| 569 | { |
| 570 | return egl::WaitNative(engine); |
| 571 | } |
| 572 | |
| 573 | EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) |
| 574 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 575 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 576 | return egl::SwapBuffers(dpy, surface); |
| 577 | } |
| 578 | |
| 579 | EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) |
| 580 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 581 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 582 | return egl::CopyBuffers(dpy, surface, target); |
| 583 | } |
| 584 | |
| 585 | EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) |
| 586 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 587 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 588 | return egl::CreateImageKHR(dpy, ctx, target, buffer, attrib_list); |
| 589 | } |
| 590 | |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 591 | EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list) |
| 592 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 593 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 594 | return egl::CreateImage(dpy, ctx, target, buffer, attrib_list); |
| 595 | } |
| 596 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 597 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) |
| 598 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 599 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 600 | return egl::DestroyImageKHR(dpy, image); |
| 601 | } |
| 602 | |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 603 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage(EGLDisplay dpy, EGLImageKHR image) |
| 604 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 605 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 606 | return egl::DestroyImageKHR(dpy, image); |
| 607 | } |
| 608 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 609 | EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list) |
| 610 | { |
| 611 | return egl::GetPlatformDisplayEXT(platform, native_display, attrib_list); |
| 612 | } |
| 613 | |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 614 | EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay(EGLenum platform, void *native_display, const EGLAttrib *attrib_list) |
| 615 | { |
| 616 | return egl::GetPlatformDisplay(platform, native_display, attrib_list); |
| 617 | } |
| 618 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 619 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list) |
| 620 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 621 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 622 | return egl::CreatePlatformWindowSurfaceEXT(dpy, config, native_window, attrib_list); |
| 623 | } |
| 624 | |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 625 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list) |
| 626 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 627 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 628 | return egl::CreatePlatformWindowSurface(dpy, config, native_window, attrib_list); |
| 629 | } |
| 630 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 631 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list) |
| 632 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 633 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 634 | return egl::CreatePlatformPixmapSurfaceEXT(dpy, config, native_pixmap, attrib_list); |
| 635 | } |
| 636 | |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 637 | EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list) |
| 638 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 639 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 640 | return egl::CreatePlatformPixmapSurface(dpy, config, native_pixmap, attrib_list); |
| 641 | } |
| 642 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 643 | EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) |
| 644 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 645 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 646 | return egl::CreateSyncKHR(dpy, type, attrib_list); |
| 647 | } |
| 648 | |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 649 | EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list) |
| 650 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 651 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 652 | return egl::CreateSync(dpy, type, attrib_list); |
| 653 | } |
| 654 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 655 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) |
| 656 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 657 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 658 | return egl::DestroySyncKHR(dpy, sync); |
| 659 | } |
| 660 | |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 661 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync(EGLDisplay dpy, EGLSyncKHR sync) |
| 662 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 663 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 664 | return egl::DestroySyncKHR(dpy, sync); |
| 665 | } |
| 666 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 667 | EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) |
| 668 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 669 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 670 | return egl::ClientWaitSyncKHR(dpy, sync, flags, timeout); |
| 671 | } |
| 672 | |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 673 | EGLAPI EGLint EGLAPIENTRY eglClientWaitSync(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) |
| 674 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 675 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 676 | return egl::ClientWaitSyncKHR(dpy, sync, flags, timeout); |
| 677 | } |
| 678 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 679 | EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) |
| 680 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 681 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 682 | return egl::GetSyncAttribKHR(dpy, sync, attribute, value); |
| 683 | } |
| 684 | |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 685 | EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLAttrib *value) |
| 686 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 687 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 688 | return egl::GetSyncAttrib(dpy, sync, attribute, value); |
| 689 | } |
| 690 | |
| 691 | EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) |
| 692 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 693 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 694 | return egl::ClientWaitSyncKHR(dpy, sync, flags, EGL_FOREVER_KHR); |
| 695 | } |
| 696 | |
| 697 | EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags) |
| 698 | { |
Chris Forbes | 1aae88c | 2018-09-11 17:31:52 -0700 | [diff] [blame] | 699 | LockGuard lock(egl::getDisplayLock(dpy)); |
Nicolas Capens | 48908cb | 2018-01-08 13:07:14 -0500 | [diff] [blame] | 700 | return egl::ClientWaitSyncKHR(dpy, sync, flags, EGL_FOREVER_KHR); |
| 701 | } |
| 702 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 703 | EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname) |
| 704 | { |
| 705 | return egl::GetProcAddress(procname); |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | LibEGLexports::LibEGLexports() |
| 710 | { |
| 711 | this->eglGetError = egl::GetError; |
| 712 | this->eglGetDisplay = egl::GetDisplay; |
| 713 | this->eglInitialize = egl::Initialize; |
| 714 | this->eglTerminate = egl::Terminate; |
| 715 | this->eglQueryString = egl::QueryString; |
| 716 | this->eglGetConfigs = egl::GetConfigs; |
| 717 | this->eglChooseConfig = egl::ChooseConfig; |
| 718 | this->eglGetConfigAttrib = egl::GetConfigAttrib; |
| 719 | this->eglCreateWindowSurface = egl::CreateWindowSurface; |
| 720 | this->eglCreatePbufferSurface = egl::CreatePbufferSurface; |
| 721 | this->eglCreatePixmapSurface = egl::CreatePixmapSurface; |
| 722 | this->eglDestroySurface = egl::DestroySurface; |
| 723 | this->eglQuerySurface = egl::QuerySurface; |
| 724 | this->eglBindAPI = egl::BindAPI; |
| 725 | this->eglQueryAPI = egl::QueryAPI; |
| 726 | this->eglWaitClient = egl::WaitClient; |
| 727 | this->eglReleaseThread = egl::ReleaseThread; |
| 728 | this->eglCreatePbufferFromClientBuffer = egl::CreatePbufferFromClientBuffer; |
| 729 | this->eglSurfaceAttrib = egl::SurfaceAttrib; |
| 730 | this->eglBindTexImage = egl::BindTexImage; |
| 731 | this->eglReleaseTexImage = egl::ReleaseTexImage; |
| 732 | this->eglSwapInterval = egl::SwapInterval; |
| 733 | this->eglCreateContext = egl::CreateContext; |
| 734 | this->eglDestroyContext = egl::DestroyContext; |
| 735 | this->eglMakeCurrent = egl::MakeCurrent; |
| 736 | this->eglGetCurrentContext = egl::GetCurrentContext; |
| 737 | this->eglGetCurrentSurface = egl::GetCurrentSurface; |
| 738 | this->eglGetCurrentDisplay = egl::GetCurrentDisplay; |
| 739 | this->eglQueryContext = egl::QueryContext; |
| 740 | this->eglWaitGL = egl::WaitGL; |
| 741 | this->eglWaitNative = egl::WaitNative; |
| 742 | this->eglSwapBuffers = egl::SwapBuffers; |
| 743 | this->eglCopyBuffers = egl::CopyBuffers; |
| 744 | this->eglCreateImageKHR = egl::CreateImageKHR; |
| 745 | this->eglDestroyImageKHR = egl::DestroyImageKHR; |
| 746 | this->eglGetProcAddress = egl::GetProcAddress; |
| 747 | this->eglCreateSyncKHR = egl::CreateSyncKHR; |
| 748 | this->eglDestroySyncKHR = egl::DestroySyncKHR; |
| 749 | this->eglClientWaitSyncKHR = egl::ClientWaitSyncKHR; |
| 750 | this->eglGetSyncAttribKHR = egl::GetSyncAttribKHR; |
| 751 | |
| 752 | this->clientGetCurrentContext = egl::getCurrentContext; |
| 753 | } |
| 754 | |
Alexis Hetu | 2a0def7 | 2018-05-14 08:16:05 -0400 | [diff] [blame] | 755 | extern "C" EGLAPI LibEGLexports *libEGL_swiftshader() |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 756 | { |
| 757 | static LibEGLexports libEGL; |
| 758 | return &libEGL; |
| 759 | } |
| 760 | |
Nicolas Capens | 5e1520f | 2018-07-03 16:13:28 -0400 | [diff] [blame] | 761 | LibGLES_CM libGLES_CM; |
| 762 | LibGLESv2 libGLESv2; |