struct buffer_info *buffer;
} canvas;
+ struct buffer_info **extra_buffer;
+
double period;
} dbox;
struct buffer_info *buffer;
} canvas;
+ struct buffer_info **extra_buffer;
+
struct client_node *owner;
int is_opened_for_reactivate;
int need_to_send_close_event;
#endif
}
-
static int viewer_deactivated_cb(struct client_node *client, void *data)
{
struct inst_info *inst = data;
if (buffer_handler_destroy(inst->dbox.canvas.buffer) == (int)DBOX_STATUS_ERROR_NONE) {
inst->dbox.canvas.buffer = NULL;
}
+
+ if (inst->dbox.extra_buffer) {
+ int i;
+
+ for (i = 0; i < DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT; i++) {
+ if (!inst->dbox.extra_buffer[i]) {
+ continue;
+ }
+
+ (void)buffer_handler_unload(inst->dbox.extra_buffer[i]);
+ if (buffer_handler_destroy(inst->dbox.extra_buffer[i]) == (int)DBOX_STATUS_ERROR_NONE) {
+ inst->dbox.extra_buffer[i] = NULL;
+ }
+ }
+
+ DbgFree(inst->dbox.extra_buffer);
+ inst->dbox.extra_buffer = NULL;
+ }
}
if (gbar_type == GBAR_TYPE_SCRIPT) {
if (buffer_handler_destroy(inst->gbar.canvas.buffer) == (int)DBOX_STATUS_ERROR_NONE) {
inst->gbar.canvas.buffer = NULL;
}
+ if (inst->gbar.extra_buffer) {
+ int i;
+
+ for (i = 0; i < DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT; i++) {
+ if (!inst->gbar.extra_buffer[i]) {
+ continue;
+ }
+
+ (void)buffer_handler_unload(inst->gbar.extra_buffer[i]);
+ if (buffer_handler_destroy(inst->gbar.extra_buffer[i]) == (int)DBOX_STATUS_ERROR_NONE) {
+ inst->gbar.extra_buffer[i] = NULL;
+ }
+ }
+
+ DbgFree(inst->gbar.extra_buffer);
+ inst->gbar.extra_buffer = NULL;
+ }
}
if (inst->client) {
EINA_LIST_FREE(inst->delete_event_list, item) {
DbgFree(item);
}
+
DbgFree(inst->icon);
DbgFree(inst->name);
DbgFree(inst->category);
inst->unicast_delete_event = 1;
inst->state = INST_INIT;
inst->requested_state = INST_INIT;
+ if (DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT) {
+ inst->dbox.extra_buffer = calloc(DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT, sizeof(*inst->dbox.extra_buffer));
+ if (!inst->dbox.extra_buffer) {
+ ErrPrint("Failed to allocate buffer for dbox extra buffer\n");
+ }
+
+ inst->gbar.extra_buffer = calloc(DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT, sizeof(*inst->gbar.extra_buffer));
+ if (!inst->gbar.extra_buffer) {
+ ErrPrint("Failed to allocate buffer for gbar extra buffer\n");
+ }
+ }
instance_ref(inst);
if (package_add_instance(inst->info, inst) < 0) {
return !!inst->gbar.canvas.buffer;
}
+HAPI int instance_create_gbar_extra_buffer(struct inst_info *inst, int pixels, int idx)
+{
+ if (!inst->gbar.extra_buffer) {
+ return 0;
+ }
+
+ if (inst->gbar.width == 0 && inst->gbar.height == 0) {
+ instance_set_gbar_size(inst, package_gbar_width(inst->info), package_gbar_height(inst->info));
+ }
+
+ if (!inst->gbar.extra_buffer[idx]) {
+ inst->gbar.extra_buffer[idx] = buffer_handler_create(inst, s_info.env_buf_type, inst->gbar.width, inst->gbar.height, pixels);
+ if (!inst->gbar.extra_buffer[idx]) {
+ ErrPrint("Failed to create GBAR Extra Buffer\n");
+ }
+ }
+
+ return !!inst->gbar.extra_buffer[idx];
+}
+
HAPI int instance_create_dbox_buffer(struct inst_info *inst, int pixels)
{
if (inst->dbox.width == 0 && inst->dbox.height == 0) {
return !!inst->dbox.canvas.buffer;
}
+HAPI int instance_create_dbox_extra_buffer(struct inst_info *inst, int pixels, int idx)
+{
+ if (!inst->dbox.extra_buffer) {
+ return 0;
+ }
+
+ if (inst->dbox.width == 0 && inst->dbox.height == 0) {
+ dynamicbox_service_get_size(DBOX_SIZE_TYPE_1x1, &inst->dbox.width, &inst->dbox.height);
+ }
+
+ if (!inst->dbox.extra_buffer[idx]) {
+ inst->dbox.extra_buffer[idx] = buffer_handler_create(inst, s_info.env_buf_type, inst->dbox.width, inst->dbox.height, pixels);
+ if (!inst->dbox.extra_buffer[idx]) {
+ ErrPrint("Failed to create DBox Extra buffer\n");
+ }
+ }
+
+ return !!inst->dbox.extra_buffer[idx];
+}
+
HAPI int instance_destroy(struct inst_info *inst, dynamicbox_destroy_type_e type)
{
struct packet *packet;
return (package_gbar_type(inst->info) == GBAR_TYPE_BUFFER) ? inst->gbar.canvas.buffer : NULL;
}
+HAPI struct buffer_info *const instance_dbox_extra_buffer(const struct inst_info *inst, int idx)
+{
+ return (package_dbox_type(inst->info) == DBOX_TYPE_BUFFER) ? (inst->dbox.extra_buffer ? inst->dbox.extra_buffer[idx] : NULL) : NULL;
+}
+
+HAPI struct buffer_info *const instance_gbar_extra_buffer(const struct inst_info *inst, int idx)
+{
+ return (package_gbar_type(inst->info) == GBAR_TYPE_BUFFER) ? (inst->gbar.extra_buffer ? inst->gbar.extra_buffer[idx] : NULL) : NULL;
+}
+
HAPI const char *const instance_id(const struct inst_info *inst)
{
return inst->id;
return send_gbar_destroyed_to_client(inst, status);
}
+HAPI int instance_client_gbar_extra_buffer_created(struct inst_info *inst, int idx)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_GBAR_CREATE_XBUF;
+ int pixmap;
+
+ pixmap = buffer_handler_pixmap(inst->gbar.extra_buffer[idx]);
+ if (pixmap == 0) {
+ ErrPrint("Invalid buffer\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return CLIENT_SEND_EVENT(inst, packet);
+}
+
+HAPI int instance_client_gbar_extra_buffer_destroyed(struct inst_info *inst, int idx)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_GBAR_DESTROY_XBUF;
+ int pixmap;
+
+ pixmap = buffer_handler_pixmap(inst->gbar.extra_buffer[idx]);
+ if (pixmap == 0) {
+ ErrPrint("Invalid buffer\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return CLIENT_SEND_EVENT(inst, packet);
+}
+
+HAPI int instance_client_dbox_extra_buffer_created(struct inst_info *inst, int idx)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_DBOX_CREATE_XBUF;
+ int pixmap;
+
+ pixmap = buffer_handler_pixmap(inst->dbox.extra_buffer[idx]);
+ if (pixmap == 0) {
+ ErrPrint("Invalid buffer\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return CLIENT_SEND_EVENT(inst, packet);
+}
+
+HAPI int instance_client_dbox_extra_buffer_destroyed(struct inst_info *inst, int idx)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_DBOX_DESTROY_XBUF;
+ int pixmap;
+
+ pixmap = buffer_handler_pixmap(inst->dbox.extra_buffer[idx]);
+ if (pixmap == 0) {
+ ErrPrint("Invalid buffer\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return CLIENT_SEND_EVENT(inst, packet);
+}
+
HAPI int instance_add_client(struct inst_info *inst, struct client_node *client)
{
if (inst->client == client) {
}
out:
- result = packet_create_reply(packet, "i", ret);
+ result = packet_create_reply(packet, "ii", ret, DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT);
if (!result) {
ErrPrint("Failed to create a packet\n");
}
return -1; /* Delete this callback */
}
+
+static struct packet *client_dbox_acquire_xpixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+{
+ struct packet *result;
+ const char *pkgname;
+ const char *id;
+ struct client_node *client;
+ struct inst_info *inst;
+ int ret;
+ int pixmap = 0;
+ void *buf_ptr;
+ struct buffer_info *buffer;
+ int idx;
+
+ client = client_find_by_rpc_handle(handle);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &idx);
+ if (ret != 3) {
+ ErrPrint("Parameter is not matched\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ if (idx >= DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT || idx < 0) {
+ DbgPrint("Index is not valid: %d\n", idx);
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto out;
+ }
+
+ buffer = instance_dbox_extra_buffer(inst, idx);
+ if (!buffer) {
+ ErrPrint("Extra buffer for %d is not available\n", idx);
+ goto out;
+ }
+
+ buf_ptr = buffer_handler_pixmap_ref(buffer);
+ if (!buf_ptr) {
+ ErrPrint("Failed to ref pixmap\n");
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ goto out;
+ }
+
+ ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
+ if (ret < 0) {
+ ErrPrint("Failed to add a new client deactivate callback\n");
+ buffer_handler_pixmap_unref(buf_ptr);
+ } else {
+ pixmap = buffer_handler_pixmap(buffer);
+ ret = DBOX_STATUS_ERROR_NONE;
+ }
+
+out:
+ result = packet_create_reply(packet, "ii", pixmap, ret);
+ if (!result) {
+ ErrPrint("Failed to create a reply packet\n");
+ }
+
+ return result;
+}
+
static struct packet *client_dbox_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct packet *result;
}
out:
- /*! \note No reply packet */
+ /**
+ * @note No reply packet
+ */
return NULL;
}
+static struct packet *client_gbar_acquire_xpixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+{
+ struct packet *result;
+ const char *pkgname;
+ const char *id;
+ struct client_node *client;
+ struct inst_info *inst;
+ int ret;
+ int pixmap = 0;
+ void *buf_ptr;
+ struct buffer_info *buffer;
+ int idx;
+
+ client = client_find_by_rpc_handle(handle);
+ if (!client) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ ErrPrint("Client %d is not exists\n", pid);
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &idx);
+ if (ret != 3) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ ErrPrint("Parameter is not matched\n");
+ goto out;
+ }
+
+ if (idx >= DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT || idx < 0) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto out;
+ }
+
+ buffer = instance_gbar_extra_buffer(inst, idx);
+ if (!buffer) {
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ goto out;
+ }
+
+ buf_ptr = buffer_handler_pixmap_ref(buffer);
+ if (!buf_ptr) {
+ ErrPrint("Failed to ref pixmap\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto out;
+ }
+
+ ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
+ if (ret < 0) {
+ ErrPrint("Failed to add a new client deactivate callback\n");
+ buffer_handler_pixmap_unref(buf_ptr);
+ } else {
+ pixmap = buffer_handler_pixmap(buffer);
+ ret = DBOX_STATUS_ERROR_NONE;
+ }
+
+out:
+ result = packet_create_reply(packet, "ii", pixmap, ret);
+ if (!result) {
+ ErrPrint("Failed to create a reply packet\n");
+ }
+
+ return result;
+}
+
static struct packet *client_gbar_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct packet *result;
out:
result = packet_create_reply(packet, "is", ret, id);
if (!result) {
- ErrPrint("Failed to create a packet\n");
+ ErrPrint("Failed to create a reply packet\n");
+ }
+
+ return result;
+}
+
+static struct packet *slave_acquire_extra_buffer(pid_t pid, int handle, const struct packet *packet)
+{
+ struct slave_node *slave;
+ struct inst_info *inst;
+ struct packet *result;
+ const struct pkg_info *pkg;
+ const char *pkgname;
+ const char *id;
+ int pixel_size;
+ int target;
+ int idx;
+ int ret;
+ int w;
+ int h;
+
+ slave = slave_find_by_pid(pid);
+ if (!slave) {
+ ErrPrint("Slave %d is not exists\n", pid);
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ id = "";
+ goto out;
+ }
+
+ ret = packet_get(packet, "issiiii", &target, &pkgname, &id, &w, &h, &pixel_size, &idx);
+ if (ret != 7) {
+ ErrPrint("Invalid parameters\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ id = "";
+ goto out;
+ }
+
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ id = "";
+
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto out;
+ }
+
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+
+ if (instance_state(inst) == INST_DESTROYED) {
+ ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
+ goto out;
+ }
+
+ if (target == TYPE_DBOX && package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ struct buffer_info *info;
+
+ info = instance_dbox_extra_buffer(inst, idx);
+ if (!info) {
+ if (!instance_create_dbox_extra_buffer(inst, pixel_size, idx)) {
+ ErrPrint("Failed to create a DBOX buffer\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto out;
+ }
+
+ info = instance_dbox_extra_buffer(inst, idx);
+ if (!info) {
+ ErrPrint("DBOX extra buffer is not valid\n");
+ /*!
+ * \NOTE
+ * ret value should not be changed.
+ */
+ goto out;
+ }
+ }
+
+ ret = buffer_handler_resize(info, w, h);
+ ret = buffer_handler_load(info);
+ if (ret == 0) {
+ /**
+ * @todo
+ * Send the extra buffer info to the viewer.
+ * Then the viewer will try to acquire extra pixmap(aka, resource id) information
+ */
+ id = buffer_handler_id(info);
+ (void)instance_client_dbox_extra_buffer_created(inst, idx);
+ } else {
+ ErrPrint("Failed to load a buffer(%d)\n", ret);
+ }
+ } else if (target == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ struct buffer_info *info;
+
+ info = instance_gbar_extra_buffer(inst, idx);
+ if (!info) {
+ if (!instance_create_gbar_extra_buffer(inst, pixel_size, idx)) {
+ ErrPrint("Failed to create a GBAR buffer\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto out;
+ }
+
+ info = instance_gbar_extra_buffer(inst, idx);
+ if (!info) {
+ ErrPrint("GBAR buffer is not valid\n");
+ /*!
+ * \NOTE
+ * ret value should not be changed.
+ */
+ goto out;
+ }
+ }
+
+ ret = buffer_handler_resize(info, w, h);
+ ret = buffer_handler_load(info);
+ if (ret == 0) {
+ id = buffer_handler_id(info);
+ /**
+ * @todo
+ * Send the extra buffer acquired event to the viewer
+ */
+ (void)instance_client_gbar_extra_buffer_created(inst, idx);
+ } else {
+ ErrPrint("Failed to load a buffer (%d)\n", ret);
+ }
+ }
+
+out:
+ result = packet_create_reply(packet, "is", ret, id);
+ if (!result) {
+ ErrPrint("Failed to create a reply packet\n");
}
return result;
ret = validate_request(pkgname, id, &inst, &pkg);
id = "";
+
if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
gbar_monitor = instance_del_data(inst, GBAR_CLOSE_MONITOR_TAG);
if (!gbar_monitor && !package_is_fault(pkg)) {
ErrPrint("Slave requests to release a buffer\n");
- /*!
- * \note
+ /**
+ * @note
* In this case just keep going to release buffer,
* Even if a user(client) doesn't wants to destroy the GBAR.
*
* which will be checked by instance_client_gbar_destroyed function.
*/
- /*!
- * \note
+ /**
+ * @note
* provider can try to resize the buffer size.
* in that case, it will release the buffer first.
* Then even though the client doesn't request to close the GBAR,
}
} else {
if (gbar_monitor) {
- /*!
- * \note
+ /**
+ * @note
* If the instance has gbar_monitor, the pd close requested from client via client_destroy_gbar.
*/
slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
goto out;
}
} /* else {
- \note
+ @note
This case means that the package is faulted so the service provider tries to release the buffer
*/
info = instance_gbar_buffer(inst);
ret = buffer_handler_unload(info);
- /*!
- * \note
+ /**
+ * @note
* Send the GBAR destroyed event to the client
*/
instance_client_gbar_destroyed(inst, ret);
return result;
}
+static struct packet *slave_release_extra_buffer(pid_t pid, int handle, const struct packet *packet)
+{
+ struct slave_node *slave;
+ struct packet *result;
+ const char *id;
+ struct buffer_info *info = NULL;
+ int ret;
+ int idx;
+ int type;
+ const char *pkgname;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+
+ slave = slave_find_by_pid(pid);
+ if (!slave) {
+ ErrPrint("Slave %d is not exists\n", pid);
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ goto out;
+ }
+
+ if (packet_get(packet, "issi", &type, &pkgname, &id, &idx) != 4) {
+ ErrPrint("Inavlid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto out;
+ }
+
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+
+ if (type == TYPE_DBOX && package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ info = instance_dbox_extra_buffer(inst, idx);
+ (void)instance_client_dbox_extra_buffer_destroyed(inst, idx);
+ } else if (type == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ info = instance_gbar_extra_buffer(inst, idx);
+ (void)instance_client_gbar_extra_buffer_destroyed(inst, idx);
+ }
+
+ if (info) {
+ ret = buffer_handler_unload(info);
+ }
+
+out:
+ result = packet_create_reply(packet, "i", ret);
+ if (!result) {
+ ErrPrint("Failed to create a reply packet\n");
+ }
+
+ return result;
+}
+
static struct packet *service_instance_count(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
.cmd = CMD_STR_CLIENT_RESUMED,
.handler = client_resume_request,
},
+ {
+ .cmd = CMD_STR_DBOX_ACQUIRE_XPIXMAP,
+ .handler = client_dbox_acquire_xpixmap,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACQUIRE_XPIXMAP,
+ .handler = client_gbar_acquire_xpixmap,
+ },
{
.cmd = NULL,
},
{
+ .cmd = CMD_STR_ACQUIRE_XBUFFER,
+ .handler = slave_acquire_extra_buffer,
+ },
+ {
+ .cmd = CMD_STR_RELEASE_XBUFFER,
+ .handler = slave_release_extra_buffer,
+ },
+
+ {
.cmd = NULL,
.handler = NULL,
},