enum buffer_type { /*!< Must have to be sync with libprovider, liblivebox-viewer */
BUFFER_TYPE_FILE,
BUFFER_TYPE_SHM,
+ BUFFER_TYPE_PIXMAP,
BUFFER_TYPE_ERROR,
};
PD_EVENT_MAX = 0xFFFFFFFF,
};
+/* Exported to user app */
enum livebox_lb_type {
LB_TYPE_IMAGE = 0x01,
LB_TYPE_BUFFER = 0x02,
evas_object_image_colorspace_set(info->box, EVAS_COLORSPACE_ARGB8888);
evas_object_image_alpha_set(info->box, EINA_TRUE);
evas_object_image_fill_set(info->box, 0, 0, w, h);
- evas_object_image_data_copy_set(info->box, fb);
+ evas_object_image_data_set(info->box, fb);
evas_object_image_data_update_add(info->box, 0, 0, w, h);
+ evas_object_image_reload(info->box);
evas_object_event_callback_add(info->box, EVAS_CALLBACK_MOUSE_DOWN, lb_mouse_down_cb, info);
evas_object_event_callback_add(info->box, EVAS_CALLBACK_MOUSE_MOVE, lb_mouse_move_cb, info);
static inline int create_new_pd(struct livebox *handler)
{
struct box_info *info;
+ Evas_Coord w, h;
info = find_box_info(handler);
if (!info)
if (info->pd)
return -EEXIST;
- info->pd = evas_object_image_add(evas_object_evas_get(s_info.win));
+ livebox_get_pdsize(handler, &w, &h);
+
+ info->pd = evas_object_image_filled_add(evas_object_evas_get(s_info.win));
if (!info->pd) {
fprintf(stderr, "Failed to add an image object for pd\n");
} else {
- Evas_Coord w, h;
Evas_Coord x, y;
void *fb;
- livebox_get_pdsize(handler, &w, &h);
fprintf(stderr, "PDSize: %dx%d\n", w, h);
fb = livebox_acquire_pdfb(handler);
if (fb) {
evas_object_image_fill_set(info->pd, 0, 0, w, h);
fprintf(stderr, "PD ptr: %p\n", fb);
- evas_object_image_data_copy_set(info->pd, fb);
+ evas_object_image_data_set(info->pd, fb);
evas_object_image_data_update_add(info->pd, 0, 0, w, h);
evas_object_resize(info->pd, w, h);
if (s_info.w != w)
evas_object_event_callback_add(info->pd, EVAS_CALLBACK_MOUSE_DOWN, pd_mouse_down_cb, info);
evas_object_event_callback_add(info->pd, EVAS_CALLBACK_MOUSE_MOVE, pd_mouse_move_cb, info);
evas_object_event_callback_add(info->pd, EVAS_CALLBACK_MOUSE_UP, pd_mouse_up_cb, info);
- fprintf(stderr, "PD created: %p\n", fb);
+ evas_object_image_reload(info->pd);
+ fprintf(stderr, "PD created: %p (%dx%d)\n", fb, x, y);
livebox_release_pdfb(fb);
}
}
y += ((oh - h) / 2);
evas_object_move(box, x, y);
- if (ow != w || oh != h) {
- evas_object_image_size_set(box, w, h);
- evas_object_image_fill_set(box, 0, 0, w, h);
- evas_object_image_data_copy_set(box, buffer);
- evas_object_resize(box, w, h);
- }
+ evas_object_image_size_set(box, w, h);
+ evas_object_image_fill_set(box, 0, 0, w, h);
+ evas_object_resize(box, w, h);
+ evas_object_image_data_set(box, buffer);
evas_object_image_data_update_add(box, 0, 0, w, h);
evas_object_show(box);
}
if (fb) {
fprintf(stderr, "pd: updated %p\n", fb);
reload_buffer(info->box, fb, 1.0, w, h);
+ evas_object_image_reload(info->box);
livebox_release_fb(fb);
} else {
fprintf(stderr, ">>>>>>>>>>> Buffer is not exists\n");
if (fb) {
fprintf(stderr, "pd: updated %p\n", fb);
reload_buffer(info->pd, fb, 1.0, w, h);
+ evas_object_image_reload(info->pd);
livebox_release_pdfb(fb);
} else {
fprintf(stderr, "!!!!!!!!!!!!!!! pd buffer is not valid\n");
int h = 0;
livebox_init();
- livebox_subscribe_group("*", "*");
+// livebox_subscribe_group("*", "*");
s_info.win = elm_win_add(NULL, "test", ELM_WIN_BASIC);
if (!s_info.win)
if (lb_text_lb(handler)) {
lb_set_size(handler, lb_w, lb_h);
ret = parse_desc(handler, URI_TO_PATH(id), 0);
+ /*!
+ * \note
+ * DESC parser will call the "text event callback".
+ */
goto out;
- }
-
- if (lb_get_lb_fb(handler)) {
+ } else if (lb_get_lb_fb(handler)) {
lb_set_size(handler, lb_w, lb_h);
lb_set_lb_fb(handler, fbfile);
ret = fb_sync(lb_get_lb_fb(handler));
FB_TYPE_UNKNOWN,
FB_TYPE_FILE,
FB_TYPE_SHM,
+ FB_TYPE_PIXMAP,
} type;
char *id;
int w;
return 0;
}
- if (info->type == FB_TYPE_UNKNOWN) {
+ if (info->type != FB_TYPE_FILE) {
DbgPrint("Ingore sync\n");
return 0;
}
info->handle = -EINVAL;
} else if (sscanf(info->id, "shm://%d", &info->handle) == 1) {
info->type = FB_TYPE_SHM;
+ } else if (sscanf(info->id, "pixmap://%d", &info->handle) == 1) {
+ info->type = FB_TYPE_PIXMAP;
} else {
info->type = FB_TYPE_FILE;
info->handle = -EINVAL;
}
buffer->type = BUFFER_TYPE_FILE;
- } else {
+ buffer->refcnt = 1;
+ buffer->state = CREATED;
+ } else if (info->type == FB_TYPE_SHM) {
DbgPrint("SHMID: %d\n", info->handle);
+ if (info->handle < 0) {
+ DbgPrint("SHM is not prepared yet\n");
+ info->bufsz = 0;
+ return 0;
+ }
buffer = shmat(info->handle, NULL, 0);
- if (!buffer) {
+ if (buffer == (void *)-1) {
ErrPrint("shmat: %s\n", strerror(errno));
info->bufsz = 0;
return -EFAULT;
}
-
- buffer->type = BUFFER_TYPE_SHM;
+ } else if (info->type == FB_TYPE_PIXMAP) {
+ buffer = NULL;
+ ErrPrint("pixmap is not supported yet\n");
+ } else {
+ ErrPrint("Invalid FB type\n");
+ return -EINVAL;
}
- buffer->refcnt = 1;
- buffer->state = CREATED;
+
info->buffer = buffer;
DbgPrint("FB allocated (%p)\n", info->buffer);
{
struct buffer *buffer;
- if (!info)
+ if (!info) {
+ ErrPrint("info == NIL\n");
return NULL;
+ }
buffer = info->buffer;
- if (!buffer)
+ if (!buffer) {
+ ErrPrint("info->buffer == NIL\n");
return NULL;
+ }
+
+ if (buffer->type == BUFFER_TYPE_SHM) {
+ buffer = shmat(info->handle, NULL, 0);
+ if (buffer == (void *)-1) {
+ ErrPrint("shmat: %s\n", strerror(errno));
+ return NULL;
+ }
+ } else if (buffer->type == BUFFER_TYPE_PIXMAP) {
+ ErrPrint("Pixmap is not supported yet\n");
+ return NULL;
+ } else {
+ buffer->refcnt++;
+ DbgPrint("FB acquired (%p) %d\n", buffer, buffer->refcnt);
+ }
- buffer->refcnt++;
return buffer->data;
}
struct buffer *buffer;
if (!data) {
- DbgPrint("Here?\n");
+ DbgPrint("buffer data == NIL\n");
return 0;
}
return -EINVAL;
}
- buffer->refcnt--;
- if (buffer->refcnt == 0) {
- DbgPrint("FB released (%p)\n", buffer);
- buffer->state = DESTROYED;
-
- if (buffer->type == BUFFER_TYPE_SHM) {
- if (shmdt(buffer) < 0)
- ErrPrint("shmdt: %s\n", strerror(errno));
- } else if (buffer->type == BUFFER_TYPE_FILE) {
- free(buffer);
+ if (buffer->type == BUFFER_TYPE_SHM) {
+ if (shmdt(buffer) < 0)
+ ErrPrint("shmdt: %s\n", strerror(errno));
+ } else if (buffer->type == BUFFER_TYPE_PIXMAP) {
+ ErrPrint("Pixmap is not supported yet\n");
+ return -ENOTSUP;
+ } else {
+ buffer->refcnt--;
+ if (buffer->refcnt == 0) {
+ DbgPrint("FB released (%p)\n", buffer);
+ buffer->state = DESTROYED;
+
+ if (buffer->type == BUFFER_TYPE_SHM) {
+ if (shmdt(buffer) < 0)
+ ErrPrint("shmdt: %s\n", strerror(errno));
+ } else if (buffer->type == BUFFER_TYPE_FILE) {
+ free(buffer);
+ }
+ } else {
+ DbgPrint("FB decrease[%p] refcnt: %d\n", buffer, buffer->refcnt);
}
}
int fb_refcnt(void *data)
{
struct buffer *buffer;
+ int ret;
if (!data)
return -EINVAL;
return -EINVAL;
}
- return buffer->refcnt;
+ if (buffer->type == BUFFER_TYPE_SHM) {
+ struct shmid_ds buf;
+
+ if (shmctl(buffer->refcnt, IPC_STAT, &buf) < 0) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ return -EFAULT;
+ }
+
+ ret = buf.shm_nattch;
+ } else if (buffer->type == BUFFER_TYPE_PIXMAP) {
+ ErrPrint("Pixmap is not supported yet\n");
+ return -ENOTSUP;
+ } else {
+ ret = buffer->refcnt;
+ }
+
+ return ret;
}
const char *fb_id(struct fb_info *info)
*w = handler->pd.width;
*h = handler->pd.height;
+
+ switch (handler->pd.type) {
+ case _PD_TYPE_BUFFER:
+ case _PD_TYPE_SCRIPT:
+ if (!fb_is_created(handler->pd.data.fb)) {
+ DbgPrint("Buffer is not created yet - reset size\n");
+ *w = 0;
+ *h = 0;
+ }
+ break;
+ default:
+ break;
+ }
+
return 0;
}
*w = handler->lb.width;
*h = handler->lb.height;
+
+ switch (handler->lb.type) {
+ case _LB_TYPE_BUFFER:
+ case _LB_TYPE_SCRIPT:
+ if (!fb_is_created(handler->lb.data.fb)) {
+ DbgPrint("Buffer is not created yet - reset size\n");
+ *w = 0;
+ *h = 0;
+ }
+ break;
+ default:
+ break;
+ }
+
return 0;
}
return NULL;
}
- if (handler->state != CREATE || !handler->id || handler->lb.type != _LB_TYPE_SCRIPT) {
- ErrPrint("Handler is not valid\n");
+ if (handler->state != CREATE || !handler->id) {
+ ErrPrint("Invalid handle\n");
+ return NULL;
+ }
+
+ if (handler->lb.type != _LB_TYPE_SCRIPT && handler->lb.type != _LB_TYPE_BUFFER) {
+ ErrPrint("Handler is not valid type\n");
return NULL;
}
EAPI int livebox_release_fb(void *buffer)
{
- DbgPrint("Release buffer: %p\n", buffer);
return fb_release_buffer(buffer);
}
return NULL;
}
- if (handler->state != CREATE || !handler->id || handler->pd.type != _PD_TYPE_SCRIPT) {
- ErrPrint("Handler is not valid\n");
+ if (handler->state != CREATE || !handler->id) {
+ ErrPrint("Invalid handler\n");
+ return NULL;
+ }
+
+ if (handler->pd.type != _PD_TYPE_SCRIPT && handler->pd.type != _PD_TYPE_BUFFER) {
+ ErrPrint("Handler is not valid type\n");
return NULL;
}
void lb_set_size(struct livebox *handler, int w, int h)
{
+ DbgPrint("LB[%s] Size: %dx%d\n", util_basename(fb_id(handler->lb.data.fb)), w, h);
handler->lb.width = w;
handler->lb.height = h;
}
void lb_set_pdsize(struct livebox *handler, int w, int h)
{
+ DbgPrint("PD[%s] Size: %dx%d\n", util_basename(fb_id(handler->pd.data.fb)), w, h);
handler->pd.width = w;
handler->pd.height = h;
}
return -EFAULT;
}
- handler->lb.type = _LB_TYPE_SCRIPT;
if (fb)
fb_destroy(fb);
return 0;
return -EFAULT;
}
- handler->pd.type = _PD_TYPE_SCRIPT;
if (fb)
fb_destroy(fb);
return 0;