e_blur: support latest ds_tizen_blur interface 81/315381/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 29 Jul 2024 02:38:20 +0000 (11:38 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 31 Jul 2024 05:54:18 +0000 (14:54 +0900)
Support ds_tizen_blur_rectangle and
Do not use DS_TIZEN_BLUR_STATE_REGION.

Change-Id: Iab8a65464ce6d3e2988c4b4d0aaf19e7a1510ea0

src/bin/server/e_blur.c
src/bin/server/e_blur_intern.h

index 401528c..593deb7 100644 (file)
@@ -1,51 +1,70 @@
 #include "e.h"
 #include "e_blur_intern.h"
-#include "e_comp_canvas_intern.h"
-#include "e_view_intern.h"
-#include "e_view_image.h"
-#include "e_view_client_intern.h"
-
 #include <pixman.h>
 #include <libds-tizen/blur.h>
 
+#define BLUR_TRACE(f, ec, x... ) \
+   do \
+     { \
+        if (blur_trace) \
+          { \
+             ELOGF("E_BLUR", f, \
+                   (ec), ##x); \
+          } \
+      } \
+   while (0)
+
 typedef struct _E_Blur_Manager E_Blur_Manager;
-typedef struct _E_Blur E_Blur;
-typedef struct _E_Blur_Object E_Blur_Object;
 
 struct _E_Blur_Manager
 {
    struct ds_tizen_blur_manager *tizen_blur_manager;
 
-   struct wl_listener destroy_listener;
-   struct wl_listener new_blur_listener;
+   struct {
+      struct wl_listener destroy;
+      struct wl_listener new_blur;
+   } listener;
+
+   Eina_Bool blur_enabled;
+
+   Eina_List *blurs;
 };
 
 struct _E_Blur
 {
    struct ds_tizen_blur *tizen_blur;
-   struct wl_listener commit_listener;
-   struct wl_listener destroy_listener;
 
-   struct wl_listener view_show_listener;
-   struct wl_listener view_hide_listener;
-   struct wl_listener view_resize_listener;
-   struct wl_listener view_move_listener;
-   struct wl_listener view_restack_listener;
+   struct {
+      struct wl_listener surface_commit;
+      struct wl_listener destroy;
+      struct wl_listener new_rectangle;
+   listener;
 
    E_Client *ec;
    E_Object_Delfn *ec_delfn;
 
-   pixman_region32_t region;
    uint32_t radius;
 
-   Eina_List *blur_objs;
+   Eina_Bool enabled;
+
+   char program[256];
+
+   Eina_List *blur_rectangles;
 };
 
-struct _E_Blur_Object
+struct _E_Blur_Rectangle
 {
+   struct ds_tizen_blur_rectangle *tizen_blur_rectangle;
+   E_Blur *blur;
+
+   struct {
+      struct wl_listener destroy;
+   } listener;
+
    int x, y, w, h;
+   int rx, ry;
 
-   E_View_Image *view_image;
+   Evas_Object *obj;
 };
 
 static int _e_blur_hooks_delete = 0;
@@ -55,12 +74,13 @@ static Eina_Inlist *_e_blur_hooks[] =
 {
    [E_BLUR_HOOK_SET] = NULL,
    [E_BLUR_HOOK_UNSET] = NULL,
+   [E_BLUR_HOOK_RECTANGLE_CREATE] = NULL,
 };
 
 static E_Blur_Manager *_blur_manager = NULL;
+static Eina_Bool blur_trace = EINA_FALSE;
 
 static void _e_blur_ec_set(E_Blur *blur, E_Client *ec);
-static void _e_blur_ec_unset(E_Blur *blur);
 
 static void
 _e_blur_hooks_clean(void)
@@ -95,106 +115,126 @@ _e_blur_hook_call(E_Blur_Hook_Point hookpoint, E_Blur *blur)
      _e_blur_hooks_clean();
 }
 
-static E_Blur_Object *
-_e_blur_object_create(int x, int y, int w, int h)
+static Eina_Bool
+_e_blur_enabled_get(E_Blur *blur)
 {
-   E_Blur_Object *blur_obj;
-   E_Canvas *canvas;
-   E_View_Tree *tree;
-   E_View_Image *view_image;
-   E_View *view;
+   return blur->enabled;
+}
 
-   blur_obj = E_NEW(E_Blur_Object, 1);
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(blur_obj, NULL);
+static void
+_e_blur_manager_blur_enabled_changed(Eina_Bool set)
+{
+   E_Blur_Manager *blur_manager = _blur_manager;
+   E_Blur *blur;
+   Eina_List *l;
 
-   canvas = e_comp_canvas_get();
-   tree = e_canvas_layer_view_tree_get(canvas, E_CANVAS_LAYER_BOTTOM);
-   view_image = e_view_image_filled_create(tree);
-   EINA_SAFETY_ON_NULL_GOTO(view_image, fail);
+   if (set)
+     {
+        if (blur_manager->blur_enabled == set)
+          return;
 
-   e_view_image_snapshot_set(view_image, EINA_TRUE);
+        e_video_debug_display_primary_plane_set(EINA_TRUE);
+     }
+   else
+     {
+        EINA_LIST_FOREACH(blur_manager->blurs, l, blur)
+          {
+             if (_e_blur_enabled_get(blur))
+               return;
+          }
 
-   view = e_view_image_view_get(view_image);
-   e_view_name_set(view, "blur_obj");
+        if (blur_manager->blur_enabled == set)
+          return;
 
-   blur_obj->x = x;
-   blur_obj->y = y;
-   blur_obj->w = w;
-   blur_obj->h = h;
-   blur_obj->view_image = view_image;
+        e_video_debug_display_primary_plane_set(EINA_FALSE);
+     }
 
-   return blur_obj;
+   blur_manager->blur_enabled = set;
+}
 
-fail:
-   free(blur_obj);
+static void
+_e_blur_enabled_set(E_Blur *blur, Eina_Bool set)
+{
+   if (blur->enabled == set) return;
 
-   return NULL;
+   blur->enabled = set;
+
+   if (set)
+     _e_blur_hook_call(E_BLUR_HOOK_SET, blur);
+   else
+     _e_blur_hook_call(E_BLUR_HOOK_UNSET, blur);
+
+   _e_blur_manager_blur_enabled_changed(set);
 }
 
 static void
-_e_blur_object_destroy(E_Blur_Object *blur_obj)
+_e_blur_rectangle_free(E_Blur_Rectangle *blur_rectangle)
 {
-   E_View *view;
+   E_Blur *blur;
+
+   ELOGF("E_BLUR", "E_Blur_Rectangle:%p Free", NULL, blur_rectangle);
 
-   view = e_view_image_view_get(blur_obj->view_image);
-   e_view_destroy(view);
+   blur = blur_rectangle->blur;
+   blur->blur_rectangles = eina_list_remove(blur->blur_rectangles, blur_rectangle);
 
-   free(blur_obj);
+   evas_object_del(blur_rectangle->obj);
+
+   if (blur_rectangle->listener.destroy.notify)
+     wl_list_remove(&blur_rectangle->listener.destroy.link);
+
+   free(blur_rectangle);
 }
 
 static void
 _e_blur_free(E_Blur *blur)
 {
-   E_Blur_Object *blur_obj;
+   E_Blur_Rectangle *blur_rectangle;
+   Eina_List *l, *ll;
 
    ELOGF("E_BLUR", "E_Blur:%p Free", blur->ec, blur);
 
-   _e_blur_ec_unset(blur);
+   _e_blur_ec_set(blur, NULL);
 
-   if (eina_list_count(blur->blur_objs))
+   if (eina_list_count(blur->blur_rectangles))
      {
-        EINA_LIST_FREE(blur->blur_objs, blur_obj)
-          _e_blur_object_destroy(blur_obj);
-
-        _e_blur_hook_call(E_BLUR_HOOK_UNSET, blur);
+        EINA_LIST_FOREACH_SAFE(blur->blur_rectangles, l, ll, blur_rectangle)
+          _e_blur_rectangle_free(blur_rectangle);
      }
 
-   pixman_region32_fini(&blur->region);
+   _e_blur_enabled_set(blur, EINA_FALSE);
+
    free(blur);
 }
 
 static void
-_e_blur_object_geometry_set(E_Blur_Object *blur_obj, E_Client *ec)
+_e_blur_rectangle_geometry_set(E_Blur_Rectangle *blur_rectangle, E_Client *ec)
 {
-   E_View_Client *view_client;
-
    int ec_x, ec_y, ec_w, ec_h;
-   int view_x, view_y, view_w, view_h;
+   int evas_x, evas_y, evas_w, evas_h;
    double scale_w, scale_h;
 
-   view_client = e_client_view_get(ec);
-   e_view_client_geometry_get(view_client, &view_x, &view_y, &view_w, &view_h);
+   evas_object_geometry_get(ec->frame, &evas_x, &evas_y, &evas_w, &evas_h);
 
    if (e_client_transform_core_enable_get(ec))
      {
         e_client_geometry_get(ec, &ec_x, &ec_y, &ec_w, &ec_h);
 
-        scale_w = (double)ec_w / (double)view_w;
-        scale_h = (double)ec_h / (double)view_h;
+        scale_w = (double)ec_w / (double)evas_w;
+        scale_h = (double)ec_h / (double)evas_h;
 
-        e_view_image_geometry_set(blur_obj->view_image,
-                                 ec_x + blur_obj->x,
-                                 ec_y + blur_obj->y,
-                                 (int)((double)blur_obj->w * scale_w),
-                                 (int)((double)blur_obj->h * scale_h));
+        evas_object_geometry_set(blur_rectangle->obj,
+                                 ec_x + blur_rectangle->x,
+                                 ec_y + blur_rectangle->y,
+                                 (int)((double)blur_rectangle->w * scale_w),
+                                 (int)((double)blur_rectangle->h * scale_h));
      }
    else
      {
-        e_view_image_geometry_set(blur_obj->view_image,
-                                 view_x + blur_obj->x,
-                                 view_y + blur_obj->y,
-                                 blur_obj->w,
-                                 blur_obj->h);
+        evas_object_geometry_set(blur_rectangle->obj,
+                                 evas_x + blur_rectangle->x,
+                                 evas_y + blur_rectangle->y,
+                                 blur_rectangle->w,
+                                 blur_rectangle->h);
      }
 }
 
@@ -202,30 +242,17 @@ static void
 _e_blur_cb_ds_tizen_blur_commit(struct wl_listener *listener, void *data)
 {
    E_Blur *blur;
-   E_Blur_Object *blur_obj;
-   pixman_box32_t *rects;
-   int rects_count, i;
-   char program[1024];
+   E_Blur_Rectangle *blur_rectangle;
    Eina_List *l;
    struct ds_tizen_blur_state *state;
-   Eina_Bool region_changed = EINA_FALSE, radius_changed = EINA_FALSE;
-   E_View *image_view, *client_view;
-   E_Canvas_Layer layer;
-   E_View_Tree *view_tree;
+   Eina_Bool radius_changed = EINA_FALSE, rectangle_changed = EINA_FALSE;
 
-   blur = container_of(listener, E_Blur, commit_listener);
+   blur = container_of(listener, E_Blur, listener.surface_commit);
    if (!blur->ec) return;
 
    state = ds_tizen_blur_get_state(blur->tizen_blur);
    if (!state) return;
 
-   if ((state->committed & DS_TIZEN_BLUR_STATE_REGION) &&
-       (!pixman_region32_equal(&blur->region, &state->region)))
-     {
-        pixman_region32_copy(&blur->region, &state->region);
-        region_changed = EINA_TRUE;
-     }
-
    if ((state->committed & DS_TIZEN_BLUR_STATE_RADIUS) &&
        (blur->radius != state->radius))
      {
@@ -233,155 +260,105 @@ _e_blur_cb_ds_tizen_blur_commit(struct wl_listener *listener, void *data)
         radius_changed = EINA_TRUE;
      }
 
-   if (blur->radius)
+   if (state->committed & DS_TIZEN_BLUR_STATE_RECTANGLE)
      {
-        snprintf(program, sizeof(program), "blur (%d) padding_set (0)", blur->radius);
-
-        if (region_changed)
-          {
-             EINA_LIST_FREE(blur->blur_objs, blur_obj)
-               _e_blur_object_destroy(blur_obj);
-
-             rects = pixman_region32_rectangles(&blur->region, &rects_count);
-             for (i = 0; i < rects_count; i++)
-               {
-                  blur_obj = _e_blur_object_create(rects[i].x1,
-                                                   rects[i].y1,
-                                                   rects[i].x2 - rects[i].x1,
-                                                   rects[i].y2 - rects[i].y1);
-                  EINA_SAFETY_ON_NULL_RETURN(blur_obj);
-
-                  _e_blur_object_geometry_set(blur_obj, blur->ec);
-
-                  e_view_image_gfx_filter_program_set(blur_obj->view_image, program,"image_filter");
-
-                  image_view = e_view_image_view_get(blur_obj->view_image);
-                  client_view = e_view_client_view_get(e_client_view_get(blur->ec));
-                  layer = e_canvas_layer_find(e_comp_canvas_get(), client_view);
-                  view_tree = e_canvas_layer_view_tree_get(e_comp_canvas_get(), layer);
-
-                  e_view_reparent(image_view, view_tree);
-                  e_view_place_below(image_view, client_view);
-
-                  if (e_view_client_visible_get(e_client_view_get(blur->ec)))
-                    e_view_show(image_view);
+        rectangle_changed = EINA_TRUE;
+     }
 
-                  blur->blur_objs = eina_list_append(blur->blur_objs, blur_obj);
+   if ((!radius_changed) && (!rectangle_changed))
+     return;
 
-                  ELOGF("E_BLUR", "E_Blur:%p set blur_obj:%p %dx%d+%d+%d radius:%d",
-                        blur->ec, blur, blur_obj,
-                        blur_obj->w, blur_obj->h, blur_obj->x, blur_obj->y,
-                        blur->radius);
-               }
+   if (blur->radius)
+     {
+        snprintf(blur->program, sizeof(blur->program), "blur (%d) padding_set (0)", blur->radius);
 
-             _e_blur_hook_call(E_BLUR_HOOK_SET, blur);
-          }
-        else if (radius_changed)
+        EINA_LIST_FOREACH(blur->blur_rectangles, l, blur_rectangle)
           {
-             EINA_LIST_FOREACH(blur->blur_objs, l, blur_obj)
-               {
-                  e_view_image_gfx_filter_program_set(blur_obj->view_image, program, "image_filter");
-
-                  ELOGF("E_BLUR", "E_Blur:%p set blur_obj:%p radius:%d",
-                        blur->ec, blur, blur_obj, blur->radius);
-               }
-
-            _e_blur_hook_call(E_BLUR_HOOK_SET, blur);
+             efl_gfx_filter_program_set(blur_rectangle->obj, blur->program, "image_filter");
+             if (!evas_object_visible_get(blur->ec->frame)) continue;
+             evas_object_show(blur_rectangle->obj);
           }
+
+        _e_blur_enabled_set(blur, EINA_TRUE);
      }
    else
      {
-        if (eina_list_count(blur->blur_objs))
-          {
-             EINA_LIST_FREE(blur->blur_objs, blur_obj)
-               _e_blur_object_destroy(blur_obj);
+        EINA_LIST_FOREACH(blur->blur_rectangles, l, blur_rectangle)
+          evas_object_hide(blur_rectangle->obj);
 
-             _e_blur_hook_call(E_BLUR_HOOK_UNSET, blur);
-          }
+        _e_blur_enabled_set(blur, EINA_FALSE);
      }
 }
 
 static void
-_e_blur_cb_view_show(struct wl_listener *listener, void *data)
+_e_blur_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
 {
    E_Blur *blur;
-   E_Blur_Object *blur_obj;
-   E_View *view;
    Eina_List *l;
+   E_Blur_Rectangle *blur_rectangle;
 
-   blur = container_of(listener, E_Blur, view_show_listener);
+   if (!(blur = data)) return;
+   if (!_e_blur_enabled_get(blur)) return;
 
-   EINA_LIST_FOREACH(blur->blur_objs, l, blur_obj)
-     {
-        view = e_view_image_view_get(blur_obj->view_image);
-        e_view_show(view);
-     }
+   EINA_LIST_FOREACH(blur->blur_rectangles, l, blur_rectangle)
+     evas_object_show(blur_rectangle->obj);
 }
 
 static void
-_e_blur_cb_view_hide(struct wl_listener *listener, void *data)
+_e_blur_evas_cb_hide(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
 {
    E_Blur *blur;
-   E_Blur_Object *blur_obj;
-   E_View *view;
    Eina_List *l;
+   E_Blur_Rectangle *blur_rectangle;
 
-   blur = container_of(listener, E_Blur, view_hide_listener);
+   if (!(blur = data)) return;
 
-   EINA_LIST_FOREACH(blur->blur_objs, l, blur_obj)
-     {
-        view = e_view_image_view_get(blur_obj->view_image);
-        e_view_hide(view);
-     }
+   EINA_LIST_FOREACH(blur->blur_rectangles, l, blur_rectangle)
+     evas_object_hide(blur_rectangle->obj);
 }
 
 static void
-_e_blur_cb_view_resize(struct wl_listener *listener, void *data)
+_e_blur_evas_cb_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
    E_Blur *blur;
-   E_Blur_Object *blur_obj;
    Eina_List *l;
+   E_Blur_Rectangle *blur_rectangle;
 
-   blur = container_of(listener, E_Blur, view_resize_listener);
+   if (!(blur = data)) return;
 
-   EINA_LIST_FOREACH(blur->blur_objs, l, blur_obj)
-     _e_blur_object_geometry_set(blur_obj, blur->ec);
+   EINA_LIST_FOREACH(blur->blur_rectangles, l, blur_rectangle)
+     _e_blur_rectangle_geometry_set(blur_rectangle, blur->ec);
 }
 
 static void
-_e_blur_cb_view_move(struct wl_listener *listener, void *data)
+_e_blur_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
    E_Blur *blur;
-   E_Blur_Object *blur_obj;
    Eina_List *l;
+   E_Blur_Rectangle *blur_rectangle;
 
-   blur = container_of(listener, E_Blur, view_move_listener);
+   if (!(blur = data)) return;
 
-   EINA_LIST_FOREACH(blur->blur_objs, l, blur_obj)
-     _e_blur_object_geometry_set(blur_obj, blur->ec);
+   EINA_LIST_FOREACH(blur->blur_rectangles, l, blur_rectangle)
+     _e_blur_rectangle_geometry_set(blur_rectangle, blur->ec);
 }
 
 static void
-_e_blur_cb_view_restack(struct wl_listener *listener, void *data)
+_e_blur_evas_cb_restack(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
    E_Blur *blur;
-   E_Blur_Object *blur_obj;
-   E_View *view, *client_view;
-   E_View_Client *view_client;
    Eina_List *l;
+   E_Blur_Rectangle *blur_rectangle;
+   short layer;
 
-   blur = container_of(listener, E_Blur, view_hide_listener);
-   if (!blur->ec) return;
-
-   view_client = e_client_view_get(blur->ec);
-   if (!view_client) return;
+   if (!(blur = data)) return;
 
-   client_view = e_view_client_view_get(view_client);
+   layer = evas_object_layer_get(obj);
 
-   EINA_LIST_FOREACH(blur->blur_objs, l, blur_obj)
+   EINA_LIST_FOREACH(blur->blur_rectangles, l, blur_rectangle)
      {
-        view = e_view_image_view_get(blur_obj->view_image);
-        e_view_place_below(view, client_view);
+        evas_object_layer_set(blur_rectangle->obj, layer);
+        evas_object_stack_below(blur_rectangle->obj, obj);
      }
 }
 
@@ -391,74 +368,136 @@ _e_blur_cb_ec_free(void *data, void *obj)
    E_Blur *blur = data;
 
    blur->ec_delfn = NULL;
-   _e_blur_ec_unset(blur);
+   _e_blur_ec_set(blur, NULL);
 }
 
 static void
 _e_blur_ec_set(E_Blur *blur, E_Client *ec)
 {
-   E_View_Client *view_client;
-   E_View *view;
-
    if (blur->ec == ec) return;
 
-   view_client = e_client_view_get(blur->ec);
-   view = e_view_client_view_get(view_client);
+   if (blur->ec)
+     {
+        evas_object_event_callback_del(blur->ec->frame, EVAS_CALLBACK_SHOW,
+                                      _e_blur_evas_cb_show);
+        evas_object_event_callback_del(blur->ec->frame, EVAS_CALLBACK_HIDE,
+                                      _e_blur_evas_cb_hide);
+        evas_object_event_callback_del(blur->ec->frame, EVAS_CALLBACK_RESIZE,
+                                      _e_blur_evas_cb_resize);
+        evas_object_event_callback_del(blur->ec->frame, EVAS_CALLBACK_MOVE,
+                                      _e_blur_evas_cb_move);
+        evas_object_event_callback_del(blur->ec->frame, EVAS_CALLBACK_RESTACK,
+                                      _e_blur_evas_cb_restack);
+
+        if (blur->ec_delfn)
+          {
+             e_object_delfn_del(E_OBJECT(blur->ec), blur->ec_delfn);
+             blur->ec_delfn = NULL;
+          }
 
-   blur->view_show_listener.notify = _e_blur_cb_view_show;
-   e_view_event_listener_add(view, E_VIEW_SHOW, &blur->view_show_listener);
+        blur->ec = NULL;
+     }
 
-   blur->view_hide_listener.notify = _e_blur_cb_view_hide;
-   e_view_event_listener_add(view, E_VIEW_HIDE, &blur->view_hide_listener);
+   if (ec)
+     {
+        evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW,
+                                       _e_blur_evas_cb_show, blur);
+        evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE,
+                                       _e_blur_evas_cb_hide, blur);
+        evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_RESIZE,
+                                       _e_blur_evas_cb_resize, blur);
+        evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE,
+                                       _e_blur_evas_cb_move, blur);
+        evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_RESTACK,
+                                       _e_blur_evas_cb_restack, blur);
+
+        blur->ec_delfn = e_object_delfn_add(E_OBJECT(ec),
+                                            _e_blur_cb_ec_free,
+                                            blur);
+        blur->ec = ec;
+     }
+}
 
