X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fvirtual_window.c;h=e1b4ca1160bdb8043e8fb1e1952d4df46c4a0a3e;hb=9648c63ba09461f7f28faac3d3c2c5d50e324c7c;hp=6b6e35294e207d320c25189204617897103e1499;hpb=141521c17442de9c44330d5008d053047cebc5a9;p=apps%2Fnative%2Fwidget%2Fwidget.git diff --git a/src/virtual_window.c b/src/virtual_window.c index 6b6e352..e1b4ca1 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -38,50 +39,16 @@ #include "widget.h" #include "widget_internal.h" #include "debug.h" +#include "binder.h" #define IS_GBAR 1 #define PUBLIC __attribute__((visibility("default"))) #define WIDGET_WIN_TAG "dynamic,box,win" +#define WIN_INFO_TAG "dynamic,box,info" #define WIDGET_DEFAULT_WIDTH 1 #define WIDGET_DEFAULT_HEIGHT 1 -#define GL_ENGINE "opengl_x11" - -static struct static_info { - Ecore_Evas *(*alloc_canvas)(int w, int h, void *(*a)(void *data, int size), void (*f)(void *data, void *ptr), void *data); - Ecore_Evas *(*alloc_canvas_with_stride)(int w, int h, void *(*a)(void *data, int size, int *stride, int *bpp), void (*f)(void *data, void *ptr), void *data); - Ecore_Evas *(*alloc_canvas_with_pixmap)(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h, Ecore_X_Pixmap (*alloc_cb)(void *data, Ecore_X_Window parent, int w, int h, int depth), void (*free_cb)(void *data, Ecore_X_Pixmap pixmap), void *data); -} s_info = { - .alloc_canvas = NULL, - .alloc_canvas_with_stride = NULL, - .alloc_canvas_with_pixmap = NULL, -}; - -/** - * @brief - * Abstracted Data Type of Virtual Window - */ -typedef struct virtual_window_info { - char *id; /**< Identification */ - widget_buffer_h handle; /**< Livebox buffer handle */ - enum win_type { - VWIN_SW_BUF = 0x00, /**< S/W buffer */ - VWIN_GEM = 0x01, /**< GEM buffer */ - VWIN_PIXMAP = 0x02, /**< PIXMAP */ - VWIN_ERROR = 0x03 /**< Unknown */ - } type; - Ecore_Evas *ee; - Evas *e; - int is_gbar; - int deleted; - int w; - int h; - unsigned int *resource_array; - int resource_cnt; - - int pressed; -} *vwin_info_t; static inline Evas_Object *get_highlighted_object(Evas_Object *obj) { @@ -94,6 +61,50 @@ static inline Evas_Object *get_highlighted_object(Evas_Object *obj) return ho; } +static inline void apply_orientation(int degree, int *x, int *y, int width, int height, input_event_source_e source) +{ + int _x; + int _y; + int _angle; + + if (source == INPUT_EVENT_SOURCE_VIEWER) { + /* Already rotated */ + return; + } + + _x = *x; + _y = *y; + + switch (degree) { + case 0: + return; + case 90: + *x = _y; + *y = width - _x; + return; + case 180: + *x = width - _x; + *y = height - _y; + return; + case 270: + *x = height - _y; + *y = _x; + return; + default: + /** + * @FIXME + * This rotation formular is not work correctly. + * The pointer should be rotated by other way. + * This is not what we want. + */ + _angle = degree; + + *x = (double)_x * cos((double)_angle) - (double)_y * sin((double)_angle); + *y = (double)_x * sin((double)_angle) + (double)_y * cos((double)_angle); + return; + } +} + /** * @note * Every user event (mouse) on the buffer will be passed via this event callback @@ -109,7 +120,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ unsigned int flags = 0; double timestamp; - if (!info->handle) { + if (!info || info->state != VWIN_INFO_CREATED || !info->handle) { /* Just ignore this event */ return 0; } @@ -183,6 +194,8 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ evas_event_feed_mouse_out(info->e, timestamp, NULL); break; case WIDGET_BUFFER_EVENT_DOWN: + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, info->w, info->h, event_info->info.pointer.source); + if (info->pressed) { ErrPrint("MOUSE UP is not called\n"); ErrPrint("UP[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); @@ -210,6 +223,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ ErrPrint("DOWN[%s] %dx%d - %lf\n", info->id, event_info->info.pointer.x, event_info->info.pointer.y, timestamp); break; case WIDGET_BUFFER_EVENT_MOVE: + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, info->w, info->h, event_info->info.pointer.source); /** * @note * Calculate the event occurred X & Y on the buffer @@ -217,6 +231,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); break; case WIDGET_BUFFER_EVENT_UP: + apply_orientation(info->orientation, &event_info->info.pointer.x, &event_info->info.pointer.y, info->w, info->h, event_info->info.pointer.source); evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, timestamp, NULL); evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, timestamp, NULL); info->pressed = 0; @@ -235,7 +250,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT; + action_type = 0; //ELM_ACCESS_ACTION_HIGHLIGHT; /** * @note * Calculate the event occurred X & Y on the buffer @@ -263,7 +278,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT; + action_type = 0; //ELM_ACCESS_ACTION_HIGHLIGHT_NEXT; action_info.highlight_cycle = EINA_FALSE; ret = elm_access_action(parent_elm, action_type, &action_info); ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_LAST : WIDGET_ACCESS_STATUS_DONE; @@ -275,7 +290,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV; + action_type = 0; //ELM_ACCESS_ACTION_HIGHLIGHT_PREV; action_info.highlight_cycle = EINA_FALSE; ret = elm_access_action(parent_elm, action_type, &action_info); ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_FIRST : WIDGET_ACCESS_STATUS_DONE; @@ -287,7 +302,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_ACTIVATE; + action_type = 0; //ELM_ACCESS_ACTION_ACTIVATE; ret = elm_access_action(parent_elm, action_type, &action_info); ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; break; @@ -298,7 +313,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UP; + action_type = 0; //ELM_ACCESS_ACTION_UP; ret = elm_access_action(parent_elm, action_type, &action_info); ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; break; @@ -309,7 +324,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_DOWN; + action_type = 0; //ELM_ACCESS_ACTION_DOWN; ret = elm_access_action(parent_elm, action_type, &action_info); ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; break; @@ -320,7 +335,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; + action_type = 0; //ELM_ACCESS_ACTION_SCROLL; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -334,7 +349,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; + action_type = 0; //ELM_ACCESS_ACTION_SCROLL; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -348,7 +363,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; + action_type = 0; //ELM_ACCESS_ACTION_SCROLL; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -362,7 +377,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT; + action_type = 0; //ELM_ACCESS_ACTION_UNHIGHLIGHT; ret = elm_access_action(parent_elm, action_type, &action_info); ret = (ret == EINA_FALSE) ? WIDGET_ACCESS_STATUS_ERROR : WIDGET_ACCESS_STATUS_DONE; break; @@ -373,7 +388,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_VALUE_CHANGE; + action_type = 0; //ELM_ACCESS_ACTION_VALUE_CHANGE; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -387,7 +402,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_MOUSE; + action_type = 0; //ELM_ACCESS_ACTION_MOUSE; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -401,7 +416,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_BACK; + action_type = 0; //ELM_ACCESS_ACTION_BACK; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -415,7 +430,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_OVER; + action_type = 0; //ELM_ACCESS_ACTION_OVER; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -429,7 +444,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_READ; + action_type = 0; //ELM_ACCESS_ACTION_READ; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -443,7 +458,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_ENABLE; + action_type = 0; //ELM_ACCESS_ACTION_ENABLE; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -457,7 +472,7 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ break; } memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_DISABLE; + action_type = 0; //ELM_ACCESS_ACTION_DISABLE; action_info.x = event_info->info.access.x; action_info.y = event_info->info.access.y; action_info.mouse_type = event_info->info.access.mouse_type; @@ -556,238 +571,11 @@ static int event_handler_cb(widget_buffer_h handler, struct widget_buffer_event_ return ret; } -/** - * @note - * This callback can be called twice (or more) to get a several pixmaps - * Acquired pixmaps are used for double/tripple buffering for canvas - */ -static Ecore_X_Pixmap alloc_pixmap_cb(void *data, Ecore_X_Window parent, int w, int h, int depth) -{ - vwin_info_t info = data; - Ecore_X_Pixmap pixmap; - - if (!info->handle) { - ErrPrint("Invalid handle\n"); - return 0u; - } - - info->w = w; - info->h = h; - DbgPrint("Size of ee is updated: %dx%d - %d (info: %p)\n", info->w, info->h, depth, info); - depth >>= 3; - - if (widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER) == 0u) { - /** - * @note - * Need to allocate a primary buffer - */ - widget_viewer_acquire_buffer(info->handle, WIDGET_PRIMARY_BUFFER, info->w, info->h, depth); - if (!info->handle) { - ErrPrint("Failed to get the buffer\n"); - return 0u; - } - - pixmap = (Ecore_X_Pixmap)widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER); - } else if (WIDGET_CONF_EXTRA_BUFFER_COUNT > 0) { - int idx; - - if (!info->resource_array) { - info->resource_array = calloc(WIDGET_CONF_EXTRA_BUFFER_COUNT, sizeof(*info->resource_array)); - if (!info->resource_array) { - ErrPrint("Out of memory: %d\n", errno); - return 0u; - } - - idx = 0; - } else { - for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) { - if (info->resource_array[idx] == 0u) { - break; - } - } - - if (idx == WIDGET_CONF_EXTRA_BUFFER_COUNT) { - ErrPrint("Out of index: %d\n", idx); - return 0u; - } - } - - if (widget_viewer_acquire_buffer(info->handle, idx, info->w, info->h, depth) < 0) { - ErrPrint("Failed to acquire a buffer for %d\n", idx); - return 0u; - } - - info->resource_array[idx] = widget_viewer_get_resource_id(info->handle, idx); - if (info->resource_array[idx] == 0u) { - ErrPrint("Failed to allocate pixmap\n"); - } - - DbgPrint("Allocated index: %d/%d - %u\n", idx, WIDGET_CONF_EXTRA_BUFFER_COUNT, info->resource_array[idx]); - pixmap = info->resource_array[idx]; - } else { - ErrPrint("Unable to allocate pixmap\n"); - pixmap = 0u; - } - - /** - * Acquire a buffer for canvas. - */ - info->type = VWIN_PIXMAP; - info->resource_cnt += !!(unsigned int)pixmap; - return pixmap; -} - -static void free_pixmap_cb(void *data, Ecore_X_Pixmap pixmap) -{ - vwin_info_t info = data; - - if (!info->handle) { - return; - } - - if (info->type != VWIN_PIXMAP) { - ErrPrint("Impossible\n"); - } - - if (widget_viewer_get_resource_id(info->handle, WIDGET_PRIMARY_BUFFER) == pixmap) { - if (widget_viewer_release_buffer(info->handle, WIDGET_PRIMARY_BUFFER) < 0) { - DbgPrint("Failed to release buffer\n"); - } - info->resource_cnt--; - } else { - int idx; - - for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) { - /** - * @note - * Find a index to release it - */ - if (info->resource_array[idx] == pixmap) { - if (widget_viewer_release_buffer(info->handle, idx) < 0) { - DbgPrint("Failed to release buffer\n"); - } - info->resource_array[idx] = 0u; - info->resource_cnt--; - break; - } - } - } - - if (info->deleted && info->resource_cnt == 0) { - DbgPrint("Destroy buffer handle\n"); - - widget_destroy_buffer(info->handle); - free(info->resource_array); - free(info->id); - free(info); - } -} - -static void *alloc_fb(void *data, int size) -{ - vwin_info_t info = data; - void *buffer; - - if (info->ee) { - ecore_evas_geometry_get(info->ee, NULL, NULL, &info->w, &info->h); - DbgPrint("Size of ee is updated: %dx%d (info: %p)\n", info->w, info->h, info); - } - - if (!info->handle) { - ErrPrint("Failed to create a buffer\n"); - return NULL; - } - - if (widget_viewer_acquire_buffer(info->handle, WIDGET_PRIMARY_BUFFER, info->w, info->h, sizeof(int)) < 0) { - ErrPrint("Failed to acquire buffer\n"); - return NULL; - } - - /** - * If it supports the H/W accelerated buffer, - * Use it. - */ - if (widget_support_hw_buffer(info->handle)) { - if (widget_create_hw_buffer(info->handle) == 0) { - buffer = widget_buffer_hw_buffer(info->handle); - if (buffer) { - DbgPrint("HW Accelerated buffer is created %p, (%dx%d)\n", info, info->w, info->h); - info->type = VWIN_GEM; - return buffer; - } - } - - ErrPrint("Failed to allocate HW Accelerated buffer\n"); - } - - /** - * Or use the buffer of a S/W backend. - */ - buffer = widget_ref_buffer(info->handle); - DbgPrint("SW buffer is created (%dx%d)\n", info->w, info->h); - info->type = VWIN_SW_BUF; - return buffer; -} - -static void *alloc_stride_fb(void *data, int size, int *stride, int *bpp) -{ - void *buffer; - - buffer = alloc_fb(data, size); - if (buffer) { - vwin_info_t info = data; - int _stride; - - *bpp = sizeof(int); - _stride = widget_buffer_stride(info->handle); - if (_stride < 0) { - _stride = info->w * *bpp; - } - - *stride = _stride; - *bpp <<= 3; - DbgPrint("bpp: %d, stride: %d\n", *bpp, *stride); - } - - return buffer; -} - -static void free_fb(void *data, void *ptr) -{ - vwin_info_t info = data; - - if (!info->handle) { - return; - } - - if (info->type == VWIN_GEM) { - if (widget_destroy_hw_buffer(info->handle) == 0) { - DbgPrint("HW Accelerated buffer is destroyed\n"); - } - } else if (info->type == VWIN_SW_BUF) { - DbgPrint("SW buffer is destroyed, %p\n", info); - widget_unref_buffer(ptr); - } else if (info->type == VWIN_PIXMAP) { - ErrPrint("Unable to reach to here\n"); - } - - if (widget_viewer_release_buffer(info->handle, WIDGET_PRIMARY_BUFFER) < 0) { - ErrPrint("Failed to release buffer\n"); - } - - if (info->deleted) { - widget_destroy_buffer(info->handle); - free(info->resource_array); - free(info->id); - free(info); - } -} - static void pre_render_cb(void *data, Evas *e, void *event_info) { vwin_info_t info = data; - if (!info->handle) { + if (!info || info->state != VWIN_INFO_CREATED || !info->handle) { return; } @@ -814,7 +602,7 @@ static void post_render_cb(void *data, Evas *e, void *event_info) { vwin_info_t info = data; - if (!info->handle) { + if (!info || info->state != VWIN_INFO_CREATED || !info->handle) { return; } @@ -863,10 +651,43 @@ static void post_render_cb(void *data, Evas *e, void *event_info) } } -static void pre_destroy_cb(const char *id, void *data) +static int pre_orientation_cb(const char *id, void *data) { vwin_info_t info = data; - char *path = NULL; + const char *path; + int orientation; + + /* Try provider_app first */ + if (!info || info->state != VWIN_INFO_CREATED || !id || !info->id) { + return WIDGET_ERROR_INVALID_PARAMETER; + } + + path = widget_util_uri_to_path(id); + if (path && strcmp(info->id, path)) { + /* Skip */ + DbgPrint("SKIP: Pre orientation event callback is called [%s], %s\n", id, info->id); + return WIDGET_ERROR_INVALID_PARAMETER; + } + + DbgPrint("Pre orientation event callback is called [%s]\n", id); + orientation = widget_get_orientation(path); + if (orientation < 0) { + ErrPrint("Failed to get orientation: %X\n", orientation); + } else { + info->orientation = orientation; + } + + return WIDGET_ERROR_NONE; +} + +static int pre_destroy_cb(const char *id, void *data) +{ + vwin_info_t info = data; + const char *path = NULL; + + if (!info || info->state != VWIN_INFO_CREATED) { + return WIDGET_ERROR_INVALID_PARAMETER; + } if (id) { path = widget_util_uri_to_path(id); @@ -874,7 +695,7 @@ static void pre_destroy_cb(const char *id, void *data) if (path && strcmp(info->id, path)) { /* Skip */ DbgPrint("SKIP: Pre destroy event callback is called [%s], %s\n", id, info->id); - return; + return WIDGET_ERROR_INVALID_PARAMETER; } } @@ -884,13 +705,15 @@ static void pre_destroy_cb(const char *id, void *data) DbgPrint("Toggle manual render mode to prevent from unwanted rendering"); ecore_evas_manual_render_set(info->ee, EINA_TRUE); } + + return WIDGET_ERROR_NONE; } static void ecore_evas_free_cb(Ecore_Evas *ee) { vwin_info_t info; - info = ecore_evas_data_get(ee, "dynamic,box,info"); + info = ecore_evas_data_get(ee, WIN_INFO_TAG); if (!info) { DbgPrint("Info is not valid\n"); return; @@ -914,8 +737,7 @@ PUBLIC Evas *widget_get_evas(const char *id) #endif /* WIDGET_FEATURE_GBAR_SUPPORTED */ { vwin_info_t info; - Evas_Object *rect; - const char *engine; + int orientation; /** * @TODO @@ -923,28 +745,6 @@ PUBLIC Evas *widget_get_evas(const char *id) * this function should returns ERROR. */ - if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride && !s_info.alloc_canvas_with_pixmap) { - s_info.alloc_canvas_with_pixmap = dlsym(RTLD_DEFAULT, "ecore_evas_gl_x11_pixmap_allocfunc_new"); - if (!s_info.alloc_canvas_with_pixmap) { - DbgPrint("pixmap_allocfunc_new is not found\n"); - } - - s_info.alloc_canvas_with_stride = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_with_stride_new"); - if (!s_info.alloc_canvas_with_stride) { - DbgPrint("allocfunc_with_stirde_new is not found\n"); - } - - s_info.alloc_canvas = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_new"); - if (!s_info.alloc_canvas) { - ErrPrint("allocfunc_new is not found\n"); - } - - if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas && !s_info.alloc_canvas_with_pixmap) { - ErrPrint("No way to allocate canvas\n"); - return NULL; - } - } - if (!id) { ErrPrint("Invalid parameter\n"); return NULL; @@ -956,9 +756,12 @@ PUBLIC Evas *widget_get_evas(const char *id) return NULL; } + info->state = VWIN_INFO_CREATED; + info->id = strdup(id); if (!info->id) { ErrPrint("Heap: %d\n", errno); + info->state = VWIN_INFO_DESTROYED; free(info); return NULL; } @@ -973,11 +776,12 @@ PUBLIC Evas *widget_get_evas(const char *id) * Acquire a buffer for canvas. */ info->handle = widget_create_buffer(info->id, info->is_gbar, - (widget_conf_auto_align() || !s_info.alloc_canvas_with_stride), + binder_widget_auto_align(), event_handler_cb, info); if (!info->handle) { ErrPrint("Failed to create a widget buffer\n"); + info->state = VWIN_INFO_DESTROYED; free(info->id); free(info); return NULL; @@ -989,34 +793,17 @@ PUBLIC Evas *widget_get_evas(const char *id) info->w = WIDGET_DEFAULT_WIDTH; info->h = WIDGET_DEFAULT_HEIGHT; - engine = elm_config_preferred_engine_get(); - DbgPrint("Preferred engine: %s (%s)\n", engine, GL_ENGINE); - if (engine && !strcmp(engine, GL_ENGINE)) { - if (s_info.alloc_canvas_with_pixmap) { - info->ee = s_info.alloc_canvas_with_pixmap(NULL, 0u, 0, 0, info->w, info->h, alloc_pixmap_cb, free_pixmap_cb, info); - if (!info->ee) { - ErrPrint("Unable to create a ee for pixmap\n"); - } - } - } - - if (!info->ee) { - if (!widget_conf_auto_align() && s_info.alloc_canvas_with_stride) { - info->ee = s_info.alloc_canvas_with_stride(info->w, info->h, alloc_stride_fb, free_fb, info); - } else if (s_info.alloc_canvas) { - info->ee = s_info.alloc_canvas(info->w, info->h, alloc_fb, free_fb, info); - } - } - + info->ee = binder_ecore_evas_new(info); if (!info->ee) { ErrPrint("Failed to create ecore_evas (%dx%d)\n", info->w, info->h); widget_destroy_buffer(info->handle); + info->state = VWIN_INFO_DESTROYED; free(info->id); free(info); return NULL; } - ecore_evas_data_set(info->ee, "dynamic,box,info", info); + ecore_evas_data_set(info->ee, WIN_INFO_TAG, info); /** * @note @@ -1042,6 +829,14 @@ PUBLIC Evas *widget_get_evas(const char *id) evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info); widget_add_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, pre_destroy_cb, info); + widget_add_pre_callback(WIDGET_PRE_ORIENTATION_CALLBACK, pre_orientation_cb, info); + + orientation = widget_get_orientation(info->id); + if (orientation < 0) { + ErrPrint("Failed to get orientation[%s]: %X\n", info->id, orientation); + } else { + info->orientation = orientation; + } return info->e; }