egl: fold Android logger into main/
authorEmil Velikov <emil.velikov@collabora.com>
Thu, 4 May 2017 18:10:21 +0000 (19:10 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Mon, 8 May 2017 14:33:51 +0000 (15:33 +0100)
Will allow us to greatly simplify a lot of the code in egllog.c

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Chad Versace <chadversary@chromium.org>
src/egl/drivers/dri2/egl_dri2.h
src/egl/drivers/dri2/platform_android.c
src/egl/main/egllog.c

index f16663712d3f5328d705325cd0d8ce8e1f2600e1..b1e224248cce491b6f4a2395165962777ebfd27c 100644 (file)
@@ -59,7 +59,6 @@
 #include <system/window.h>
 #include <hardware/gralloc.h>
 #include <gralloc_drm_handle.h>
-#include <cutils/log.h>
 
 #endif /* HAVE_ANDROID_PLATFORM */
 
index b7276997879219b02f0b790ab489c01edc2c5be7..49cbeb4698e265b468942469e923100b92eccf8e 100644 (file)
@@ -1045,38 +1045,6 @@ droid_open_device(struct dri2_egl_display *dri2_dpy)
    return (fd >= 0) ? fcntl(fd, F_DUPFD_CLOEXEC, 3) : -1;
 }
 
-/* support versions < JellyBean */
-#ifndef ALOGW
-#define ALOGW LOGW
-#endif
-#ifndef ALOGD
-#define ALOGD LOGD
-#endif
-#ifndef ALOGI
-#define ALOGI LOGI
-#endif
-
-static void
-droid_log(EGLint level, const char *msg)
-{
-   switch (level) {
-   case _EGL_DEBUG:
-      ALOGD("%s", msg);
-      break;
-   case _EGL_INFO:
-      ALOGI("%s", msg);
-      break;
-   case _EGL_WARNING:
-      ALOGW("%s", msg);
-      break;
-   case _EGL_FATAL:
-      LOG_FATAL("%s", msg);
-      break;
-   default:
-      break;
-   }
-}
-
 static struct dri2_egl_display_vtbl droid_display_vtbl = {
    .authenticate = NULL,
    .create_window_surface = droid_create_window_surface,
@@ -1133,8 +1101,6 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
    const char *err;
    int ret;
 
-   _eglSetLogProc(droid_log);
-
    loader_set_logger(_eglLog);
 
    dri2_dpy = calloc(1, sizeof(*dri2_dpy));
index c830748290295fa8aa19ed33755275fe568eef96..9d7e93023413f67f5a79a1a1abc1bcc63b244581 100644 (file)
 
 #include "egllog.h"
 
+#ifdef HAVE_ANDROID_PLATFORM
+#define LOG_TAG "EGL-MAIN"
+#include <cutils/log.h>
+
+/* support versions < JellyBean */
+#ifndef ALOGW
+#define ALOGW LOGW
+#endif
+#ifndef ALOGD
+#define ALOGD LOGD
+#endif
+#ifndef ALOGI
+#define ALOGI LOGI
+#endif
+
+#endif /* HAVE_ANDROID_PLATFORM */
+
 #define MAXSTRING 1000
 #define FALLBACK_LOG_LEVEL _EGL_WARNING
 
@@ -107,7 +124,26 @@ _eglSetLogProc(_EGLLogProc logger)
 static void
 _eglDefaultLogger(EGLint level, const char *msg)
 {
+#ifdef HAVE_ANDROID_PLATFORM
+   switch (level) {
+   case _EGL_DEBUG:
+      ALOGD("%s", msg);
+      break;
+   case _EGL_INFO:
+      ALOGI("%s", msg);
+      break;
+   case _EGL_WARNING:
+      ALOGW("%s", msg);
+      break;
+   case _EGL_FATAL:
+      LOG_FATAL("%s", msg);
+      break;
+   default:
+      break;
+   }
+#else
    fprintf(stderr, "libEGL %s: %s\n", level_strings[level], msg);
+#endif /* HAVE_ANDROID_PLATFORM */
 }