-   blur->view_move_listener.notify = _e_blur_cb_view_move;
-   e_view_event_listener_add(view, E_VIEW_MOVE, &blur->view_move_listener);
+static void
+_e_blur_cb_ds_tizen_blur_destroy(struct wl_listener *listener, void *data)
+{
+   E_Blur *blur;
+   E_Blur_Manager *blur_manager = _blur_manager;
 
-   blur->view_resize_listener.notify = _e_blur_cb_view_resize;
-   e_view_event_listener_add(view, E_VIEW_RESIZE, &blur->view_resize_listener);
+   blur = wl_container_of(listener, blur, listener.destroy);
 
-   blur->view_restack_listener.notify = _e_blur_cb_view_restack;
-   e_view_event_listener_add(view, E_VIEW_RESTACK, &blur->view_restack_listener);
+   if (blur_manager)
+      blur_manager->blurs = eina_list_remove(blur_manager->blurs, blur);
 
-   blur->ec_delfn = e_object_delfn_add(E_OBJECT(ec),
-                                       _e_blur_cb_ec_free,
-                                       blur);
-   blur->ec = ec;
+   _e_blur_free(blur);
 }
 
 static void
-_e_blur_ec_unset(E_Blur *blur)
+_e_blur_rectangle_cb_ds_tizen_blur_rectangle_destroy(struct wl_listener *listener, void *data)
 {
-   E_View_Client *view_client;
-   E_View *view;
-
-   if (!blur->ec) return;
-
-   view_client = e_client_view_get(blur->ec);
-   view = e_view_client_view_get(view_client);
+   E_Blur_Rectangle *blur_rectangle;
+   E_Blur *blur;
 
-   e_view_event_listener_del(view, E_VIEW_SHOW, &blur->view_show_listener);
-   e_view_event_listener_del(view, E_VIEW_HIDE, &blur->view_hide_listener);
-   e_view_event_listener_del(view, E_VIEW_MOVE, &blur->view_move_listener);
-   e_view_event_listener_del(view, E_VIEW_RESIZE, &blur->view_resize_listener);
-   e_view_event_listener_del(view, E_VIEW_RESTACK, &blur->view_restack_listener);
+   blur_rectangle = wl_container_of(listener, blur_rectangle, listener.destroy);
+   blur = blur_rectangle->blur;
 
-   blur->ec = NULL;
+   _e_blur_rectangle_free(blur_rectangle);
 
-   if (blur->ec_delfn)
-      {
-         e_object_delfn_del(E_OBJECT(blur->ec), blur->ec_delfn);
-         blur->ec_delfn = NULL;
-      }
+   if (!eina_list_count(blur->blur_rectangles))
+     _e_blur_hook_call(E_BLUR_HOOK_UNSET, blur);
 }
 
 static void
