summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp')
-rw-r--r--src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp784
1 files changed, 541 insertions, 243 deletions
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
index 6c7e2ffc3d..ee8cdb94dc 100644
--- a/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/entry_points_egl_ext.cpp
@@ -9,9 +9,12 @@
#include "libGLESv2/entry_points_egl_ext.h"
#include "libGLESv2/global_state.h"
+#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/Device.h"
#include "libANGLE/Surface.h"
+#include "libANGLE/Stream.h"
+#include "libANGLE/Thread.h"
#include "libANGLE/validationEGL.h"
#include "common/debug.h"
@@ -24,6 +27,7 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, void **value = 0x%0.8p)",
dpy, surface, attribute, value);
+ Thread *thread = GetCurrentThread();
Display *display = static_cast<Display*>(dpy);
Surface *eglSurface = static_cast<Surface*>(surface);
@@ -31,19 +35,19 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa
Error error = ValidateSurface(display, eglSurface);
if (error.isError())
{
- SetGlobalError(error);
+ thread->setError(error);
return EGL_FALSE;
}
if (!display->getExtensions().querySurfacePointer)
{
- SetGlobalError(Error(EGL_SUCCESS));
+ thread->setError(NoError());
return EGL_FALSE;
}
if (surface == EGL_NO_SURFACE)
{
- SetGlobalError(Error(EGL_BAD_SURFACE));
+ thread->setError(EglBadSurface());
return EGL_FALSE;
}
@@ -55,24 +59,24 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa
case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
if (!display->getExtensions().surfaceD3DTexture2DShareHandle)
{
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ thread->setError(EglBadAttribute());
return EGL_FALSE;
}
break;
case EGL_DXGI_KEYED_MUTEX_ANGLE:
if (!display->getExtensions().keyedMutex)
{
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ thread->setError(EglBadAttribute());
return EGL_FALSE;
}
break;
default:
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
- return EGL_FALSE;
+ thread->setError(EglBadAttribute());
+ return EGL_FALSE;
}
error = eglSurface->querySurfacePointerANGLE(attribute, value);
- SetGlobalError(error);
+ thread->setError(error);
return (error.isError() ? EGL_FALSE : EGL_TRUE);
}
@@ -81,10 +85,11 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa
EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height)
{
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);
+ Thread *thread = GetCurrentThread();
if (x < 0 || y < 0 || width < 0 || height < 0)
{
- SetGlobalError(Error(EGL_BAD_PARAMETER));
+ thread->setError(EglBadParameter());
return EGL_FALSE;
}
@@ -94,39 +99,38 @@ EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLin
Error error = ValidateSurface(display, eglSurface);
if (error.isError())
{
- SetGlobalError(error);
+ thread->setError(error);
return EGL_FALSE;
}
- if (display->isDeviceLost())
+ if (display->testDeviceLost())
{
- SetGlobalError(Error(EGL_CONTEXT_LOST));
+ thread->setError(EglContextLost());
return EGL_FALSE;
}
if (surface == EGL_NO_SURFACE)
{
- SetGlobalError(Error(EGL_BAD_SURFACE));
+ thread->setError(EglBadSurface());
return EGL_FALSE;
}
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE) || (defined(ANGLE_ENABLE_WINDOWS_STORE) && WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) // Qt WP: Allow this entry point as a workaround
if (!display->getExtensions().postSubBuffer)
{
// Spec is not clear about how this should be handled.
- SetGlobalError(Error(EGL_SUCCESS));
+ thread->setError(NoError());
return EGL_TRUE;
}
-#endif
- error = eglSurface->postSubBuffer(x, y, width, height);
+ // TODO(jmadill): Validate Surface is bound to the thread.
+ error = eglSurface->postSubBuffer(thread->getContext(), x, y, width, height);
if (error.isError())
{
- SetGlobalError(error);
+ thread->setError(error);
return EGL_FALSE;
}
- SetGlobalError(Error(EGL_SUCCESS));
+ thread->setError(NoError());
return EGL_TRUE;
}
@@ -135,215 +139,25 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
{
EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)",
platform, native_display, attrib_list);
+ Thread *thread = GetCurrentThread();
- const ClientExtensions &clientExtensions = Display::getClientExtensions();
-
- switch (platform)
+ Error err = ValidateGetPlatformDisplayEXT(platform, native_display, attrib_list);
+ thread->setError(err);
+ if (err.isError())
{
- case EGL_PLATFORM_ANGLE_ANGLE:
- if (!clientExtensions.platformANGLE)
- {
- SetGlobalError(Error(EGL_BAD_PARAMETER));
- return EGL_NO_DISPLAY;
- }
- break;
- case EGL_PLATFORM_DEVICE_EXT:
- if (!clientExtensions.platformDevice)
- {
- SetGlobalError(Error(EGL_BAD_PARAMETER, "Platform Device extension is not active"));
- return EGL_NO_DISPLAY;
- }
- break;
- default:
- SetGlobalError(Error(EGL_BAD_CONFIG));
return EGL_NO_DISPLAY;
}
+ const auto &attribMap = AttributeMap::CreateFromIntArray(attrib_list);
if (platform == EGL_PLATFORM_ANGLE_ANGLE)
{
- EGLint platformType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
- EGLint deviceType = EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE;
- bool majorVersionSpecified = false;
- bool minorVersionSpecified = false;
- bool enableAutoTrimSpecified = false;
- bool deviceTypeSpecified = false;
- bool presentPathSpecified = false;
-
- if (attrib_list)
- {
- for (const EGLint *curAttrib = attrib_list; curAttrib[0] != EGL_NONE; curAttrib += 2)
- {
- switch (curAttrib[0])
- {
- case EGL_PLATFORM_ANGLE_TYPE_ANGLE:
- switch (curAttrib[1])
- {
- case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
- break;
-
- case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
- case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
- if (!clientExtensions.platformANGLED3D)
- {
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
- return EGL_NO_DISPLAY;
- }
- break;
-
- case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
- case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
- if (!clientExtensions.platformANGLEOpenGL)
- {
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
- return EGL_NO_DISPLAY;
- }
- break;
-
- default:
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
- return EGL_NO_DISPLAY;
- }
- platformType = curAttrib[1];
- break;
-
- case EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE:
- if (curAttrib[1] != EGL_DONT_CARE)
- {
- majorVersionSpecified = true;
- }
- break;
-
- case EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE:
- if (curAttrib[1] != EGL_DONT_CARE)
- {
- minorVersionSpecified = true;
- }
- break;
-
- case EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE:
- switch (curAttrib[1])
- {
- case EGL_TRUE:
- case EGL_FALSE:
- break;
- default:
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
- return EGL_NO_DISPLAY;
- }
- enableAutoTrimSpecified = true;
- break;
-
- case EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE:
- if (!clientExtensions.experimentalPresentPath)
- {
- SetGlobalError(
- Error(EGL_BAD_ATTRIBUTE,
- "EGL_ANGLE_experimental_present_path extension not active"));
- return EGL_NO_DISPLAY;
- }
-
- switch (curAttrib[1])
- {
- case EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE:
- case EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE:
- break;
- default:
- SetGlobalError(
- Error(EGL_BAD_ATTRIBUTE,
- "Invalid value for EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE"));
- return EGL_NO_DISPLAY;
- }
- presentPathSpecified = true;
- break;
-
- case EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE:
- switch (curAttrib[1])
- {
- case EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE:
- case EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE:
- case EGL_PLATFORM_ANGLE_DEVICE_TYPE_REFERENCE_ANGLE:
- deviceTypeSpecified = true;
- break;
-
- case EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE:
- // This is a hidden option, accepted by the OpenGL back-end.
- break;
-
- default:
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE,
- "Invalid value for "
- "EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE "
- "attrib"));
- return EGL_NO_DISPLAY;
- }
- deviceType = curAttrib[1];
- break;
-
- default:
- break;
- }
- }
- }
-
- if (!majorVersionSpecified && minorVersionSpecified)
- {
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
- return EGL_NO_DISPLAY;
- }
-
- if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE &&
- platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
- {
- SetGlobalError(
- Error(EGL_BAD_ATTRIBUTE,
- "EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE requires a device type of "
- "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
- return EGL_NO_DISPLAY;
- }
-
- if (enableAutoTrimSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
- {
- SetGlobalError(
- Error(EGL_BAD_ATTRIBUTE,
- "EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE requires a device type of "
- "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
- return EGL_NO_DISPLAY;
- }
-
- if (presentPathSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
- {
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE,
- "EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE requires a device type of "
- "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
- return EGL_NO_DISPLAY;
- }
-
- if (deviceTypeSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE &&
- platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
- {
- SetGlobalError(
- Error(EGL_BAD_ATTRIBUTE,
- "EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE requires a device type of "
- "EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE or EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE."));
- return EGL_NO_DISPLAY;
- }
-
- SetGlobalError(Error(EGL_SUCCESS));
- return Display::GetDisplayFromAttribs(native_display, AttributeMap(attrib_list));
+ return Display::GetDisplayFromNativeDisplay(
+ gl::bitCast<EGLNativeDisplayType>(native_display), attribMap);
}
else if (platform == EGL_PLATFORM_DEVICE_EXT)
{
Device *eglDevice = reinterpret_cast<Device *>(native_display);
- if (eglDevice == nullptr || !Device::IsValidDevice(eglDevice))
- {
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE,
- "native_display should be a valid EGL device if platform equals "
- "EGL_PLATFORM_DEVICE_EXT"));
- return EGL_NO_DISPLAY;
- }
-
- SetGlobalError(Error(EGL_SUCCESS));
- return Display::GetDisplayFromDevice(native_display);
+ return Display::GetDisplayFromDevice(eglDevice, attribMap);
}
else
{
@@ -357,11 +171,12 @@ EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribut
{
EVENT("(EGLDeviceEXT device = 0x%0.8p, EGLint attribute = %d, EGLAttrib *value = 0x%0.8p)",
device, attribute, value);
+ Thread *thread = GetCurrentThread();
Device *dev = static_cast<Device*>(device);
if (dev == EGL_NO_DEVICE_EXT || !Device::IsValidDevice(dev))
{
- SetGlobalError(Error(EGL_BAD_ACCESS));
+ thread->setError(EglBadAccess());
return EGL_FALSE;
}
@@ -370,13 +185,13 @@ EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribut
Display *owningDisplay = dev->getOwningDisplay();
if (owningDisplay != nullptr && !owningDisplay->getExtensions().deviceQuery)
{
- SetGlobalError(Error(EGL_BAD_ACCESS,
- "Device wasn't created using eglCreateDeviceANGLE, and the Display "
- "that created it doesn't support device querying"));
+ thread->setError(EglBadAccess() << "Device wasn't created using eglCreateDeviceANGLE, "
+ "and the Display that created it doesn't support "
+ "device querying");
return EGL_FALSE;
}
- Error error(EGL_SUCCESS);
+ Error error(NoError());
// validate the attribute parameter
switch (attribute)
@@ -385,17 +200,17 @@ EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribut
case EGL_D3D9_DEVICE_ANGLE:
if (!dev->getExtensions().deviceD3D || dev->getType() != attribute)
{
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
+ thread->setError(EglBadAttribute());
return EGL_FALSE;
}
error = dev->getDevice(value);
break;
default:
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
- return EGL_FALSE;
+ thread->setError(EglBadAttribute());
+ return EGL_FALSE;
}
- SetGlobalError(error);
+ thread->setError(error);
return (error.isError() ? EGL_FALSE : EGL_TRUE);
}
@@ -404,11 +219,12 @@ const char * EGLAPIENTRY QueryDeviceStringEXT(EGLDeviceEXT device, EGLint name)
{
EVENT("(EGLDeviceEXT device = 0x%0.8p, EGLint name = %d)",
device, name);
+ Thread *thread = GetCurrentThread();
Device *dev = static_cast<Device*>(device);
if (dev == EGL_NO_DEVICE_EXT || !Device::IsValidDevice(dev))
{
- SetGlobalError(Error(EGL_BAD_DEVICE_EXT));
+ thread->setError(EglBadDevice());
return nullptr;
}
@@ -419,11 +235,11 @@ const char * EGLAPIENTRY QueryDeviceStringEXT(EGLDeviceEXT device, EGLint name)
result = dev->getExtensionString().c_str();
break;
default:
- SetGlobalError(Error(EGL_BAD_DEVICE_EXT));
- return nullptr;
+ thread->setError(EglBadDevice());
+ return nullptr;
}
- SetGlobalError(Error(EGL_SUCCESS));
+ thread->setError(NoError());
return result;
}
@@ -432,13 +248,20 @@ EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, E
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint attribute = %d, EGLAttrib *value = 0x%0.8p)",
dpy, attribute, value);
+ Thread *thread = GetCurrentThread();
Display *display = static_cast<Display*>(dpy);
- Error error(EGL_SUCCESS);
+
+ Error error = ValidateDisplay(display);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
if (!display->getExtensions().deviceQuery)
{
- SetGlobalError(Error(EGL_BAD_ACCESS));
+ thread->setError(EglBadAccess());
return EGL_FALSE;
}
@@ -450,11 +273,11 @@ EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, E
break;
default:
- SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
- return EGL_FALSE;
+ thread->setError(EglBadAttribute());
+ return EGL_FALSE;
}
- SetGlobalError(error);
+ thread->setError(error);
return (error.isError() ? EGL_FALSE : EGL_TRUE);
}
@@ -468,23 +291,24 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy,
"(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLenum target = 0x%X, "
"EGLClientBuffer buffer = 0x%0.8p, const EGLAttrib *attrib_list = 0x%0.8p)",
dpy, ctx, target, buffer, attrib_list);
+ Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
gl::Context *context = static_cast<gl::Context *>(ctx);
- AttributeMap attributes(attrib_list);
+ AttributeMap attributes = AttributeMap::CreateFromIntArray(attrib_list);
Error error = ValidateCreateImageKHR(display, context, target, buffer, attributes);
if (error.isError())
{
- SetGlobalError(error);
+ thread->setError(error);
return EGL_NO_IMAGE;
}
Image *image = nullptr;
- error = display->createImage(context, target, buffer, attributes, &image);
+ error = display->createImage(context, target, buffer, attributes, &image);
if (error.isError())
{
- SetGlobalError(error);
+ thread->setError(error);
return EGL_NO_IMAGE;
}
@@ -494,6 +318,7 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy,
ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLImage image = 0x%0.8p)", dpy, image);
+ Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Image *img = static_cast<Image *>(image);
@@ -501,7 +326,7 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroyImageKHR(EGLDisplay dpy, EGLImageKHR
Error error = ValidateDestroyImageKHR(display, img);
if (error.isError())
{
- SetGlobalError(error);
+ thread->setError(error);
return EGL_FALSE;
}
@@ -518,11 +343,12 @@ ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type,
"(EGLint device_type = %d, void* native_device = 0x%0.8p, const EGLAttrib* attrib_list = "
"0x%0.8p)",
device_type, native_device, attrib_list);
+ Thread *thread = GetCurrentThread();
Error error = ValidateCreateDeviceANGLE(device_type, native_device, attrib_list);
if (error.isError())
{
- SetGlobalError(error);
+ thread->setError(error);
return EGL_NO_DEVICE_EXT;
}
@@ -531,7 +357,7 @@ ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type,
if (error.isError())
{
ASSERT(device == nullptr);
- SetGlobalError(error);
+ thread->setError(error);
return EGL_NO_DEVICE_EXT;
}
@@ -541,13 +367,14 @@ ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type,
ANGLE_EXPORT EGLBoolean EGLAPIENTRY ReleaseDeviceANGLE(EGLDeviceEXT device)
{
EVENT("(EGLDeviceEXT device = 0x%0.8p)", device);
+ Thread *thread = GetCurrentThread();
Device *dev = static_cast<Device *>(device);
Error error = ValidateReleaseDeviceANGLE(dev);
if (error.isError())
{
- SetGlobalError(error);
+ thread->setError(error);
return EGL_FALSE;
}
@@ -555,4 +382,475 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY ReleaseDeviceANGLE(EGLDeviceEXT device)
return EGL_TRUE;
}
+
+// EGL_KHR_stream
+EGLStreamKHR EGLAPIENTRY CreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, const EGLAttrib* attrib_list = 0x%0.8p)", dpy, 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);
+ return EGL_NO_STREAM_KHR;
+ }
+
+ Stream *stream;
+ error = display->createStream(attributes, &stream);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_NO_STREAM_KHR;
+ }
+
+ thread->setError(error);
+ return static_cast<EGLStreamKHR>(stream);
+}
+
+EGLBoolean EGLAPIENTRY DestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, 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);
+ return EGL_FALSE;
+ }
+
+ display->destroyStream(streamObject);
+ thread->setError(error);
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY StreamAttribKHR(EGLDisplay dpy,
+ EGLStreamKHR stream,
+ EGLenum attribute,
+ EGLint value)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLenum attribute = 0x%X, "
+ "EGLint value = 0x%X)",
+ dpy, 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);
+ 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->setError(error);
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY QueryStreamKHR(EGLDisplay dpy,
+ EGLStreamKHR stream,
+ EGLenum attribute,
+ EGLint *value)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLenum attribute = 0x%X, "
+ "EGLint value = 0x%0.8p)",
+ dpy, stream, attribute, 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);
+ 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->setError(error);
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY QueryStreamu64KHR(EGLDisplay dpy,
+ EGLStreamKHR stream,
+ EGLenum attribute,
+ EGLuint64KHR *value)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLenum attribute = 0x%X, "
+ "EGLuint64KHR value = 0x%0.8p)",
+ dpy, stream, attribute, 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);
+ 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->setError(error);
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, 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);
+ return EGL_FALSE;
+ }
+
+ error = streamObject->createConsumerGLTextureExternal(AttributeMap(), context);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ thread->setError(error);
+ return EGL_TRUE;
}
+
+EGLBoolean EGLAPIENTRY StreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, 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);
+ return EGL_FALSE;
+ }
+
+ error = streamObject->consumerAcquire(context);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ thread->setError(error);
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY StreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, 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);
+ return EGL_FALSE;
+ }
+
+ error = streamObject->consumerRelease(context);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ thread->setError(error);
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy,
+ EGLStreamKHR stream,
+ const EGLAttrib *attrib_list)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLAttrib attrib_list = 0x%0.8p",
+ dpy, stream, 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);
+ return EGL_FALSE;
+ }
+
+ error = streamObject->createConsumerGLTextureExternal(attributes, context);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ thread->setError(error);
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy,
+ EGLStreamKHR stream,
+ const EGLAttrib *attrib_list)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLAttrib attrib_list = 0x%0.8p",
+ dpy, stream, 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 =
+ ValidateCreateStreamProducerD3DTextureNV12ANGLE(display, streamObject, attributes);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ error = streamObject->createProducerD3D11TextureNV12(attributes);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ thread->setError(error);
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy,
+ EGLStreamKHR stream,
+ void *texture,
+ const EGLAttrib *attrib_list)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, void* texture = 0x%0.8p, "
+ "EGLAttrib attrib_list = 0x%0.8p",
+ dpy, stream, texture, 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 = ValidateStreamPostD3DTextureNV12ANGLE(display, streamObject, texture, attributes);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ error = streamObject->postD3D11NV12Texture(texture, attributes);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ thread->setError(error);
+ return EGL_TRUE;
+}
+
+EGLBoolean EGLAPIENTRY GetSyncValuesCHROMIUM(EGLDisplay dpy,
+ EGLSurface surface,
+ EGLuint64KHR *ust,
+ EGLuint64KHR *msc,
+ EGLuint64KHR *sbc)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLuint64KHR* ust = 0x%0.8p, "
+ "EGLuint64KHR* msc = 0x%0.8p, EGLuint64KHR* sbc = 0x%0.8p",
+ dpy, surface, ust, msc, 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);
+ return EGL_FALSE;
+ }
+
+ error = eglSurface->getSyncValues(ust, msc, sbc);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ thread->setError(error);
+ return EGL_TRUE;
+}
+
+ANGLE_EXPORT EGLBoolean SwapBuffersWithDamageEXT(EGLDisplay dpy,
+ EGLSurface surface,
+ EGLint *rects,
+ EGLint n_rects)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint *rects = 0x%0.8p, EGLint "
+ "n_rects = %d)",
+ dpy, surface, rects, n_rects);
+ Thread *thread = GetCurrentThread();
+
+ Display *display = static_cast<Display *>(dpy);
+ Surface *eglSurface = static_cast<Surface *>(surface);
+
+ Error error = ValidateSwapBuffersWithDamageEXT(display, eglSurface, rects, n_rects);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ error = eglSurface->swapWithDamage(thread->getContext(), rects, n_rects);
+ if (error.isError())
+ {
+ thread->setError(error);
+ return EGL_FALSE;
+ }
+
+ return EGL_TRUE;
+}
+
+EGLint EGLAPIENTRY ProgramCacheGetAttribANGLE(EGLDisplay dpy, EGLenum attrib)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLenum attrib = 0x%X)", dpy, attrib);
+
+ Display *display = static_cast<Display *>(dpy);
+ Thread *thread = GetCurrentThread();
+
+ ANGLE_EGL_TRY_RETURN(thread, ValidateProgramCacheGetAttribANGLE(display, attrib), 0);
+
+ return display->programCacheGetAttrib(attrib);
+}
+
+void EGLAPIENTRY ProgramCacheQueryANGLE(EGLDisplay dpy,
+ EGLint index,
+ void *key,
+ EGLint *keysize,
+ void *binary,
+ EGLint *binarysize)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, EGLint index = %d, void *key = 0x%0.8p, EGLint *keysize = "
+ "0x%0.8p, void *binary = 0x%0.8p, EGLint *size = 0x%0.8p)",
+ dpy, index, key, keysize, binary, binarysize);
+
+ Display *display = static_cast<Display *>(dpy);
+ Thread *thread = GetCurrentThread();
+
+ ANGLE_EGL_TRY(thread,
+ ValidateProgramCacheQueryANGLE(display, index, key, keysize, binary, binarysize));
+
+ ANGLE_EGL_TRY(thread, display->programCacheQuery(index, key, keysize, binary, binarysize));
+}
+
+void EGLAPIENTRY ProgramCachePopulateANGLE(EGLDisplay dpy,
+ const void *key,
+ EGLint keysize,
+ const void *binary,
+ EGLint binarysize)
+{
+ EVENT(
+ "(EGLDisplay dpy = 0x%0.8p, void *key = 0x%0.8p, EGLint keysize = %d, void *binary = "
+ "0x%0.8p, EGLint *size = 0x%0.8p)",
+ dpy, key, keysize, binary, binarysize);
+
+ Display *display = static_cast<Display *>(dpy);
+ Thread *thread = GetCurrentThread();
+
+ ANGLE_EGL_TRY(thread,
+ ValidateProgramCachePopulateANGLE(display, key, keysize, binary, binarysize));
+
+ ANGLE_EGL_TRY(thread, display->programCachePopulate(key, keysize, binary, binarysize));
+}
+
+EGLint EGLAPIENTRY ProgramCacheResizeANGLE(EGLDisplay dpy, EGLint limit, EGLenum mode)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint limit = %d, EGLenum mode = 0x%X)", dpy, limit, mode);
+
+ Display *display = static_cast<Display *>(dpy);
+ Thread *thread = GetCurrentThread();
+
+ ANGLE_EGL_TRY_RETURN(thread, ValidateProgramCacheResizeANGLE(display, limit, mode), 0);
+
+ return display->programCacheResize(limit, mode);
+}
+
+} // namespace egl