|
Packit Service |
f6fdc3 |
/*
|
|
Packit Service |
f6fdc3 |
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
|
|
Packit Service |
f6fdc3 |
*
|
|
Packit Service |
f6fdc3 |
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
Packit Service |
f6fdc3 |
* copy of this software and associated documentation files (the "Software"),
|
|
Packit Service |
f6fdc3 |
* to deal in the Software without restriction, including without limitation
|
|
Packit Service |
f6fdc3 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
Packit Service |
f6fdc3 |
* and/or sell copies of the Software, and to permit persons to whom the
|
|
Packit Service |
f6fdc3 |
* Software is furnished to do so, subject to the following conditions:
|
|
Packit Service |
f6fdc3 |
*
|
|
Packit Service |
f6fdc3 |
* The above copyright notice and this permission notice shall be included in
|
|
Packit Service |
f6fdc3 |
* all copies or substantial portions of the Software.
|
|
Packit Service |
f6fdc3 |
*
|
|
Packit Service |
f6fdc3 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit Service |
f6fdc3 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit Service |
f6fdc3 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
Packit Service |
f6fdc3 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
Packit Service |
f6fdc3 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
Packit Service |
f6fdc3 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
Packit Service |
f6fdc3 |
* DEALINGS IN THE SOFTWARE.
|
|
Packit Service |
f6fdc3 |
*/
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
#include <EGL/egl.h>
|
|
Packit Service |
f6fdc3 |
#include "wayland-external-exports.h"
|
|
Packit Service |
f6fdc3 |
#include "wayland-egldisplay.h"
|
|
Packit Service |
f6fdc3 |
#include "wayland-eglstream.h"
|
|
Packit Service |
f6fdc3 |
#include "wayland-eglsurface.h"
|
|
Packit Service |
f6fdc3 |
#include "wayland-eglswap.h"
|
|
Packit Service |
f6fdc3 |
#include "wayland-eglutils.h"
|
|
Packit Service |
f6fdc3 |
#include "wayland-eglhandle.h"
|
|
Packit Service |
f6fdc3 |
#include <stdlib.h>
|
|
Packit Service |
f6fdc3 |
#include <string.h>
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
typedef struct WlEglHookRec {
|
|
Packit Service |
f6fdc3 |
const char *name;
|
|
Packit Service |
f6fdc3 |
void *func;
|
|
Packit Service |
f6fdc3 |
} WlEglHook;
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
static const WlEglHook wlEglHooksMap[] = {
|
|
Packit Service |
f6fdc3 |
/* Keep names in ascending order */
|
|
Packit Service |
f6fdc3 |
{ "eglBindWaylandDisplayWL", wlEglBindDisplaysHook },
|
|
Packit Service |
f6fdc3 |
{ "eglChooseConfig", wlEglChooseConfigHook },
|
|
Packit Service |
f6fdc3 |
{ "eglCreatePbufferSurface", wlEglCreatePbufferSurfaceHook },
|
|
Packit Service |
f6fdc3 |
{ "eglCreatePlatformPixmapSurface", wlEglCreatePlatformPixmapSurfaceHook },
|
|
Packit Service |
f6fdc3 |
{ "eglCreatePlatformWindowSurface", wlEglCreatePlatformWindowSurfaceHook },
|
|
Packit Service |
f6fdc3 |
{ "eglCreateStreamAttribNV", wlEglCreateStreamAttribHook },
|
|
Packit Service |
f6fdc3 |
{ "eglCreateStreamProducerSurfaceKHR", wlEglCreateStreamProducerSurfaceHook },
|
|
Packit Service |
f6fdc3 |
{ "eglDestroySurface", wlEglDestroySurfaceHook },
|
|
Packit Service |
f6fdc3 |
{ "eglGetConfigAttrib", wlEglGetConfigAttribHook },
|
|
Packit Service |
f6fdc3 |
{ "eglInitialize", wlEglInitializeHook },
|
|
Packit Service |
f6fdc3 |
{ "eglQueryDisplayAttribEXT", wlEglQueryDisplayAttribHook },
|
|
Packit Service |
f6fdc3 |
{ "eglQueryDisplayAttribKHR", wlEglQueryDisplayAttribHook },
|
|
Packit Service |
f6fdc3 |
{ "eglQueryWaylandBufferWL", wlEglQueryNativeResourceHook },
|
|
Packit Service |
f6fdc3 |
{ "eglSwapBuffers", wlEglSwapBuffersHook },
|
|
Packit Service |
f6fdc3 |
{ "eglSwapBuffersWithDamageKHR", wlEglSwapBuffersWithDamageHook },
|
|
Packit Service |
f6fdc3 |
{ "eglSwapInterval", wlEglSwapIntervalHook },
|
|
Packit Service |
f6fdc3 |
{ "eglTerminate", wlEglTerminateHook },
|
|
Packit Service |
f6fdc3 |
{ "eglUnbindWaylandDisplayWL", wlEglUnbindDisplaysHook },
|
|
Packit Service |
f6fdc3 |
};
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
static int hookCmp(const void *elemA, const void *elemB)
|
|
Packit Service |
f6fdc3 |
{
|
|
Packit Service |
f6fdc3 |
const char *key = (const char *)elemA;
|
|
Packit Service |
f6fdc3 |
const WlEglHook *hook = (const WlEglHook *)elemB;
|
|
Packit Service |
f6fdc3 |
return strcmp(key, hook->name);
|
|
Packit Service |
f6fdc3 |
}
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
static void* wlEglGetHookAddressExport(void *data, const char *name)
|
|
Packit Service |
f6fdc3 |
{
|
|
Packit Service |
f6fdc3 |
WlEglHook *hook;
|
|
Packit Service |
f6fdc3 |
(void) data;
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
hook = (WlEglHook *)bsearch((const void *)name,
|
|
Packit Service |
f6fdc3 |
(const void *)wlEglHooksMap,
|
|
Packit Service |
f6fdc3 |
sizeof(wlEglHooksMap)/sizeof(WlEglHook),
|
|
Packit Service |
f6fdc3 |
sizeof(WlEglHook),
|
|
Packit Service |
f6fdc3 |
hookCmp);
|
|
Packit Service |
f6fdc3 |
if (hook) {
|
|
Packit Service |
f6fdc3 |
return hook->func;
|
|
Packit Service |
f6fdc3 |
}
|
|
Packit Service |
f6fdc3 |
return NULL;
|
|
Packit Service |
f6fdc3 |
}
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
static EGLBoolean wlEglUnloadPlatformExport(void *data) {
|
|
Packit Service |
f6fdc3 |
EGLBoolean res;
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
res = wlEglDestroyAllDisplays((WlEglPlatformData *)data);
|
|
Packit Service |
f6fdc3 |
wlEglDestroyPlatformData((WlEglPlatformData *)data);
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
return res;
|
|
Packit Service |
f6fdc3 |
}
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
EGLBoolean loadEGLExternalPlatform(int major, int minor,
|
|
Packit Service |
f6fdc3 |
const EGLExtDriver *driver,
|
|
Packit Service |
f6fdc3 |
EGLExtPlatform *platform)
|
|
Packit Service |
f6fdc3 |
{
|
|
Packit Service |
f6fdc3 |
if (!platform ||
|
|
Packit Service |
f6fdc3 |
!EGL_EXTERNAL_PLATFORM_VERSION_CHECK(major, minor)) {
|
|
Packit Service |
f6fdc3 |
return EGL_FALSE;
|
|
Packit Service |
f6fdc3 |
}
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
platform->version.major = WAYLAND_EXTERNAL_VERSION_MAJOR;
|
|
Packit Service |
f6fdc3 |
platform->version.minor = WAYLAND_EXTERNAL_VERSION_MINOR;
|
|
Packit Service |
f6fdc3 |
platform->version.micro = WAYLAND_EXTERNAL_VERSION_MICRO;
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
platform->platform = EGL_PLATFORM_WAYLAND_EXT;
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
platform->data = (void *)wlEglCreatePlatformData(major, minor, driver);
|
|
Packit Service |
f6fdc3 |
if (platform->data == NULL) {
|
|
Packit Service |
f6fdc3 |
return EGL_FALSE;
|
|
Packit Service |
f6fdc3 |
}
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
platform->exports.unloadEGLExternalPlatform = wlEglUnloadPlatformExport;
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
platform->exports.getHookAddress = wlEglGetHookAddressExport;
|
|
Packit Service |
f6fdc3 |
platform->exports.isValidNativeDisplay = wlEglIsValidNativeDisplayExport;
|
|
Packit Service |
f6fdc3 |
platform->exports.getPlatformDisplay = wlEglGetPlatformDisplayExport;
|
|
Packit Service |
f6fdc3 |
platform->exports.queryString = wlEglQueryStringExport;
|
|
Packit Service |
f6fdc3 |
platform->exports.getInternalHandle = wlEglGetInternalHandleExport;
|
|
Packit Service |
f6fdc3 |
|
|
Packit Service |
f6fdc3 |
return EGL_TRUE;
|
|
Packit Service |
f6fdc3 |
}
|