Hash :
a390ebd9
Author :
Date :
2018-10-18T13:04:40
Add compiler printf attribute to relevant functions
Relands 27a472c60 with reinterpret_cast changed to C-style cast to
support types that are pointers on some platforms and integers on
others.
This commit includes fixes to undefined behavior caught by this
attribute. The following changes have been made:
- 0x%0.8p is changed to %016 PRIxPTR. Both 0 and . have undefined
behavior with p. Additionally, %p already prints 0x with both gcc and
clang. This results in a small output change:
void *x = (void *)0x1234;
void *y = (void *)0x1234567890abcdef;
printf("|%0.8p|\n", x);
printf("|%0.8p|\n", y);
printf("|%016" PRIxPTR "|\n", (uintptr_t)x);
printf("|%016" PRIxPTR "|\n", (uintptr_t)y);
prints:
|0x00001234|
|0x1234567890abcdef|
|0x0000000000001234|
|0x1234567890abcdef|
- %d used for GLintptr, GLsizeiptr, EGLTime and EGLnsecsANDROID is
changed to %llu and the relevant argument is cast to unsigned long
long. This is due to these types being typedefs to unknown types (on
Linux for example, these are unsigned long, and my guess would be
unsigned long long on Windows where long is 32 bits).
- %llu is used for GLuint64, which could be unsigned long (as is on
Linux). Those arguments are cast to unsigned long long.
- %p is used for some EGLNative types, but those types may not be a
pointer. Those arguments are cast to uintptr_t and printed as above.
Bug: angleproject:2928
Change-Id: Idf9f705c3d00f69e41e7603453016276a2e13a64
Reviewed-on: https://chromium-review.googlesource.com/c/1300913
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164
//
// Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// entry_points_ext.cpp : Implements the EGL extension entry points.
#include "libGLESv2/entry_points_egl_ext.h"
#include "libGLESv2/global_state.h"
#include "libANGLE/Context.h"
#include "libANGLE/Device.h"
#include "libANGLE/Display.h"
#include "libANGLE/Stream.h"
#include "libANGLE/Surface.h"
#include "libANGLE/Thread.h"
#include "libANGLE/validationEGL.h"
#include "common/debug.h"
namespace egl
{
// EGL_ANGLE_query_surface_pointer
EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy,
EGLSurface surface,
EGLint attribute,
void **value)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLSurface surface = 0x%016" PRIxPTR
", EGLint attribute = %d, void "
"**value = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, (uintptr_t)surface, attribute, (uintptr_t)value);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Surface *eglSurface = static_cast<Surface *>(surface);
Error error = ValidateSurface(display, eglSurface);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglQuerySurfacePointerANGLE",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
if (!display->getExtensions().querySurfacePointer)
{
thread->setSuccess();
return EGL_FALSE;
}
if (surface == EGL_NO_SURFACE)
{
thread->setError(EglBadSurface(), GetDebug(), "eglQuerySurfacePointerANGLE",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
// validate the attribute parameter
switch (attribute)
{
case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
if (!display->getExtensions().surfaceD3DTexture2DShareHandle)
{
thread->setError(EglBadAttribute(), GetDebug(), "eglQuerySurfacePointerANGLE",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
break;
case EGL_DXGI_KEYED_MUTEX_ANGLE:
if (!display->getExtensions().keyedMutex)
{
thread->setError(EglBadAttribute(), GetDebug(), "eglQuerySurfacePointerANGLE",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
break;
default:
thread->setError(EglBadAttribute(), GetDebug(), "eglQuerySurfacePointerANGLE",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
error = eglSurface->querySurfacePointerANGLE(attribute, value);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglQuerySurfacePointerANGLE",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
// EGL_NV_post_sub_buffer
EGLBoolean EGLAPIENTRY
PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLSurface surface = 0x%016" PRIxPTR
", EGLint x = %d, EGLint y = %d, "
"EGLint width = %d, EGLint height = %d)",
(uintptr_t)dpy, (uintptr_t)surface, x, y, width, height);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Surface *eglSurface = static_cast<Surface *>(surface);
if (x < 0 || y < 0 || width < 0 || height < 0)
{
thread->setError(EglBadParameter(), GetDebug(), "eglPostSubBufferNV",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
Error error = ValidateSurface(display, eglSurface);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglPostSubBufferNV",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
if (display->testDeviceLost())
{
thread->setError(EglContextLost(), GetDebug(), "eglPostSubBufferNV",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
if (surface == EGL_NO_SURFACE)
{
thread->setError(EglBadSurface(), GetDebug(), "eglPostSubBufferNV",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
if (!display->getExtensions().postSubBuffer)
{
// Spec is not clear about how this should be handled.
thread->setSuccess();
return EGL_TRUE;
}
// TODO(jmadill): Validate Surface is bound to the thread.
error = eglSurface->postSubBuffer(thread->getContext(), x, y, width, height);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglPostSubBufferNV",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
// EGL_EXT_platform_base
EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform,
void *native_display,
const EGLint *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLenum platform = %d, void* native_display = 0x%016" PRIxPTR
", const EGLint* attrib_list = "
"0x%016" PRIxPTR ")",
platform, (uintptr_t)native_display, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
Error err = ValidateGetPlatformDisplayEXT(platform, native_display, attrib_list);
thread->setError(err, GetDebug(), "eglGetPlatformDisplayEXT", GetThreadIfValid(thread));
if (err.isError())
{
return EGL_NO_DISPLAY;
}
const auto &attribMap = AttributeMap::CreateFromIntArray(attrib_list);
if (platform == EGL_PLATFORM_ANGLE_ANGLE)
{
return Display::GetDisplayFromNativeDisplay(
gl::bitCast<EGLNativeDisplayType>(native_display), attribMap);
}
else if (platform == EGL_PLATFORM_DEVICE_EXT)
{
Device *eglDevice = static_cast<Device *>(native_display);
return Display::GetDisplayFromDevice(eglDevice, attribMap);
}
else
{
UNREACHABLE();
return EGL_NO_DISPLAY;
}
}
EGLSurface EGLAPIENTRY CreatePlatformWindowSurfaceEXT(EGLDisplay dpy,
EGLConfig config,
void *native_window,
const EGLint *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLConfig config = 0x%016" PRIxPTR
", void *native_window = 0x%016" PRIxPTR
", "
"const EGLint *attrib_list = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, (uintptr_t)config, (uintptr_t)native_window, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Config *configuration = static_cast<Config *>(config);
AttributeMap attributes = AttributeMap::CreateFromIntArray(attrib_list);
ANGLE_EGL_TRY_RETURN(
thread,
ValidateCreatePlatformWindowSurfaceEXT(display, configuration, native_window, attributes),
"eglCreatePlatformWindowSurfaceEXT", GetDisplayIfValid(display), EGL_NO_SURFACE);
thread->setError(EglBadDisplay() << "CreatePlatformWindowSurfaceEXT unimplemented.", GetDebug(),
"eglCreatePlatformWindowSurfaceEXT", GetDisplayIfValid(display));
return EGL_NO_SURFACE;
}
EGLSurface EGLAPIENTRY CreatePlatformPixmapSurfaceEXT(EGLDisplay dpy,
EGLConfig config,
void *native_pixmap,
const EGLint *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLConfig config = 0x%016" PRIxPTR
", void *native_pixmap = 0x%016" PRIxPTR
", "
"const EGLint *attrib_list = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, (uintptr_t)config, (uintptr_t)native_pixmap, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Config *configuration = static_cast<Config *>(config);
AttributeMap attributes = AttributeMap::CreateFromIntArray(attrib_list);
ANGLE_EGL_TRY_RETURN(
thread,
ValidateCreatePlatformPixmapSurfaceEXT(display, configuration, native_pixmap, attributes),
"eglCreatePlatformPixmapSurfaceEXT", GetDisplayIfValid(display), EGL_NO_SURFACE);
thread->setError(EglBadDisplay() << "CreatePlatformPixmapSurfaceEXT unimplemented.", GetDebug(),
"eglCreatePlatformPixmapSurfaceEXT", GetDisplayIfValid(display));
return EGL_NO_SURFACE;
}
// EGL_EXT_device_query
EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribute, EGLAttrib *value)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDeviceEXT device = 0x%016" PRIxPTR
", EGLint attribute = %d, EGLAttrib *value = 0x%016" PRIxPTR ")",
(uintptr_t)device, attribute, (uintptr_t)value);
Thread *thread = GetCurrentThread();
Device *dev = static_cast<Device *>(device);
Error error = ValidateDevice(dev);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglQueryDeviceAttribEXT", GetDeviceIfValid(dev));
return EGL_FALSE;
}
// If the device was created by (and is owned by) a display, and that display doesn't support
// device querying, then this call should fail
Display *owningDisplay = dev->getOwningDisplay();
if (owningDisplay != nullptr && !owningDisplay->getExtensions().deviceQuery)
{
thread->setError(EglBadAccess() << "Device wasn't created using eglCreateDeviceANGLE, "
"and the Display that created it doesn't support "
"device querying",
GetDebug(), "eglQueryDeviceAttribEXT", GetDeviceIfValid(dev));
return EGL_FALSE;
}
// validate the attribute parameter
switch (attribute)
{
case EGL_D3D11_DEVICE_ANGLE:
case EGL_D3D9_DEVICE_ANGLE:
if (!dev->getExtensions().deviceD3D || dev->getType() != attribute)
{
thread->setError(EglBadAttribute(), GetDebug(), "eglQueryDeviceAttribEXT",
GetDeviceIfValid(dev));
return EGL_FALSE;
}
error = dev->getDevice(value);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglQueryDeviceAttribEXT",
GetDeviceIfValid(dev));
return EGL_FALSE;
}
break;
default:
thread->setError(EglBadAttribute(), GetDebug(), "eglQueryDeviceAttribEXT",
GetDeviceIfValid(dev));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
// EGL_EXT_device_query
const char *EGLAPIENTRY QueryDeviceStringEXT(EGLDeviceEXT device, EGLint name)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDeviceEXT device = 0x%016" PRIxPTR ", EGLint name = %d)", (uintptr_t)device, name);
Thread *thread = GetCurrentThread();
Device *dev = static_cast<Device *>(device);
Error error = ValidateDevice(dev);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglQueryDeviceStringEXT", GetDeviceIfValid(dev));
return EGL_FALSE;
}
const char *result;
switch (name)
{
case EGL_EXTENSIONS:
result = dev->getExtensionString().c_str();
break;
default:
thread->setError(EglBadDevice(), GetDebug(), "eglQueryDeviceStringEXT",
GetDeviceIfValid(dev));
return nullptr;
}
thread->setSuccess();
return result;
}
// EGL_EXT_device_query
EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, EGLAttrib *value)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR
", EGLint attribute = %d, EGLAttrib *value = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, attribute, (uintptr_t)value);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Error error = ValidateDisplay(display);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglQueryDisplayAttribEXT", GetDisplayIfValid(display));
return EGL_FALSE;
}
if (!display->getExtensions().deviceQuery)
{
thread->setError(EglBadAccess(), GetDebug(), "eglQueryDisplayAttribEXT",
GetDisplayIfValid(display));
return EGL_FALSE;
}
// validate the attribute parameter
switch (attribute)
{
case EGL_DEVICE_EXT:
*value = reinterpret_cast<EGLAttrib>(display->getDevice());
break;
default:
thread->setError(EglBadAttribute(), GetDebug(), "eglQueryDisplayAttribEXT",
GetDisplayIfValid(display));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy,
EGLContext ctx,
EGLenum target,
EGLClientBuffer buffer,
const EGLint *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLContext ctx = 0x%016" PRIxPTR
", EGLenum target = 0x%X, "
"EGLClientBuffer buffer = 0x%016" PRIxPTR
", const EGLAttrib *attrib_list = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, (uintptr_t)ctx, target, (uintptr_t)buffer, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
gl::Context *context = static_cast<gl::Context *>(ctx);
AttributeMap attributes = AttributeMap::CreateFromIntArray(attrib_list);
Error error = ValidateCreateImageKHR(display, context, target, buffer, attributes);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglCreateImageKHR", GetDisplayIfValid(display));
return EGL_NO_IMAGE;
}
Image *image = nullptr;
error = display->createImage(context, target, buffer, attributes, &image);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglCreateImageKHR", GetDisplayIfValid(display));
return EGL_NO_IMAGE;
}
thread->setSuccess();
return static_cast<EGLImage>(image);
}
ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLImage image = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, (uintptr_t)image);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Image *img = static_cast<Image *>(image);
Error error = ValidateDestroyImageKHR(display, img);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglDestroyImageKHR", GetImageIfValid(display, img));
return EGL_FALSE;
}
display->destroyImage(img);
thread->setSuccess();
return EGL_TRUE;
}
ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type,
void *native_device,
const EGLAttrib *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLint device_type = %d, void* native_device = 0x%016" PRIxPTR
", const EGLAttrib* attrib_list = "
"0x%016" PRIxPTR ")",
device_type, (uintptr_t)native_device, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
Error error = ValidateCreateDeviceANGLE(device_type, native_device, attrib_list);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglCreateDeviceANGLE", GetThreadIfValid(thread));
return EGL_NO_DEVICE_EXT;
}
Device *device = nullptr;
error = Device::CreateDevice(device_type, native_device, &device);
if (error.isError())
{
ASSERT(device == nullptr);
thread->setError(error, GetDebug(), "eglCreateDeviceANGLE", GetThreadIfValid(thread));
return EGL_NO_DEVICE_EXT;
}
thread->setSuccess();
return device;
}
ANGLE_EXPORT EGLBoolean EGLAPIENTRY ReleaseDeviceANGLE(EGLDeviceEXT device)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDeviceEXT device = 0x%016" PRIxPTR ")", (uintptr_t)device);
Thread *thread = GetCurrentThread();
Device *dev = static_cast<Device *>(device);
Error error = ValidateReleaseDeviceANGLE(dev);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglReleaseDeviceANGLE", GetDeviceIfValid(dev));
return EGL_FALSE;
}
SafeDelete(dev);
thread->setSuccess();
return EGL_TRUE;
}
// EGL_KHR_stream
EGLStreamKHR EGLAPIENTRY CreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", const EGLAttrib* attrib_list = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
AttributeMap attributes = AttributeMap::CreateFromIntArray(attrib_list);
Error error = ValidateCreateStreamKHR(display, attributes);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglCreateStreamKHR", GetDisplayIfValid(display));
return EGL_NO_STREAM_KHR;
}
Stream *stream;
error = display->createStream(attributes, &stream);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglCreateStreamKHR", GetDisplayIfValid(display));
return EGL_NO_STREAM_KHR;
}
thread->setSuccess();
return static_cast<EGLStreamKHR>(stream);
}
EGLBoolean EGLAPIENTRY DestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR = 0x%016" PRIxPTR ")", (uintptr_t)dpy,
(uintptr_t)stream);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
Error error = ValidateDestroyStreamKHR(display, streamObject);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglDestroyStreamKHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
display->destroyStream(streamObject);
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY StreamAttribKHR(EGLDisplay dpy,
EGLStreamKHR stream,
EGLenum attribute,
EGLint value)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR stream = 0x%016" PRIxPTR
", EGLenum attribute = 0x%X, "
"EGLint value = 0x%X)",
(uintptr_t)dpy, (uintptr_t)stream, attribute, value);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
Error error = ValidateStreamAttribKHR(display, streamObject, attribute, value);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamAttribKHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
switch (attribute)
{
case EGL_CONSUMER_LATENCY_USEC_KHR:
streamObject->setConsumerLatency(value);
break;
case EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR:
streamObject->setConsumerAcquireTimeout(value);
break;
default:
UNREACHABLE();
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY QueryStreamKHR(EGLDisplay dpy,
EGLStreamKHR stream,
EGLenum attribute,
EGLint *value)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR stream = 0x%016" PRIxPTR
", EGLenum attribute = 0x%X, "
"EGLint value = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, (uintptr_t)stream, attribute, (uintptr_t)value);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
Error error = ValidateQueryStreamKHR(display, streamObject, attribute, value);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglQueryStreamKHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
switch (attribute)
{
case EGL_STREAM_STATE_KHR:
*value = streamObject->getState();
break;
case EGL_CONSUMER_LATENCY_USEC_KHR:
*value = streamObject->getConsumerLatency();
break;
case EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR:
*value = streamObject->getConsumerAcquireTimeout();
break;
default:
UNREACHABLE();
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY QueryStreamu64KHR(EGLDisplay dpy,
EGLStreamKHR stream,
EGLenum attribute,
EGLuint64KHR *value)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR stream = 0x%016" PRIxPTR
", EGLenum attribute = 0x%X, "
"EGLuint64KHR value = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, (uintptr_t)stream, attribute, (uintptr_t)value);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
Error error = ValidateQueryStreamu64KHR(display, streamObject, attribute, value);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglQueryStreamu64KHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
switch (attribute)
{
case EGL_PRODUCER_FRAME_KHR:
*value = streamObject->getProducerFrame();
break;
case EGL_CONSUMER_FRAME_KHR:
*value = streamObject->getConsumerFrame();
break;
default:
UNREACHABLE();
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR = 0x%016" PRIxPTR ")", (uintptr_t)dpy,
(uintptr_t)stream);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
gl::Context *context = gl::GetValidGlobalContext();
Error error = ValidateStreamConsumerGLTextureExternalKHR(display, context, streamObject);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamConsumerGLTextureExternalKHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
error = streamObject->createConsumerGLTextureExternal(AttributeMap(), context);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamConsumerGLTextureExternalKHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY StreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR = 0x%016" PRIxPTR ")", (uintptr_t)dpy,
(uintptr_t)stream);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
gl::Context *context = gl::GetValidGlobalContext();
Error error = ValidateStreamConsumerAcquireKHR(display, context, streamObject);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamConsumerAcquireKHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
error = streamObject->consumerAcquire(context);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamConsumerAcquireKHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY StreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR = 0x%016" PRIxPTR ")", (uintptr_t)dpy,
(uintptr_t)stream);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
gl::Context *context = gl::GetValidGlobalContext();
Error error = ValidateStreamConsumerReleaseKHR(display, context, streamObject);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglSStreamConsumerReleaseKHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
error = streamObject->consumerRelease(context);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamConsumerReleaseKHR",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy,
EGLStreamKHR stream,
const EGLAttrib *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR stream = 0x%016" PRIxPTR
", EGLAttrib attrib_list = 0x%016" PRIxPTR "",
(uintptr_t)dpy, (uintptr_t)stream, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
gl::Context *context = gl::GetValidGlobalContext();
AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list);
Error error = ValidateStreamConsumerGLTextureExternalAttribsNV(display, context, streamObject,
attributes);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamConsumerGLTextureExternalAttribsNV",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
error = streamObject->createConsumerGLTextureExternal(attributes, context);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamConsumerGLTextureExternalAttribsNV",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureANGLE(EGLDisplay dpy,
EGLStreamKHR stream,
const EGLAttrib *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR stream = 0x%016" PRIxPTR
", EGLAttrib attrib_list = 0x%016" PRIxPTR "",
(uintptr_t)dpy, (uintptr_t)stream, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list);
Error error = ValidateCreateStreamProducerD3DTextureANGLE(display, streamObject, attributes);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglCreateStreamProducerD3DTextureANGLE",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
error = streamObject->createProducerD3D11Texture(attributes);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglCreateStreamProducerD3DTextureANGLE",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY StreamPostD3DTextureANGLE(EGLDisplay dpy,
EGLStreamKHR stream,
void *texture,
const EGLAttrib *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLStreamKHR stream = 0x%016" PRIxPTR
", void* texture = 0x%016" PRIxPTR
", "
"EGLAttrib attrib_list = 0x%016" PRIxPTR "",
(uintptr_t)dpy, (uintptr_t)stream, (uintptr_t)texture, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Stream *streamObject = static_cast<Stream *>(stream);
AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list);
Error error = ValidateStreamPostD3DTextureANGLE(display, streamObject, texture, attributes);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamPostD3DTextureANGLE",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
error = streamObject->postD3D11Texture(texture, attributes);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglStreamPostD3DTextureANGLE",
GetStreamIfValid(display, streamObject));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY GetSyncValuesCHROMIUM(EGLDisplay dpy,
EGLSurface surface,
EGLuint64KHR *ust,
EGLuint64KHR *msc,
EGLuint64KHR *sbc)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLSurface surface = 0x%016" PRIxPTR
", EGLuint64KHR* ust = 0x%016" PRIxPTR
", "
"EGLuint64KHR* msc = 0x%016" PRIxPTR ", EGLuint64KHR* sbc = 0x%016" PRIxPTR "",
(uintptr_t)dpy, (uintptr_t)surface, (uintptr_t)ust, (uintptr_t)msc, (uintptr_t)sbc);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Surface *eglSurface = static_cast<Surface *>(surface);
Error error = ValidateGetSyncValuesCHROMIUM(display, eglSurface, ust, msc, sbc);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglGetSyncValuesCHROMIUM",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
error = eglSurface->getSyncValues(ust, msc, sbc);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglGetSyncValuesCHROMIUM",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY SwapBuffersWithDamageKHR(EGLDisplay dpy,
EGLSurface surface,
EGLint *rects,
EGLint n_rects)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLSurface surface = 0x%016" PRIxPTR
", EGLint *rects = 0x%016" PRIxPTR
", EGLint "
"n_rects = %d)",
(uintptr_t)dpy, (uintptr_t)surface, (uintptr_t)rects, n_rects);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Surface *eglSurface = static_cast<Surface *>(surface);
Error error = ValidateSwapBuffersWithDamageKHR(display, eglSurface, rects, n_rects);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglSwapBuffersWithDamageEXT",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
error = eglSurface->swapWithDamage(thread->getContext(), rects, n_rects);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglSwapBuffersWithDamageEXT",
GetSurfaceIfValid(display, eglSurface));
return EGL_FALSE;
}
thread->setSuccess();
return EGL_TRUE;
}
EGLBoolean EGLAPIENTRY PresentationTimeANDROID(EGLDisplay dpy,
EGLSurface surface,
EGLnsecsANDROID time)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLSurface surface = 0x%016" PRIxPTR
", EGLnsecsANDROID time = %llu)",
(uintptr_t)dpy, (uintptr_t)surface, static_cast<unsigned long long>(time));
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Surface *eglSurface = static_cast<Surface *>(surface);
ANGLE_EGL_TRY_RETURN(thread, ValidatePresentationTimeANDROID(display, eglSurface, time),
"eglPresentationTimeANDROID", GetSurfaceIfValid(display, eglSurface),
EGL_FALSE);
ANGLE_EGL_TRY_RETURN(thread, eglSurface->setPresentationTime(time),
"eglPresentationTimeANDROID", GetSurfaceIfValid(display, eglSurface),
EGL_FALSE);
return EGL_TRUE;
}
ANGLE_EXPORT void EGLAPIENTRY SetBlobCacheFuncsANDROID(EGLDisplay dpy,
EGLSetBlobFuncANDROID set,
EGLGetBlobFuncANDROID get)
{
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLSetBlobFuncANDROID set = 0x%016" PRIxPTR
", EGLGetBlobFuncANDROID get "
"= 0x%016" PRIxPTR ")",
(uintptr_t)dpy, (uintptr_t)set, (uintptr_t)get);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
ANGLE_EGL_TRY(thread, ValidateSetBlobCacheANDROID(display, set, get),
"eglSetBlobCacheFuncsANDROID", GetDisplayIfValid(display));
thread->setSuccess();
display->setBlobCacheFuncs(set, get);
}
EGLint EGLAPIENTRY ProgramCacheGetAttribANGLE(EGLDisplay dpy, EGLenum attrib)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLenum attrib = 0x%X)", (uintptr_t)dpy, attrib);
Display *display = static_cast<Display *>(dpy);
Thread *thread = GetCurrentThread();
ANGLE_EGL_TRY_RETURN(thread, ValidateProgramCacheGetAttribANGLE(display, attrib),
"eglProgramCacheGetAttribANGLE", GetDisplayIfValid(display), 0);
thread->setSuccess();
return display->programCacheGetAttrib(attrib);
}
void EGLAPIENTRY ProgramCacheQueryANGLE(EGLDisplay dpy,
EGLint index,
void *key,
EGLint *keysize,
void *binary,
EGLint *binarysize)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLint index = %d, void *key = 0x%016" PRIxPTR
", EGLint *keysize = "
"0x%016" PRIxPTR ", void *binary = 0x%016" PRIxPTR ", EGLint *size = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, index, (uintptr_t)key, (uintptr_t)keysize, (uintptr_t)binary,
(uintptr_t)binarysize);
Display *display = static_cast<Display *>(dpy);
Thread *thread = GetCurrentThread();
ANGLE_EGL_TRY(thread,
ValidateProgramCacheQueryANGLE(display, index, key, keysize, binary, binarysize),
"eglProgramCacheQueryANGLE", GetDisplayIfValid(display));
ANGLE_EGL_TRY(thread, display->programCacheQuery(index, key, keysize, binary, binarysize),
"eglProgramCacheQueryANGLE", GetDisplayIfValid(display));
thread->setSuccess();
}
void EGLAPIENTRY ProgramCachePopulateANGLE(EGLDisplay dpy,
const void *key,
EGLint keysize,
const void *binary,
EGLint binarysize)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", void *key = 0x%016" PRIxPTR
", EGLint keysize = %d, void *binary = "
"0x%016" PRIxPTR ", EGLint size = %d)",
(uintptr_t)dpy, (uintptr_t)key, keysize, (uintptr_t)binary, binarysize);
Display *display = static_cast<Display *>(dpy);
Thread *thread = GetCurrentThread();
ANGLE_EGL_TRY(thread,
ValidateProgramCachePopulateANGLE(display, key, keysize, binary, binarysize),
"eglProgramCachePopulateANGLE", GetDisplayIfValid(display));
ANGLE_EGL_TRY(thread, display->programCachePopulate(key, keysize, binary, binarysize),
"eglProgramCachePopulateANGLE", GetDisplayIfValid(display));
thread->setSuccess();
}
EGLint EGLAPIENTRY ProgramCacheResizeANGLE(EGLDisplay dpy, EGLint limit, EGLenum mode)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR ", EGLint limit = %d, EGLenum mode = 0x%X)",
(uintptr_t)dpy, limit, mode);
Display *display = static_cast<Display *>(dpy);
Thread *thread = GetCurrentThread();
ANGLE_EGL_TRY_RETURN(thread, ValidateProgramCacheResizeANGLE(display, limit, mode),
"eglProgramCacheResizeANGLE", GetDisplayIfValid(display), 0);
thread->setSuccess();
return display->programCacheResize(limit, mode);
}
EGLint EGLAPIENTRY DebugMessageControlKHR(EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDEBUGPROCKHR callback = 0x%016" PRIxPTR ", EGLAttrib attrib_list = 0x%016" PRIxPTR
")",
(uintptr_t)callback, (uintptr_t)attrib_list);
Thread *thread = GetCurrentThread();
AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list);
Error error = ValidateDebugMessageControlKHR(callback, attributes);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglDebugMessageControlKHR", nullptr);
return error.getCode();
}
Debug *debug = GetDebug();
debug->setCallback(callback, attributes);
thread->setSuccess();
return EGL_SUCCESS;
}
EGLBoolean EGLAPIENTRY QueryDebugKHR(EGLint attribute, EGLAttrib *value)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLint attribute = 0x%X, EGLAttrib* value = 0x%016" PRIxPTR ")", attribute,
(uintptr_t)value);
Thread *thread = GetCurrentThread();
Error error = ValidateQueryDebugKHR(attribute, value);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglQueryDebugKHR", nullptr);
return EGL_FALSE;
}
Debug *debug = GetDebug();
switch (attribute)
{
case EGL_DEBUG_MSG_CRITICAL_KHR:
case EGL_DEBUG_MSG_ERROR_KHR:
case EGL_DEBUG_MSG_WARN_KHR:
case EGL_DEBUG_MSG_INFO_KHR:
*value = debug->isMessageTypeEnabled(FromEGLenum<MessageType>(attribute)) ? EGL_TRUE
: EGL_FALSE;
break;
case EGL_DEBUG_CALLBACK_KHR:
*value = reinterpret_cast<EGLAttrib>(debug->getCallback());
break;
default:
UNREACHABLE();
}
thread->setSuccess();
return EGL_TRUE;
}
EGLint EGLAPIENTRY LabelObjectKHR(EGLDisplay dpy,
EGLenum objectType,
EGLObjectKHR object,
EGLLabelKHR label)
{
ANGLE_SCOPED_GLOBAL_LOCK();
EVENT("(EGLDisplay dpy = 0x%016" PRIxPTR
"f, EGLenum objectType = 0x%X, EGLObjectKHR object = 0x%016" PRIxPTR
", "
"EGLLabelKHR label = 0x%016" PRIxPTR ")",
(uintptr_t)dpy, objectType, (uintptr_t)object, (uintptr_t)label);
Display *display = static_cast<Display *>(dpy);
Thread *thread = GetCurrentThread();
ObjectType objectTypePacked = FromEGLenum<ObjectType>(objectType);
Error error = ValidateLabelObjectKHR(thread, display, objectTypePacked, object, label);
if (error.isError())
{
thread->setError(error, GetDebug(), "eglLabelObjectKHR",
GetLabeledObjectIfValid(thread, display, objectTypePacked, object));
return error.getCode();
}
LabeledObject *labeledObject =
GetLabeledObjectIfValid(thread, display, objectTypePacked, object);
ASSERT(labeledObject != nullptr);
labeledObject->setLabel(label);
thread->setSuccess();
return EGL_SUCCESS;
}
} // namespace egl