efl vector: use paint opacity method to toggle visibility. 56/246756/3
authorHermet Park <chuneon.park@samsung.com>
Wed, 4 Nov 2020 02:57:26 +0000 (11:57 +0900)
committerHermet Park <chuneon.park@samsung.com>
Wed, 4 Nov 2020 08:12:36 +0000 (08:12 +0000)
This method simplifies efl canvas vg code in thorvg integration.

Change-Id: Ic7424f7b1bf4ac055935dffc6855c3aa7766128d

packaging/efl.spec
src/lib/evas/canvas/efl_canvas_vg_shape.c

index 9a43b58..a4a1682 100644 (file)
@@ -72,6 +72,7 @@ BuildRequires:  pkgconfig(sm)
 BuildRequires:  pkgconfig(ibus-1.0)
 %endif
 
+#BuildRequires:  pkgconfig(thorvg)
 BuildRequires:  pkgconfig(rlottie)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(openssl1.1)
index 66bfd02..5f33b30 100644 (file)
@@ -55,11 +55,6 @@ struct _Efl_Canvas_Vg_Shape_Data
    //scaling using scale * width
    double scale;
 
-   //thorvg don't supported visibility, implementation is based on alpha change for stroke
-   //and fill, but color have to be saved here to recreate it when visibility will be changed back
-   Tvg_Color stroke_color;
-   Tvg_Color fill_color;
-
    //Flag indicates if shape was pushed to canvas. Shape has access to canvas only in
    //render function which may be called multiple times, and shape should be pushed
    //only once.
@@ -68,10 +63,6 @@ struct _Efl_Canvas_Vg_Shape_Data
    //Flag indicates if shape was started. It is used to store start position
    //and keep shape current point valid when shape close API is called.
    Eina_Bool started;
-
-   //Used to compare it with node data. Don't call visibility change if it has the same value
-   Eina_Bool visibility;
-
 #endif
 };
 
@@ -640,49 +631,6 @@ _efl_canvas_vg_shape_render_pre(Evas_Object_Protected_Data *vg_pd,
 
 #ifdef HAVE_THORVG
 static void
-_visibility_set(Efl_Canvas_Vg_Node_Data *nd)
-{
-   Efl_Canvas_Vg_Shape_Data *sd = NULL;
-
-   if (!nd || !nd->data) return;
-   sd = nd->data;
-
-   if (sd->visibility == nd->visibility) return;
-   sd->visibility = nd->visibility;
-
-   if (nd->visibility == EINA_FALSE)
-     {
-        tvg_shape_get_stroke_color(sd->shape,
-                                   &sd->stroke_color.r,
-                                   &sd->stroke_color.g,
-                                   &sd->stroke_color.b,
-                                   &sd->stroke_color.a);
-
-        tvg_shape_get_fill_color(sd->shape,
-                                 &sd->fill_color.r,
-                                 &sd->fill_color.g,
-                                 &sd->fill_color.b,
-                                 &sd->fill_color.a);
-
-        tvg_shape_set_stroke_color(sd->shape, 0, 0, 0, 0);
-        tvg_shape_set_fill_color(sd->shape, 0, 0, 0, 0);
-     }
-   else
-     {
-        tvg_shape_set_stroke_color(sd->shape,
-                                   sd->stroke_color.r,
-                                   sd->stroke_color.g,
-                                   sd->stroke_color.b,
-                                   sd->stroke_color.a);
-
-        tvg_shape_set_fill_color(sd->shape,
-                                 sd->fill_color.r,
-                                 sd->fill_color.g,
-                                 sd->fill_color.b,
-                                 sd->fill_color.a);
-     }
-}
-static void
 _convert_eina_to_tvg_mat(const Eina_Matrix3 *eina_mat, Tvg_Matrix *tvg_mat)
 {
    if (!eina_mat || !tvg_mat) return;
@@ -739,7 +687,6 @@ _efl_canvas_vg_shape_render_pre_tvg(EINA_UNUSED Evas_Object_Protected_Data *vg_p
         tvg_paint_transform(sd->shape, &trans_mat);
      }
 
-   _visibility_set(nd);
 
    if (sd->pushed == EINA_FALSE)
      {
@@ -750,6 +697,8 @@ _efl_canvas_vg_shape_render_pre_tvg(EINA_UNUSED Evas_Object_Protected_Data *vg_p
    //get fill color and set it
    efl_gfx_color_get(obj, &r, &g, &b, &a);
    tvg_shape_set_fill_color(sd->shape, r, g, b, a);
+   uint8_t opacity = nd->visibility ? 255 : 0;
+   tvg_paint_set_opacity(sd->shape, nd->visibility);
    tvg_canvas_update_paint((Tvg_Canvas *) canvas, sd->shape);
 }
 #endif
@@ -776,7 +725,6 @@ _efl_canvas_vg_shape_efl_object_constructor(Eo *obj, Efl_Canvas_Vg_Shape_Data *p
 #else
    nd->render_pre_tvg = _efl_canvas_vg_shape_render_pre_tvg;
    pd->shape = tvg_shape_new();
-   pd->visibility = EINA_TRUE;
    pd->scale = 1.0;
 #endif