1*61046927SAndroid Build Coastguard Worker /*
2*61046927SAndroid Build Coastguard Worker * (C) Copyright 2016, NVIDIA CORPORATION.
3*61046927SAndroid Build Coastguard Worker * All Rights Reserved.
4*61046927SAndroid Build Coastguard Worker *
5*61046927SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a
6*61046927SAndroid Build Coastguard Worker * copy of this software and associated documentation files (the "Software"),
7*61046927SAndroid Build Coastguard Worker * to deal in the Software without restriction, including without limitation
8*61046927SAndroid Build Coastguard Worker * on the rights to use, copy, modify, merge, publish, distribute, sub
9*61046927SAndroid Build Coastguard Worker * license, and/or sell copies of the Software, and to permit persons to whom
10*61046927SAndroid Build Coastguard Worker * the Software is furnished to do so, subject to the following conditions:
11*61046927SAndroid Build Coastguard Worker *
12*61046927SAndroid Build Coastguard Worker * The above copyright notice and this permission notice (including the next
13*61046927SAndroid Build Coastguard Worker * paragraph) shall be included in all copies or substantial portions of the
14*61046927SAndroid Build Coastguard Worker * Software.
15*61046927SAndroid Build Coastguard Worker *
16*61046927SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*61046927SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*61046927SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19*61046927SAndroid Build Coastguard Worker * IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*61046927SAndroid Build Coastguard Worker * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21*61046927SAndroid Build Coastguard Worker * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22*61046927SAndroid Build Coastguard Worker * IN THE SOFTWARE.
23*61046927SAndroid Build Coastguard Worker *
24*61046927SAndroid Build Coastguard Worker * Authors:
25*61046927SAndroid Build Coastguard Worker * Kyle Brenneman <[email protected]>
26*61046927SAndroid Build Coastguard Worker */
27*61046927SAndroid Build Coastguard Worker
28*61046927SAndroid Build Coastguard Worker #include <assert.h>
29*61046927SAndroid Build Coastguard Worker #include <string.h>
30*61046927SAndroid Build Coastguard Worker
31*61046927SAndroid Build Coastguard Worker #include <glvnd/libeglabi.h>
32*61046927SAndroid Build Coastguard Worker
33*61046927SAndroid Build Coastguard Worker #include "eglcurrent.h"
34*61046927SAndroid Build Coastguard Worker #include "egldispatchstubs.h"
35*61046927SAndroid Build Coastguard Worker #include "eglglobals.h"
36*61046927SAndroid Build Coastguard Worker
37*61046927SAndroid Build Coastguard Worker static const __EGLapiExports *__eglGLVNDApiExports = NULL;
38*61046927SAndroid Build Coastguard Worker
39*61046927SAndroid Build Coastguard Worker static const char *EGLAPIENTRY
__eglGLVNDQueryString(EGLDisplay dpy,EGLenum name)40*61046927SAndroid Build Coastguard Worker __eglGLVNDQueryString(EGLDisplay dpy, EGLenum name)
41*61046927SAndroid Build Coastguard Worker {
42*61046927SAndroid Build Coastguard Worker // For client extensions, return the list of non-platform extensions. The
43*61046927SAndroid Build Coastguard Worker // platform extensions are returned by __eglGLVNDGetVendorString.
44*61046927SAndroid Build Coastguard Worker if (dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS)
45*61046927SAndroid Build Coastguard Worker return _eglGlobal.ClientOnlyExtensionString;
46*61046927SAndroid Build Coastguard Worker
47*61046927SAndroid Build Coastguard Worker // For everything else, forward to the normal eglQueryString function.
48*61046927SAndroid Build Coastguard Worker return eglQueryString(dpy, name);
49*61046927SAndroid Build Coastguard Worker }
50*61046927SAndroid Build Coastguard Worker
51*61046927SAndroid Build Coastguard Worker static const char *
__eglGLVNDGetVendorString(int name)52*61046927SAndroid Build Coastguard Worker __eglGLVNDGetVendorString(int name)
53*61046927SAndroid Build Coastguard Worker {
54*61046927SAndroid Build Coastguard Worker if (name == __EGL_VENDOR_STRING_PLATFORM_EXTENSIONS)
55*61046927SAndroid Build Coastguard Worker return _eglGlobal.PlatformExtensionString;
56*61046927SAndroid Build Coastguard Worker
57*61046927SAndroid Build Coastguard Worker return NULL;
58*61046927SAndroid Build Coastguard Worker }
59*61046927SAndroid Build Coastguard Worker
60*61046927SAndroid Build Coastguard Worker static EGLDisplay
__eglGLVNDGetPlatformDisplay(EGLenum platform,void * native_display,const EGLAttrib * attrib_list)61*61046927SAndroid Build Coastguard Worker __eglGLVNDGetPlatformDisplay(EGLenum platform, void *native_display,
62*61046927SAndroid Build Coastguard Worker const EGLAttrib *attrib_list)
63*61046927SAndroid Build Coastguard Worker {
64*61046927SAndroid Build Coastguard Worker if (platform == EGL_NONE) {
65*61046927SAndroid Build Coastguard Worker assert(native_display == (void *)EGL_DEFAULT_DISPLAY);
66*61046927SAndroid Build Coastguard Worker assert(attrib_list == NULL);
67*61046927SAndroid Build Coastguard Worker return eglGetDisplay((EGLNativeDisplayType)native_display);
68*61046927SAndroid Build Coastguard Worker } else {
69*61046927SAndroid Build Coastguard Worker return eglGetPlatformDisplay(platform, native_display, attrib_list);
70*61046927SAndroid Build Coastguard Worker }
71*61046927SAndroid Build Coastguard Worker }
72*61046927SAndroid Build Coastguard Worker
73*61046927SAndroid Build Coastguard Worker static void *
__eglGLVNDGetProcAddress(const char * procName)74*61046927SAndroid Build Coastguard Worker __eglGLVNDGetProcAddress(const char *procName)
75*61046927SAndroid Build Coastguard Worker {
76*61046927SAndroid Build Coastguard Worker if (strcmp(procName, "eglQueryString") == 0)
77*61046927SAndroid Build Coastguard Worker return (void *)__eglGLVNDQueryString;
78*61046927SAndroid Build Coastguard Worker
79*61046927SAndroid Build Coastguard Worker return (void *)eglGetProcAddress(procName);
80*61046927SAndroid Build Coastguard Worker }
81*61046927SAndroid Build Coastguard Worker
82*61046927SAndroid Build Coastguard Worker PUBLIC EGLAPI EGLBoolean
__egl_Main(uint32_t version,const __EGLapiExports * exports,__EGLvendorInfo * vendor,__EGLapiImports * imports)83*61046927SAndroid Build Coastguard Worker __egl_Main(uint32_t version, const __EGLapiExports *exports,
84*61046927SAndroid Build Coastguard Worker __EGLvendorInfo *vendor, __EGLapiImports *imports)
85*61046927SAndroid Build Coastguard Worker {
86*61046927SAndroid Build Coastguard Worker if (EGL_VENDOR_ABI_GET_MAJOR_VERSION(version) !=
87*61046927SAndroid Build Coastguard Worker EGL_VENDOR_ABI_MAJOR_VERSION)
88*61046927SAndroid Build Coastguard Worker return EGL_FALSE;
89*61046927SAndroid Build Coastguard Worker
90*61046927SAndroid Build Coastguard Worker __eglGLVNDApiExports = exports;
91*61046927SAndroid Build Coastguard Worker __eglInitDispatchStubs(exports);
92*61046927SAndroid Build Coastguard Worker
93*61046927SAndroid Build Coastguard Worker imports->getPlatformDisplay = __eglGLVNDGetPlatformDisplay;
94*61046927SAndroid Build Coastguard Worker imports->getSupportsAPI = _eglIsApiValid;
95*61046927SAndroid Build Coastguard Worker imports->getVendorString = __eglGLVNDGetVendorString;
96*61046927SAndroid Build Coastguard Worker imports->getProcAddress = __eglGLVNDGetProcAddress;
97*61046927SAndroid Build Coastguard Worker imports->getDispatchAddress = __eglDispatchFindDispatchFunction;
98*61046927SAndroid Build Coastguard Worker imports->setDispatchIndex = __eglSetDispatchIndex;
99*61046927SAndroid Build Coastguard Worker
100*61046927SAndroid Build Coastguard Worker return EGL_TRUE;
101*61046927SAndroid Build Coastguard Worker }
102