-_e_blur_cb_ds_tizen_blur_destroy(struct wl_listener *listener, void *data)
+_e_blur_cb_new_rectangle(struct wl_listener *listener, void *data)
 {
    E_Blur *blur;
+   E_Blur_Rectangle *blur_rectangle;
+   struct ds_tizen_blur_rectangle *tizen_blur_rectangle = data;
+   Evas_Object *obj;
 
-   blur = wl_container_of(listener, blur, destroy_listener);
-   _e_blur_free(blur);
+   blur = wl_container_of(listener, blur, listener.new_rectangle);
+   EINA_SAFETY_ON_NULL_RETURN(blur);
+   EINA_SAFETY_ON_NULL_RETURN(blur->ec);
+
+   obj = evas_object_image_filled_add(e_comp->evas);
+   EINA_SAFETY_ON_NULL_RETURN(obj);
+
+   blur_rectangle = E_NEW(E_Blur_Rectangle, 1);
+   EINA_SAFETY_ON_NULL_RETURN(blur_rectangle);
+
+   ds_tizen_blur_rectangle_get_geometry(tizen_blur_rectangle,
+                                        &blur_rectangle->x,
+                                        &blur_rectangle->y,
+                                        &blur_rectangle->w,
+                                        &blur_rectangle->h);
+
+   ds_tizen_blur_rectangle_get_corner_radius(tizen_blur_rectangle,
+                                             &blur_rectangle->rx,
+                                             &blur_rectangle->ry);
+
+   blur_rectangle->listener.destroy.notify = _e_blur_rectangle_cb_ds_tizen_blur_rectangle_destroy;
+   ds_tizen_blur_rectangle_add_destroy_listener(tizen_blur_rectangle, &blur_rectangle->listener.destroy);
+   blur_rectangle->tizen_blur_rectangle = tizen_blur_rectangle;
+
+   evas_object_image_snapshot_set(obj, EINA_TRUE);
+   evas_object_name_set(obj, "blur_obj");
+   blur_rectangle->obj = obj;
+
+   blur_rectangle->blur = blur;
+   blur->blur_rectangles = eina_list_append(blur->blur_rectangles, blur_rectangle);
+
+   efl_gfx_filter_program_set(blur_rectangle->obj, blur->program, "image_filter");
+
+   _e_blur_rectangle_geometry_set(blur_rectangle, blur->ec);
+   evas_object_layer_set(blur_rectangle->obj, evas_object_layer_get(blur->ec->frame));
+   evas_object_stack_below(blur_rectangle->obj, blur->ec->frame);
+
+   if (evas_object_visible_get(blur->ec->frame) && _e_blur_enabled_get(blur))
+     evas_object_show(blur_rectangle->obj);
+
+   ELOGF("E_BLUR", "E_Blur_Rectangle:%p Create", blur->ec, blur_rectangle);
+
+   _e_blur_hook_call(E_BLUR_HOOK_RECTANGLE_CREATE, blur);
 }
 
 static void
