2 * Copyright (C) 2013 libhybris
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 static struct ws_module
*ws
= NULL
;
26 static void _init_ws()
33 // Mesa uses EGL_PLATFORM for its own purposes.
34 // Add HYBRIS_EGLPLATFORM to avoid the conflicts
35 egl_platform
=getenv("HYBRIS_EGLPLATFORM");
37 if (egl_platform
== NULL
)
38 egl_platform
=getenv("EGL_PLATFORM");
40 if (egl_platform
== NULL
)
41 egl_platform
= DEFAULT_EGL_PLATFORM
;
43 snprintf(ws_name
, 2048, PKGLIBDIR
"eglplatform_%s.so", egl_platform
);
45 void *wsmod
= (void *) dlopen(ws_name
, RTLD_LAZY
);
48 fprintf(stderr
, "ERROR: %s\n\t%s\n", ws_name
, dlerror());
51 ws
= dlsym(wsmod
, "ws_module_info");
57 int ws_IsValidDisplay(EGLNativeDisplayType display
)
60 return ws
->IsValidDisplay(display
);
63 EGLNativeWindowType
ws_CreateWindow(EGLNativeWindowType win
, EGLNativeDisplayType display
)
66 return ws
->CreateWindow(win
, display
);
69 void ws_DestroyWindow(EGLNativeWindowType win
)
72 return ws
->DestroyWindow(win
);
75 __eglMustCastToProperFunctionPointerType
ws_eglGetProcAddress(const char *procname
)
78 return ws
->eglGetProcAddress(procname
);
81 void ws_passthroughImageKHR(EGLContext
*ctx
, EGLenum
*target
, EGLClientBuffer
*buffer
, const EGLint
**attrib_list
)
84 return ws
->passthroughImageKHR(ctx
, target
, buffer
, attrib_list
);
87 const char *ws_eglQueryString(EGLDisplay dpy
, EGLint name
, const char *(*real_eglQueryString
)(EGLDisplay dpy
, EGLint name
))
90 return ws
->eglQueryString(dpy
, name
, real_eglQueryString
);
93 // vim:ts=4:sw=4:noexpandtab