#include "e_client_intern.h"
#include "e_comp_object_intern.h"
-#include <wtz-blender-server-protocol.h>
+#include <libds-tizen/blender.h>
-static E_Blender *_blender = NULL;
-
-static void _e_blend_surface_set(E_Blend *blend, struct wl_resource *surface);
+typedef struct _E_Blender E_Blender;
+typedef struct _E_Blend E_Blend;
-static void
-_e_blend_cb_destroy(struct wl_client *client,
- struct wl_resource *resource)
+struct _E_Blender
{
- wl_resource_destroy(resource);
-}
+ struct ds_tizen_blender *tizen_blender;
-static void
-_e_blend_cb_set_alpha(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t value)
-{
- E_Blend *blend;
-
- blend = wl_resource_get_user_data(resource);
- if (!blend) return;
- if (!blend->surface) return;
- if (blend->alpha == value) return;
-
- blend->alpha = value;
- blend->changed = EINA_TRUE;
-
- ELOGF("E_BLENDER", "E_Blend:%p set alpha:%x",
- e_client_from_surface_resource(blend->surface), blend, value);
-}
+ struct wl_listener destroy_listener;
+ struct wl_listener new_blend_listener;
+};
-static void
-_e_blend_cb_set_equation(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t equation)
+struct _E_Blend
{
- E_Blend *blend;
-
- blend = wl_resource_get_user_data(resource);
- if (!blend) return;
- if (!blend->surface) return;
- if (blend->equation == equation) return;
+ struct ds_tizen_blend *tizen_blend;
+ struct wl_listener commit_listener;
+ struct wl_listener destroy_listener;
- if ((equation != WTZ_BLEND_EQUATION_PREMULTIPLIED) &&
- (equation != WTZ_BLEND_EQUATION_NONE))
- {
- wl_resource_post_error(resource, WTZ_BLEND_ERROR_INVALID_EQUATION,
- "Invalid equation");
- return;
- }
+ E_Client *ec;
+ E_Object_Delfn *ec_delfn;
- blend->equation = equation;
- blend->changed = EINA_TRUE;
+ uint32_t alpha;
+ enum ds_tizen_blend_equation equation;
+};
- ELOGF("E_BLENDER", "E_Blend:%p set equation:%d",
- e_client_from_surface_resource(blend->surface), blend, equation);
-}
+static E_Blender *_blender = NULL;
-static const struct wtz_blend_interface _e_blend_implementation = {
- _e_blend_cb_destroy,
- _e_blend_cb_set_alpha,
- _e_blend_cb_set_equation,
-};
+static void _e_blend_ec_set(E_Blend *blend, E_Client *ec);
static void
_e_blend_free(E_Blend *blend)
{
- ELOGF("E_BLENDER", "E_Blend:%p Free",
- blend->surface ? e_client_from_surface_resource(blend->surface) : NULL,
- blend);
-
- _e_blend_surface_set(blend, NULL);
- free(blend);
-}
+ ELOGF("E_BLENDER", "E_Blend:%p Free", blend->ec, blend);
-static void
-_e_blend_cb_surface_destroy(struct wl_listener *listener, void *data)
-{
- E_Blend *blend;
+ if (blend->ec)
+ {
+ e_comp_object_render_op_set(blend->ec->frame, EVAS_RENDER_BLEND);
+ evas_object_color_set(blend->ec->frame, 255, 255, 255, 255);
+ }
- blend = container_of(listener, E_Blend, surface_destroy_listener);
+ _e_blend_ec_set(blend, NULL);
- if (blend->resource)
- _e_blend_surface_set(blend, NULL);
- else
- _e_blend_free(blend);
+ free(blend);
}
static void
-_e_blend_cb_surface_state_commit(struct wl_listener *listener, void *data)
+_e_blend_cb_ds_tizen_blend_commit(struct wl_listener *listener, void *data)
{
E_Blend *blend;
- E_Client *ec;
+ struct ds_tizen_blend_state *state;
int a, r, g, b;
- blend = container_of(listener, E_Blend, surface_state_commit_listener);
- if (!blend->changed) return;
+ blend = container_of(listener, E_Blend, commit_listener);
+ if (!blend) return;
+ if (!blend->ec) return;
- ec = e_client_from_surface_resource(blend->surface);
- if (!ec) return;
+ state = ds_tizen_blend_get_state(blend->tizen_blend);
+ if (!state) return;
- if (!blend->resource)
- {
- e_comp_object_render_op_set(ec->frame, EVAS_RENDER_BLEND);
- evas_object_color_set(ec->frame, 255, 255, 255, 255);
- _e_blend_free(blend);
- return;
- }
+ blend->alpha = state->alpha;
+ blend->equation = state->equation;
- if (!ec->argb) return;
+ if (!blend->ec->argb) return;
a = r = g = b = 255;
a = (int)((blend->alpha / (double)0xffffffff) * a);
evas_color_argb_premul(a, &r, &g, &b);
- evas_object_color_set(ec->frame, r, g, b, a);
+ evas_object_color_set(blend->ec->frame, r, g, b, a);
- if (blend->equation == WTZ_BLEND_EQUATION_PREMULTIPLIED)
- e_comp_object_render_op_set(ec->frame, EVAS_RENDER_BLEND);
- else if (blend->equation == WTZ_BLEND_EQUATION_NONE)
- e_comp_object_render_op_set(ec->frame, EVAS_RENDER_COPY);
-
- blend->changed = EINA_FALSE;
+ if (blend->equation == DS_TIZEN_BLEND_EQUATION_PREMULTIPLIED)
+ e_comp_object_render_op_set(blend->ec->frame, EVAS_RENDER_BLEND);
+ else if (blend->equation == DS_TIZEN_BLEND_EQUATION_NONE)
+ e_comp_object_render_op_set(blend->ec->frame, EVAS_RENDER_COPY);
}
static void
-_e_blend_surface_set(E_Blend *blend, struct wl_resource *surface)
+_e_blend_cb_ec_free(void *data, void *obj)
{
- E_Client *ec;
- E_Comp_Client_Data *cdata;
+ E_Blend *blend = data;
- if (blend->surface == surface) return;
+ blend->ec_delfn = NULL;
+ _e_blend_ec_set(blend, NULL);
+}
- if (blend->surface_destroy_listener.notify)
- {
- wl_list_remove(&blend->surface_destroy_listener.link);
- blend->surface_destroy_listener.notify = NULL;
- }
+static void
+_e_blend_ec_set(E_Blend *blend, E_Client *ec)
+{
+ if (blend->ec == ec) return;
- if (blend->surface_state_commit_listener.notify)
+ if (blend->ec)
{
- wl_list_remove(&blend->surface_state_commit_listener.link);
- blend->surface_state_commit_listener.notify = NULL;
- }
+ if (blend->ec_delfn)
+ {
+ e_object_delfn_del(E_OBJECT(blend->ec), blend->ec_delfn);
+ blend->ec_delfn = NULL;
+ }
- blend->surface = NULL;
+ blend->ec = NULL;
+ }
- if (surface)
+ if (ec)
{
- ec = e_client_from_surface_resource(surface);
- EINA_SAFETY_ON_NULL_RETURN(ec);
-
- cdata = e_client_cdata_get(ec);
- EINA_SAFETY_ON_NULL_RETURN(cdata);
-
- blend->surface = surface;
-
- blend->surface_destroy_listener.notify = _e_blend_cb_surface_destroy;
- wl_resource_add_destroy_listener(surface, &blend->surface_destroy_listener);
-
- blend->surface_state_commit_listener.notify = _e_blend_cb_surface_state_commit;
- wl_signal_add(&cdata->state_commit_signal, &blend->surface_state_commit_listener);
+ blend->ec_delfn = e_object_delfn_add(E_OBJECT(ec),
+ _e_blend_cb_ec_free,
+ blend);
+ blend->ec = ec;
}
}
static void
-_e_blend_cb_resource_destroy(struct wl_resource *resource)
+_e_blend_cb_ds_tizen_blend_destroy(struct wl_listener *listener, void *data)
{
E_Blend *blend;
- Evas_Render_Op render_op;
- E_Client *ec;
- int a;
- blend = wl_resource_get_user_data(resource);
+ blend = wl_container_of(listener, blend, destroy_listener);
if (!blend) return;
- if (blend->surface)
- {
- ec = e_client_from_surface_resource(blend->surface);
- if (ec)
- {
- e_comp_object_color_get(ec->frame, NULL, NULL, NULL, &a);
- render_op = e_comp_object_render_op_get(ec->frame);
- if ((a != 255) || (render_op != EVAS_RENDER_BLEND))
- {
- blend->resource = NULL;
- blend->changed = EINA_TRUE;
- return;
- }
- }
- }
-
_e_blend_free(blend);
}
static void
-_e_blender_cb_destroy(struct wl_client *client,
- struct wl_resource *resource)
-{
- wl_resource_destroy(resource);
-}
-
-static E_Blend *
-_e_blender_blend_get_from_surface(struct wl_resource *surface)
+_e_blender_cb_new_blend(struct wl_listener *listener, void *data)
{
+ E_Blender *blender = _blender;
+ struct ds_tizen_blend *tizen_blend = data;
E_Blend *blend;
- struct wl_listener *listener;
-
- listener = wl_resource_get_destroy_listener(surface, _e_blend_cb_surface_destroy);
- if (!listener) return NULL;
-
- return wl_container_of(listener, blend, surface_destroy_listener);
-}
-
-static void
-_e_blender_cb_get_blend(struct wl_client *client, struct wl_resource *resource,
- uint32_t id, struct wl_resource *surface)
-{
+ struct ds_surface *surface;
+ struct wl_resource *surface_resource;
E_Client *ec;
- E_Blend *blend = NULL;
- E_Blender *blender = _blender;
if (!blender)
{
- ERR("blender is not initialized");
+ ERR("blend is not initialized");
return;
}
- ec = e_client_from_surface_resource(surface);
- if ((!ec) || (e_object_is_del(E_OBJECT(ec))))
- {
- wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
- "invalid wl_surface resource:%u",
- (unsigned int)wl_resource_get_id(surface));
- goto fail;
- }
+ surface = ds_tizen_blend_get_surface(tizen_blend);
+ EINA_SAFETY_ON_NULL_RETURN(surface);
- blend = _e_blender_blend_get_from_surface(surface);
- if (blend)
- {
- if (blend->resource)
- {
- wl_resource_post_error(resource, WTZ_BLENDER_ERROR_BLEND_EXISTS,
- "blend object already exists");
- goto fail;
- }
- else
- {
- _e_blend_free(blend);
- }
- }
+ surface_resource = ds_surface_get_wl_resource(surface);
+ EINA_SAFETY_ON_NULL_RETURN(surface_resource);
- blend = E_NEW(E_Blend, 1);
- if (!blend)
- {
- wl_client_post_no_memory(client);
- goto fail;
- }
+ ec = e_client_from_surface_resource(surface_resource);
+ EINA_SAFETY_ON_NULL_RETURN(surface_resource);
- blend->resource = wl_resource_create(client,
- &wtz_blend_interface,
- wl_resource_get_version(resource),
- id);
- if (!blend->resource)
- {
- wl_client_post_no_memory(client);
- goto fail;
- }
+ blend = E_NEW(E_Blend, 1);
+ EINA_SAFETY_ON_NULL_RETURN(blend);
- wl_resource_set_implementation(blend->resource,
- &_e_blend_implementation,
- blend,
- _e_blend_cb_resource_destroy);
+ blend->destroy_listener.notify = _e_blend_cb_ds_tizen_blend_destroy;
+ ds_tizen_blend_add_destroy_listener(tizen_blend, &blend->destroy_listener);
- blend->alpha = 0xffffffff;
- _e_blend_surface_set(blend, surface);
+ blend->commit_listener.notify = _e_blend_cb_ds_tizen_blend_commit;
+ ds_tizen_blend_add_commit_listener(tizen_blend, &blend->commit_listener);
- ELOGF("E_BLENDER", "E_Blend:%p Create", ec, blend);
+ blend->tizen_blend = tizen_blend;
- return;
+ _e_blend_ec_set(blend, ec);
-fail:
- if (blend)
- free(blend);
+ ELOGF("E_BLENDER", "E_Blend:%p Create", ec, blend);
return;
}
-static const struct wtz_blender_interface _e_blender_implementation = {
- _e_blender_cb_destroy,
- _e_blender_cb_get_blend,
-};
-
static void
-_e_blender_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
+_e_blender_cb_destroy(struct wl_listener *listener, void *data)
{
- struct wl_resource *resource;
E_Blender *blender;
- blender = _blender;
- if (!blender) return;
+ blender = container_of(listener, E_Blender, destroy_listener);
- resource = wl_resource_create(client, &wtz_blender_interface, version, id);
- if (!resource)
- {
- wl_client_post_no_memory(client);
- return;
- }
+ free(blender);
- wl_resource_set_implementation(resource, &_e_blender_implementation,
- blender, NULL);
+ _blender = NULL;
}
EINTERN Eina_Bool
blender = E_NEW(E_Blender, 1);
EINA_SAFETY_ON_NULL_RETURN_VAL(blender, EINA_FALSE);
- blender->global = wl_global_create(e_comp_wl->wl.disp,
- &wtz_blender_interface,
- 1,
- blender,
- _e_blender_cb_bind);
- EINA_SAFETY_ON_NULL_GOTO(blender->global, fail);
+ blender->tizen_blender = ds_tizen_blender_create(e_comp_wl->wl.disp);
+ EINA_SAFETY_ON_NULL_GOTO(blender, fail);
+
+ blender->destroy_listener.notify = _e_blender_cb_destroy;
+ ds_tizen_blender_add_destroy_listener(blender->tizen_blender,
+ &blender->destroy_listener);
+
+ blender->new_blend_listener.notify = _e_blender_cb_new_blend;
+ ds_tizen_blender_add_new_blend_listener(blender->tizen_blender,
+ &blender->new_blend_listener);
_blender = blender;
return EINA_TRUE;
fail:
- if (blender->global)
- wl_global_destroy(blender->global);
-
- E_FREE(blender);
+ free(blender);
return EINA_FALSE;
}
-
-EINTERN void
-e_blender_shutdown(void)
-{
- E_Blender *blender;
-
- blender = _blender;
- if (!blender) return;
-
- wl_global_destroy(blender->global);
- E_FREE(blender);
-
- _blender = NULL;
-}