Commit | Line | Data |
---|---|---|
d42e7319 JB |
1 | #include <ws.h> |
2 | #include <dlfcn.h> | |
3 | #include <stdlib.h> | |
4 | ||
5 | #include <hybris/internal/binding.h> | |
6 | ||
7 | static void * (*_androidCreateDisplaySurface)(); | |
8 | ||
9 | static void *_libui = NULL; | |
10 | ||
11 | static void _init_androidui() | |
12 | { | |
13 | _libui = (void *) android_dlopen("/system/lib/libui.so", RTLD_LAZY); | |
14 | } | |
15 | ||
16 | #define UI_DLSYM(fptr, sym) do { if (_libui == NULL) { _init_androidui(); }; if (*(fptr) == NULL) { *(fptr) = (void *) android_dlsym(_libui, sym); } } while (0) | |
17 | ||
18 | static EGLNativeWindowType android_createDisplaySurface() | |
19 | { | |
20 | UI_DLSYM(&_androidCreateDisplaySurface, "android_createDisplaySurface"); | |
21 | return (EGLNativeWindowType) (*_androidCreateDisplaySurface)(); | |
22 | } | |
23 | ||
24 | ||
25 | ||
26 | static int nullws_IsValidDisplay(EGLNativeDisplayType display) | |
27 | { | |
28 | return 1; | |
29 | } | |
30 | ||
31 | static EGLNativeWindowType nullws_CreateWindow(EGLNativeWindowType win, EGLNativeDisplayType display) | |
32 | { | |
33 | if (win == 0) | |
34 | { | |
35 | return android_createDisplaySurface(); | |
36 | } | |
37 | else | |
38 | return win; | |
39 | } | |
40 | ||
41 | static void nullws_DestroyWindow(EGLNativeWindowType win) | |
42 | { | |
43 | // TODO: Cleanup? | |
44 | } | |
45 | ||
46 | static __eglMustCastToProperFunctionPointerType nullws_eglGetProcAddress(const char *procname) | |
47 | { | |
48 | return NULL; | |
49 | } | |
50 | ||
51 | static void nullws_passthroughImageKHR(EGLContext *ctx, EGLenum *target, EGLClientBuffer *buffer, const EGLint **attrib_list) | |
52 | { | |
53 | } | |
54 | ||
55 | const char *nullws_eglQueryString(EGLDisplay dpy, EGLint name, const char *(*real_eglQueryString)(EGLDisplay dpy, EGLint name)) | |
56 | { | |
57 | return (*real_eglQueryString)(dpy, name); | |
58 | } | |
59 | ||
60 | ||
61 | struct ws_module ws_module_info = { | |
62 | nullws_IsValidDisplay, | |
63 | nullws_CreateWindow, | |
64 | nullws_DestroyWindow, | |
65 | nullws_eglGetProcAddress, | |
66 | nullws_passthroughImageKHR, | |
67 | nullws_eglQueryString | |
68 | }; | |
69 |