gfx/angle/src/libEGL/libEGL.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 //
michael@0 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
michael@0 3 // Use of this source code is governed by a BSD-style license that can be
michael@0 4 // found in the LICENSE file.
michael@0 5 //
michael@0 6
michael@0 7 // libEGL.cpp: Implements the exported EGL functions.
michael@0 8
michael@0 9 #include <exception>
michael@0 10
michael@0 11 #include "common/debug.h"
michael@0 12 #include "common/version.h"
michael@0 13 #include "libGLESv2/Context.h"
michael@0 14 #include "libGLESv2/Texture.h"
michael@0 15 #include "libGLESv2/main.h"
michael@0 16 #include "libGLESv2/renderer/SwapChain.h"
michael@0 17
michael@0 18 #include "libEGL/main.h"
michael@0 19 #include "libEGL/Display.h"
michael@0 20 #include "libEGL/Surface.h"
michael@0 21
michael@0 22 bool validateDisplay(egl::Display *display)
michael@0 23 {
michael@0 24 if (display == EGL_NO_DISPLAY)
michael@0 25 {
michael@0 26 return egl::error(EGL_BAD_DISPLAY, false);
michael@0 27 }
michael@0 28
michael@0 29 if (!display->isInitialized())
michael@0 30 {
michael@0 31 return egl::error(EGL_NOT_INITIALIZED, false);
michael@0 32 }
michael@0 33
michael@0 34 return true;
michael@0 35 }
michael@0 36
michael@0 37 bool validateConfig(egl::Display *display, EGLConfig config)
michael@0 38 {
michael@0 39 if (!validateDisplay(display))
michael@0 40 {
michael@0 41 return false;
michael@0 42 }
michael@0 43
michael@0 44 if (!display->isValidConfig(config))
michael@0 45 {
michael@0 46 return egl::error(EGL_BAD_CONFIG, false);
michael@0 47 }
michael@0 48
michael@0 49 return true;
michael@0 50 }
michael@0 51
michael@0 52 bool validateContext(egl::Display *display, gl::Context *context)
michael@0 53 {
michael@0 54 if (!validateDisplay(display))
michael@0 55 {
michael@0 56 return false;
michael@0 57 }
michael@0 58
michael@0 59 if (!display->isValidContext(context))
michael@0 60 {
michael@0 61 return egl::error(EGL_BAD_CONTEXT, false);
michael@0 62 }
michael@0 63
michael@0 64 return true;
michael@0 65 }
michael@0 66
michael@0 67 bool validateSurface(egl::Display *display, egl::Surface *surface)
michael@0 68 {
michael@0 69 if (!validateDisplay(display))
michael@0 70 {
michael@0 71 return false;
michael@0 72 }
michael@0 73
michael@0 74 if (!display->isValidSurface(surface))
michael@0 75 {
michael@0 76 return egl::error(EGL_BAD_SURFACE, false);
michael@0 77 }
michael@0 78
michael@0 79 return true;
michael@0 80 }
michael@0 81
michael@0 82 extern "C"
michael@0 83 {
michael@0 84 EGLint __stdcall eglGetError(void)
michael@0 85 {
michael@0 86 EVENT("()");
michael@0 87
michael@0 88 EGLint error = egl::getCurrentError();
michael@0 89
michael@0 90 if (error != EGL_SUCCESS)
michael@0 91 {
michael@0 92 egl::setCurrentError(EGL_SUCCESS);
michael@0 93 }
michael@0 94
michael@0 95 return error;
michael@0 96 }
michael@0 97
michael@0 98 EGLDisplay __stdcall eglGetDisplay(EGLNativeDisplayType display_id)
michael@0 99 {
michael@0 100 EVENT("(EGLNativeDisplayType display_id = 0x%0.8p)", display_id);
michael@0 101
michael@0 102 try
michael@0 103 {
michael@0 104 return egl::Display::getDisplay(display_id);
michael@0 105 }
michael@0 106 catch(std::bad_alloc&)
michael@0 107 {
michael@0 108 return egl::error(EGL_BAD_ALLOC, EGL_NO_DISPLAY);
michael@0 109 }
michael@0 110 }
michael@0 111
michael@0 112 EGLBoolean __stdcall eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
michael@0 113 {
michael@0 114 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)",
michael@0 115 dpy, major, minor);
michael@0 116
michael@0 117 try
michael@0 118 {
michael@0 119 if (dpy == EGL_NO_DISPLAY)
michael@0 120 {
michael@0 121 return egl::error(EGL_BAD_DISPLAY, EGL_FALSE);
michael@0 122 }
michael@0 123
michael@0 124 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 125
michael@0 126 if (!display->initialize())
michael@0 127 {
michael@0 128 return egl::error(EGL_NOT_INITIALIZED, EGL_FALSE);
michael@0 129 }
michael@0 130
michael@0 131 if (major) *major = 1;
michael@0 132 if (minor) *minor = 4;
michael@0 133
michael@0 134 return egl::success(EGL_TRUE);
michael@0 135 }
michael@0 136 catch(std::bad_alloc&)
michael@0 137 {
michael@0 138 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 139 }
michael@0 140 }
michael@0 141
michael@0 142 EGLBoolean __stdcall eglTerminate(EGLDisplay dpy)
michael@0 143 {
michael@0 144 EVENT("(EGLDisplay dpy = 0x%0.8p)", dpy);
michael@0 145
michael@0 146 try
michael@0 147 {
michael@0 148 if (dpy == EGL_NO_DISPLAY)
michael@0 149 {
michael@0 150 return egl::error(EGL_BAD_DISPLAY, EGL_FALSE);
michael@0 151 }
michael@0 152
michael@0 153 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 154
michael@0 155 display->terminate();
michael@0 156
michael@0 157 return egl::success(EGL_TRUE);
michael@0 158 }
michael@0 159 catch(std::bad_alloc&)
michael@0 160 {
michael@0 161 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 162 }
michael@0 163 }
michael@0 164
michael@0 165 const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name)
michael@0 166 {
michael@0 167 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint name = %d)", dpy, name);
michael@0 168
michael@0 169 try
michael@0 170 {
michael@0 171 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 172
michael@0 173 if (!validateDisplay(display))
michael@0 174 {
michael@0 175 return NULL;
michael@0 176 }
michael@0 177
michael@0 178 switch (name)
michael@0 179 {
michael@0 180 case EGL_CLIENT_APIS:
michael@0 181 return egl::success("OpenGL_ES");
michael@0 182 case EGL_EXTENSIONS:
michael@0 183 return egl::success(display->getExtensionString());
michael@0 184 case EGL_VENDOR:
michael@0 185 return egl::success(display->getVendorString());
michael@0 186 case EGL_VERSION:
michael@0 187 return egl::success("1.4 (ANGLE " VERSION_STRING ")");
michael@0 188 }
michael@0 189
michael@0 190 return egl::error(EGL_BAD_PARAMETER, (const char*)NULL);
michael@0 191 }
michael@0 192 catch(std::bad_alloc&)
michael@0 193 {
michael@0 194 return egl::error(EGL_BAD_ALLOC, (const char*)NULL);
michael@0 195 }
michael@0 196 }
michael@0 197
michael@0 198 EGLBoolean __stdcall eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
michael@0 199 {
michael@0 200 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig *configs = 0x%0.8p, "
michael@0 201 "EGLint config_size = %d, EGLint *num_config = 0x%0.8p)",
michael@0 202 dpy, configs, config_size, num_config);
michael@0 203
michael@0 204 try
michael@0 205 {
michael@0 206 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 207
michael@0 208 if (!validateDisplay(display))
michael@0 209 {
michael@0 210 return EGL_FALSE;
michael@0 211 }
michael@0 212
michael@0 213 if (!num_config)
michael@0 214 {
michael@0 215 return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
michael@0 216 }
michael@0 217
michael@0 218 const EGLint attribList[] = {EGL_NONE};
michael@0 219
michael@0 220 if (!display->getConfigs(configs, attribList, config_size, num_config))
michael@0 221 {
michael@0 222 return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
michael@0 223 }
michael@0 224
michael@0 225 return egl::success(EGL_TRUE);
michael@0 226 }
michael@0 227 catch(std::bad_alloc&)
michael@0 228 {
michael@0 229 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 230 }
michael@0 231 }
michael@0 232
michael@0 233 EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
michael@0 234 {
michael@0 235 EVENT("(EGLDisplay dpy = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p, "
michael@0 236 "EGLConfig *configs = 0x%0.8p, EGLint config_size = %d, EGLint *num_config = 0x%0.8p)",
michael@0 237 dpy, attrib_list, configs, config_size, num_config);
michael@0 238
michael@0 239 try
michael@0 240 {
michael@0 241 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 242
michael@0 243 if (!validateDisplay(display))
michael@0 244 {
michael@0 245 return EGL_FALSE;
michael@0 246 }
michael@0 247
michael@0 248 if (!num_config)
michael@0 249 {
michael@0 250 return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
michael@0 251 }
michael@0 252
michael@0 253 const EGLint attribList[] = {EGL_NONE};
michael@0 254
michael@0 255 if (!attrib_list)
michael@0 256 {
michael@0 257 attrib_list = attribList;
michael@0 258 }
michael@0 259
michael@0 260 display->getConfigs(configs, attrib_list, config_size, num_config);
michael@0 261
michael@0 262 return egl::success(EGL_TRUE);
michael@0 263 }
michael@0 264 catch(std::bad_alloc&)
michael@0 265 {
michael@0 266 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 267 }
michael@0 268 }
michael@0 269
michael@0 270 EGLBoolean __stdcall eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
michael@0 271 {
michael@0 272 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
michael@0 273 dpy, config, attribute, value);
michael@0 274
michael@0 275 try
michael@0 276 {
michael@0 277 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 278
michael@0 279 if (!validateConfig(display, config))
michael@0 280 {
michael@0 281 return EGL_FALSE;
michael@0 282 }
michael@0 283
michael@0 284 if (!display->getConfigAttrib(config, attribute, value))
michael@0 285 {
michael@0 286 return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
michael@0 287 }
michael@0 288
michael@0 289 return egl::success(EGL_TRUE);
michael@0 290 }
michael@0 291 catch(std::bad_alloc&)
michael@0 292 {
michael@0 293 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 294 }
michael@0 295 }
michael@0 296
michael@0 297 EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
michael@0 298 {
michael@0 299 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativeWindowType win = 0x%0.8p, "
michael@0 300 "const EGLint *attrib_list = 0x%0.8p)", dpy, config, win, attrib_list);
michael@0 301
michael@0 302 try
michael@0 303 {
michael@0 304 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 305
michael@0 306 if (!validateConfig(display, config))
michael@0 307 {
michael@0 308 return EGL_NO_SURFACE;
michael@0 309 }
michael@0 310
michael@0 311 HWND window = (HWND)win;
michael@0 312
michael@0 313 if (!IsWindow(window))
michael@0 314 {
michael@0 315 return egl::error(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
michael@0 316 }
michael@0 317
michael@0 318 return display->createWindowSurface(window, config, attrib_list);
michael@0 319 }
michael@0 320 catch(std::bad_alloc&)
michael@0 321 {
michael@0 322 return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
michael@0 323 }
michael@0 324 }
michael@0 325
michael@0 326 EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
michael@0 327 {
michael@0 328 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)",
michael@0 329 dpy, config, attrib_list);
michael@0 330
michael@0 331 try
michael@0 332 {
michael@0 333 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 334
michael@0 335 if (!validateConfig(display, config))
michael@0 336 {
michael@0 337 return EGL_NO_SURFACE;
michael@0 338 }
michael@0 339
michael@0 340 return display->createOffscreenSurface(config, NULL, attrib_list);
michael@0 341 }
michael@0 342 catch(std::bad_alloc&)
michael@0 343 {
michael@0 344 return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
michael@0 345 }
michael@0 346 }
michael@0 347
michael@0 348 EGLSurface __stdcall eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
michael@0 349 {
michael@0 350 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativePixmapType pixmap = 0x%0.8p, "
michael@0 351 "const EGLint *attrib_list = 0x%0.8p)", dpy, config, pixmap, attrib_list);
michael@0 352
michael@0 353 try
michael@0 354 {
michael@0 355 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 356
michael@0 357 if (!validateConfig(display, config))
michael@0 358 {
michael@0 359 return EGL_NO_SURFACE;
michael@0 360 }
michael@0 361
michael@0 362 UNIMPLEMENTED(); // FIXME
michael@0 363
michael@0 364 return egl::success(EGL_NO_SURFACE);
michael@0 365 }
michael@0 366 catch(std::bad_alloc&)
michael@0 367 {
michael@0 368 return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
michael@0 369 }
michael@0 370 }
michael@0 371
michael@0 372 EGLBoolean __stdcall eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
michael@0 373 {
michael@0 374 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface);
michael@0 375
michael@0 376 try
michael@0 377 {
michael@0 378 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 379 egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
michael@0 380
michael@0 381 if (!validateSurface(display, eglSurface))
michael@0 382 {
michael@0 383 return EGL_FALSE;
michael@0 384 }
michael@0 385
michael@0 386 if (surface == EGL_NO_SURFACE)
michael@0 387 {
michael@0 388 return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
michael@0 389 }
michael@0 390
michael@0 391 display->destroySurface((egl::Surface*)surface);
michael@0 392
michael@0 393 return egl::success(EGL_TRUE);
michael@0 394 }
michael@0 395 catch(std::bad_alloc&)
michael@0 396 {
michael@0 397 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 398 }
michael@0 399 }
michael@0 400
michael@0 401 EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
michael@0 402 {
michael@0 403 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
michael@0 404 dpy, surface, attribute, value);
michael@0 405
michael@0 406 try
michael@0 407 {
michael@0 408 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 409 egl::Surface *eglSurface = (egl::Surface*)surface;
michael@0 410
michael@0 411 if (!validateSurface(display, eglSurface))
michael@0 412 {
michael@0 413 return EGL_FALSE;
michael@0 414 }
michael@0 415
michael@0 416 if (surface == EGL_NO_SURFACE)
michael@0 417 {
michael@0 418 return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
michael@0 419 }
michael@0 420
michael@0 421 switch (attribute)
michael@0 422 {
michael@0 423 case EGL_VG_ALPHA_FORMAT:
michael@0 424 UNIMPLEMENTED(); // FIXME
michael@0 425 break;
michael@0 426 case EGL_VG_COLORSPACE:
michael@0 427 UNIMPLEMENTED(); // FIXME
michael@0 428 break;
michael@0 429 case EGL_CONFIG_ID:
michael@0 430 UNIMPLEMENTED(); // FIXME
michael@0 431 break;
michael@0 432 case EGL_HEIGHT:
michael@0 433 *value = eglSurface->getHeight();
michael@0 434 break;
michael@0 435 case EGL_HORIZONTAL_RESOLUTION:
michael@0 436 UNIMPLEMENTED(); // FIXME
michael@0 437 break;
michael@0 438 case EGL_LARGEST_PBUFFER:
michael@0 439 UNIMPLEMENTED(); // FIXME
michael@0 440 break;
michael@0 441 case EGL_MIPMAP_TEXTURE:
michael@0 442 UNIMPLEMENTED(); // FIXME
michael@0 443 break;
michael@0 444 case EGL_MIPMAP_LEVEL:
michael@0 445 UNIMPLEMENTED(); // FIXME
michael@0 446 break;
michael@0 447 case EGL_MULTISAMPLE_RESOLVE:
michael@0 448 UNIMPLEMENTED(); // FIXME
michael@0 449 break;
michael@0 450 case EGL_PIXEL_ASPECT_RATIO:
michael@0 451 UNIMPLEMENTED(); // FIXME
michael@0 452 break;
michael@0 453 case EGL_RENDER_BUFFER:
michael@0 454 UNIMPLEMENTED(); // FIXME
michael@0 455 break;
michael@0 456 case EGL_SWAP_BEHAVIOR:
michael@0 457 UNIMPLEMENTED(); // FIXME
michael@0 458 break;
michael@0 459 case EGL_TEXTURE_FORMAT:
michael@0 460 UNIMPLEMENTED(); // FIXME
michael@0 461 break;
michael@0 462 case EGL_TEXTURE_TARGET:
michael@0 463 UNIMPLEMENTED(); // FIXME
michael@0 464 break;
michael@0 465 case EGL_VERTICAL_RESOLUTION:
michael@0 466 UNIMPLEMENTED(); // FIXME
michael@0 467 break;
michael@0 468 case EGL_WIDTH:
michael@0 469 *value = eglSurface->getWidth();
michael@0 470 break;
michael@0 471 case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
michael@0 472 *value = eglSurface->isPostSubBufferSupported();
michael@0 473 break;
michael@0 474 default:
michael@0 475 return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
michael@0 476 }
michael@0 477
michael@0 478 return egl::success(EGL_TRUE);
michael@0 479 }
michael@0 480 catch(std::bad_alloc&)
michael@0 481 {
michael@0 482 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 483 }
michael@0 484 }
michael@0 485
michael@0 486 EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value)
michael@0 487 {
michael@0 488 TRACE("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, void **value = 0x%0.8p)",
michael@0 489 dpy, surface, attribute, value);
michael@0 490
michael@0 491 try
michael@0 492 {
michael@0 493 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 494 egl::Surface *eglSurface = (egl::Surface*)surface;
michael@0 495
michael@0 496 if (!validateSurface(display, eglSurface))
michael@0 497 {
michael@0 498 return EGL_FALSE;
michael@0 499 }
michael@0 500
michael@0 501 if (surface == EGL_NO_SURFACE)
michael@0 502 {
michael@0 503 return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
michael@0 504 }
michael@0 505
michael@0 506 switch (attribute)
michael@0 507 {
michael@0 508 case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
michael@0 509 {
michael@0 510 rx::SwapChain *swapchain = eglSurface->getSwapChain();
michael@0 511 *value = (void*) (swapchain ? swapchain->getShareHandle() : NULL);
michael@0 512 }
michael@0 513 break;
michael@0 514 default:
michael@0 515 return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
michael@0 516 }
michael@0 517
michael@0 518 return egl::success(EGL_TRUE);
michael@0 519 }
michael@0 520 catch(std::bad_alloc&)
michael@0 521 {
michael@0 522 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 523 }
michael@0 524 }
michael@0 525
michael@0 526 EGLBoolean __stdcall eglBindAPI(EGLenum api)
michael@0 527 {
michael@0 528 EVENT("(EGLenum api = 0x%X)", api);
michael@0 529
michael@0 530 try
michael@0 531 {
michael@0 532 switch (api)
michael@0 533 {
michael@0 534 case EGL_OPENGL_API:
michael@0 535 case EGL_OPENVG_API:
michael@0 536 return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); // Not supported by this implementation
michael@0 537 case EGL_OPENGL_ES_API:
michael@0 538 break;
michael@0 539 default:
michael@0 540 return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
michael@0 541 }
michael@0 542
michael@0 543 egl::setCurrentAPI(api);
michael@0 544
michael@0 545 return egl::success(EGL_TRUE);
michael@0 546 }
michael@0 547 catch(std::bad_alloc&)
michael@0 548 {
michael@0 549 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 550 }
michael@0 551 }
michael@0 552
michael@0 553 EGLenum __stdcall eglQueryAPI(void)
michael@0 554 {
michael@0 555 EVENT("()");
michael@0 556
michael@0 557 try
michael@0 558 {
michael@0 559 EGLenum API = egl::getCurrentAPI();
michael@0 560
michael@0 561 return egl::success(API);
michael@0 562 }
michael@0 563 catch(std::bad_alloc&)
michael@0 564 {
michael@0 565 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 566 }
michael@0 567 }
michael@0 568
michael@0 569 EGLBoolean __stdcall eglWaitClient(void)
michael@0 570 {
michael@0 571 EVENT("()");
michael@0 572
michael@0 573 try
michael@0 574 {
michael@0 575 UNIMPLEMENTED(); // FIXME
michael@0 576
michael@0 577 return egl::success(0);
michael@0 578 }
michael@0 579 catch(std::bad_alloc&)
michael@0 580 {
michael@0 581 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 582 }
michael@0 583 }
michael@0 584
michael@0 585 EGLBoolean __stdcall eglReleaseThread(void)
michael@0 586 {
michael@0 587 EVENT("()");
michael@0 588
michael@0 589 try
michael@0 590 {
michael@0 591 eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE);
michael@0 592
michael@0 593 return egl::success(EGL_TRUE);
michael@0 594 }
michael@0 595 catch(std::bad_alloc&)
michael@0 596 {
michael@0 597 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 598 }
michael@0 599 }
michael@0 600
michael@0 601 EGLSurface __stdcall eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
michael@0 602 {
michael@0 603 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLenum buftype = 0x%X, EGLClientBuffer buffer = 0x%0.8p, "
michael@0 604 "EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)",
michael@0 605 dpy, buftype, buffer, config, attrib_list);
michael@0 606
michael@0 607 try
michael@0 608 {
michael@0 609 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 610
michael@0 611 if (!validateConfig(display, config))
michael@0 612 {
michael@0 613 return EGL_NO_SURFACE;
michael@0 614 }
michael@0 615
michael@0 616 if (buftype != EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE || !buffer)
michael@0 617 {
michael@0 618 return egl::error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
michael@0 619 }
michael@0 620
michael@0 621 return display->createOffscreenSurface(config, (HANDLE)buffer, attrib_list);
michael@0 622 }
michael@0 623 catch(std::bad_alloc&)
michael@0 624 {
michael@0 625 return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
michael@0 626 }
michael@0 627 }
michael@0 628
michael@0 629 EGLBoolean __stdcall eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
michael@0 630 {
michael@0 631 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint value = %d)",
michael@0 632 dpy, surface, attribute, value);
michael@0 633
michael@0 634 try
michael@0 635 {
michael@0 636 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 637 egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
michael@0 638
michael@0 639 if (!validateSurface(display, eglSurface))
michael@0 640 {
michael@0 641 return EGL_FALSE;
michael@0 642 }
michael@0 643
michael@0 644 UNIMPLEMENTED(); // FIXME
michael@0 645
michael@0 646 return egl::success(EGL_TRUE);
michael@0 647 }
michael@0 648 catch(std::bad_alloc&)
michael@0 649 {
michael@0 650 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 651 }
michael@0 652 }
michael@0 653
michael@0 654 EGLBoolean __stdcall eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
michael@0 655 {
michael@0 656 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer);
michael@0 657
michael@0 658 try
michael@0 659 {
michael@0 660 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 661 egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
michael@0 662
michael@0 663 if (!validateSurface(display, eglSurface))
michael@0 664 {
michael@0 665 return EGL_FALSE;
michael@0 666 }
michael@0 667
michael@0 668 if (buffer != EGL_BACK_BUFFER)
michael@0 669 {
michael@0 670 return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
michael@0 671 }
michael@0 672
michael@0 673 if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle())
michael@0 674 {
michael@0 675 return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
michael@0 676 }
michael@0 677
michael@0 678 if (eglSurface->getBoundTexture())
michael@0 679 {
michael@0 680 return egl::error(EGL_BAD_ACCESS, EGL_FALSE);
michael@0 681 }
michael@0 682
michael@0 683 if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
michael@0 684 {
michael@0 685 return egl::error(EGL_BAD_MATCH, EGL_FALSE);
michael@0 686 }
michael@0 687
michael@0 688 if (!glBindTexImage(eglSurface))
michael@0 689 {
michael@0 690 return egl::error(EGL_BAD_MATCH, EGL_FALSE);
michael@0 691 }
michael@0 692
michael@0 693 return egl::success(EGL_TRUE);
michael@0 694 }
michael@0 695 catch(std::bad_alloc&)
michael@0 696 {
michael@0 697 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 698 }
michael@0 699 }
michael@0 700
michael@0 701 EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
michael@0 702 {
michael@0 703 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer);
michael@0 704
michael@0 705 try
michael@0 706 {
michael@0 707 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 708 egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
michael@0 709
michael@0 710 if (!validateSurface(display, eglSurface))
michael@0 711 {
michael@0 712 return EGL_FALSE;
michael@0 713 }
michael@0 714
michael@0 715 if (buffer != EGL_BACK_BUFFER)
michael@0 716 {
michael@0 717 return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
michael@0 718 }
michael@0 719
michael@0 720 if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle())
michael@0 721 {
michael@0 722 return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
michael@0 723 }
michael@0 724
michael@0 725 if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
michael@0 726 {
michael@0 727 return egl::error(EGL_BAD_MATCH, EGL_FALSE);
michael@0 728 }
michael@0 729
michael@0 730 gl::Texture2D *texture = eglSurface->getBoundTexture();
michael@0 731
michael@0 732 if (texture)
michael@0 733 {
michael@0 734 texture->releaseTexImage();
michael@0 735 }
michael@0 736
michael@0 737 return egl::success(EGL_TRUE);
michael@0 738 }
michael@0 739 catch(std::bad_alloc&)
michael@0 740 {
michael@0 741 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 742 }
michael@0 743 }
michael@0 744
michael@0 745 EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval)
michael@0 746 {
michael@0 747 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint interval = %d)", dpy, interval);
michael@0 748
michael@0 749 try
michael@0 750 {
michael@0 751 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 752
michael@0 753 if (!validateDisplay(display))
michael@0 754 {
michael@0 755 return EGL_FALSE;
michael@0 756 }
michael@0 757
michael@0 758 egl::Surface *draw_surface = static_cast<egl::Surface*>(egl::getCurrentDrawSurface());
michael@0 759
michael@0 760 if (draw_surface == NULL)
michael@0 761 {
michael@0 762 return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
michael@0 763 }
michael@0 764
michael@0 765 draw_surface->setSwapInterval(interval);
michael@0 766
michael@0 767 return egl::success(EGL_TRUE);
michael@0 768 }
michael@0 769 catch(std::bad_alloc&)
michael@0 770 {
michael@0 771 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 772 }
michael@0 773 }
michael@0 774
michael@0 775 EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
michael@0 776 {
michael@0 777 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLContext share_context = 0x%0.8p, "
michael@0 778 "const EGLint *attrib_list = 0x%0.8p)", dpy, config, share_context, attrib_list);
michael@0 779
michael@0 780 try
michael@0 781 {
michael@0 782 // Get the requested client version (default is 1) and check it is two.
michael@0 783 EGLint client_version = 1;
michael@0 784 bool reset_notification = false;
michael@0 785 bool robust_access = false;
michael@0 786
michael@0 787 if (attrib_list)
michael@0 788 {
michael@0 789 for (const EGLint* attribute = attrib_list; attribute[0] != EGL_NONE; attribute += 2)
michael@0 790 {
michael@0 791 switch (attribute[0])
michael@0 792 {
michael@0 793 case EGL_CONTEXT_CLIENT_VERSION:
michael@0 794 client_version = attribute[1];
michael@0 795 break;
michael@0 796 case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
michael@0 797 if (attribute[1] == EGL_TRUE)
michael@0 798 {
michael@0 799 return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT); // Unimplemented
michael@0 800 // robust_access = true;
michael@0 801 }
michael@0 802 else if (attribute[1] != EGL_FALSE)
michael@0 803 return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
michael@0 804 break;
michael@0 805 case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
michael@0 806 if (attribute[1] == EGL_LOSE_CONTEXT_ON_RESET_EXT)
michael@0 807 reset_notification = true;
michael@0 808 else if (attribute[1] != EGL_NO_RESET_NOTIFICATION_EXT)
michael@0 809 return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
michael@0 810 break;
michael@0 811 default:
michael@0 812 return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
michael@0 813 }
michael@0 814 }
michael@0 815 }
michael@0 816
michael@0 817 if (client_version != 2)
michael@0 818 {
michael@0 819 return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);
michael@0 820 }
michael@0 821
michael@0 822 if (share_context && static_cast<gl::Context*>(share_context)->isResetNotificationEnabled() != reset_notification)
michael@0 823 {
michael@0 824 return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
michael@0 825 }
michael@0 826
michael@0 827 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 828
michael@0 829 if (!validateConfig(display, config))
michael@0 830 {
michael@0 831 return EGL_NO_CONTEXT;
michael@0 832 }
michael@0 833
michael@0 834 EGLContext context = display->createContext(config, static_cast<gl::Context*>(share_context), reset_notification, robust_access);
michael@0 835
michael@0 836 if (context)
michael@0 837 return egl::success(context);
michael@0 838 else
michael@0 839 return egl::error(EGL_CONTEXT_LOST, EGL_NO_CONTEXT);
michael@0 840 }
michael@0 841 catch(std::bad_alloc&)
michael@0 842 {
michael@0 843 return egl::error(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
michael@0 844 }
michael@0 845 }
michael@0 846
michael@0 847 EGLBoolean __stdcall eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
michael@0 848 {
michael@0 849 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p)", dpy, ctx);
michael@0 850
michael@0 851 try
michael@0 852 {
michael@0 853 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 854 gl::Context *context = static_cast<gl::Context*>(ctx);
michael@0 855
michael@0 856 if (!validateContext(display, context))
michael@0 857 {
michael@0 858 return EGL_FALSE;
michael@0 859 }
michael@0 860
michael@0 861 if (ctx == EGL_NO_CONTEXT)
michael@0 862 {
michael@0 863 return egl::error(EGL_BAD_CONTEXT, EGL_FALSE);
michael@0 864 }
michael@0 865
michael@0 866 display->destroyContext(context);
michael@0 867
michael@0 868 return egl::success(EGL_TRUE);
michael@0 869 }
michael@0 870 catch(std::bad_alloc&)
michael@0 871 {
michael@0 872 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 873 }
michael@0 874 }
michael@0 875
michael@0 876 EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
michael@0 877 {
michael@0 878 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface draw = 0x%0.8p, EGLSurface read = 0x%0.8p, EGLContext ctx = 0x%0.8p)",
michael@0 879 dpy, draw, read, ctx);
michael@0 880
michael@0 881 try
michael@0 882 {
michael@0 883 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 884 gl::Context *context = static_cast<gl::Context*>(ctx);
michael@0 885
michael@0 886 if (ctx != EGL_NO_CONTEXT && !validateContext(display, context))
michael@0 887 {
michael@0 888 return EGL_FALSE;
michael@0 889 }
michael@0 890
michael@0 891 if (dpy != EGL_NO_DISPLAY)
michael@0 892 {
michael@0 893 rx::Renderer *renderer = display->getRenderer();
michael@0 894 if (renderer->testDeviceLost(true))
michael@0 895 {
michael@0 896 return EGL_FALSE;
michael@0 897 }
michael@0 898
michael@0 899 if (renderer->isDeviceLost())
michael@0 900 {
michael@0 901 return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
michael@0 902 }
michael@0 903 }
michael@0 904
michael@0 905 if ((draw != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(draw))) ||
michael@0 906 (read != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(read))))
michael@0 907 {
michael@0 908 return EGL_FALSE;
michael@0 909 }
michael@0 910
michael@0 911 if (draw != read)
michael@0 912 {
michael@0 913 UNIMPLEMENTED(); // FIXME
michael@0 914 }
michael@0 915
michael@0 916 egl::setCurrentDisplay(dpy);
michael@0 917 egl::setCurrentDrawSurface(draw);
michael@0 918 egl::setCurrentReadSurface(read);
michael@0 919
michael@0 920 glMakeCurrent(context, display, static_cast<egl::Surface*>(draw));
michael@0 921
michael@0 922 return egl::success(EGL_TRUE);
michael@0 923 }
michael@0 924 catch(std::bad_alloc&)
michael@0 925 {
michael@0 926 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 927 }
michael@0 928 }
michael@0 929
michael@0 930 EGLContext __stdcall eglGetCurrentContext(void)
michael@0 931 {
michael@0 932 EVENT("()");
michael@0 933
michael@0 934 try
michael@0 935 {
michael@0 936 EGLContext context = glGetCurrentContext();
michael@0 937
michael@0 938 return egl::success(context);
michael@0 939 }
michael@0 940 catch(std::bad_alloc&)
michael@0 941 {
michael@0 942 return egl::error(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
michael@0 943 }
michael@0 944 }
michael@0 945
michael@0 946 EGLSurface __stdcall eglGetCurrentSurface(EGLint readdraw)
michael@0 947 {
michael@0 948 EVENT("(EGLint readdraw = %d)", readdraw);
michael@0 949
michael@0 950 try
michael@0 951 {
michael@0 952 if (readdraw == EGL_READ)
michael@0 953 {
michael@0 954 EGLSurface read = egl::getCurrentReadSurface();
michael@0 955 return egl::success(read);
michael@0 956 }
michael@0 957 else if (readdraw == EGL_DRAW)
michael@0 958 {
michael@0 959 EGLSurface draw = egl::getCurrentDrawSurface();
michael@0 960 return egl::success(draw);
michael@0 961 }
michael@0 962 else
michael@0 963 {
michael@0 964 return egl::error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
michael@0 965 }
michael@0 966 }
michael@0 967 catch(std::bad_alloc&)
michael@0 968 {
michael@0 969 return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
michael@0 970 }
michael@0 971 }
michael@0 972
michael@0 973 EGLDisplay __stdcall eglGetCurrentDisplay(void)
michael@0 974 {
michael@0 975 EVENT("()");
michael@0 976
michael@0 977 try
michael@0 978 {
michael@0 979 EGLDisplay dpy = egl::getCurrentDisplay();
michael@0 980
michael@0 981 return egl::success(dpy);
michael@0 982 }
michael@0 983 catch(std::bad_alloc&)
michael@0 984 {
michael@0 985 return egl::error(EGL_BAD_ALLOC, EGL_NO_DISPLAY);
michael@0 986 }
michael@0 987 }
michael@0 988
michael@0 989 EGLBoolean __stdcall eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
michael@0 990 {
michael@0 991 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
michael@0 992 dpy, ctx, attribute, value);
michael@0 993
michael@0 994 try
michael@0 995 {
michael@0 996 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 997 gl::Context *context = static_cast<gl::Context*>(ctx);
michael@0 998
michael@0 999 if (!validateContext(display, context))
michael@0 1000 {
michael@0 1001 return EGL_FALSE;
michael@0 1002 }
michael@0 1003
michael@0 1004 UNIMPLEMENTED(); // FIXME
michael@0 1005
michael@0 1006 return egl::success(0);
michael@0 1007 }
michael@0 1008 catch(std::bad_alloc&)
michael@0 1009 {
michael@0 1010 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 1011 }
michael@0 1012 }
michael@0 1013
michael@0 1014 EGLBoolean __stdcall eglWaitGL(void)
michael@0 1015 {
michael@0 1016 EVENT("()");
michael@0 1017
michael@0 1018 try
michael@0 1019 {
michael@0 1020 UNIMPLEMENTED(); // FIXME
michael@0 1021
michael@0 1022 return egl::success(0);
michael@0 1023 }
michael@0 1024 catch(std::bad_alloc&)
michael@0 1025 {
michael@0 1026 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 1027 }
michael@0 1028 }
michael@0 1029
michael@0 1030 EGLBoolean __stdcall eglWaitNative(EGLint engine)
michael@0 1031 {
michael@0 1032 EVENT("(EGLint engine = %d)", engine);
michael@0 1033
michael@0 1034 try
michael@0 1035 {
michael@0 1036 UNIMPLEMENTED(); // FIXME
michael@0 1037
michael@0 1038 return egl::success(0);
michael@0 1039 }
michael@0 1040 catch(std::bad_alloc&)
michael@0 1041 {
michael@0 1042 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 1043 }
michael@0 1044 }
michael@0 1045
michael@0 1046 EGLBoolean __stdcall eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
michael@0 1047 {
michael@0 1048 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface);
michael@0 1049
michael@0 1050 try
michael@0 1051 {
michael@0 1052 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 1053 egl::Surface *eglSurface = (egl::Surface*)surface;
michael@0 1054
michael@0 1055 if (!validateSurface(display, eglSurface))
michael@0 1056 {
michael@0 1057 return EGL_FALSE;
michael@0 1058 }
michael@0 1059
michael@0 1060 if (display->getRenderer()->isDeviceLost())
michael@0 1061 {
michael@0 1062 return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
michael@0 1063 }
michael@0 1064
michael@0 1065 if (surface == EGL_NO_SURFACE)
michael@0 1066 {
michael@0 1067 return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
michael@0 1068 }
michael@0 1069
michael@0 1070 if (eglSurface->swap())
michael@0 1071 {
michael@0 1072 return egl::success(EGL_TRUE);
michael@0 1073 }
michael@0 1074 }
michael@0 1075 catch(std::bad_alloc&)
michael@0 1076 {
michael@0 1077 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 1078 }
michael@0 1079
michael@0 1080 return EGL_FALSE;
michael@0 1081 }
michael@0 1082
michael@0 1083 EGLBoolean __stdcall eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
michael@0 1084 {
michael@0 1085 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLNativePixmapType target = 0x%0.8p)", dpy, surface, target);
michael@0 1086
michael@0 1087 try
michael@0 1088 {
michael@0 1089 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 1090 egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
michael@0 1091
michael@0 1092 if (!validateSurface(display, eglSurface))
michael@0 1093 {
michael@0 1094 return EGL_FALSE;
michael@0 1095 }
michael@0 1096
michael@0 1097 if (display->getRenderer()->isDeviceLost())
michael@0 1098 {
michael@0 1099 return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
michael@0 1100 }
michael@0 1101
michael@0 1102 UNIMPLEMENTED(); // FIXME
michael@0 1103
michael@0 1104 return egl::success(0);
michael@0 1105 }
michael@0 1106 catch(std::bad_alloc&)
michael@0 1107 {
michael@0 1108 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 1109 }
michael@0 1110 }
michael@0 1111
michael@0 1112 EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height)
michael@0 1113 {
michael@0 1114 EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint x = %d, EGLint y = %d, EGLint width = %d, EGLint height = %d)", dpy, surface, x, y, width, height);
michael@0 1115
michael@0 1116 try
michael@0 1117 {
michael@0 1118 if (x < 0 || y < 0 || width < 0 || height < 0)
michael@0 1119 {
michael@0 1120 return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
michael@0 1121 }
michael@0 1122
michael@0 1123 egl::Display *display = static_cast<egl::Display*>(dpy);
michael@0 1124 egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
michael@0 1125
michael@0 1126 if (!validateSurface(display, eglSurface))
michael@0 1127 {
michael@0 1128 return EGL_FALSE;
michael@0 1129 }
michael@0 1130
michael@0 1131 if (display->getRenderer()->isDeviceLost())
michael@0 1132 {
michael@0 1133 return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
michael@0 1134 }
michael@0 1135
michael@0 1136 if (surface == EGL_NO_SURFACE)
michael@0 1137 {
michael@0 1138 return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
michael@0 1139 }
michael@0 1140
michael@0 1141 if (eglSurface->postSubBuffer(x, y, width, height))
michael@0 1142 {
michael@0 1143 return egl::success(EGL_TRUE);
michael@0 1144 }
michael@0 1145 }
michael@0 1146 catch(std::bad_alloc&)
michael@0 1147 {
michael@0 1148 return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
michael@0 1149 }
michael@0 1150
michael@0 1151 return EGL_FALSE;
michael@0 1152 }
michael@0 1153
michael@0 1154 __eglMustCastToProperFunctionPointerType __stdcall eglGetProcAddress(const char *procname)
michael@0 1155 {
michael@0 1156 EVENT("(const char *procname = \"%s\")", procname);
michael@0 1157
michael@0 1158 try
michael@0 1159 {
michael@0 1160 struct Extension
michael@0 1161 {
michael@0 1162 const char *name;
michael@0 1163 __eglMustCastToProperFunctionPointerType address;
michael@0 1164 };
michael@0 1165
michael@0 1166 static const Extension eglExtensions[] =
michael@0 1167 {
michael@0 1168 {"eglQuerySurfacePointerANGLE", (__eglMustCastToProperFunctionPointerType)eglQuerySurfacePointerANGLE},
michael@0 1169 {"eglPostSubBufferNV", (__eglMustCastToProperFunctionPointerType)eglPostSubBufferNV},
michael@0 1170 {"", NULL},
michael@0 1171 };
michael@0 1172
michael@0 1173 for (unsigned int ext = 0; ext < ArraySize(eglExtensions); ext++)
michael@0 1174 {
michael@0 1175 if (strcmp(procname, eglExtensions[ext].name) == 0)
michael@0 1176 {
michael@0 1177 return (__eglMustCastToProperFunctionPointerType)eglExtensions[ext].address;
michael@0 1178 }
michael@0 1179 }
michael@0 1180
michael@0 1181 return glGetProcAddress(procname);
michael@0 1182 }
michael@0 1183 catch(std::bad_alloc&)
michael@0 1184 {
michael@0 1185 return egl::error(EGL_BAD_ALLOC, (__eglMustCastToProperFunctionPointerType)NULL);
michael@0 1186 }
michael@0 1187 }
michael@0 1188 }

mercurial