From 6396f9f5229466230747e03b64ab711176e17d77 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 6 Jun 2017 08:30:23 +0200 Subject: [PATCH] wineandroid: Load the gralloc module in all processes. Signed-off-by: Alexandre Julliard --- dlls/wineandroid.drv/android.h | 2 ++ dlls/wineandroid.drv/init.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index 3d9ac5adee6..bfdd69707a6 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -107,4 +107,6 @@ int send_event( const union event_data *data ); extern JavaVM *wine_get_java_vm(void); extern jobject wine_get_java_object(void); +extern struct gralloc_module_t *gralloc_module; + #endif /* __WINE_ANDROID_H */ diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index ecf32adca56..45117bc9bc2 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -402,6 +402,31 @@ static const JNINativeMethod methods[] = DECL_FUNCPTR( __android_log_print ); DECL_FUNCPTR( ANativeWindow_fromSurface ); DECL_FUNCPTR( ANativeWindow_release ); +DECL_FUNCPTR( hw_get_module ); + +struct gralloc_module_t *gralloc_module = NULL; + +static void load_hardware_libs(void) +{ + const struct hw_module_t *module; + void *libhardware; + char error[256]; + + if ((libhardware = wine_dlopen( "libhardware.so", RTLD_GLOBAL, error, sizeof(error) ))) + { + LOAD_FUNCPTR( libhardware, hw_get_module ); + } + else + { + ERR( "failed to load libhardware: %s\n", error ); + return; + } + + if (phw_get_module( GRALLOC_HARDWARE_MODULE_ID, &module ) == 0) + gralloc_module = (struct gralloc_module_t *)module; + else + ERR( "failed to load gralloc module\n" ); +} static void load_android_libs(void) { @@ -433,6 +458,8 @@ static BOOL process_attach(void) JNIEnv *jni_env; JavaVM *java_vm; + load_hardware_libs(); + if ((java_vm = wine_get_java_vm())) /* running under Java */ { #ifdef __i386__