summaryrefslogtreecommitdiff
path: root/src/lib/ector/software/ector_software_gradient.c
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-10-26 11:12:42 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-10 11:20:38 +0900
commit76e75dc105ce98b29d5fd9026a0bc2fd18e41acd (patch)
tree397f1fe9b924bd3390070f570d11e02a1d2c40e3 /src/lib/ector/software/ector_software_gradient.c
parent5f9c54a1b2724abcb02ba0a70640a927a1f67ccc (diff)
ector: move gradient generation api to draw library for reuse.
Diffstat (limited to 'src/lib/ector/software/ector_software_gradient.c')
-rw-r--r--src/lib/ector/software/ector_software_gradient.c63
1 files changed, 2 insertions, 61 deletions
diff --git a/src/lib/ector/software/ector_software_gradient.c b/src/lib/ector/software/ector_software_gradient.c
index 2656a1da5f..7f4e916511 100644
--- a/src/lib/ector/software/ector_software_gradient.c
+++ b/src/lib/ector/software/ector_software_gradient.c
@@ -280,73 +280,14 @@ _linear_helper_sse3(uint32_t *buffer, int length, Ector_Renderer_Software_Gradie
280 280
281#endif 281#endif
282 282
283static inline double
284_ease_linear(double t)
285{
286 return t;
287}
288
289static Eina_Bool
290_generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_count, uint32_t *color_table, int size)
291{
292 int dist, idist, pos = 0, i;
293 Eina_Bool alpha = EINA_FALSE;
294 Efl_Gfx_Gradient_Stop *curr, *next;
295 uint32_t current_color, next_color;
296 double delta, t, incr, fpos;
297
298 assert(stop_count > 0);
299
300 curr = gradient_stops;
301 if (curr->a != 255) alpha = EINA_TRUE;
302 current_color = DRAW_ARGB_JOIN(curr->a, curr->r, curr->g, curr->b);
303 incr = 1.0 / (double)size;
304 fpos = 1.5 * incr;
305
306 color_table[pos++] = current_color;
307
308 while (fpos <= curr->offset)
309 {
310 color_table[pos] = color_table[pos - 1];
311 pos++;
312 fpos += incr;
313 }
314
315 for (i = 0; i < stop_count - 1; ++i)
316 {
317 curr = (gradient_stops + i);
318 next = (gradient_stops + i + 1);
319 delta = 1/(next->offset - curr->offset);
320 if (next->a != 255) alpha = EINA_TRUE;
321 next_color = DRAW_ARGB_JOIN(next->a, next->r, next->g, next->b);
322 while (fpos < next->offset && pos < size)
323 {
324 t = _ease_linear((fpos - curr->offset) * delta);
325 dist = (int)(256 * t);
326 idist = 256 - dist;
327 color_table[pos] = draw_interpolate_256(current_color, idist, next_color, dist);
328 ++pos;
329 fpos += incr;
330 }
331 current_color = next_color;
332 }
333
334 for (;pos < size; ++pos)
335 color_table[pos] = current_color;
336
337 // Make sure the last color stop is represented at the end of the table
338 color_table[size-1] = current_color;
339 return alpha;
340}
341
342static void 283static void
343_update_color_table(void *data, Ector_Software_Thread *t EINA_UNUSED) 284_update_color_table(void *data, Ector_Software_Thread *t EINA_UNUSED)
344{ 285{
345 Ector_Renderer_Software_Gradient_Data *gdata = data; 286 Ector_Renderer_Software_Gradient_Data *gdata = data;
346 287
347 gdata->color_table = malloc(GRADIENT_STOPTABLE_SIZE * 4); 288 gdata->color_table = malloc(GRADIENT_STOPTABLE_SIZE * 4);
348 gdata->alpha = _generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count, 289 gdata->alpha = efl_draw_generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count,
349 gdata->color_table, GRADIENT_STOPTABLE_SIZE); 290 gdata->color_table, GRADIENT_STOPTABLE_SIZE);
350} 291}
351 292
352static void 293static void