summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-09-17 11:46:09 -0700
committerCedric Bail <cedric@osg.samsung.com>2017-09-17 11:49:48 -0700
commit39fdfc3cac94746c9943cac04c99314d1b0b95a3 (patch)
treeefe8c497a6ee12cac5d318f59d8029c2b709daf3 /src/lib
parente380ddb742384546ad05a5f8f5472ecdce795538 (diff)
ector: move gradient color computation to a pool of thread.
This has been a long standing plan for improving performance in rendering vector object. If your test involve updating gradient, you will get another speedup of around 15%. Combined with previous shape, we get a 65% improvement with doing the CPU intensive computation in there own thread before the rendering kickoff. This was motly theorical until now, but well, it works great !
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ector/software/ector_renderer_software_gradient_linear.c15
-rw-r--r--src/lib/ector/software/ector_renderer_software_gradient_radial.c10
-rw-r--r--src/lib/ector/software/ector_software_gradient.c31
-rw-r--r--src/lib/ector/software/ector_software_private.h7
4 files changed, 46 insertions, 17 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 4bd4806..f024594 100644
--- a/src/lib/ector/software/ector_renderer_software_gradient_linear.c
+++ b/src/lib/ector/software/ector_renderer_software_gradient_linear.c
@@ -11,7 +11,7 @@
11 11
12static Eina_Bool 12static Eina_Bool
13_ector_renderer_software_gradient_linear_ector_renderer_prepare(Eo *obj, 13_ector_renderer_software_gradient_linear_ector_renderer_prepare(Eo *obj,
14 Ector_Renderer_Software_Gradient_Data *pd) 14 Ector_Renderer_Software_Gradient_Data *pd)
15{ 15{
16 if (!pd->surface) 16 if (!pd->surface)
17 { 17 {
@@ -21,7 +21,7 @@ _ector_renderer_software_gradient_linear_ector_renderer_prepare(Eo *obj,
21 pd->surface = efl_data_xref(base->surface, ECTOR_SOFTWARE_SURFACE_CLASS, obj); 21 pd->surface = efl_data_xref(base->surface, ECTOR_SOFTWARE_SURFACE_CLASS, obj);
22 } 22 }
23 23
24 update_color_table(pd); 24 ector_software_gradient_color_update(pd);
25 25
26 pd->linear.x1 = pd->gld->start.x; 26 pd->linear.x1 = pd->gld->start.x;
27 pd->linear.y1 = pd->gld->start.y; 27 pd->linear.y1 = pd->gld->start.y;
@@ -46,19 +46,19 @@ _ector_renderer_software_gradient_linear_ector_renderer_prepare(Eo *obj,
46 46
47static Eina_Bool 47static Eina_Bool
48_ector_renderer_software_gradient_linear_ector_renderer_draw(Eo *obj EINA_UNUSED, 48_ector_renderer_software_gradient_linear_ector_renderer_draw(Eo *obj EINA_UNUSED,
49 Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, 49 Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED,
50 Efl_Gfx_Render_Op op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, 50 Efl_Gfx_Render_Op op EINA_UNUSED, Eina_Array *clips EINA_UNUSED,
51 unsigned int mul_col EINA_UNUSED) 51 unsigned int mul_col EINA_UNUSED)
52{ 52{
53 return EINA_TRUE; 53 return EINA_TRUE;
54} 54}
55 55
56static Eina_Bool 56static Eina_Bool
57_ector_renderer_software_gradient_linear_ector_renderer_software_fill(Eo *obj EINA_UNUSED, 57_ector_renderer_software_gradient_linear_ector_renderer_software_fill(Eo *obj EINA_UNUSED,
58 Ector_Renderer_Software_Gradient_Data *pd) 58 Ector_Renderer_Software_Gradient_Data *pd)
59{ 59{
60 ector_software_rasterizer_linear_gradient_set(pd->surface->rasterizer, pd); 60 ector_software_rasterizer_linear_gradient_set(pd->surface->rasterizer, pd);
61 61 ector_software_gradient_color_update(pd);
62 return EINA_TRUE; 62 return EINA_TRUE;
63} 63}
64 64
@@ -71,6 +71,7 @@ _ector_renderer_software_gradient_linear_efl_object_constructor(Eo *obj,
71 71
72 pd->gd = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_MIXIN, obj); 72 pd->gd = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_MIXIN, obj);
73 pd->gld = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN, obj); 73 pd->gld = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN, obj);
74 pd->done = EINA_TRUE;
74 75
75 return obj; 76 return obj;
76} 77}
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 0925cb9..d28ed0c 100644
--- a/src/lib/ector/software/ector_renderer_software_gradient_radial.c
+++ b/src/lib/ector/software/ector_renderer_software_gradient_radial.c
@@ -20,7 +20,7 @@ _ector_renderer_software_gradient_radial_ector_renderer_prepare(Eo *obj, Ector_R
20 pd->surface = efl_data_xref(base->surface, ECTOR_SOFTWARE_SURFACE_CLASS, obj); 20 pd->surface = efl_data_xref(base->surface, ECTOR_SOFTWARE_SURFACE_CLASS, obj);
21 } 21 }
22 22
23 update_color_table(pd); 23 ector_software_gradient_color_update(pd);
24 24
25 pd->radial.cx = pd->grd->radial.x; 25 pd->radial.cx = pd->grd->radial.x;
26 pd->radial.cy = pd->grd->radial.y; 26 pd->radial.cy = pd->grd->radial.y;
@@ -57,9 +57,9 @@ _ector_renderer_software_gradient_radial_ector_renderer_prepare(Eo *obj, Ector_R
57// Clearly duplicated and should be in a common place... 57// Clearly duplicated and should be in a common place...
58static Eina_Bool 58static Eina_Bool
59_ector_renderer_software_gradient_radial_ector_renderer_draw(Eo *obj EINA_UNUSED, 59_ector_renderer_software_gradient_radial_ector_renderer_draw(Eo *obj EINA_UNUSED,
60 Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, 60 Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED,
61 Efl_Gfx_Render_Op op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, 61 Efl_Gfx_Render_Op op EINA_UNUSED, Eina_Array *clips EINA_UNUSED,
62 unsigned int mul_col EINA_UNUSED) 62 unsigned int mul_col EINA_UNUSED)
63{ 63{
64 return EINA_TRUE; 64 return EINA_TRUE;
65} 65}
@@ -69,6 +69,7 @@ static Eina_Bool
69_ector_renderer_software_gradient_radial_ector_renderer_software_fill(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd) 69_ector_renderer_software_gradient_radial_ector_renderer_software_fill(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd)
70{ 70{
71 ector_software_rasterizer_radial_gradient_set(pd->surface->rasterizer, pd); 71 ector_software_rasterizer_radial_gradient_set(pd->surface->rasterizer, pd);
72 ector_software_gradient_color_update(pd);
72 return EINA_TRUE; 73 return EINA_TRUE;
73} 74}
74 75
@@ -79,6 +80,7 @@ _ector_renderer_software_gradient_radial_efl_object_constructor(Eo *obj,
79 obj = efl_constructor(efl_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_RADIAL_CLASS)); 80 obj = efl_constructor(efl_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_RADIAL_CLASS));
80 pd->gd = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_MIXIN, obj); 81 pd->gd = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_MIXIN, obj);
81 pd->gld = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN, obj); 82 pd->gld = efl_data_xref(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN, obj);
83 pd->done = EINA_TRUE;
82 84
83 return obj; 85 return obj;
84} 86}
diff --git a/src/lib/ector/software/ector_software_gradient.c b/src/lib/ector/software/ector_software_gradient.c
index 627bd3e..2656a1d 100644
--- a/src/lib/ector/software/ector_software_gradient.c
+++ b/src/lib/ector/software/ector_software_gradient.c
@@ -339,17 +339,40 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c
339 return alpha; 339 return alpha;
340} 340}
341 341
342 342static void
343void 343_update_color_table(void *data, Ector_Software_Thread *t EINA_UNUSED)
344update_color_table(Ector_Renderer_Software_Gradient_Data *gdata)
345{ 344{
346 if (gdata->color_table) return; 345 Ector_Renderer_Software_Gradient_Data *gdata = data;
347 346
348 gdata->color_table = malloc(GRADIENT_STOPTABLE_SIZE * 4); 347 gdata->color_table = malloc(GRADIENT_STOPTABLE_SIZE * 4);
349 gdata->alpha = _generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count, 348 gdata->alpha = _generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count,
350 gdata->color_table, GRADIENT_STOPTABLE_SIZE); 349 gdata->color_table, GRADIENT_STOPTABLE_SIZE);
351} 350}
352 351
352static void
353_done_color_table(void *data)
354{
355 Ector_Renderer_Software_Gradient_Data *gdata = data;
356
357 gdata->done = EINA_TRUE;
358}
359
360void
361ector_software_gradient_color_update(Ector_Renderer_Software_Gradient_Data *gdata)
362{
363 if (!gdata->done)
364 {
365 ector_software_wait(_update_color_table, _done_color_table, gdata);
366 return ;
367 }
368
369 if (!gdata->color_table)
370 {
371 gdata->done = EINA_FALSE;
372 ector_software_schedule(_update_color_table, _done_color_table, gdata);
373 }
374}
375
353void 376void
354destroy_color_table(Ector_Renderer_Software_Gradient_Data *gdata) 377destroy_color_table(Ector_Renderer_Software_Gradient_Data *gdata)
355{ 378{
diff --git a/src/lib/ector/software/ector_software_private.h b/src/lib/ector/software/ector_software_private.h
index e35f681..270a14d 100644
--- a/src/lib/ector/software/ector_software_private.h
+++ b/src/lib/ector/software/ector_software_private.h
@@ -44,8 +44,10 @@ typedef struct _Ector_Renderer_Software_Gradient_Data
44 Software_Gradient_Linear_Data linear; 44 Software_Gradient_Linear_Data linear;
45 Software_Gradient_Radial_Data radial; 45 Software_Gradient_Radial_Data radial;
46 }; 46 };
47 Eina_Bool alpha;
48 uint32_t* color_table; 47 uint32_t* color_table;
48
49 Eina_Bool alpha;
50 Eina_Bool done;
49} Ector_Renderer_Software_Gradient_Data; 51} Ector_Renderer_Software_Gradient_Data;
50 52
51typedef struct _Shape_Rle_Data 53typedef struct _Shape_Rle_Data
@@ -133,7 +135,6 @@ void ector_software_rasterizer_destroy_rle_data(Shape_Rle_Data *rle);
133 135
134 136
135// Gradient Api 137// Gradient Api
136void update_color_table(Ector_Renderer_Software_Gradient_Data *gdata);
137void destroy_color_table(Ector_Renderer_Software_Gradient_Data *gdata); 138void destroy_color_table(Ector_Renderer_Software_Gradient_Data *gdata);
138void fetch_linear_gradient(uint32_t *buffer, Span_Data *data, int y, int x, int length); 139void fetch_linear_gradient(uint32_t *buffer, Span_Data *data, int y, int x, int length);
139void fetch_radial_gradient(uint32_t *buffer, Span_Data *data, int y, int x, int length); 140void fetch_radial_gradient(uint32_t *buffer, Span_Data *data, int y, int x, int length);
@@ -146,4 +147,6 @@ typedef void (*Ector_Thread_Worker_Cb)(void *data, Ector_Software_Thread *thread
146void ector_software_wait(Ector_Thread_Worker_Cb cb, Eina_Free_Cb done, void *data); 147void ector_software_wait(Ector_Thread_Worker_Cb cb, Eina_Free_Cb done, void *data);
147void ector_software_schedule(Ector_Thread_Worker_Cb cb, Eina_Free_Cb done, void *data); 148void ector_software_schedule(Ector_Thread_Worker_Cb cb, Eina_Free_Cb done, void *data);
148 149
150void ector_software_gradient_color_update(Ector_Renderer_Software_Gradient_Data *gdata);
151
149#endif 152#endif