summaryrefslogtreecommitdiff
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
parent5f9c54a1b2724abcb02ba0a70640a927a1f67ccc (diff)
downloadefl-76e75dc105ce98b29d5fd9026a0bc2fd18e41acd.tar.gz
ector: move gradient generation api to draw library for reuse.
-rw-r--r--src/lib/ector/software/ector_software_gradient.c63
-rw-r--r--src/static_libs/draw/draw.h2
-rw-r--r--src/static_libs/draw/draw_main.c58
3 files changed, 62 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
#endif
-static inline double
-_ease_linear(double t)
-{
- return t;
-}
-
-static Eina_Bool
-_generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_count, uint32_t *color_table, int size)
-{
- int dist, idist, pos = 0, i;
- Eina_Bool alpha = EINA_FALSE;
- Efl_Gfx_Gradient_Stop *curr, *next;
- uint32_t current_color, next_color;
- double delta, t, incr, fpos;
-
- assert(stop_count > 0);
-
- curr = gradient_stops;
- if (curr->a != 255) alpha = EINA_TRUE;
- current_color = DRAW_ARGB_JOIN(curr->a, curr->r, curr->g, curr->b);
- incr = 1.0 / (double)size;
- fpos = 1.5 * incr;
-
- color_table[pos++] = current_color;
-
- while (fpos <= curr->offset)
- {
- color_table[pos] = color_table[pos - 1];
- pos++;
- fpos += incr;
- }
-
- for (i = 0; i < stop_count - 1; ++i)
- {
- curr = (gradient_stops + i);
- next = (gradient_stops + i + 1);
- delta = 1/(next->offset - curr->offset);
- if (next->a != 255) alpha = EINA_TRUE;
- next_color = DRAW_ARGB_JOIN(next->a, next->r, next->g, next->b);
- while (fpos < next->offset && pos < size)
- {
- t = _ease_linear((fpos - curr->offset) * delta);
- dist = (int)(256 * t);
- idist = 256 - dist;
- color_table[pos] = draw_interpolate_256(current_color, idist, next_color, dist);
- ++pos;
- fpos += incr;
- }
- current_color = next_color;
- }
-
- for (;pos < size; ++pos)
- color_table[pos] = current_color;
-
- // Make sure the last color stop is represented at the end of the table
- color_table[size-1] = current_color;
- return alpha;
-}
-
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 = _generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count,
- gdata->color_table, GRADIENT_STOPTABLE_SIZE);
+ gdata->alpha = efl_draw_generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count,
+ gdata->color_table, GRADIENT_STOPTABLE_SIZE);
}
static void
diff --git a/src/static_libs/draw/draw.h b/src/static_libs/draw/draw.h
index e4f64340f4..825d6338f0 100644
--- a/src/static_libs/draw/draw.h
+++ b/src/static_libs/draw/draw.h
@@ -29,6 +29,8 @@ Cspace_Convert_Func efl_draw_convert_func_get (Efl_Gfx_Colorspace origcs,
int efl_draw_argb_premul(uint32_t *data, unsigned int len);
void efl_draw_argb_unpremul(uint32_t *data, unsigned int len);
+Eina_Bool efl_draw_generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_count, uint32_t *color_table, int size);
+
/* common sw draw helpers */
diff --git a/src/static_libs/draw/draw_main.c b/src/static_libs/draw/draw_main.c
index 92d2044541..2731514789 100644
--- a/src/static_libs/draw/draw_main.c
+++ b/src/static_libs/draw/draw_main.c
@@ -276,6 +276,64 @@ efl_draw_func_span_get(Efl_Gfx_Render_Op op, uint32_t color, Eina_Bool src_alpha
return func_for_mode[op];
}
+static double
+_ease_linear(double t)
+{
+ return t;
+}
+
+Eina_Bool
+efl_draw_generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_count, uint32_t *color_table, int size)
+{
+ int dist, idist, pos = 0, i;
+ Eina_Bool alpha = EINA_FALSE;
+ Efl_Gfx_Gradient_Stop *curr, *next;
+ uint32_t current_color, next_color;
+ double delta, t, incr, fpos;
+
+ curr = gradient_stops;
+ if (curr->a != 255) alpha = EINA_TRUE;
+ current_color = DRAW_ARGB_JOIN(curr->a, curr->r, curr->g, curr->b);
+ incr = 1.0 / (double)size;
+ fpos = 1.5 * incr;
+
+ color_table[pos++] = current_color;
+
+ while (fpos <= curr->offset)
+ {
+ color_table[pos] = color_table[pos - 1];
+ pos++;
+ fpos += incr;
+ }
+
+ for (i = 0; i < stop_count - 1; ++i)
+ {
+ curr = (gradient_stops + i);
+ next = (gradient_stops + i + 1);
+ delta = 1/(next->offset - curr->offset);
+ if (next->a != 255) alpha = EINA_TRUE;
+ next_color = DRAW_ARGB_JOIN(next->a, next->r, next->g, next->b);
+ while (fpos < next->offset && pos < size)
+ {
+ t = _ease_linear((fpos - curr->offset) * delta);
+ dist = (int)(256 * t);
+ idist = 256 - dist;
+ color_table[pos] = draw_interpolate_256(current_color, idist, next_color, dist);
+ ++pos;
+ fpos += incr;
+ }
+ current_color = next_color;
+ }
+
+ for (;pos < size; ++pos)
+ color_table[pos] = current_color;
+
+ // Make sure the last color stop is represented at the end of the table
+ color_table[size-1] = current_color;
+ return alpha;
+}
+
+
int
efl_draw_init(void)
{