Imported Debian patch 0.1.0+git20131207+e452e83-0ubuntu12
[deb_libhybris.git] / hybris / egl / platforms / null / eglplatform_null.c
... / ...
CommitLineData
1#include <ws.h>
2#include <dlfcn.h>
3#include <stdlib.h>
4
5#include <hybris/internal/binding.h>
6
7static void * (*_androidCreateDisplaySurface)();
8
9static void *_libui = NULL;
10
11static 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
18static EGLNativeWindowType android_createDisplaySurface()
19{
20 UI_DLSYM(&_androidCreateDisplaySurface, "android_createDisplaySurface");
21 return (EGLNativeWindowType) (*_androidCreateDisplaySurface)();
22}
23
24
25
26static int nullws_IsValidDisplay(EGLNativeDisplayType display)
27{
28 return 1;
29}
30
31static 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
41static void nullws_DestroyWindow(EGLNativeWindowType win)
42{
43 // TODO: Cleanup?
44}
45
46static __eglMustCastToProperFunctionPointerType nullws_eglGetProcAddress(const char *procname)
47{
48 return NULL;
49}
50
51static void nullws_passthroughImageKHR(EGLContext *ctx, EGLenum *target, EGLClientBuffer *buffer, const EGLint **attrib_list)
52{
53}
54
55const 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
61struct 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