hermet pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=11a1fc9f2b6c6da4bc0000acfdb7840248bb6c78

commit 11a1fc9f2b6c6da4bc0000acfdb7840248bb6c78
Author: Hermet Park <hermetp...@gmail.com>
Date:   Thu Dec 19 20:27:11 2019 +0900

    ector software: catch up losing tasks among the threads.
    
    This is a subsequent change after 8465904c19ea3de2c94c25259ca6a75d0241b4f1.
    
    The major change is almost same but just for gradient stuff.
---
 .../ector_renderer_software_gradient_linear.c      | 20 ++++++++++----------
 .../ector_renderer_software_gradient_radial.c      | 17 +++++++++--------
 src/lib/ector/software/ector_software_gradient.c   | 22 +++++++++++-----------
 src/lib/ector/software/ector_software_gradient.h   |  4 ++++
 src/lib/ector/software/ector_software_private.h    |  2 +-
 5 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/src/lib/ector/software/ector_renderer_software_gradient_linear.c 
b/src/lib/ector/software/ector_renderer_software_gradient_linear.c
index 999feedc42..0e5bc93921 100644
--- a/src/lib/ector/software/ector_renderer_software_gradient_linear.c
+++ b/src/lib/ector/software/ector_renderer_software_gradient_linear.c
@@ -8,19 +8,19 @@
 
 #include "ector_private.h"
 #include "ector_software_private.h"
+#include "ector_software_gradient.h"
 
 static Eina_Bool
 _ector_renderer_software_gradient_linear_ector_renderer_prepare(Eo *obj,
                                                                 
Ector_Renderer_Software_Gradient_Data *pd)
 {
+   pd->ctable_status = CTABLE_NOT_READY;
+
    if (!pd->surface)
      {
-        Ector_Renderer_Data *base;
-
-        base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
+        Ector_Renderer_Data *base = efl_data_scope_get(obj, 
ECTOR_RENDERER_CLASS);
         pd->surface = efl_data_xref(base->surface, 
ECTOR_SOFTWARE_SURFACE_CLASS, obj);
      }
-
    ector_software_gradient_color_update(pd);
 
    pd->linear.x1 = pd->gld->start.x;
@@ -55,23 +55,24 @@ 
_ector_renderer_software_gradient_linear_ector_renderer_draw(Eo *obj EINA_UNUSED
 
 static Eina_Bool
 _ector_renderer_software_gradient_linear_ector_renderer_software_op_fill(Eo 
*obj EINA_UNUSED,
-                                                                      
Ector_Renderer_Software_Gradient_Data *pd)
+                                                                         
Ector_Renderer_Software_Gradient_Data *pd)
 {
    ector_software_rasterizer_linear_gradient_set(pd->surface->rasterizer, pd);
    ector_software_gradient_color_update(pd);
+
    return EINA_TRUE;
 }
 
 static Eo *
 _ector_renderer_software_gradient_linear_efl_object_constructor(Eo *obj,
-                                                             
Ector_Renderer_Software_Gradient_Data *pd)
+                                                                
Ector_Renderer_Software_Gradient_Data *pd)
 {
    obj = efl_constructor(efl_super(obj, 
ECTOR_RENDERER_SOFTWARE_GRADIENT_LINEAR_CLASS));
    if (!obj) return NULL;
 
    pd->gd  = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_MIXIN, obj);
    pd->gld = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN, obj);
-   pd->done = EINA_TRUE;
+   pd->ctable_status = CTABLE_NOT_READY;
 
    return obj;
 }
@@ -94,11 +95,10 @@ 
_ector_renderer_software_gradient_linear_efl_object_destructor(Eo *obj,
 }
 
 void
-_ector_renderer_software_gradient_linear_efl_gfx_gradient_stop_set(Eo *obj, 
Ector_Renderer_Software_Gradient_Data *pd, const Efl_Gfx_Gradient_Stop *colors, 
unsigned int length)
+_ector_renderer_software_gradient_linear_efl_gfx_gradient_stop_set(Eo *obj, 
Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED,
+                                                                   const 
Efl_Gfx_Gradient_Stop *colors, unsigned int length)
 {
    efl_gfx_gradient_stop_set(efl_super(obj, 
ECTOR_RENDERER_SOFTWARE_GRADIENT_LINEAR_CLASS), colors, length);
-
-   destroy_color_table(pd);
 }
 
 static unsigned int
diff --git a/src/lib/ector/software/ector_renderer_software_gradient_radial.c 
b/src/lib/ector/software/ector_renderer_software_gradient_radial.c
index 989bcaadbe..6f6c87700c 100644
--- a/src/lib/ector/software/ector_renderer_software_gradient_radial.c
+++ b/src/lib/ector/software/ector_renderer_software_gradient_radial.c
@@ -8,15 +8,16 @@
 
 #include "ector_private.h"
 #include "ector_software_private.h"
+#include "ector_software_gradient.h"
 
 static Eina_Bool
 _ector_renderer_software_gradient_radial_ector_renderer_prepare(Eo *obj, 
Ector_Renderer_Software_Gradient_Data *pd)
 {
+   pd->ctable_status = CTABLE_NOT_READY;
+
    if (!pd->surface)
      {
-        Ector_Renderer_Data *base;
-
-        base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
+        Ector_Renderer_Data *base = efl_data_scope_get(obj, 
ECTOR_RENDERER_CLASS);
         pd->surface = efl_data_xref(base->surface, 
ECTOR_SOFTWARE_SURFACE_CLASS, obj);
      }
 
@@ -70,17 +71,18 @@ 
_ector_renderer_software_gradient_radial_ector_renderer_software_op_fill(Eo *obj
 {
    ector_software_rasterizer_radial_gradient_set(pd->surface->rasterizer, pd);
    ector_software_gradient_color_update(pd);
+
    return EINA_TRUE;
 }
 
 Eo *
 _ector_renderer_software_gradient_radial_efl_object_constructor(Eo *obj,
-                                                             
Ector_Renderer_Software_Gradient_Data *pd)
+                                                                
Ector_Renderer_Software_Gradient_Data *pd)
 {
    obj = efl_constructor(efl_super(obj, 
ECTOR_RENDERER_SOFTWARE_GRADIENT_RADIAL_CLASS));
    pd->gd  = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_MIXIN, obj);
    pd->gld = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN, obj);