@@ -489,18 +528,21 @@ _e_blur_manager_cb_new_blur(struct wl_listener *listener, void *data)
    blur = E_NEW(E_Blur, 1);
    EINA_SAFETY_ON_NULL_RETURN(blur);
 
-   blur->destroy_listener.notify = _e_blur_cb_ds_tizen_blur_destroy;
-   ds_tizen_blur_add_destroy_listener(tizen_blur, &blur->destroy_listener);
+   blur->listener.destroy.notify = _e_blur_cb_ds_tizen_blur_destroy;
+   ds_tizen_blur_add_destroy_listener(tizen_blur, &blur->listener.destroy);
 
-   blur->commit_listener.notify = _e_blur_cb_ds_tizen_blur_commit;
-   ds_tizen_blur_add_commit_listener(tizen_blur, &blur->commit_listener);
+   blur->listener.surface_commit.notify = _e_blur_cb_ds_tizen_blur_commit;
+   ds_tizen_blur_add_commit_listener(tizen_blur, &blur->listener.surface_commit);
 
    blur->tizen_blur = tizen_blur;
 
-   pixman_region32_init_rect(&blur->region, 0, 0, ec->w, ec->h);
-
    _e_blur_ec_set(blur, ec);
 
+   blur->listener.new_rectangle.notify = _e_blur_cb_new_rectangle;
+   ds_tizen_blur_add_new_rectangle_listener(tizen_blur, &blur->listener.new_rectangle);
+
+   blur_manager->blurs = eina_list_append(blur_manager->blurs, blur);
+
    ELOGF("E_BLUR", "E_Blur:%p Create", ec, blur);
 
    return;
