summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2013-05-02 16:13:28 +0800
committerChia-I Wu <olvaffe@gmail.com>2013-05-03 13:04:00 +0800
commit8b2a967e3250e2cb01d9651f2ccad25c0409a4eb (patch)
treefd08464aef8a63915ac88118735458707fbc142b
parent7346ab3b4344d648b2fd7fffe3b89b0b8923a26c (diff)
st/egl: fix bulid errors on Android 4.2
The differences from the previous releases that affect st/egl are - logging macros are prefixed with an 'A' - dequeueBuffer() and enqueueBuffer() require an additoinal argument for fence fd, acquired from libsync Additionally, include gralloc_drm.h with extern "C".
-rw-r--r--src/gallium/state_trackers/egl/android/native_android.cpp85
1 files changed, 62 insertions, 23 deletions
diff --git a/src/gallium/state_trackers/egl/android/native_android.cpp b/src/gallium/state_trackers/egl/android/native_android.cpp
index 391decc0e7a..82a9bb9cc7e 100644
--- a/src/gallium/state_trackers/egl/android/native_android.cpp
+++ b/src/gallium/state_trackers/egl/android/native_android.cpp
@@ -29,5 +29,12 @@
#if ANDROID_VERSION >= 0x0400
+
+#if ANDROID_VERSION >= 0x0402
+#include <sync/sync.h>
+#endif
+
#include <stdlib.h>
#include <system/window.h>
-#else
+
+#else /* ANDROID_VERSION >= 0x0400 */
+
#define android_native_buffer_t ANativeWindowBuffer
@@ -35,2 +42,11 @@
#include <ui/android_native_buffer.h>
+
+#endif /* ANDROID_VERSION >= 0x0400 */
+
+#if ANDROID_VERSION < 0x0402
+/* rename to old logging macros */
+#define ALOGE(...) LOGE(__VA_ARGS__)
+#define ALOGW(...) LOGW(__VA_ARGS__)
+#define ALOGI(...) LOGI(__VA_ARGS__)
+#define ALOGD(...) LOGD(__VA_ARGS__)
#endif
@@ -139,3 +155,3 @@ get_pipe_format(int native)
default:
- LOGE("unsupported native format 0x%x", native);
+ ALOGE("unsupported native format 0x%x", native);
fmt = PIPE_FORMAT_NONE;
@@ -149,3 +165,6 @@ get_pipe_format(int native)
+extern "C" {
#include <gralloc_drm.h>
+}
+
static int
@@ -178,3 +197,3 @@ import_buffer(struct android_display *adpy, const struct pipe_resource *templ,
templ->target, 0, PIPE_BIND_RENDER_TARGET))
- LOGW("importing unsupported buffer as render target");
+ ALOGW("importing unsupported buffer as render target");
}
@@ -183,3 +202,3 @@ import_buffer(struct android_display *adpy, const struct pipe_resource *templ,
templ->target, 0, PIPE_BIND_SAMPLER_VIEW))
- LOGW("importing unsupported buffer as sampler view");
+ ALOGW("importing unsupported buffer as sampler view");
}
@@ -194,3 +213,3 @@ import_buffer(struct android_display *adpy, const struct pipe_resource *templ,
if (!handle.handle) {
- LOGE("unable to import invalid buffer %p", abuf);
+ ALOGE("unable to import invalid buffer %p", abuf);
return NULL;
@@ -216,3 +235,3 @@ import_buffer(struct android_display *adpy, const struct pipe_resource *templ,
if (!res)
- LOGE("failed to import buffer %p", abuf);
+ ALOGE("failed to import buffer %p", abuf);
@@ -255,3 +274,3 @@ android_surface_add_cache(struct native_surface *nsurf,
if (!handle) {
- LOGE("invalid buffer native buffer %p", abuf);
+ ALOGE("invalid buffer native buffer %p", abuf);
return NULL;
@@ -265,3 +284,3 @@ android_surface_add_cache(struct native_surface *nsurf,
if (idx == Elements(asurf->cache_handles)) {
- LOGW("cache full: buf %p, width %d, height %d, format %d, usage 0x%x",
+ ALOGW("cache full: buf %p, width %d, height %d, format %d, usage 0x%x",
abuf, abuf->width, abuf->height, abuf->format, abuf->usage);
@@ -319,4 +338,19 @@ android_surface_dequeue_buffer(struct native_surface *nsurf)
+#if ANDROID_VERSION >= 0x0402
+ int fence_fd;
+
+ if (asurf->win->dequeueBuffer(asurf->win, &asurf->buf, &fence_fd) != NO_ERROR) {
+ ALOGE("failed to dequeue window %p", asurf->win);
+ return FALSE;
+ }
+
+ if (fence_fd >= 0) {
+ sync_wait(fence_fd, -1);
+ close(fence_fd);
+ }
+
+ asurf->buf->common.incRef(&asurf->buf->common);
+#else
if (asurf->win->dequeueBuffer(asurf->win, &asurf->buf) != NO_ERROR) {
- LOGE("failed to dequeue window %p", asurf->win);
+ ALOGE("failed to dequeue window %p", asurf->win);
return FALSE;
@@ -326,2 +360,3 @@ android_surface_dequeue_buffer(struct native_surface *nsurf)
asurf->win->lockBuffer(asurf->win, asurf->buf);
+#endif
@@ -346,3 +381,7 @@ android_surface_enqueue_buffer(struct native_surface *nsurf)
+#if ANDROID_VERSION >= 0x0402
+ asurf->win->queueBuffer(asurf->win, asurf->buf, -1);
+#else
asurf->win->queueBuffer(asurf->win, asurf->buf);
+#endif
@@ -507,3 +546,3 @@ android_display_create_window_surface(struct native_display *ndpy,
if (win->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
- LOGE("invalid native window with magic 0x%x", win->common.magic);
+ ALOGE("invalid native window with magic 0x%x", win->common.magic);
return NULL;
@@ -511,3 +550,3 @@ android_display_create_window_surface(struct native_display *ndpy,
if (win->query(win, NATIVE_WINDOW_FORMAT, &val)) {
- LOGE("failed to query native window format");
+ ALOGE("failed to query native window format");
return NULL;
@@ -516,3 +555,3 @@ android_display_create_window_surface(struct native_display *ndpy,
if (format != nconf->color_format) {
- LOGW("native window format 0x%x != config format 0x%x",
+ ALOGW("native window format 0x%x != config format 0x%x",
format, nconf->color_format);
@@ -520,3 +559,3 @@ android_display_create_window_surface(struct native_display *ndpy,
format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET)) {
- LOGE("and the native window cannot be used as a render target");
+ ALOGE("and the native window cannot be used as a render target");
return NULL;
@@ -573,3 +612,3 @@ android_display_init_configs(struct native_display *ndpy)
color_format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET)) {
- LOGI("skip unsupported native format 0x%x", native_formats[i]);
+ ALOGI("skip unsupported native format 0x%x", native_formats[i]);
continue;
@@ -614,3 +653,3 @@ android_display_init_drm(struct native_display *ndpy)
if (adpy->base.screen) {
- LOGI("using DRM screen");
+ ALOGI("using DRM screen");
return TRUE;
@@ -618,4 +657,4 @@ android_display_init_drm(struct native_display *ndpy)
else {
- LOGW("failed to create DRM screen");
- LOGW("will fall back to other EGL drivers if any");
+ ALOGW("failed to create DRM screen");
+ ALOGW("will fall back to other EGL drivers if any");
return FALSE;
@@ -637,3 +676,3 @@ android_display_init_sw(struct native_display *ndpy)
if (adpy->base.screen) {
- LOGI("using SW screen");
+ ALOGI("using SW screen");
return TRUE;
@@ -641,3 +680,3 @@ android_display_init_sw(struct native_display *ndpy)
else {
- LOGE("failed to create SW screen");
+ ALOGE("failed to create SW screen");
return FALSE;
@@ -732,3 +771,3 @@ android_display_import_buffer(struct native_display *ndpy,
abuf->common.version != sizeof(*abuf)) {
- LOGE("invalid android native buffer");
+ ALOGE("invalid android native buffer");
return NULL;
@@ -826,9 +865,9 @@ android_log(EGLint level, const char *msg)
case _EGL_DEBUG:
- LOGD("%s", msg);
+ ALOGD("%s", msg);
break;
case _EGL_INFO:
- LOGI("%s", msg);
+ ALOGI("%s", msg);
break;
case _EGL_WARNING:
- LOGW("%s", msg);
+ ALOGW("%s", msg);
break;