From cf8ce00fae1cc49d690effb755e6c317b1f69568 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 19 Dec 2023 18:03:02 +0900 Subject: [PATCH] e_blender: use ds_tizen_blender instead wtz-blender protocol Change-Id: I10a20effe4d7a9d2f1fc545414cfead6eea933fd --- configure.ac | 2 +- packaging/enlightenment.spec | 1 - src/bin/e_blender.c | 354 +++++++++++++------------------------------ src/bin/e_blender_intern.h | 22 --- src/bin/e_comp_wl.c | 1 - 5 files changed, 103 insertions(+), 277 deletions(-) diff --git a/configure.ac b/configure.ac index 8dd5222..def81d1 100755 --- a/configure.ac +++ b/configure.ac @@ -378,7 +378,7 @@ if test "x${e_cv_want_wayland_only}" != "xno" || test "x${e_cv_want_wayland_clie tizen-launch-server tizen-surface-server tizen-dpms-server eom-server presentation-time-server tizen-hwc-server linux-explicit-synchronization-unstable-v1-server wtz-foreign-server wtz-shell-server relative-pointer-unstable-v1-server pointer-constraints-unstable-v1-server - single-pixel-buffer-v1-server wtz-blender-server], + single-pixel-buffer-v1-server], [ have_wayland=yes AC_DEFINE_UNQUOTED([HAVE_WAYLAND],[1],[enable wayland support]) diff --git a/packaging/enlightenment.spec b/packaging/enlightenment.spec index e4b7e68..d13ea16 100644 --- a/packaging/enlightenment.spec +++ b/packaging/enlightenment.spec @@ -67,7 +67,6 @@ BuildRequires: pkgconfig(relative-pointer-unstable-v1-server) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gobject-2.0) BuildRequires: pkgconfig(single-pixel-buffer-v1-server) -BuildRequires: pkgconfig(wtz-blender-server) BuildRequires: pkgconfig(capi-system-resource) Requires: libwayland-extension-server diff --git a/src/bin/e_blender.c b/src/bin/e_blender.c index d2d3a25..4ac0f43 100644 --- a/src/bin/e_blender.c +++ b/src/bin/e_blender.c @@ -2,318 +2,181 @@ #include "e_client_intern.h" #include "e_comp_object_intern.h" -#include +#include -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 @@ -329,36 +192,23 @@ e_blender_init(void) 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; -} diff --git a/src/bin/e_blender_intern.h b/src/bin/e_blender_intern.h index c916f99..e16abf4 100644 --- a/src/bin/e_blender_intern.h +++ b/src/bin/e_blender_intern.h @@ -3,28 +3,6 @@ #include "e_intern.h" -typedef struct _E_Blender E_Blender; -typedef struct _E_Blend E_Blend; - -struct _E_Blender -{ - struct wl_global *global; -}; - -struct _E_Blend -{ - struct wl_resource *resource; - - struct wl_resource *surface; - struct wl_listener surface_destroy_listener; - struct wl_listener surface_state_commit_listener; - - uint32_t alpha; - uint32_t equation; - Eina_Bool changed; -}; - EINTERN Eina_Bool e_blender_init(void); -EINTERN void e_blender_shutdown(void); #endif // E_BLENDER_INTERN_H diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index b46d297..5f29d18 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -3961,7 +3961,6 @@ e_comp_wl_shutdown(void) E_FREE_LIST(hooks, e_client_hook_del); _e_comp_wl_gl_shutdown(); - e_blender_shutdown(); e_presentation_time_shutdown(); e_comp_wl_renderer_shutdown(); e_comp_wl_capture_shutdown(); -- 2.7.4