@@ -511,7 +553,9 @@ _e_blur_manager_cb_destroy(struct wl_listener *listener, void *data)
 {
    E_Blur_Manager *blur_manager;
 
-   blur_manager = container_of(listener, E_Blur_Manager, destroy_listener);
+   blur_manager = container_of(listener, E_Blur_Manager, listener.destroy);
+
+   eina_list_free(blur_manager->blurs);
 
    free(blur_manager);
 
@@ -522,6 +566,7 @@ EINTERN Eina_Bool
 e_blur_manager_init(void)
 {
    E_Blur_Manager *blur_manager;
+   E_Comp_Config *conf = e_comp_config_get();
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_wl->wl.disp, EINA_FALSE);
@@ -534,19 +579,20 @@ e_blur_manager_init(void)
    blur_manager->tizen_blur_manager = ds_tizen_blur_manager_create(e_comp_wl->wl.disp);
    EINA_SAFETY_ON_NULL_GOTO(blur_manager->tizen_blur_manager, fail);
 
-   blur_manager->destroy_listener.notify = _e_blur_manager_cb_destroy;
+   blur_manager->listener.destroy.notify = _e_blur_manager_cb_destroy;
    ds_tizen_blur_manager_add_destroy_listener(blur_manager->tizen_blur_manager,
-                                              &blur_manager->destroy_listener);
+                                              &blur_manager->listener.destroy);
 
