hermet pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=228b91e36f1cb9105b9f628b85d751086a9ef70f

commit 228b91e36f1cb9105b9f628b85d751086a9ef70f
Author: JunsuChoi <[email protected]>
Date:   Tue Jul 9 14:21:19 2019 +0900

    efl_gfx_shape: Stroke color use a premultiplied color.
    
    Summary: R, G, and B must not be higher than alpha.
    
    Test Plan:
    //test code
    Ecore_Evas *ee = ecore_evas_new(NULL, 0, 0, 600, 600, NULL);
    ecore_evas_show(ee);
    
    Evas *evas = ecore_evas_get(ee);
    Evas_Object *vg,*bg;
    
    bg = evas_object_rectangle_add(evas);
    evas_object_color_set(bg, 0, 0, 255, 255);
    evas_object_focus_set(bg, 1);
    evas_object_show(bg);
    int w, h;
    ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
    evas_object_resize(bg, w, h);
    
    vg = evas_object_vg_add(evas);
    evas_object_focus_set(vg, 1);
    evas_object_show(vg);
    evas_object_resize(vg, w, h);
    
    Efl_VG *shape, *container;
    container = evas_vg_container_add(vg);
    shape = evas_vg_shape_add(container);
    
    evas_vg_shape_append_rect(shape, 0, 0, 200 , 200, 10, 10);
    evas_vg_shape_stroke_color_set(shape, 255, 255, 255, 10);
    evas_vg_shape_stroke_width_set(shape, 20);
    evas_vg_node_origin_set(shape, 200, 200);
    
    evas_object_vg_root_node_set(vg, container);
    ecore_main_loop_begin();
    ecore_evas_shutdown();
    
    Reviewers: Hermet, smohanty, kimcinoo
    
    Reviewed By: Hermet
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D9217
---
 src/lib/efl/interfaces/efl_gfx_shape.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c 
b/src/lib/efl/interfaces/efl_gfx_shape.c
index f5ebdab18e..fa3b718e1b 100644
--- a/src/lib/efl/interfaces/efl_gfx_shape.c
+++ b/src/lib/efl/interfaces/efl_gfx_shape.c
@@ -8,6 +8,8 @@
 
 #include <Efl.h>
 
+#define ERR(...) EINA_LOG_DOM_ERR(EINA_LOG_DOMAIN_DEFAULT, __VA_ARGS__)
+
 #define MY_CLASS EFL_GFX_SHAPE_MIXIN
 
 typedef struct _Efl_Gfx_Shape_Data
@@ -142,6 +144,17 @@ EOLIAN static void
 _efl_gfx_shape_stroke_color_set(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd,
                                 int r, int g, int b, int a)
 {
+   Eina_Bool err = EINA_FALSE;
+   if (a > 255) { a = 255; err = EINA_TRUE; }
+   if (a < 0) { a = 0; err = EINA_TRUE; }
+   if (r > a) { r = a; err = EINA_TRUE; }
+   if (r < 0) { r = 0; err = EINA_TRUE; }
+   if (g > a) { g = a; err = EINA_TRUE; }
+   if (g < 0) { g = 0; err = EINA_TRUE; }
+   if (b > a) { b = a; err = EINA_TRUE; }
+   if (b < 0) { b = 0; err = EINA_TRUE; }
+   if (err)
+     ERR("Only handles premultiplied colors (0 <= R,G,B <= A <= 255)");
    pd->public.stroke.color.r = r;
    pd->public.stroke.color.g = g;
    pd->public.stroke.color.b = b;

-- 


Reply via email to