e_blur: Support corner radius of blur rectangle 27/316427/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 19 Aug 2024 01:50:24 +0000 (10:50 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Wed, 21 Aug 2024 07:28:40 +0000 (16:28 +0900)
Change-Id: Ib4dd9b107597a7859bd5def402b5e2e5f748e338

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

index 490d5cd..2bf1933 100644 (file)
@@ -49,8 +49,6 @@ struct _E_Blur
 
    Eina_Bool enabled;
 
-   char program[256];
-
    Eina_List *blur_rectangles;
 };
 
@@ -243,6 +241,27 @@ _e_blur_rectangle_geometry_set(E_Blur_Rectangle *blur_rectangle, E_Client *ec)
 }
 
 static void
+_e_blur_rectangle_filter_set(E_Blur_Rectangle *blur_rectangle)
+{
+   char program[256];
+
+   if ((blur_rectangle->rx != 0) && (blur_rectangle->ry != 0))
+     {
+        snprintf(program, sizeof(program),
+                 "a = buffer { 'rgba' } blur { %d, dst = a } rounded_corner { src = a, rx = %d, ry = %d}",
+                 blur_rectangle->blur->radius, blur_rectangle->rx, blur_rectangle->ry);
+     }
+   else
+     {
+        snprintf(program, sizeof(program),
+                 "blur (%d) padding_set (0)",
+                 blur_rectangle->blur->radius);
+     }
+
+   efl_gfx_filter_program_set(blur_rectangle->obj, program, "image_filter");
+}
+
+static void
 _e_blur_cb_ds_tizen_blur_commit(struct wl_listener *listener, void *data)
 {
    E_Blur *blur;
@@ -274,11 +293,9 @@ _e_blur_cb_ds_tizen_blur_commit(struct wl_listener *listener, void *data)
 
    if (blur->radius)
      {
-        snprintf(blur->program, sizeof(blur->program), "blur (%d) padding_set (0)", blur->radius);
-
         EINA_LIST_FOREACH(blur->blur_rectangles, l, blur_rectangle)
           {
-             efl_gfx_filter_program_set(blur_rectangle->obj, blur->program, "image_filter");
+             _e_blur_rectangle_filter_set(blur_rectangle);
              if (!evas_object_visible_get(blur->ec->frame)) continue;
              evas_object_show(blur_rectangle->obj);
           }
@@ -490,9 +507,7 @@ _e_blur_cb_new_rectangle(struct wl_listener *listener, void *data)
    blur_rectangle->blur = blur;
    blur->blur_rectangles = eina_list_append(blur->blur_rectangles, blur_rectangle);
 
-   if (*blur->program != 0)
-      efl_gfx_filter_program_set(blur_rectangle->obj, blur->program, "image_filter");
-
+   _e_blur_rectangle_filter_set(blur_rectangle);
    _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);
@@ -678,6 +693,15 @@ e_blur_rectangle_object_get(E_Blur_Rectangle *blur_rectangle)
 }
 
 EINTERN void
+e_blur_rectangle_corner_radius_get(E_Blur_Rectangle *blur_rectangle, int *rx, int *ry)
+{
+   EINA_SAFETY_ON_NULL_RETURN(blur_rectangle);
+
+   if (rx) *rx = blur_rectangle->rx;
+   if (ry) *ry = blur_rectangle->ry;
+}
+
+EINTERN void
 e_blur_trace_debug(Eina_Bool onoff)
 {
    if (onoff == blur_trace) return;
index d20b5ae..4ae88e6 100644 (file)
@@ -44,6 +44,6 @@ EINTERN Evas_Object *e_blur_rectangle_object_get(E_Blur_Rectangle *blur_rectangl
 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);
-
+EINTERN void e_blur_rectangle_corner_radius_get(E_Blur_Rectangle *blur_rectangle, int *rx, int *ry);
 
 #endif // E_BLUR_INTERN_H
index d29138c..508fe52 100644 (file)
@@ -267,6 +267,9 @@ _e_blur_video_capture_object_get(E_Blur_Video_Capture_Client *client, E_Blur_Rec
    E_Blur_Video_Capture_Object *object;
    int x, y, w, h;
    Eina_List *l;
+   unsigned int *pixels;
+   char program[256];
+   int rx = 0, ry = 0;
 
    if (!blur_rectangle) return NULL;
 
@@ -282,8 +285,20 @@ _e_blur_video_capture_object_get(E_Blur_Video_Capture_Client *client, E_Blur_Rec
    object = E_NEW(E_Blur_Video_Capture_Object, 1);
    EINA_SAFETY_ON_NULL_RETURN_VAL(object, NULL);
 
-   object->blur_clip_obj = evas_object_rectangle_add(e_comp->evas);
+   object->blur_clip_obj = evas_object_image_filled_add(e_comp->evas);
    EINA_SAFETY_ON_NULL_GOTO(object->blur_clip_obj, fail);
+   evas_object_image_size_set(object->blur_clip_obj, 1, 1);
+   pixels = evas_object_image_data_get(object->blur_clip_obj, EINA_TRUE);
+   EINA_SAFETY_ON_NULL_GOTO(pixels, fail);
+   *pixels = 0xffffffff;
+   evas_object_image_data_set(object->blur_clip_obj, pixels);
+   evas_object_image_data_update_add(object->blur_clip_obj, 0, 0, 1, 1);
+   e_blur_rectangle_corner_radius_get(blur_rectangle, &rx, &ry);
+   if ((rx != 0) && (ry != 0))
+     {
+        snprintf(program, sizeof(program), "rounded_corner { rx = %d, ry = %d}", rx, ry);
+        efl_gfx_filter_program_set(object->blur_clip_obj, program, "rounded_corner");
+     }
    evas_object_name_set(object->blur_clip_obj, "blur_video_capture_blur_clip_obj");
    evas_object_pass_events_set(object->blur_clip_obj, EINA_TRUE);