-   blur_manager->new_blur_listener.notify = _e_blur_manager_cb_new_blur;
+   blur_manager->listener.new_blur.notify = _e_blur_manager_cb_new_blur;
    ds_tizen_blur_manager_add_new_blur_listener(blur_manager->tizen_blur_manager,
-                                               &blur_manager->new_blur_listener);
+                                               &blur_manager->listener.new_blur);
 
    _blur_manager = blur_manager;
 
    return EINA_TRUE;
 
 fail:
+
    free(blur_manager);
 
    return EINA_FALSE;
@@ -554,7 +600,8 @@ fail:
 
 EINTERN void
 e_blur_manager_shutdown(void)
-{}
+{
+}
 
 EINTERN E_Blur_Hook *
 e_blur_hook_add(E_Blur_Hook_Point hookpoint, E_Blur_Hook_Cb func, const void *data)
@@ -591,3 +638,37 @@ e_blur_client_get(E_Blur *blur)
 
    return blur->ec;
 }
+
+EINTERN Eina_List *
+e_blur_rectangles_get(E_Blur *blur)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(blur, NULL);
+
+   return blur->blur_rectangles;
+}
+
+EINTERN Eina_List *
+e_blur_manager_blurs_get(void)
+{
+   E_Blur_Manager *blur_manager = _blur_manager;
+
+   if (!_blur_manager) return NULL;
+
+   return blur_manager->blurs;
+}
+
+EINTERN Evas_Object *
+e_blur_rectangle_object_get(E_Blur_Rectangle *blur_rectangle)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(blur_rectangle, NULL);
+
+   return blur_rectangle->obj;
+}
+
+EINTERN void
+e_blur_trace_debug(Eina_Bool onoff)
+{
+   if (onoff == blur_trace) return;
+   blur_trace = onoff;
+   INF("Blur Debug is %s", onoff?"ON":"OFF");
+}
index 053fce5..d20b5ae 100644 (file)
@@ -14,6 +14,7 @@
   while (0)
 
 typedef struct _E_Blur E_Blur;