-   pd->done = EINA_TRUE;
+   pd->ctable_status = CTABLE_NOT_READY;
 
    return obj;
 }
@@ -103,11 +105,10 @@ 
_ector_renderer_software_gradient_radial_efl_object_destructor(Eo *obj,
 }
 
 void
-_ector_renderer_software_gradient_radial_efl_gfx_gradient_stop_set(Eo *obj, 
Ector_Renderer_Software_Gradient_Data *pd, const Efl_Gfx_Gradient_Stop *colors, 
unsigned int length)
+_ector_renderer_software_gradient_radial_efl_gfx_gradient_stop_set(Eo *obj, 
Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED,
+                                                                   const 
Efl_Gfx_Gradient_Stop *colors, unsigned int length)
 {
    efl_gfx_gradient_stop_set(efl_super(obj, 
ECTOR_RENDERER_SOFTWARE_GRADIENT_RADIAL_CLASS), colors, length);
-
-   destroy_color_table(pd);
 }
 
 static unsigned int
diff --git a/src/lib/ector/software/ector_software_gradient.c 
b/src/lib/ector/software/ector_software_gradient.c
index 1681d80724..be20635e29 100644
--- a/src/lib/ector/software/ector_software_gradient.c
+++ b/src/lib/ector/software/ector_software_gradient.c
@@ -11,7 +11,6 @@ void _linear_helper_sse3(uint32_t *buffer, int length, 
Ector_Renderer_Software_G
 
 typedef void (*Ector_Radial_Helper_Func)(uint32_t *buffer, int length, 
Ector_Renderer_Software_Gradient_Data *g_data,
                                           float det, float delta_det, float 
delta_delta_det, float b, float delta_b);
-
 typedef void (*Ector_Linear_Helper_Func)(uint32_t *buffer, int length, 
Ector_Renderer_Software_Gradient_Data *g_data,
                                           int t_fixed, int inc_fixed);
 
@@ -22,8 +21,6 @@ static void
 _update_color_table(void *data, Ector_Software_Thread *t EINA_UNUSED)
 {
    Ector_Renderer_Software_Gradient_Data *gdata = data;
-
-   gdata->color_table = malloc(GRADIENT_STOPTABLE_SIZE * 4);
    gdata->alpha = efl_draw_generate_gradient_color_table(gdata->gd->colors, 
gdata->gd->colors_count,
                                                          gdata->color_table, 
GRADIENT_STOPTABLE_SIZE);
 }
@@ -32,24 +29,27 @@ static void
 _done_color_table(void *data)
 {
    Ector_Renderer_Software_Gradient_Data *gdata = data;
-
-   gdata->done = EINA_TRUE;
+   gdata->ctable_status = CTABLE_READY_DONE;
 }
 
 void
 ector_software_gradient_color_update(Ector_Renderer_Software_Gradient_Data 
*gdata)
 {
-   if (!gdata->done)
-     {
-        ector_software_wait(_update_color_table, _done_color_table, gdata);
-        return ;
-     }
+   if (gdata->ctable_status == CTABLE_READY_DONE) return;
+
+   //OPTIMIZE: This color can be updated only when gradient properties are 
changed.
 
+   //Alloc only one time.
    if (!gdata->color_table)
+     gdata->color_table = malloc(GRADIENT_STOPTABLE_SIZE * 4);
+
+   if (gdata->ctable_status == CTABLE_NOT_READY)
      {
-        gdata->done = EINA_FALSE;
+        gdata->ctable_status = CTABLE_PROCESSING;
         ector_software_schedule(_update_color_table, _done_color_table, gdata);
      }
+   else if (gdata->ctable_status == CTABLE_PROCESSING)
+        ector_software_wait(_update_color_table, _done_color_table, gdata);
 }
 
 void
diff --git a/src/lib/ector/software/ector_software_gradient.h 
b/src/lib/ector/software/ector_software_gradient.h
index 2cbf2f99d7..38731de97d 100644
--- a/src/lib/ector/software/ector_software_gradient.h
+++ b/src/lib/ector/software/ector_software_gradient.h
@@ -18,6 +18,10 @@
 #define FIXPT_BITS 8
 #define FIXPT_SIZE (1<<FIXPT_BITS)
 
+#define CTABLE_NOT_READY 0
+#define CTABLE_PROCESSING 1
+#define CTABLE_READY_DONE 2
+
 static inline int
 _gradient_clamp(const Ector_Renderer_Software_Gradient_Data *data, int ipos)
 {
diff --git a/src/lib/ector/software/ector_software_private.h 
b/src/lib/ector/software/ector_software_private.h
index 24fe240f58..a769cc8a87 100644
--- a/src/lib/ector/software/ector_software_private.h
+++ b/src/lib/ector/software/ector_software_private.h
@@ -48,7 +48,7 @@ typedef struct _Ector_Renderer_Software_Gradient_Data
    uint32_t* color_table;
 
    Eina_Bool alpha;
-   Eina_Bool done;
+   int ctable_status;       //Ready for color table?
 } Ector_Renderer_Software_Gradient_Data;
 
 typedef struct _Shape_Rle_Data

-- 


Reply via email to