forked from enlightenment/efl
ector: add alpha field to gradient data.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
e9896ee363
commit
48b558a997
|
@ -71,17 +71,21 @@ _ease_linear(double t)
|
|||
return t;
|
||||
}
|
||||
|
||||
static void
|
||||
static Eina_Bool
|
||||
_generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_count, uint *color_table, int size)
|
||||
{
|
||||
int pos = 0;
|
||||
int dist, idist, pos = 0, i;
|
||||
Eina_Bool alpha = EINA_FALSE;
|
||||
Efl_Gfx_Gradient_Stop *curr, *next;
|
||||
uint current_color, next_color;
|
||||
double delta, t, incr, fpos;
|
||||
assert(stop_count > 0);
|
||||
|
||||
curr = gradient_stops;
|
||||
uint current_color = ECTOR_ARGB_JOIN(curr->a, curr->r, curr->g, curr->b);
|
||||
double incr = 1.0 / (double)size;
|
||||
double fpos = 1.5 * incr;
|
||||
if (curr->a != 255) alpha = EINA_TRUE;
|
||||
current_color = ECTOR_ARGB_JOIN(curr->a, curr->r, curr->g, curr->b);
|
||||
incr = 1.0 / (double)size;
|
||||
fpos = 1.5 * incr;
|
||||
|
||||
color_table[pos++] = current_color;
|
||||
|
||||
|
@ -92,18 +96,19 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c
|
|||
fpos += incr;
|
||||
}
|
||||
|
||||
for (int i = 0; i < stop_count - 1; ++i)
|
||||
for (i = 0; i < stop_count - 1; ++i)
|
||||
{
|
||||
curr = (gradient_stops + i);
|
||||
next = (gradient_stops + i + 1);
|
||||
double delta = 1/(next->offset - curr->offset);
|
||||
uint next_color = ECTOR_ARGB_JOIN(next->a, next->r, next->g, next->b);
|
||||
delta = 1/(next->offset - curr->offset);
|
||||
if (next->a != 255) alpha = EINA_TRUE;
|
||||
next_color = ECTOR_ARGB_JOIN(next->a, next->r, next->g, next->b);
|
||||
BLEND_FUNC func = &_ease_linear;
|
||||
while (fpos < next->offset && pos < size)
|
||||
{
|
||||
double t = func((fpos - curr->offset) * delta);
|
||||
int dist = (int)(256 * t);
|
||||
int idist = 256 - dist;
|
||||
t = func((fpos - curr->offset) * delta);
|
||||
dist = (int)(256 * t);
|
||||
idist = 256 - dist;
|
||||
color_table[pos] = INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist);
|
||||
++pos;
|
||||
fpos += incr;
|
||||
|
@ -116,16 +121,17 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c
|
|||
|
||||
// Make sure the last color stop is represented at the end of the table
|
||||
color_table[size-1] = current_color;
|
||||
return alpha;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
update_color_table(Ector_Renderer_Software_Gradient_Data *gdata)
|
||||
{
|
||||
if(gdata->color_table) return;
|
||||
if (gdata->color_table) return;
|
||||
|
||||
gdata->color_table = malloc(GRADIENT_STOPTABLE_SIZE * 4);
|
||||
_generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count, gdata->color_table, GRADIENT_STOPTABLE_SIZE);
|
||||
gdata->alpha = _generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count, gdata->color_table, GRADIENT_STOPTABLE_SIZE);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -42,6 +42,7 @@ typedef struct _Ector_Renderer_Software_Gradient_Data
|
|||
Software_Gradient_Linear_Data linear;
|
||||
Software_Gradient_Radial_Data radial;
|
||||
};
|
||||
Eina_Bool alpha;
|
||||
uint* color_table;
|
||||
} Ector_Renderer_Software_Gradient_Data;
|
||||
|
||||
|
|
Loading…
Reference in New Issue