+typedef struct _E_Blur_Rectangle E_Blur_Rectangle;
 typedef struct _E_Blur_Hook E_Blur_Hook;
 typedef void (*E_Blur_Hook_Cb) (void *data, E_Blur *blur);
 
@@ -21,6 +22,7 @@ typedef enum _E_Blur_Hook_Point
 {
    E_BLUR_HOOK_SET,
    E_BLUR_HOOK_UNSET,
+   E_BLUR_HOOK_RECTANGLE_CREATE,
    E_BLUR_HOOK_LAST
 } E_Blur_Hook_Point;
 
@@ -35,9 +37,13 @@ struct _E_Blur_Hook
 
 EINTERN Eina_Bool e_blur_manager_init(void);
 EINTERN void e_blur_manager_shutdown(void);
+EINTERN Eina_List *e_blur_manager_blurs_get(void);
 EINTERN E_Client *e_blur_client_get(E_Blur *blur);
+EINTERN Eina_List *e_blur_rectangles_get(E_Blur *blur);
+EINTERN Evas_Object *e_blur_rectangle_object_get(E_Blur_Rectangle *blur_rectangle);
 EINTERN E_Blur_Hook *e_blur_hook_add(E_Blur_Hook_Point hookpoint, E_Blur_Hook_Cb func, const void *data);
 EINTERN void e_blur_hook_del(E_Blur_Hook *ch);
+EINTERN void e_blur_trace_debug(Eina_Bool onoff);
 
 
 #endif // E_BLUR_INTERN_H