diff options
author | Chia-I Wu <[email protected]> | 2011-11-25 11:59:02 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2011-11-25 12:34:33 +0800 |
commit | 75cc24c876059d6eb183e07ed802f997fb416864 (patch) | |
tree | d54eaf925a263684e7086a8671db540636e0660d /src/gallium/winsys/sw/android/android_sw_winsys.cpp | |
parent | 42c2c371d6c4c82c3e9176e028281a91edfadafd (diff) |
android: add support for ICS
With ICS (Android 4.0), several headers and structs are renamed. Define
ANDROID_VERSION so that we can choose a different path depending on the
platform version.
I've tested only softpipe and llvmpipe. r600g is also reported to work.
Diffstat (limited to 'src/gallium/winsys/sw/android/android_sw_winsys.cpp')
-rw-r--r-- | src/gallium/winsys/sw/android/android_sw_winsys.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/gallium/winsys/sw/android/android_sw_winsys.cpp b/src/gallium/winsys/sw/android/android_sw_winsys.cpp index 02faf1e0cca..f9b90044ac5 100644 --- a/src/gallium/winsys/sw/android/android_sw_winsys.cpp +++ b/src/gallium/winsys/sw/android/android_sw_winsys.cpp @@ -32,10 +32,12 @@ #include "util/u_format.h" #include "state_tracker/sw_winsys.h" +#include <hardware/gralloc.h> #include <utils/Errors.h> -#include <private/ui/sw_gralloc_handle.h> -#include <hardware/gralloc.h> +#if ANDROID_VERSION < 0x0300 +#include <private/ui/sw_gralloc_handle.h> +#endif #include "android_sw_winsys.h" @@ -105,14 +107,17 @@ android_displaytarget_unmap(struct sw_winsys *ws, struct android_sw_winsys *droid = android_sw_winsys(ws); struct android_sw_displaytarget *adt = android_sw_displaytarget(dt); +#if ANDROID_VERSION < 0x0300 + /* try sw_gralloc first */ + if (adt->mapped && sw_gralloc_handle_t::validate(adt->handle) >= 0) { + adt->mapped = NULL; + return; + } +#endif + if (adt->mapped) { - if (sw_gralloc_handle_t::validate(adt->handle) >= 0) { - adt->mapped = NULL; - } - else { - droid->grmod->unlock(droid->grmod, adt->handle); - adt->mapped = NULL; - } + droid->grmod->unlock(droid->grmod, adt->handle); + adt->mapped = NULL; } } @@ -124,17 +129,21 @@ android_displaytarget_map(struct sw_winsys *ws, struct android_sw_winsys *droid = android_sw_winsys(ws); struct android_sw_displaytarget *adt = android_sw_displaytarget(dt); +#if ANDROID_VERSION < 0x0300 + /* try sw_gralloc first */ + if (sw_gralloc_handle_t::validate(adt->handle) >= 0) { + const sw_gralloc_handle_t *swhandle = + reinterpret_cast<const sw_gralloc_handle_t *>(adt->handle); + adt->mapped = reinterpret_cast<void *>(swhandle->base); + + return adt->mapped; + } +#endif + if (!adt->mapped) { - if (sw_gralloc_handle_t::validate(adt->handle) >= 0) { - const sw_gralloc_handle_t *swhandle = - reinterpret_cast<const sw_gralloc_handle_t *>(adt->handle); - adt->mapped = reinterpret_cast<void *>(swhandle->base); - } - else { - /* lock the buffer for CPU access */ - droid->grmod->lock(droid->grmod, adt->handle, - adt->usage, 0, 0, adt->width, adt->height, &adt->mapped); - } + /* lock the buffer for CPU access */ + droid->grmod->lock(droid->grmod, adt->handle, + adt->usage, 0, 0, adt->width, adt->height, &adt->mapped); } return adt->mapped; |