forked from enlightenment/efl
Draw: Add new mask functions
Copy & blend to uint32 with a uint8 mask + color.
This commit is contained in:
parent
9f1eb3e021
commit
9457411861
|
@ -9,13 +9,15 @@
|
||||||
|
|
||||||
typedef void (*RGBA_Comp_Func) (uint32_t *dest, const uint32_t *src, int length, uint32_t mul_col, uint32_t const_alpha);
|
typedef void (*RGBA_Comp_Func) (uint32_t *dest, const uint32_t *src, int length, uint32_t mul_col, uint32_t const_alpha);
|
||||||
typedef void (*RGBA_Comp_Func_Solid) (uint32_t *dest, int length, uint32_t color, uint32_t const_alpha);
|
typedef void (*RGBA_Comp_Func_Solid) (uint32_t *dest, int length, uint32_t color, uint32_t const_alpha);
|
||||||
|
typedef void (*RGBA_Comp_Func_Mask) (uint32_t *dest, uint8_t *mask, int length, uint32_t color);
|
||||||
typedef void (*Alpha_Gfx_Func) (uint8_t *src, uint8_t *dst, int len);
|
typedef void (*Alpha_Gfx_Func) (uint8_t *src, uint8_t *dst, int len);
|
||||||
|
|
||||||
int efl_draw_init(void);
|
int efl_draw_init(void);
|
||||||
|
|
||||||
RGBA_Comp_Func efl_draw_func_span_get(Efl_Gfx_Render_Op op, uint32_t color, Eina_Bool src_alpha);
|
RGBA_Comp_Func efl_draw_func_span_get (Efl_Gfx_Render_Op op, uint32_t color, Eina_Bool src_alpha);
|
||||||
RGBA_Comp_Func_Solid efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint32_t color);
|
RGBA_Comp_Func_Solid efl_draw_func_solid_span_get (Efl_Gfx_Render_Op op, uint32_t color);
|
||||||
Alpha_Gfx_Func efl_draw_alpha_func_get(Efl_Gfx_Render_Op op, Eina_Bool has_mask);
|
RGBA_Comp_Func_Mask efl_draw_func_mask_span_get (Efl_Gfx_Render_Op op, uint32_t color);
|
||||||
|
Alpha_Gfx_Func efl_draw_alpha_func_get (Efl_Gfx_Render_Op op, Eina_Bool has_mask);
|
||||||
|
|
||||||
|
|
||||||
/* common sw draw helpers */
|
/* common sw draw helpers */
|
||||||
|
@ -57,12 +59,16 @@ Alpha_Gfx_Func efl_draw_alpha_func_get(Efl_Gfx_Render_Op op, Eina_Bool has_mask)
|
||||||
((((((x) & 0xff00) * ((y) & 0xff00)) + 0xff0000) >> 16) & 0xff00) + \
|
((((((x) & 0xff00) * ((y) & 0xff00)) + 0xff0000) >> 16) & 0xff00) + \
|
||||||
(((((x) & 0xff) * ((y) & 0xff)) + 0xff) >> 8) )
|
(((((x) & 0xff) * ((y) & 0xff)) + 0xff) >> 8) )
|
||||||
|
|
||||||
#define DRAW_MUL_256(a, c) \
|
/* alpha from 1 to 256 */
|
||||||
( (((((c) >> 8) & 0x00ff00ff) * (a)) & 0xff00ff00) + \
|
static inline uint32_t
|
||||||
(((((c) & 0x00ff00ff) * (a)) >> 8) & 0x00ff00ff) )
|
draw_mul_256(int a, uint32_t c)
|
||||||
|
{
|
||||||
|
return (((((c) >> 8) & 0x00ff00ff) * (a)) & 0xff00ff00) |
|
||||||
|
(((((c) & 0x00ff00ff) * (a)) >> 8) & 0x00ff00ff);
|
||||||
|
}
|
||||||
|
|
||||||
static inline uint32_t
|
static inline uint32_t
|
||||||
draw_interpolate_256(uint32_t x, uint32_t a, uint32_t y, uint32_t b)
|
draw_interpolate_256(uint32_t x, int a, uint32_t y, int b)
|
||||||
{
|
{
|
||||||
uint32_t t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
|
uint32_t t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
|
||||||
t >>= 8;
|
t >>= 8;
|
||||||
|
|
|
@ -128,6 +128,39 @@ _comp_func_source(uint32_t *dest, const uint32_t *src, int length, uint32_t colo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* s = m * color
|
||||||
|
* d = d * (1-sa) + s * sa
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
_comp_func_mask_blend(uint32_t *dest, uint8_t *mask, int length, uint32_t color)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
|
||||||
|
for (k = 0; k < length; k++, dest++, mask++)
|
||||||
|
{
|
||||||
|
uint32_t c = draw_mul_256(*mask, color);
|
||||||
|
int a = 256 - (c >> 24);
|
||||||
|
*dest = c + draw_mul_256(a, *dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_comp_func_mask_copy(uint32_t *dest, uint8_t *mask, int length, uint32_t color)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
|
||||||
|
for (k = 0; k < length; k++, dest++, mask++)
|
||||||
|
{
|
||||||
|
int a = (*mask & 0x80) ? *mask + 1 : *mask;
|
||||||
|
*dest = draw_mul_256(a, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBA_Comp_Func_Mask func_for_mode_mask[EFL_GFX_RENDER_OP_LAST] = {
|
||||||
|
_comp_func_mask_blend,
|
||||||
|
_comp_func_mask_copy
|
||||||
|
};
|
||||||
|
|
||||||
RGBA_Comp_Func_Solid func_for_mode_solid[EFL_GFX_RENDER_OP_LAST] = {
|
RGBA_Comp_Func_Solid func_for_mode_solid[EFL_GFX_RENDER_OP_LAST] = {
|
||||||
_comp_func_solid_source_over,
|
_comp_func_solid_source_over,
|
||||||
_comp_func_solid_source
|
_comp_func_solid_source
|
||||||
|
@ -138,6 +171,12 @@ RGBA_Comp_Func func_for_mode[EFL_GFX_RENDER_OP_LAST] = {
|
||||||
_comp_func_source
|
_comp_func_source
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RGBA_Comp_Func_Mask
|
||||||
|
efl_draw_func_mask_span_get(Efl_Gfx_Render_Op op, uint32_t color EINA_UNUSED)
|
||||||
|
{
|
||||||
|
return func_for_mode_mask[op];
|
||||||
|
}
|
||||||
|
|
||||||
RGBA_Comp_Func_Solid
|
RGBA_Comp_Func_Solid
|
||||||
efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint32_t color)
|
efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint32_t color)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 255 - alpha */
|
||||||
static inline int
|
static inline int
|
||||||
alpha_inverse(uint32_t color)
|
alpha_inverse(uint32_t color)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue