diff options
Diffstat (limited to 'src/3rdparty/angle/src/libEGL/libEGL.cpp')
-rw-r--r-- | src/3rdparty/angle/src/libEGL/libEGL.cpp | 1235 |
1 files changed, 111 insertions, 1124 deletions
diff --git a/src/3rdparty/angle/src/libEGL/libEGL.cpp b/src/3rdparty/angle/src/libEGL/libEGL.cpp index 68399d63a4..d09219e308 100644 --- a/src/3rdparty/angle/src/libEGL/libEGL.cpp +++ b/src/3rdparty/angle/src/libEGL/libEGL.cpp @@ -6,1258 +6,245 @@ // libEGL.cpp: Implements the exported EGL functions. -#undef EGLAPI -#define EGLAPI +#include "libGLESv2/entry_points_egl.h" +#include "libGLESv2/entry_points_egl_ext.h" -#include <exception> - -#include "common/debug.h" -#include "common/version.h" -#include "libGLESv2/Context.h" -#include "libGLESv2/Texture.h" -#include "libGLESv2/main.h" -#include "libGLESv2/renderer/SwapChain.h" -#if defined(ANGLE_ENABLE_D3D11) -# include "libGLESv2/renderer/d3d/d3d11/Renderer11.h" -#endif - -#include "libEGL/main.h" -#include "libEGL/Display.h" -#include "libEGL/Surface.h" - -#include "common/NativeWindow.h" - -bool validateDisplay(egl::Display *display) +extern "C" { - if (display == EGL_NO_DISPLAY) - { - recordError(egl::Error(EGL_BAD_DISPLAY)); - return false; - } - - if (!display->isInitialized()) - { - recordError(egl::Error(EGL_NOT_INITIALIZED)); - return false; - } - return true; +EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) +{ + return egl::ChooseConfig(dpy, attrib_list, configs, config_size, num_config); } -bool validateConfig(egl::Display *display, EGLConfig config) +EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { - if (!validateDisplay(display)) - { - return false; - } - - if (!display->isValidConfig(config)) - { - recordError(egl::Error(EGL_BAD_CONFIG)); - return false; - } - - return true; + return egl::CopyBuffers(dpy, surface, target); } -bool validateContext(egl::Display *display, gl::Context *context) +EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) { - if (!validateDisplay(display)) - { - return false; - } - - if (!display->isValidContext(context)) - { - recordError(egl::Error(EGL_BAD_CONTEXT)); - return false; - } - - return true; + return egl::CreateContext(dpy, config, share_context, attrib_list); } -bool validateSurface(egl::Display *display, egl::Surface *surface) +EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) { - if (!validateDisplay(display)) - { - return false; - } - - if (!display->isValidSurface(surface)) - { - recordError(egl::Error(EGL_BAD_SURFACE)); - return false; - } - - return true; + return egl::CreatePbufferSurface(dpy, config, attrib_list); } -extern "C" -{ -EGLint __stdcall eglGetError(void) +EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) { - EVENT("()"); - - EGLint error = egl::getCurrentError(); - recordError(egl::Error(EGL_SUCCESS)); - return error; + return egl::CreatePixmapSurface(dpy, config, pixmap, attrib_list); } -EGLDisplay __stdcall eglGetDisplay(EGLNativeDisplayType display_id) +EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) { - EVENT("(EGLNativeDisplayType display_id = 0x%0.8p)", display_id); - - return egl::Display::getDisplay(display_id, egl::AttributeMap()); + return egl::CreateWindowSurface(dpy, config, win, attrib_list); } -EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list) +EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { - EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)", - platform, native_display, attrib_list); - - switch (platform) - { - case EGL_PLATFORM_ANGLE_ANGLE: - break; - - default: - recordError(egl::Error(EGL_BAD_CONFIG)); - return EGL_NO_DISPLAY; - } - - EGLNativeDisplayType displayId = static_cast<EGLNativeDisplayType>(native_display); - -#if !defined(ANGLE_ENABLE_WINDOWS_STORE) - // Validate the display device context - if (WindowFromDC(displayId) == NULL) - { - recordError(egl::Error(EGL_SUCCESS)); - return EGL_NO_DISPLAY; - } -#endif - - EGLint platformType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE; - bool majorVersionSpecified = false; - bool minorVersionSpecified = false; - bool requestedWARP = 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 (!egl::Display::supportsPlatformD3D()) - { - recordError(egl::Error(EGL_SUCCESS)); - return EGL_NO_DISPLAY; - } - break; - - case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE: - case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: - if (!egl::Display::supportsPlatformOpenGL()) - { - recordError(egl::Error(EGL_SUCCESS)); - return EGL_NO_DISPLAY; - } - break; - - default: - recordError(egl::Error(EGL_SUCCESS)); - 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_USE_WARP_ANGLE: - if (!egl::Display::supportsPlatformD3D()) - { - recordError(egl::Error(EGL_SUCCESS)); - return EGL_NO_DISPLAY; - } - - switch (curAttrib[1]) - { - case EGL_FALSE: - case EGL_TRUE: - break; - - default: - recordError(egl::Error(EGL_SUCCESS)); - return EGL_NO_DISPLAY; - } - - requestedWARP = (curAttrib[1] == EGL_TRUE); - break; - - default: - break; - } - } - } - - if (!majorVersionSpecified && minorVersionSpecified) - { - recordError(egl::Error(EGL_BAD_ATTRIBUTE)); - return EGL_NO_DISPLAY; - } - - if (platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE && requestedWARP) - { - recordError(egl::Error(EGL_BAD_ATTRIBUTE)); - return EGL_NO_DISPLAY; - } - - recordError(egl::Error(EGL_SUCCESS)); - return egl::Display::getDisplay(displayId, egl::AttributeMap(attrib_list)); + return egl::DestroyContext(dpy, ctx); } -EGLBoolean __stdcall eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) +EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)", - dpy, major, minor); - - if (dpy == EGL_NO_DISPLAY) - { - recordError(egl::Error(EGL_BAD_DISPLAY)); - return EGL_FALSE; - } - - egl::Display *display = static_cast<egl::Display*>(dpy); - - egl::Error error = display->initialize(); - if (error.isError()) - { - recordError(error); - return EGL_FALSE; - } - - if (major) *major = 1; - if (minor) *minor = 4; - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::DestroySurface(dpy, surface); } -EGLBoolean __stdcall eglTerminate(EGLDisplay dpy) +EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) { - EVENT("(EGLDisplay dpy = 0x%0.8p)", dpy); - - if (dpy == EGL_NO_DISPLAY) - { - recordError(egl::Error(EGL_BAD_DISPLAY)); - return EGL_FALSE; - } - - egl::Display *display = static_cast<egl::Display*>(dpy); - - display->terminate(); - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::GetConfigAttrib(dpy, config, attribute, value); } -const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name) +EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint name = %d)", dpy, name); - - egl::Display *display = static_cast<egl::Display*>(dpy); - if (!(display == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) && !validateDisplay(display)) - { - return NULL; - } - - const char *result; - switch (name) - { - case EGL_CLIENT_APIS: - result = "OpenGL_ES"; - break; - case EGL_EXTENSIONS: - result = egl::Display::getExtensionString(display); - break; - case EGL_VENDOR: - result = display->getVendorString(); - break; - case EGL_VERSION: - result = "1.4 (ANGLE " ANGLE_VERSION_STRING ")"; - break; - default: - recordError(egl::Error(EGL_BAD_PARAMETER)); - return NULL; - } - - recordError(egl::Error(EGL_SUCCESS)); - return result; + return egl::GetConfigs(dpy, configs, config_size, num_config); } -EGLBoolean __stdcall eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) +EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig *configs = 0x%0.8p, " - "EGLint config_size = %d, EGLint *num_config = 0x%0.8p)", - dpy, configs, config_size, num_config); - - egl::Display *display = static_cast<egl::Display*>(dpy); - - if (!validateDisplay(display)) - { - return EGL_FALSE; - } - - if (!num_config) - { - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; - } - - const EGLint attribList[] = {EGL_NONE}; - - if (!display->getConfigs(configs, attribList, config_size, num_config)) - { - recordError(egl::Error(EGL_BAD_ATTRIBUTE)); - return EGL_FALSE; - } - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::GetCurrentDisplay(); } -EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) +EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { - EVENT("(EGLDisplay dpy = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p, " - "EGLConfig *configs = 0x%0.8p, EGLint config_size = %d, EGLint *num_config = 0x%0.8p)", - dpy, attrib_list, configs, config_size, num_config); - - egl::Display *display = static_cast<egl::Display*>(dpy); - - if (!validateDisplay(display)) - { - return EGL_FALSE; - } - - if (!num_config) - { - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; - } - - const EGLint attribList[] = {EGL_NONE}; - - if (!attrib_list) - { - attrib_list = attribList; - } - - display->getConfigs(configs, attrib_list, config_size, num_config); - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::GetCurrentSurface(readdraw); } -EGLBoolean __stdcall eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) +EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)", - dpy, config, attribute, value); - - egl::Display *display = static_cast<egl::Display*>(dpy); - - if (!validateConfig(display, config)) - { - return EGL_FALSE; - } - - if (!display->getConfigAttrib(config, attribute, value)) - { - recordError(egl::Error(EGL_BAD_ATTRIBUTE)); - return EGL_FALSE; - } - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::GetDisplay(display_id); } -EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) +EGLint EGLAPIENTRY eglGetError(void) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativeWindowType win = 0x%0.8p, " - "const EGLint *attrib_list = 0x%0.8p)", dpy, config, win, attrib_list); - - egl::Display *display = static_cast<egl::Display*>(dpy); - - if (!validateConfig(display, config)) - { - return EGL_NO_SURFACE; - } - - if (!rx::IsValidEGLNativeWindowType(win)) - { - recordError(egl::Error(EGL_BAD_NATIVE_WINDOW)); - return EGL_NO_SURFACE; - } - - EGLSurface surface = EGL_NO_SURFACE; - egl::Error error = display->createWindowSurface(win, config, attrib_list, &surface); - if (error.isError()) - { - recordError(error); - return EGL_NO_SURFACE; - } - - return surface; + return egl::GetError(); } -EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) +EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)", - dpy, config, attrib_list); - - egl::Display *display = static_cast<egl::Display*>(dpy); - - if (!validateConfig(display, config)) - { - return EGL_NO_SURFACE; - } - - EGLSurface surface = EGL_NO_SURFACE; - egl::Error error = display->createOffscreenSurface(config, NULL, attrib_list, &surface); - if (error.isError()) - { - recordError(error); - return EGL_NO_SURFACE; - } - - return surface; + return egl::Initialize(dpy, major, minor); } -EGLSurface __stdcall eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) +EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativePixmapType pixmap = 0x%0.8p, " - "const EGLint *attrib_list = 0x%0.8p)", dpy, config, pixmap, attrib_list); - - egl::Display *display = static_cast<egl::Display*>(dpy); - - if (!validateConfig(display, config)) - { - return EGL_NO_SURFACE; - } - - UNIMPLEMENTED(); // FIXME - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_NO_SURFACE; + return egl::MakeCurrent(dpy, draw, read, ctx); } -EGLBoolean __stdcall eglDestroySurface(EGLDisplay dpy, EGLSurface surface) +EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface); - - egl::Display *display = static_cast<egl::Display*>(dpy); - egl::Surface *eglSurface = static_cast<egl::Surface*>(surface); - - if (!validateSurface(display, eglSurface)) - { - return EGL_FALSE; - } - - if (surface == EGL_NO_SURFACE) - { - recordError(egl::Error(EGL_BAD_SURFACE)); - return EGL_FALSE; - } - - display->destroySurface((egl::Surface*)surface); - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::QueryContext(dpy, ctx, attribute, value); } -EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) +const char* EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)", - dpy, surface, attribute, value); - - egl::Display *display = static_cast<egl::Display*>(dpy); - egl::Surface *eglSurface = (egl::Surface*)surface; - - if (!validateSurface(display, eglSurface)) - { - return EGL_FALSE; - } - - if (surface == EGL_NO_SURFACE) - { - recordError(egl::Error(EGL_BAD_SURFACE)); - return EGL_FALSE; - } - - switch (attribute) - { - case EGL_VG_ALPHA_FORMAT: - UNIMPLEMENTED(); // FIXME - break; - case EGL_VG_COLORSPACE: - UNIMPLEMENTED(); // FIXME - break; - case EGL_CONFIG_ID: - *value = eglSurface->getConfigID(); - break; - case EGL_HEIGHT: - *value = eglSurface->getHeight(); - break; - case EGL_HORIZONTAL_RESOLUTION: - UNIMPLEMENTED(); // FIXME - break; - case EGL_LARGEST_PBUFFER: - UNIMPLEMENTED(); // FIXME - break; - case EGL_MIPMAP_TEXTURE: - UNIMPLEMENTED(); // FIXME - break; - case EGL_MIPMAP_LEVEL: - UNIMPLEMENTED(); // FIXME - break; - case EGL_MULTISAMPLE_RESOLVE: - UNIMPLEMENTED(); // FIXME - break; - case EGL_PIXEL_ASPECT_RATIO: - *value = eglSurface->getPixelAspectRatio(); - break; - case EGL_RENDER_BUFFER: - *value = eglSurface->getRenderBuffer(); - break; - case EGL_SWAP_BEHAVIOR: - *value = eglSurface->getSwapBehavior(); - break; - case EGL_TEXTURE_FORMAT: - *value = eglSurface->getTextureFormat(); - break; - case EGL_TEXTURE_TARGET: - *value = eglSurface->getTextureTarget(); - break; - case EGL_VERTICAL_RESOLUTION: - UNIMPLEMENTED(); // FIXME - break; - case EGL_WIDTH: - *value = eglSurface->getWidth(); - break; - case EGL_POST_SUB_BUFFER_SUPPORTED_NV: - *value = eglSurface->isPostSubBufferSupported(); - break; - case EGL_FIXED_SIZE_ANGLE: - *value = eglSurface->isFixedSize(); - break; - default: - recordError(egl::Error(EGL_BAD_ATTRIBUTE)); - return EGL_FALSE; - } - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::QueryString(dpy, name); } -EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value) +EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) { - TRACE("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, void **value = 0x%0.8p)", - dpy, surface, attribute, value); - - egl::Display *display = static_cast<egl::Display*>(dpy); - egl::Surface *eglSurface = (egl::Surface*)surface; - - switch (attribute) - { - case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE: - { - if (!validateSurface(display, eglSurface)) - { - return EGL_FALSE; - } - - if (surface == EGL_NO_SURFACE) - { - recordError(egl::Error(EGL_BAD_SURFACE)); - return EGL_FALSE; - } - - rx::SwapChain *swapchain = eglSurface->getSwapChain(); - *value = (void*) (swapchain ? swapchain->getShareHandle() : NULL); - } - break; -#if defined(ANGLE_ENABLE_D3D11) - case EGL_DEVICE_EXT: - { - if (!validateDisplay(display)) - { - return EGL_FALSE; - } - - rx::Renderer *renderer = display->getRenderer(); - if (!renderer) - { - *value = NULL; - break; - } - - if (renderer->getMajorShaderModel() < 4) - { - recordError(egl::Error(EGL_BAD_CONTEXT)); - return EGL_FALSE; - } - - *value = static_cast<rx::Renderer11*>(renderer)->getDevice(); - } - break; -#endif - default: - recordError(egl::Error(EGL_BAD_ATTRIBUTE)); - return EGL_FALSE; - } - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::QuerySurface(dpy, surface, attribute, value); } -EGLBoolean __stdcall eglBindAPI(EGLenum api) +EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { - EVENT("(EGLenum api = 0x%X)", api); - - switch (api) - { - case EGL_OPENGL_API: - case EGL_OPENVG_API: - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; // Not supported by this implementation - case EGL_OPENGL_ES_API: - break; - default: - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; - } - - egl::setCurrentAPI(api); - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::SwapBuffers(dpy, surface); } -EGLenum __stdcall eglQueryAPI(void) +EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) { - EVENT("()"); - - EGLenum API = egl::getCurrentAPI(); - - recordError(egl::Error(EGL_SUCCESS)); - return API; + return egl::Terminate(dpy); } -EGLBoolean __stdcall eglWaitClient(void) +EGLBoolean EGLAPIENTRY eglWaitGL(void) { - EVENT("()"); - - UNIMPLEMENTED(); // FIXME - - recordError(egl::Error(EGL_SUCCESS)); - return 0; + return egl::WaitGL(); } -EGLBoolean __stdcall eglReleaseThread(void) +EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) { - EVENT("()"); - - eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE); - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::WaitNative(engine); } -EGLSurface __stdcall eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) +EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLenum buftype = 0x%X, EGLClientBuffer buffer = 0x%0.8p, " - "EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)", - dpy, buftype, buffer, config, attrib_list); - - egl::Display *display = static_cast<egl::Display*>(dpy); - - if (!validateConfig(display, config)) - { - return EGL_NO_SURFACE; - } - - if (buftype != EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE || !buffer) - { - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_NO_SURFACE; - } - - EGLSurface surface = EGL_NO_SURFACE; - egl::Error error = display->createOffscreenSurface(config, (HANDLE)buffer, attrib_list, &surface); - if (error.isError()) - { - recordError(error); - return EGL_NO_SURFACE; - } - - return surface; + return egl::BindTexImage(dpy, surface, buffer); } -EGLBoolean __stdcall eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) +EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint value = %d)", - dpy, surface, attribute, value); - - egl::Display *display = static_cast<egl::Display*>(dpy); - egl::Surface *eglSurface = static_cast<egl::Surface*>(surface); - - if (!validateSurface(display, eglSurface)) - { - return EGL_FALSE; - } - - switch (attribute) - { - case EGL_WIDTH: - if (!eglSurface->isFixedSize() || !value) { - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; - } - eglSurface->setFixedWidth(value); - return EGL_TRUE; - case EGL_HEIGHT: - if (!eglSurface->isFixedSize() || !value) { - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; - } - eglSurface->setFixedHeight(value); - return EGL_TRUE; - default: - break; - } - - UNIMPLEMENTED(); // FIXME - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::ReleaseTexImage(dpy, surface, buffer); } -EGLBoolean __stdcall eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) +EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer); - - egl::Display *display = static_cast<egl::Display*>(dpy); - egl::Surface *eglSurface = static_cast<egl::Surface*>(surface); - - if (!validateSurface(display, eglSurface)) - { - return EGL_FALSE; - } - - if (buffer != EGL_BACK_BUFFER) - { - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; - } - - if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle()) - { - recordError(egl::Error(EGL_BAD_SURFACE)); - return EGL_FALSE; - } - - if (eglSurface->getBoundTexture()) - { - recordError(egl::Error(EGL_BAD_ACCESS)); - return EGL_FALSE; - } - - if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) - { - recordError(egl::Error(EGL_BAD_MATCH)); - return EGL_FALSE; - } - - if (!glBindTexImage(eglSurface)) - { - recordError(egl::Error(EGL_BAD_MATCH)); - return EGL_FALSE; - } - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::SurfaceAttrib(dpy, surface, attribute, value); } -EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) +EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer); - - egl::Display *display = static_cast<egl::Display*>(dpy); - egl::Surface *eglSurface = static_cast<egl::Surface*>(surface); - - if (!validateSurface(display, eglSurface)) - { - return EGL_FALSE; - } - - if (buffer != EGL_BACK_BUFFER) - { - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; - } - - if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle()) - { - recordError(egl::Error(EGL_BAD_SURFACE)); - return EGL_FALSE; - } - - if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) - { - recordError(egl::Error(EGL_BAD_MATCH)); - return EGL_FALSE; - } - - gl::Texture2D *texture = eglSurface->getBoundTexture(); - - if (texture) - { - texture->releaseTexImage(); - } - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::SwapInterval(dpy, interval); } -EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval) +EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint interval = %d)", dpy, interval); - - egl::Display *display = static_cast<egl::Display*>(dpy); - - if (!validateDisplay(display)) - { - return EGL_FALSE; - } - - egl::Surface *draw_surface = static_cast<egl::Surface*>(egl::getCurrentDrawSurface()); - - if (draw_surface == NULL) - { - recordError(egl::Error(EGL_BAD_SURFACE)); - return EGL_FALSE; - } - - draw_surface->setSwapInterval(interval); - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::BindAPI(api); } -EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) +EGLenum EGLAPIENTRY eglQueryAPI(void) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLContext share_context = 0x%0.8p, " - "const EGLint *attrib_list = 0x%0.8p)", dpy, config, share_context, attrib_list); - - // Get the requested client version (default is 1) and check it is 2 or 3. - EGLint client_version = 1; - bool reset_notification = false; - bool robust_access = false; - - if (attrib_list) - { - for (const EGLint* attribute = attrib_list; attribute[0] != EGL_NONE; attribute += 2) - { - switch (attribute[0]) - { - case EGL_CONTEXT_CLIENT_VERSION: - client_version = attribute[1]; - break; - case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT: - if (attribute[1] == EGL_TRUE) - { - recordError(egl::Error(EGL_BAD_CONFIG)); // Unimplemented - return EGL_NO_CONTEXT; - // robust_access = true; - } - else if (attribute[1] != EGL_FALSE) - { - recordError(egl::Error(EGL_BAD_ATTRIBUTE)); - return EGL_NO_CONTEXT; - } - break; - case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT: - if (attribute[1] == EGL_LOSE_CONTEXT_ON_RESET_EXT) - { - reset_notification = true; - } - else if (attribute[1] != EGL_NO_RESET_NOTIFICATION_EXT) - { - recordError(egl::Error(EGL_BAD_ATTRIBUTE)); - return EGL_NO_CONTEXT; - } - break; - default: - recordError(egl::Error(EGL_BAD_ATTRIBUTE)); - return EGL_NO_CONTEXT; - } - } - } - - if (client_version != 2 && client_version != 3) - { - recordError(egl::Error(EGL_BAD_CONFIG)); - return EGL_NO_CONTEXT; - } - - egl::Display *display = static_cast<egl::Display*>(dpy); - - if (share_context) - { - gl::Context* sharedGLContext = static_cast<gl::Context*>(share_context); - - if (sharedGLContext->isResetNotificationEnabled() != reset_notification) - { - recordError(egl::Error(EGL_BAD_MATCH)); - return EGL_NO_CONTEXT; - } - - if (sharedGLContext->getClientVersion() != client_version) - { - recordError(egl::Error(EGL_BAD_CONTEXT)); - return EGL_NO_CONTEXT; - } - - // Can not share contexts between displays - if (sharedGLContext->getRenderer() != display->getRenderer()) - { - recordError(egl::Error(EGL_BAD_MATCH)); - return EGL_NO_CONTEXT; - } - } - - if (!validateConfig(display, config)) - { - return EGL_NO_CONTEXT; - } - - EGLContext context = EGL_NO_CONTEXT; - egl::Error error = display->createContext(config, client_version, static_cast<gl::Context*>(share_context), - reset_notification, robust_access, &context); - if (error.isError()) - { - recordError(error); - return EGL_NO_CONTEXT; - } - - return context; + return egl::QueryAPI(); } -EGLBoolean __stdcall eglDestroyContext(EGLDisplay dpy, EGLContext ctx) +EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p)", dpy, ctx); - - egl::Display *display = static_cast<egl::Display*>(dpy); - gl::Context *context = static_cast<gl::Context*>(ctx); - - if (!validateContext(display, context)) - { - return EGL_FALSE; - } - - if (ctx == EGL_NO_CONTEXT) - { - recordError(egl::Error(EGL_BAD_CONTEXT)); - return EGL_FALSE; - } - - display->destroyContext(context); - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::CreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list); } -EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) +EGLBoolean EGLAPIENTRY eglReleaseThread(void) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface draw = 0x%0.8p, EGLSurface read = 0x%0.8p, EGLContext ctx = 0x%0.8p)", - dpy, draw, read, ctx); - - egl::Display *display = static_cast<egl::Display*>(dpy); - gl::Context *context = static_cast<gl::Context*>(ctx); - - bool noContext = (ctx == EGL_NO_CONTEXT); - bool noSurface = (draw == EGL_NO_SURFACE || read == EGL_NO_SURFACE); - if (noContext != noSurface) - { - recordError(egl::Error(EGL_BAD_MATCH)); - return EGL_FALSE; - } - - if (ctx != EGL_NO_CONTEXT && !validateContext(display, context)) - { - return EGL_FALSE; - } - - if (dpy != EGL_NO_DISPLAY && display->isInitialized()) - { - rx::Renderer *renderer = display->getRenderer(); - if (renderer->testDeviceLost(true)) - { - return EGL_FALSE; - } - - if (renderer->isDeviceLost()) - { - recordError(egl::Error(EGL_CONTEXT_LOST)); - return EGL_FALSE; - } - } - - if ((draw != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(draw))) || - (read != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(read)))) - { - return EGL_FALSE; - } - - if (draw != read) - { - UNIMPLEMENTED(); // FIXME - } - - egl::setCurrentDisplay(dpy); - egl::setCurrentDrawSurface(draw); - egl::setCurrentReadSurface(read); - - glMakeCurrent(context, display, static_cast<egl::Surface*>(draw)); - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::ReleaseThread(); } -EGLContext __stdcall eglGetCurrentContext(void) +EGLBoolean EGLAPIENTRY eglWaitClient(void) { - EVENT("()"); - - EGLContext context = glGetCurrentContext(); - - recordError(egl::Error(EGL_SUCCESS)); - return context; + return egl::WaitClient(); } -EGLSurface __stdcall eglGetCurrentSurface(EGLint readdraw) +EGLContext EGLAPIENTRY eglGetCurrentContext(void) { - EVENT("(EGLint readdraw = %d)", readdraw); - - if (readdraw == EGL_READ) - { - recordError(egl::Error(EGL_SUCCESS)); - return egl::getCurrentReadSurface(); - } - else if (readdraw == EGL_DRAW) - { - recordError(egl::Error(EGL_SUCCESS)); - return egl::getCurrentDrawSurface(); - } - else - { - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_NO_SURFACE; - } + return egl::GetCurrentContext(); } -EGLDisplay __stdcall eglGetCurrentDisplay(void) +EGLSync EGLAPIENTRY eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list) { - EVENT("()"); - - EGLDisplay dpy = egl::getCurrentDisplay(); - - recordError(egl::Error(EGL_SUCCESS)); - return dpy; + return egl::CreateSync(dpy, type, attrib_list); } -EGLBoolean __stdcall eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) +EGLBoolean EGLAPIENTRY eglDestroySync(EGLDisplay dpy, EGLSync sync) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)", - dpy, ctx, attribute, value); - - egl::Display *display = static_cast<egl::Display*>(dpy); - gl::Context *context = static_cast<gl::Context*>(ctx); - - if (!validateContext(display, context)) - { - return EGL_FALSE; - } - - UNIMPLEMENTED(); // FIXME - - recordError(egl::Error(EGL_SUCCESS)); - return 0; + return egl::DestroySync(dpy, sync); } -EGLBoolean __stdcall eglWaitGL(void) +EGLint EGLAPIENTRY eglClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) { - EVENT("()"); - - UNIMPLEMENTED(); // FIXME - - recordError(egl::Error(EGL_SUCCESS)); - return 0; + return egl::ClientWaitSync(dpy, sync, flags, timeout); } -EGLBoolean __stdcall eglWaitNative(EGLint engine) +EGLBoolean EGLAPIENTRY eglGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value) { - EVENT("(EGLint engine = %d)", engine); - - UNIMPLEMENTED(); // FIXME - - recordError(egl::Error(EGL_SUCCESS)); - return 0; + return egl::GetSyncAttrib(dpy, sync, attribute, value); } -EGLBoolean __stdcall eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) +EGLImage EGLAPIENTRY eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface); - - egl::Display *display = static_cast<egl::Display*>(dpy); - egl::Surface *eglSurface = (egl::Surface*)surface; - - if (!validateSurface(display, eglSurface)) - { - return EGL_FALSE; - } - - if (display->getRenderer()->isDeviceLost()) - { - recordError(egl::Error(EGL_CONTEXT_LOST)); - return EGL_FALSE; - } - - if (surface == EGL_NO_SURFACE) - { - recordError(egl::Error(EGL_BAD_SURFACE)); - return EGL_FALSE; - } - - egl::Error error = eglSurface->swap(); - if (error.isError()) - { - recordError(error); - return EGL_FALSE; - } - - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; + return egl::CreateImage(dpy, ctx, target, buffer, attrib_list); } -EGLBoolean __stdcall eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) +EGLBoolean EGLAPIENTRY eglDestroyImage(EGLDisplay dpy, EGLImage image) { - EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLNativePixmapType target = 0x%0.8p)", dpy, surface, target); - - egl::Display *display = static_cast<egl::Display*>(dpy); - egl::Surface *eglSurface = static_cast<egl::Surface*>(surface); - - if (!validateSurface(display, eglSurface)) - { - return EGL_FALSE; - } - - if (display->getRenderer()->isDeviceLost()) - { - recordError(egl::Error(EGL_CONTEXT_LOST)); - return EGL_FALSE; - } - - UNIMPLEMENTED(); // FIXME - - recordError(egl::Error(EGL_SUCCESS)); - return 0; + return egl::DestroyImage(dpy, image); } -EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height) +EGLDisplay EGLAPIENTRY eglGetPlatformDisplay(EGLenum platform, void *native_display, const EGLAttrib *attrib_list) { - 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); - - if (x < 0 || y < 0 || width < 0 || height < 0) - { - recordError(egl::Error(EGL_BAD_PARAMETER)); - return EGL_FALSE; - } - - egl::Display *display = static_cast<egl::Display*>(dpy); - egl::Surface *eglSurface = static_cast<egl::Surface*>(surface); - - if (!validateSurface(display, eglSurface)) - { - return EGL_FALSE; - } - - if (display->getRenderer()->isDeviceLost()) - { - recordError(egl::Error(EGL_CONTEXT_LOST)); - return EGL_FALSE; - } - - if (surface == EGL_NO_SURFACE) - { - recordError(egl::Error(EGL_BAD_SURFACE)); - return EGL_FALSE; - } + return egl::GetPlatformDisplay(platform, native_display, attrib_list); +} - egl::Error error = eglSurface->postSubBuffer(x, y, width, height); - if (error.isError()) - { - recordError(error); - return EGL_FALSE; - } +EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list) +{ + return egl::CreatePlatformWindowSurface(dpy, config, native_window, attrib_list); +} - recordError(egl::Error(EGL_SUCCESS)); - return EGL_TRUE; +EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list) +{ + return egl::CreatePlatformPixmapSurface(dpy, config, native_pixmap, attrib_list); } -__eglMustCastToProperFunctionPointerType __stdcall eglGetProcAddress(const char *procname) +EGLBoolean EGLAPIENTRY eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags) { - EVENT("(const char *procname = \"%s\")", procname); + return egl::WaitSync(dpy, sync, flags); +} - struct Extension - { - const char *name; - __eglMustCastToProperFunctionPointerType address; - }; +EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value) +{ + return egl::QuerySurfacePointerANGLE(dpy, surface, attribute, value); +} - static const Extension eglExtensions[] = - { - { "eglQuerySurfacePointerANGLE", (__eglMustCastToProperFunctionPointerType)eglQuerySurfacePointerANGLE }, - { "eglPostSubBufferNV", (__eglMustCastToProperFunctionPointerType)eglPostSubBufferNV }, - { "eglGetPlatformDisplayEXT", (__eglMustCastToProperFunctionPointerType)eglGetPlatformDisplayEXT }, - { "", NULL }, - }; +EGLBoolean EGLAPIENTRY eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height) +{ + return egl::PostSubBufferNV(dpy, surface, x, y, width, height); +} - for (unsigned int ext = 0; ext < ArraySize(eglExtensions); ext++) - { - if (strcmp(procname, eglExtensions[ext].name) == 0) - { - return (__eglMustCastToProperFunctionPointerType)eglExtensions[ext].address; - } - } +EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list) +{ + return egl::GetPlatformDisplayEXT(platform, native_display, attrib_list); +} - return glGetProcAddress(procname); +__eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname) +{ + return egl::GetProcAddress(procname); } + } |