From 9e34ab777d36a4f190749248f79e0a458a307055 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Fri, 13 Jun 2014 14:50:45 +0900 Subject: [PATCH] Add new feature for "auto_align" it should be supported by ECORE. by default, it will be 1. if the ecore_evas support manual stride, auto_align could be 0 Change-Id: If28025e4e3772d9ac05be5798f6eaf8d8670fe5b --- CMakeLists.txt | 1 + include/abi.h | 4 +++- packaging/liblivebox-edje.spec | 2 +- src/abi.c | 45 ++++++++++++++++++++++++++++++++++++++++++ src/script_port.c | 43 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ddaec9..0f6a68c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ ADD_DEFINITIONS("${EXTRA_CFLAGS} -g -Wall -Werror") ADD_DEFINITIONS("-DNDEBUG") ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET") ADD_DEFINITIONS("-DLOG_TAG=\"LIVEBOX_EDJE\"") +ADD_DEFINITIONS("-DAUTO_ALIGN=1") ADD_LIBRARY(${PROJECT_NAME} SHARED src/script_port.c diff --git a/include/abi.h b/include/abi.h index 5c611d7..1ebc8e5 100644 --- a/include/abi.h +++ b/include/abi.h @@ -22,7 +22,9 @@ extern void *script_buffer_pixmap_find(int pixmap); extern void *script_buffer_pixmap_buffer(void *handle); extern int script_buffer_lock(void *handle); extern int script_buffer_unlock(void *handle); - +extern int script_buffer_stride(void *handle); +extern int script_buffer_auto_align(void); +extern int script_buffer_pixels(void *handle); extern void *script_buffer_fb(void *handle); extern int script_buffer_get_size(void *handle, int *w, int *h); diff --git a/packaging/liblivebox-edje.spec b/packaging/liblivebox-edje.spec index b9375d1..4877fc3 100644 --- a/packaging/liblivebox-edje.spec +++ b/packaging/liblivebox-edje.spec @@ -1,6 +1,6 @@ Name: liblivebox-edje Summary: EDJE Script loader for the data provider master -Version: 0.6.4 +Version: 0.7.0 Release: 1 Group: HomeTF/Livebox License: Flora diff --git a/src/abi.c b/src/abi.c index 98a42c8..045f1ed 100644 --- a/src/abi.c +++ b/src/abi.c @@ -383,5 +383,50 @@ int script_buffer_signal_emit(void *buffer_handle, const char *part, const char return signal_emit(buffer_handle, part, signal, x, y, ex, ey); } +int script_buffer_stride(void *handle) +{ + static int (*buffer_stride)(void *handle) = NULL; + + if (!buffer_stride) { + buffer_stride = dlsym(RTLD_DEFAULT, "buffer_handler_stride"); + if (!buffer_stride) { + ErrPrint("broken ABI: %s\n", dlerror()); + return LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + } + + return buffer_stride(handle); +} + +int script_buffer_auto_align(void) +{ + static int (*buffer_auto_align)(void) = NULL; + + if (!buffer_auto_align) { + buffer_auto_align = dlsym(RTLD_DEFAULT, "buffer_handler_auto_align"); + if (!buffer_auto_align) { + ErrPrint("borken ABI: %s\n", dlerror()); + return LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + } + + return buffer_auto_align(); +} + +int script_buffer_pixels(void *handle) +{ + static int (*buffer_pixels)(void *handle) = NULL; + + if (!buffer_pixels) { + buffer_pixels = dlsym(RTLD_DEFAULT, "buffer_handler_pixels"); + if (!buffer_pixels) { + ErrPrint("broken ABI: %s\n", dlerror()); + return LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + } + + return buffer_pixels(handle); +} + /* End of a file */ diff --git a/src/script_port.c b/src/script_port.c index d743d71..f28aece 100644 --- a/src/script_port.c +++ b/src/script_port.c @@ -1640,6 +1640,7 @@ static void render_post_cb(void *data, Evas *e, void *event_info) } } +#if AUTO_ALIGN static void *alloc_fb(void *data, int size) { struct info *handle = data; @@ -1651,6 +1652,40 @@ static void *alloc_fb(void *data, int size) return script_buffer_fb(handle->buffer_handle); } +#else +static void *alloc_fb(void *data, int size, int *stride, int *bpp) +{ + struct info *handle = data; + int _stride; + int _bpp; + + _bpp = script_buffer_pixels(handle->buffer_handle); + if (_bpp < 0) { + ErrPrint("Failed to get pixel size, fallback to 4\n"); + _bpp = sizeof(int); + } + + _stride = script_buffer_stride(handle->buffer_handle); + if (_stride < 0) { + int w = 0; + + ecore_evas_geometry_get(handle->ee, NULL, NULL, &w, NULL); + + _stride = w * _bpp; + ErrPrint("Failed to get stride info, fallback to %d\n", _stride); + } + + *stride = _stride; + *bpp = _bpp; + + if (script_buffer_load(handle->buffer_handle) < 0) { + ErrPrint("Failed to load buffer handler\n"); + return NULL; + } + + return script_buffer_fb(handle->buffer_handle); +} +#endif static void free_fb(void *data, void *ptr) { @@ -1700,11 +1735,19 @@ static int create_ecore_evas(struct info *handle, int *w, int *h) return LB_STATUS_SUCCESS; } +#if AUTO_ALIGN handle->ee = ecore_evas_buffer_allocfunc_new(*w, *h, alloc_fb, free_fb, handle); if (!handle->ee) { ErrPrint("Failed to create a buffer\n"); return LB_STATUS_ERROR_FAULT; } +#else + handle->ee = ecore_evas_buffer_allocfunc_with_stride_new(*w, *h, alloc_fb, free_fb, handle); + if (!handle->ee) { + ErrPrint("Failed to create a buffer\n"); + return LB_STATUS_ERROR_FAULT; + } +#endif handle->e = ecore_evas_get(handle->ee); if (!handle->e) { -- 2.7.4