1 #include "e_blender_intern.h"
2 #include "e_client_intern.h"
3 #include "e_comp_object_intern.h"
5 #include <libds-tizen/blender.h>
7 typedef struct _E_Blender E_Blender;
8 typedef struct _E_Blend E_Blend;
12 struct ds_tizen_blender *tizen_blender;
14 struct wl_listener destroy_listener;
15 struct wl_listener new_blend_listener;
20 struct ds_tizen_blend *tizen_blend;
21 struct wl_listener commit_listener;
22 struct wl_listener destroy_listener;
25 E_Object_Delfn *ec_delfn;
28 enum ds_tizen_blend_equation equation;
31 static E_Blender *_blender = NULL;
33 static void _e_blend_ec_set(E_Blend *blend, E_Client *ec);
36 _e_blend_free(E_Blend *blend)
38 ELOGF("E_BLENDER", "E_Blend:%p Free", blend->ec, blend);
42 e_comp_object_render_op_set(blend->ec->frame, EVAS_RENDER_BLEND);
43 evas_object_color_set(blend->ec->frame, 255, 255, 255, 255);
46 _e_blend_ec_set(blend, NULL);
52 _e_blend_cb_ds_tizen_blend_commit(struct wl_listener *listener, void *data)
55 struct ds_tizen_blend_state *state;
58 blend = container_of(listener, E_Blend, commit_listener);
60 if (!blend->ec) return;
62 state = ds_tizen_blend_get_state(blend->tizen_blend);
65 blend->alpha = state->alpha;
66 blend->equation = state->equation;
68 if (!blend->ec->argb) return;
71 a = (int)((blend->alpha / (double)0xffffffff) * a);
72 evas_color_argb_premul(a, &r, &g, &b);
74 evas_object_color_set(blend->ec->frame, r, g, b, a);
76 if (blend->equation == DS_TIZEN_BLEND_EQUATION_PREMULTIPLIED)
77 e_comp_object_render_op_set(blend->ec->frame, EVAS_RENDER_BLEND);
78 else if (blend->equation == DS_TIZEN_BLEND_EQUATION_NONE)
79 e_comp_object_render_op_set(blend->ec->frame, EVAS_RENDER_COPY);
83 _e_blend_cb_ec_free(void *data, void *obj)
85 E_Blend *blend = data;
87 blend->ec_delfn = NULL;
88 _e_blend_ec_set(blend, NULL);
92 _e_blend_ec_set(E_Blend *blend, E_Client *ec)
94 if (blend->ec == ec) return;
100 e_object_delfn_del(E_OBJECT(blend->ec), blend->ec_delfn);
101 blend->ec_delfn = NULL;
109 blend->ec_delfn = e_object_delfn_add(E_OBJECT(ec),
117 _e_blend_cb_ds_tizen_blend_destroy(struct wl_listener *listener, void *data)
121 blend = wl_container_of(listener, blend, destroy_listener);
124 _e_blend_free(blend);
128 _e_blender_cb_new_blend(struct wl_listener *listener, void *data)
130 E_Blender *blender = _blender;
131 struct ds_tizen_blend *tizen_blend = data;
133 struct ds_surface *surface;
134 struct wl_resource *surface_resource;
139 ERR("blend is not initialized");
143 surface = ds_tizen_blend_get_surface(tizen_blend);
144 EINA_SAFETY_ON_NULL_RETURN(surface);
146 surface_resource = ds_surface_get_wl_resource(surface);
147 EINA_SAFETY_ON_NULL_RETURN(surface_resource);
149 ec = e_client_from_surface_resource(surface_resource);
150 EINA_SAFETY_ON_NULL_RETURN(surface_resource);
152 blend = E_NEW(E_Blend, 1);
153 EINA_SAFETY_ON_NULL_RETURN(blend);
155 blend->destroy_listener.notify = _e_blend_cb_ds_tizen_blend_destroy;
156 ds_tizen_blend_add_destroy_listener(tizen_blend, &blend->destroy_listener);
158 blend->commit_listener.notify = _e_blend_cb_ds_tizen_blend_commit;
159 ds_tizen_blend_add_commit_listener(tizen_blend, &blend->commit_listener);
161 blend->tizen_blend = tizen_blend;
163 _e_blend_ec_set(blend, ec);
165 ELOGF("E_BLENDER", "E_Blend:%p Create", ec, blend);
171 _e_blender_cb_destroy(struct wl_listener *listener, void *data)
175 blender = container_of(listener, E_Blender, destroy_listener);
187 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
188 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->wl.disp, EINA_FALSE);
190 if (_blender) return EINA_TRUE;
192 blender = E_NEW(E_Blender, 1);
193 EINA_SAFETY_ON_NULL_RETURN_VAL(blender, EINA_FALSE);
195 blender->tizen_blender = ds_tizen_blender_create(e_comp_wl->wl.disp);
196 EINA_SAFETY_ON_NULL_GOTO(blender, fail);
198 blender->destroy_listener.notify = _e_blender_cb_destroy;
199 ds_tizen_blender_add_destroy_listener(blender->tizen_blender,
200 &blender->destroy_listener);
202 blender->new_blend_listener.notify = _e_blender_cb_new_blend;
203 ds_tizen_blender_add_new_blend_listener(blender->tizen_blender,
204 &blender->new_blend_listener);