return ret;
}
-EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_create_handle(char *id, int surface_id,
- screen_connector_toolkit_ops *ops, void *data)
+EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add_by_rid(screen_connector_toolkit_ops *ops, char *id,
+ screen_connector_screen_type_e type, int surface_id, void *data)
{
screen_connector_toolkit_h toolkit_h = NULL;
screen_connector_toolkit_ops *ops_copy;
+ screen_connector_type_h type_h;
+
+ type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type));
+ if (type_h == NULL) {
+ LOGE("type %d is not initialized !!", type);
+ return NULL;
+ }
ops_copy = (screen_connector_toolkit_ops *)calloc(1, sizeof(screen_connector_toolkit_ops));
if (ops_copy == NULL) {
toolkit_h->instance_id = strdup(id);
toolkit_h->data = data;
toolkit_h->ops = ops_copy;
+ toolkit_h->type_h = type_h;
+
+ if (type_h->toolkit_table == NULL)
+ type_h->toolkit_table = g_hash_table_new_full(g_str_hash,
+ g_str_equal, free, __destroy_toolkit_h);
+
+ g_hash_table_insert(type_h->toolkit_table, strdup(id), toolkit_h);
+
+ if (type_h->aul_handle == NULL)
+ aul_screen_connector_add_screen_viewer(__aul_screen_viewer_cb, type, true, type_h, &type_h->aul_handle);
+
+ screen_connector_toolkit_redirect_surface(toolkit_h);
return toolkit_h;
}
#include <tizen-remote-surface-client-protocol.h>
#include <tbm_surface.h>
#include <tbm_surface_internal.h>
+#include <uuid/uuid.h>
#include "screen_connector_toolkit.h"
#include "screen_connector_toolkit_evas.h"
Evas_Object *viewer_win;
};
+struct _cur_buffer_info_h {
+ struct wl_buffer *cur_buffer;
+ int ref_count;
+};
+typedef struct _cur_buffer_info_h *cur_buffer_info_h;
+
struct _screen_connector_toolkit_evas_h {
screen_connector_toolkit_evas_ops *ops;
screen_connector_toolkit_h toolkit_h;
Evas_Object *img_tbm;
Evas_Object *img_file;
uint32_t img_type;
- struct wl_buffer *pre_buffer;
+ struct wl_buffer *cur_buffer;
struct _screen_connector_type_evas_h *type_h;
guint resuming_timer;
void *data;
};
+static GHashTable *__cur_buffer_table = NULL;
static GHashTable *__type_table = NULL;
static Ecore_Event_Handler *__visibility_listener;
static int __delayed_resuming_time;
free(type_h);
}
+static void __cur_buffer_info_ref(cur_buffer_info_h info)
+{
+ info->ref_count++;
+}
+
+static void __cur_buffer_info_unref(struct tizen_remote_surface *trs, cur_buffer_info_h info)
+{
+ tbm_surface_h cur_tbm_surface;
+
+ info->ref_count--;
+ if (info->ref_count == 0) {
+ tizen_remote_surface_release(trs, info->cur_buffer);
+ cur_tbm_surface = (tbm_surface_h)wl_buffer_get_user_data(info->cur_buffer);
+ tbm_surface_internal_unref(cur_tbm_surface);
+ g_hash_table_remove(__cur_buffer_table, info->cur_buffer);
+ }
+}
+
+static void __destroy_cur_buffer(gpointer data)
+{
+ cur_buffer_info_h info = (cur_buffer_info_h)data;
+
+ if (!info)
+ return;
+
+ if (info->cur_buffer)
+ wl_buffer_destroy(info->cur_buffer);
+
+ free(info);
+}
+
static void __clear_img_tbm(screen_connector_toolkit_evas_h toolkit_evas_h)
{
char *plug_id;
if (__type_table == NULL)
__type_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __destroy_type_h);
+ if (__cur_buffer_table == NULL)
+ __cur_buffer_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __destroy_cur_buffer);
+
type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type));
if (type_h == NULL) {
type_h = (screen_connector_type_evas_h)calloc(1, sizeof(struct _screen_connector_type_evas_h));
if (g_hash_table_size(__type_table) == 0) {
g_hash_table_destroy(__type_table);
__type_table = NULL;
+
+ if (__cur_buffer_table)
+ g_hash_table_destroy(__cur_buffer_table);
+ __cur_buffer_table = NULL;
}
__delayed_resuming_time = 0;
char format[] = "png";
char plug_id[256];
screen_connector_toolkit_evas_h toolkit_evas_h;
- tbm_surface_h pre_tbm_surface;
+ cur_buffer_info_h c_buf_info;
toolkit_evas_h = (screen_connector_toolkit_evas_h)data;
if (toolkit_evas_h->img_tbm == NULL) {
evas_object_image_native_surface_set(toolkit_evas_h->img_tbm, NULL); /* set null to previous object for the tbm type */
}
- if (toolkit_evas_h->pre_buffer) {
+ if (toolkit_evas_h->cur_buffer) {
if (tizen_remote_surface_get_version(trs) >= TIZEN_REMOTE_SURFACE_RELEASE_SINCE_VERSION) {
- tizen_remote_surface_release(trs, toolkit_evas_h->pre_buffer);
- pre_tbm_surface = (tbm_surface_h)wl_buffer_get_user_data(toolkit_evas_h->pre_buffer);
- tbm_surface_internal_unref(pre_tbm_surface);
- wl_buffer_destroy(toolkit_evas_h->pre_buffer);
+ c_buf_info = g_hash_table_lookup(__cur_buffer_table, toolkit_evas_h->cur_buffer);
+ if (c_buf_info != NULL)
+ __cur_buffer_info_unref(trs, c_buf_info);
}
}
- toolkit_evas_h->pre_buffer = tbm;
+
+ toolkit_evas_h->cur_buffer = tbm;
+ c_buf_info = g_hash_table_lookup(__cur_buffer_table, toolkit_evas_h->cur_buffer);
+ if (c_buf_info == NULL) {
+ c_buf_info = (cur_buffer_info_h)calloc(1, sizeof(struct _cur_buffer_info_h));
+ c_buf_info->cur_buffer = toolkit_evas_h->cur_buffer;
+ __cur_buffer_info_ref(c_buf_info);
+ g_hash_table_insert(__cur_buffer_table, toolkit_evas_h->cur_buffer, c_buf_info);
+ } else {
+ __cur_buffer_info_ref(c_buf_info);
+ }
if (is_added) {
LOGD("call added !!!! %s, type %d", appid, type);
__clear_img_file(toolkit_evas_h);
}
} else {
- LOGD("call updated !!!! %s, type %d", appid, type);
if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) {
toolkit_evas_h->ops->updated_cb(appid, instance_id, pid, toolkit_evas_h->img_file,
toolkit_evas_h->data);
screen_connector_toolkit_evas_ops *evas_ops;
screen_connector_toolkit_ops toolkit_ops;
screen_connector_type_evas_h type_h;
- char rid_str[32];
+ char id_str[70];
+ char uuid[37];
+ uuid_t u;
type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type));
if (type_h == NULL) {
handle->data = data;
handle->type_h = type_h;
- snprintf(rid_str, sizeof(rid_str), "%d", res_id);
- handle->toolkit_h = screen_connector_toolkit_create_handle(rid_str, res_id, &toolkit_ops, handle);
- screen_connector_toolkit_redirect_surface(handle->toolkit_h);
+ uuid_generate(u);
+ uuid_unparse(u, uuid);
+ snprintf(id_str, sizeof(id_str), "%s:%d", uuid, res_id);
+ handle->toolkit_h = screen_connector_toolkit_add_by_rid(&toolkit_ops, id_str, type, res_id, handle);
return handle;
}