Add new feature for "auto_align"
authorSung-jae Park <nicesj.park@samsung.com>
Fri, 13 Jun 2014 05:50:45 +0000 (14:50 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Fri, 13 Jun 2014 05:50:45 +0000 (14:50 +0900)
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
include/abi.h
packaging/liblivebox-edje.spec
src/abi.c
src/script_port.c

index 3ddaec9..0f6a68c 100644 (file)
@@ -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
index 5c611d7..1ebc8e5 100644 (file)
@@ -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);
index b9375d1..4877fc3 100644 (file)
@@ -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
index 98a42c8..045f1ed 100644 (file)
--- 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 */
 
index d743d71..f28aece 100644 (file)
@@ -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) {