Evas masking: Implement support for line draw (SW)

Signed-off-by: Jean-Philippe Andre <jp.andre@samsung.com>
This commit is contained in:
Jaeun Choi 2014-11-13 20:45:14 +09:00 committed by Jean-Philippe Andre
parent 145fe108b8
commit 6747fadd9a
3 changed files with 321 additions and 55 deletions

View File

@ -3,12 +3,12 @@
typedef void (*Evas_Common_Line_Draw_Cb)(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1); typedef void (*Evas_Common_Line_Draw_Cb)(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1, int y1);
EAPI void evas_common_line_point_draw (RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x, int y); EAPI void evas_common_line_point_draw (RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x, int y, RGBA_Image *mask_ie, int mask_x, int mask_y);
EAPI void evas_common_line_init (void); EAPI void evas_common_line_init (void);
EAPI void evas_common_line_draw_line (RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x1, int y1, int x2, int y2); EAPI void evas_common_line_draw_line (RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x1, int y1, int x2, int y2, RGBA_Image *mask_ie, int mask_x, int mask_y);
EAPI void evas_common_line_draw_line_aa (RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x1, int y1, int x2, int y2); EAPI void evas_common_line_draw_line_aa (RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x1, int y1, int x2, int y2, RGBA_Image *mask_ie, int mask_x, int mask_y);
EAPI void evas_common_line_draw_cb (RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, int x2, int y2, Evas_Common_Line_Draw_Cb cb); EAPI void evas_common_line_draw_cb (RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, int x2, int y2, Evas_Common_Line_Draw_Cb cb);
EAPI void evas_common_line_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, int x2, int y2); EAPI void evas_common_line_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, int x2, int y2);

View File

@ -29,6 +29,7 @@ static void
_evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y) _evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y)
{ {
RGBA_Gfx_Pt_Func pfunc; RGBA_Gfx_Pt_Func pfunc;
DATA8 *mask = NULL;
if (!dst->image.data) return; if (!dst->image.data) return;
if (!IN_RANGE(x, y, dst->cache_entry.w, dst->cache_entry.h)) if (!IN_RANGE(x, y, dst->cache_entry.w, dst->cache_entry.h))
@ -48,18 +49,32 @@ _evas_draw_point(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y)
else else
# endif # endif
#endif #endif
{
if (dc->clip.mask)
{
RGBA_Image *im = dc->clip.mask;
mask = im->image.data8
+ (y - dc->clip.mask_y) * im->cache_entry.w
+ (x - dc->clip.mask_x);
pfunc = evas_common_gfx_func_composite_mask_color_pt_get(dc->col.col, dst->cache_entry.flags.alpha, dc->render_op);
if (pfunc)
pfunc(0, *mask, dc->col.col, dst->image.data + (dst->cache_entry.w * y) + x);
}
else
{ {
pfunc = evas_common_gfx_func_composite_color_pt_get(dc->col.col, dst->cache_entry.flags.alpha, dc->render_op); pfunc = evas_common_gfx_func_composite_color_pt_get(dc->col.col, dst->cache_entry.flags.alpha, dc->render_op);
if (pfunc) if (pfunc)
pfunc(0, 255, dc->col.col, dst->image.data + (dst->cache_entry.w * y) + x); pfunc(0, 255, dc->col.col, dst->image.data + (dst->cache_entry.w * y) + x);
} }
}
} }
EAPI void EAPI void
evas_common_line_point_draw(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x, int y) evas_common_line_point_draw(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x, int y, RGBA_Image *mask_ie, int mask_x, int mask_y)
{ {
Eina_Bool no_cuse; Eina_Bool no_cuse;
RGBA_Gfx_Pt_Func pfunc; RGBA_Gfx_Pt_Func pfunc;
DATA8 *mask = NULL;
if (!dst->image.data) return; if (!dst->image.data) return;
no_cuse = ((clip_x == 0) && (clip_y == 0) && no_cuse = ((clip_x == 0) && (clip_y == 0) &&
@ -70,9 +85,21 @@ evas_common_line_point_draw(RGBA_Image *dst, int clip_x, int clip_y, int clip_w,
if ((!no_cuse) && (!IN_RECT(x, y, clip_x, clip_y, clip_w, clip_h))) if ((!no_cuse) && (!IN_RECT(x, y, clip_x, clip_y, clip_w, clip_h)))
return; return;
if (mask_ie)
{
mask = mask_ie->image.data8
+ (y - mask_y) * mask_ie->cache_entry.w
+ (x - mask_x);
pfunc = evas_common_gfx_func_composite_mask_color_pt_get(color, dst->cache_entry.flags.alpha, render_op);
if (pfunc)
pfunc(0, *mask, color, dst->image.data + (dst->cache_entry.w * y) + x);
}
else
{
pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, render_op); pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, render_op);
if (pfunc) if (pfunc)
pfunc(0, 255, color, dst->image.data + (dst->cache_entry.w * y) + x); pfunc(0, 255, color, dst->image.data + (dst->cache_entry.w * y) + x);
}
} }
/* /*
@ -86,8 +113,9 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
{ {
int dx, dy, len, lx, ty, rx, by; int dx, dy, len, lx, ty, rx, by;
int clx, cly, clw, clh; int clx, cly, clw, clh;
int dstw; int dstw, mask_w = 0;
DATA32 *p, color; DATA32 *p, color;
DATA8 *mask = NULL;
RGBA_Gfx_Pt_Func pfunc; RGBA_Gfx_Pt_Func pfunc;
RGBA_Gfx_Func sfunc; RGBA_Gfx_Func sfunc;
@ -146,15 +174,30 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
else else
# endif # endif
#endif #endif
{
if (dc->clip.mask)
{
RGBA_Image *im = dc->clip.mask;
mask = im->image.data8
+ ((y0 - dc->clip.mask_y) * im->cache_entry.w)
+ (x0 - dc->clip.mask_x);
sfunc = evas_common_gfx_func_composite_mask_color_span_get(color, dst->cache_entry.flags.alpha, len, dc->render_op);
if (sfunc) sfunc(NULL, mask, color, p, len);
}
else
{ {
sfunc = evas_common_gfx_func_composite_color_span_get(color, dst->cache_entry.flags.alpha, len, dc->render_op); sfunc = evas_common_gfx_func_composite_color_span_get(color, dst->cache_entry.flags.alpha, len, dc->render_op);
if (sfunc) if (sfunc)
sfunc(NULL, NULL, color, p, len); sfunc(NULL, NULL, color, p, len);
} }
} }
}
return; return;
} }
if (dc->clip.mask)
pfunc = evas_common_gfx_func_composite_mask_color_pt_get(color, dst->cache_entry.flags.alpha, dc->render_op);
else
pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, dc->render_op); pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, dc->render_op);
if (!pfunc) return; if (!pfunc) return;
@ -176,6 +219,22 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
else else
# endif # endif
#endif #endif
{
if (dc->clip.mask)
{
RGBA_Image *im = dc->clip.mask;
mask_w = im->cache_entry.w;
mask = im->image.data8
+ ((y0 - dc->clip.mask_y) * mask_w)
+ (x0 - dc->clip.mask_x);
while (len--)
{
pfunc(0, *mask, color, p);
p += dstw;
mask += mask_w;
}
}
else
{ {
while (len--) while (len--)
{ {
@ -184,6 +243,7 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
} }
} }
} }
}
return; return;
} }
@ -254,6 +314,16 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
len = y1 - y0 + 1; len = y1 - y0 + 1;
if (dx > 0) dstw++; if (dx > 0) dstw++;
else dstw--; else dstw--;
if (dc->clip.mask)
{
RGBA_Image *im = dc->clip.mask;
mask_w = im->cache_entry.w;
mask = im->image.data8
+ ((y0 - dc->clip.mask_y) * mask_w)
+ (x0 - dc->clip.mask_x);
if (dx > 0) mask_w++;
else mask_w--;
}
} }
else else
{ {
@ -261,6 +331,16 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
p = dst->image.data + (dstw * y1) + x1; p = dst->image.data + (dstw * y1) + x1;
if (dx > 0) dstw--; if (dx > 0) dstw--;
else dstw++; else dstw++;
if (dc->clip.mask)
{
RGBA_Image *im = dc->clip.mask;
mask_w = im->cache_entry.w;
mask = im->image.data8
+ ((y1 - dc->clip.mask_y) * mask_w)
+ (x1 - dc->clip.mask_x);
if (dx > 0) mask_w--;
else mask_w++;
}
} }
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
@ -283,7 +363,15 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
else else
# endif # endif
#endif #endif
{
if (mask)
{
pfunc(0, *mask, color, p);
mask += mask_w;
}
else
pfunc(0, 255, color, p); pfunc(0, 255, color, p);
}
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pixman_x_position += x_unit; pixman_x_position += x_unit;
@ -442,12 +530,13 @@ _evas_draw_simple_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, i
rx = clw - 1; rx = clw - 1;
static void static void
_draw_render_thread_simple_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x0, int y0, int x1, int y1) _draw_render_thread_simple_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x0, int y0, int x1, int y1, RGBA_Image *mask_ie, int mask_x, int mask_y)
{ {
int dx, dy, len, lx, ty, rx, by; int dx, dy, len, lx, ty, rx, by;
int clx, cly, clw, clh; int clx, cly, clw, clh;
int dstw; int dstw, mask_w = 0;
DATA32 *p; DATA32 *p;
DATA8 *mask = NULL;
RGBA_Gfx_Pt_Func pfunc; RGBA_Gfx_Pt_Func pfunc;
RGBA_Gfx_Func sfunc; RGBA_Gfx_Func sfunc;
@ -488,12 +577,26 @@ _draw_render_thread_simple_line(RGBA_Image *dst, int clip_x, int clip_y, int cli
len = x1 - x0 + 1; len = x1 - x0 + 1;
p = dst->image.data + (dstw * y0) + x0; p = dst->image.data + (dstw * y0) + x0;
if (mask_ie)
{
mask = mask_ie->image.data8
+ ((y0 - mask_y) * mask_ie->cache_entry.w)
+ (x0 - mask_x);
sfunc = evas_common_gfx_func_composite_mask_color_span_get(color, dst->cache_entry.flags.alpha, len, render_op);
if (sfunc) sfunc(NULL, mask, color, p, len);
}
else
{
sfunc = evas_common_gfx_func_composite_color_span_get(color, dst->cache_entry.flags.alpha, len, render_op); sfunc = evas_common_gfx_func_composite_color_span_get(color, dst->cache_entry.flags.alpha, len, render_op);
if (sfunc) sfunc(NULL, NULL, color, p, len); if (sfunc) sfunc(NULL, NULL, color, p, len);
} }
}
return; return;
} }
if (mask_ie)
pfunc = evas_common_gfx_func_composite_mask_color_pt_get(color, dst->cache_entry.flags.alpha, render_op);
else
pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, render_op); pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, render_op);
if (!pfunc) return; if (!pfunc) return;
@ -506,12 +609,28 @@ _draw_render_thread_simple_line(RGBA_Image *dst, int clip_x, int clip_y, int cli
len = y1 - y0 + 1; len = y1 - y0 + 1;
p = dst->image.data + (dstw * y0) + x0; p = dst->image.data + (dstw * y0) + x0;
if (mask_ie)
{
mask_w = mask_ie->cache_entry.w;
mask = mask_ie->image.data8
+ ((y0 - mask_y) * mask_w)
+ (x0 - mask_x);
while (len--)
{
pfunc(0, *mask, color, p);
p += dstw;
mask += mask_w;
}
}
else
{
while (len--) while (len--)
{ {
pfunc(0, 255, color, p); pfunc(0, 255, color, p);
p += dstw; p += dstw;
} }
} }
}
return; return;
} }
@ -582,6 +701,15 @@ _draw_render_thread_simple_line(RGBA_Image *dst, int clip_x, int clip_y, int cli
len = y1 - y0 + 1; len = y1 - y0 + 1;
if (dx > 0) dstw++; if (dx > 0) dstw++;
else dstw--; else dstw--;
if (mask_ie)
{
mask_w = mask_ie->cache_entry.w;
mask = mask_ie->image.data8
+ ((y0 - mask_y) * mask_w)
+ (x0 - mask_x);
if (dx > 0) mask_w++;
else mask_w--;
}
} }
else else
{ {
@ -589,13 +717,34 @@ _draw_render_thread_simple_line(RGBA_Image *dst, int clip_x, int clip_y, int cli
p = dst->image.data + (dstw * y1) + x1; p = dst->image.data + (dstw * y1) + x1;
if (dx > 0) dstw--; if (dx > 0) dstw--;
else dstw++; else dstw++;
if (mask_ie)
{
mask_w = mask_ie->cache_entry.w;
mask = mask_ie->image.data8
+ ((y1 - mask_y) * mask_w)
+ (x1 - mask_x);
if (dx > 0) mask_w--;
else mask_w++;
} }
}
if (mask)
{
while (len--)
{
pfunc(0, *mask, color, p);
p += dstw;
mask += mask_w;
}
}
else
{
while (len--) while (len--)
{ {
pfunc(0, 255, color, p); pfunc(0, 255, color, p);
p += dstw; p += dstw;
} }
} }
}
} }
#define SETUP_LINE_SHALLOW \ #define SETUP_LINE_SHALLOW \
@ -745,14 +894,15 @@ _draw_render_thread_simple_line(RGBA_Image *dst, int clip_x, int clip_y, int cli
rx = clw - 1; rx = clw - 1;
EAPI void EAPI void
evas_common_line_draw_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x0, int y0, int x1, int y1) evas_common_line_draw_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x0, int y0, int x1, int y1, RGBA_Image *mask_ie, int mask_x, int mask_y)
{ {
int px, py, x, y, prev_x, prev_y; int px, py, x, y, prev_x, prev_y;
int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 0; int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 0;
int delx, dely, xx, yy, dxx, dyy; int delx, dely, xx, yy, dxx, dyy;
int clx, cly, clw, clh; int clx, cly, clw, clh;
int dstw; int dstw, mask_w = 0;
DATA32 *p, *data; DATA32 *p, *data;
DATA8 *mask = NULL;
RGBA_Gfx_Pt_Func pfunc; RGBA_Gfx_Pt_Func pfunc;
dx = x1 - x0; dx = x1 - x0;
@ -763,10 +913,14 @@ evas_common_line_draw_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w,
_draw_render_thread_simple_line _draw_render_thread_simple_line
(dst, clip_x, clip_y, clip_w, clip_h, (dst, clip_x, clip_y, clip_w, clip_h,
color, render_op, color, render_op,
x0, y0, x1, y1); x0, y0, x1, y1,
mask_ie, mask_x, mask_y);
return; return;
} }
if (mask_ie)
pfunc = evas_common_gfx_func_composite_mask_color_pt_get(color, dst->cache_entry.flags.alpha, render_op);
else
pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, render_op); pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, render_op);
if (!pfunc) return; if (!pfunc) return;
@ -784,11 +938,19 @@ evas_common_line_draw_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w,
x1 -= clx; x1 -= clx;
y1 -= cly; y1 -= cly;
if (mask_ie)
{
mask_w = mask_ie->cache_entry.w;
mask = mask_ie->image.data8
+ ((cly - mask_y) * mask_w) + (clx - mask_x);
}
/* shallow: x-parametric */ /* shallow: x-parametric */
if ((dy < dx) || (dy < -dx)) if ((dy < dx) || (dy < -dx))
{ {
SETUP_LINE_SHALLOW; SETUP_LINE_SHALLOW;
if (mask) mask += (py * mask_w) + px;
while (px < rx) while (px < rx)
{ {
y = (yy >> 16); y = (yy >> 16);
@ -797,6 +959,7 @@ evas_common_line_draw_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w,
{ {
prev_y = y; prev_y = y;
p += dh; p += dh;
if (mask) mask += mask_w;
py += dely; py += dely;
} }
if (!p1_in) if (!p1_in)
@ -808,12 +971,17 @@ evas_common_line_draw_line(RGBA_Image *dst, int clip_x, int clip_y, int clip_w,
{ {
if (py < 0) goto next_x; if (py < 0) goto next_x;
} }
if (IN_RANGE(px, py, clw, clh)) pfunc(0, 255, color, p); if (IN_RANGE(px, py, clw, clh))
{
if (mask) pfunc(0, *mask, color, p);
else pfunc(0, 255, color, p);
}
next_x: next_x:
yy += dyy; yy += dyy;
px++; px++;
p++; p++;
if (mask) mask++;
} }
return; return;
} }
@ -821,6 +989,7 @@ next_x:
/* steep: y-parametric */ /* steep: y-parametric */
SETUP_LINE_STEEP; SETUP_LINE_STEEP;
if (mask) mask += (py * mask_w) + px;
while (py < by) while (py < by)
{ {
@ -831,6 +1000,7 @@ next_x:
prev_x = x; prev_x = x;
px += delx; px += delx;
p += delx; p += delx;
if (mask) mask += delx;
} }
if (!p1_in) if (!p1_in)
{ {
@ -841,12 +1011,17 @@ next_x:
{ {
if (px < 0) goto next_y; if (px < 0) goto next_y;
} }
if (IN_RANGE(px, py, clw, clh)) pfunc(0, 255, color, p); if (IN_RANGE(px, py, clw, clh))
{
if (mask) pfunc(0, *mask, color, p);
else pfunc(0, 255, color, p);
}
next_y: next_y:
xx += dxx; xx += dxx;
py++; py++;
p += dstw; p += dstw;
if (mask) mask += mask_w;
} }
} }
@ -857,8 +1032,9 @@ _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1,
int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 0; int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 0;
int delx, dely, xx, yy, dxx, dyy; int delx, dely, xx, yy, dxx, dyy;
int clx, cly, clw, clh; int clx, cly, clw, clh;
int dstw; int dstw, mask_w = 0;
DATA32 *p, *data, color; DATA32 *p, *data, color;
DATA8 *mask = NULL;
RGBA_Gfx_Pt_Func pfunc; RGBA_Gfx_Pt_Func pfunc;
dx = x1 - x0; dx = x1 - x0;
@ -896,6 +1072,9 @@ _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1,
} }
color = dc->col.col; color = dc->col.col;
if (dc->clip.mask)
pfunc = evas_common_gfx_func_composite_mask_color_pt_get(color, dst->cache_entry.flags.alpha, dc->render_op);
else
pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, dc->render_op); pfunc = evas_common_gfx_func_composite_color_pt_get(color, dst->cache_entry.flags.alpha, dc->render_op);
if (!pfunc) return; if (!pfunc) return;
@ -913,11 +1092,20 @@ _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1,
x1 -= clx; x1 -= clx;
y1 -= cly; y1 -= cly;
if (dc->clip.mask)
{
RGBA_Image *im = dc->clip.mask;
mask_w = im->cache_entry.w;
mask = im->image.data8
+ ((cly - dc->clip.mask_y) * mask_w) + (clx - dc->clip.mask_x);
}
/* shallow: x-parametric */ /* shallow: x-parametric */
if ((dy < dx) || (dy < -dx)) if ((dy < dx) || (dy < -dx))
{ {
SETUP_LINE_SHALLOW; SETUP_LINE_SHALLOW;
if (mask) mask += (py * mask_w) + px;
while (px < rx) while (px < rx)
{ {
y = (yy >> 16); y = (yy >> 16);
@ -926,6 +1114,7 @@ _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1,
{ {
prev_y = y; prev_y = y;
p += dh; p += dh;
if (mask) mask += mask_w;
py += dely; py += dely;
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
@ -954,13 +1143,17 @@ _evas_draw_line(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x1,
else else
# endif # endif
#endif #endif
pfunc(0, 255, color, p); {
if (mask) pfunc(0, *mask, color, p);
else pfunc(0, 255, color, p);
}
} }
next_x: next_x:
yy += dyy; yy += dyy;
px++; px++;
p++; p++;
if (mask) mask++;
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pix_x += pix_x_unit; pix_x += pix_x_unit;
@ -973,6 +1166,7 @@ next_x:
/* steep: y-parametric */ /* steep: y-parametric */
SETUP_LINE_STEEP; SETUP_LINE_STEEP;
if (mask) mask += (py * mask_w) + px;
while (py < by) while (py < by)
{ {
@ -983,6 +1177,7 @@ next_x:
prev_x = x; prev_x = x;
px += delx; px += delx;
p += delx; p += delx;
if (mask) mask += delx;
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pix_x += pix_x_unit; pix_x += pix_x_unit;
@ -1010,12 +1205,16 @@ next_x:
else else
# endif # endif
#endif #endif
pfunc(0, 255, color, p); {
if (mask) pfunc(0, *mask, color, p);
else pfunc(0, 255, color, p);
}
} }
next_y: next_y:
xx += dxx; xx += dxx;
py++; py++;
p += dstw; p += dstw;
if (mask) mask += mask_w;
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pix_y += pix_y_unit; pix_y += pix_y_unit;
@ -1025,14 +1224,15 @@ next_y:
} }
EAPI void EAPI void
evas_common_line_draw_line_aa(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x0, int y0, int x1, int y1) evas_common_line_draw_line_aa(RGBA_Image *dst, int clip_x, int clip_y, int clip_w, int clip_h, DATA32 color, int render_op, int x0, int y0, int x1, int y1, RGBA_Image *mask_ie, int mask_x, int mask_y)
{ {
int px, py, x, y, prev_x, prev_y; int px, py, x, y, prev_x, prev_y;
int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 1; int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 1;
int delx, dely, xx, yy, dxx, dyy; int delx, dely, xx, yy, dxx, dyy;
int clx, cly, clw, clh; int clx, cly, clw, clh;
int dstw; int dstw, mask_w = 0;
DATA32 *p, *data; DATA32 *p, *data;
DATA8 *mask = NULL;
RGBA_Gfx_Pt_Func pfunc; RGBA_Gfx_Pt_Func pfunc;
dx = x1 - x0; dx = x1 - x0;
@ -1049,7 +1249,8 @@ evas_common_line_draw_line_aa(RGBA_Image *dst, int clip_x, int clip_y, int clip_
_draw_render_thread_simple_line _draw_render_thread_simple_line
(dst, clip_x, clip_y, clip_w, clip_h, (dst, clip_x, clip_y, clip_w, clip_h,
color, render_op, color, render_op,
x0, y0, x1, y1); x0, y0, x1, y1,
mask_ie, mask_x, mask_y);
return; return;
} }
@ -1070,11 +1271,19 @@ evas_common_line_draw_line_aa(RGBA_Image *dst, int clip_x, int clip_y, int clip_
x1 -= clx; x1 -= clx;
y1 -= cly; y1 -= cly;
if (mask_ie)
{
mask_w = mask_ie->cache_entry.w;
mask = mask_ie->image.data8
+ (cly - mask_y) * mask_w + (clx - mask_x);
}
/* shallow: x-parametric */ /* shallow: x-parametric */
if ((dy < dx) || (dy < -dx)) if ((dy < dx) || (dy < -dx))
{ {
SETUP_LINE_SHALLOW; SETUP_LINE_SHALLOW;
if (mask) mask += (py * mask_w) + px;
while (px < rx) while (px < rx)
{ {
DATA8 aa; DATA8 aa;
@ -1084,6 +1293,7 @@ evas_common_line_draw_line_aa(RGBA_Image *dst, int clip_x, int clip_y, int clip_
{ {
prev_y = y; prev_y = y;
p += dh; p += dh;
if (mask) mask += mask_w;
py += dely; py += dely;
} }
if (!p1_in) if (!p1_in)
@ -1099,20 +1309,30 @@ evas_common_line_draw_line_aa(RGBA_Image *dst, int clip_x, int clip_y, int clip_
{ {
aa = ((yy - (y << 16)) >> 8); aa = ((yy - (y << 16)) >> 8);
if (mask)
{
if ((py) < clh) pfunc(0, (255 - aa) * (*mask) / 255, color, p);
if ((py + 1) < clh) pfunc(0, aa * (*(mask + mask_w)) / 255, color, p + dstw);
}
else
{
if ((py) < clh) pfunc(0, 255 - aa, color, p); if ((py) < clh) pfunc(0, 255 - aa, color, p);
if ((py + 1) < clh) pfunc(0, aa, color, p + dstw); if ((py + 1) < clh) pfunc(0, aa, color, p + dstw);
} }
}
next_x: next_x:
yy += dyy; yy += dyy;
px++; px++;
p++; p++;
if (mask) mask++;
} }
return; return;
} }
/* steep: y-parametric */ /* steep: y-parametric */
SETUP_LINE_STEEP; SETUP_LINE_STEEP;
if (mask) mask += (py * mask_w) + px;
while (py < by) while (py < by)
{ {
@ -1124,6 +1344,7 @@ next_x:
prev_x = x; prev_x = x;
px += delx; px += delx;
p += delx; p += delx;
if (mask) mask += delx;
} }
if (!p1_in) if (!p1_in)
{ {
@ -1137,14 +1358,24 @@ next_x:
if (py < clh) if (py < clh)
{ {
aa = ((xx - (x << 16)) >> 8); aa = ((xx - (x << 16)) >> 8);
if (mask)
{
if ((px) < clw) pfunc(0, (255 - aa) * (*mask) / 255, color, p);
if ((px + 1) < clw) pfunc(0, aa * (*(mask + 1)) / 255, color, p + 1);
}
else
{
if ((px) < clw) pfunc(0, 255 - aa, color, p); if ((px) < clw) pfunc(0, 255 - aa, color, p);
if ((px + 1) < clw) pfunc(0, aa, color, p + 1); if ((px + 1) < clw) pfunc(0, aa, color, p + 1);
} }
}
next_y: next_y:
xx += dxx; xx += dxx;
py++; py++;
p += dstw; p += dstw;
if (mask) mask += mask_w;
} }
} }
@ -1155,8 +1386,9 @@ _evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x
int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 1; int dx, dy, rx, by, p0_in, p1_in, dh, a_a = 1;
int delx, dely, xx, yy, dxx, dyy; int delx, dely, xx, yy, dxx, dyy;
int clx, cly, clw, clh; int clx, cly, clw, clh;
int dstw; int dstw, mask_w = 0;
DATA32 *p, *data, color; DATA32 *p, *data, color;
DATA8 *mask = NULL;
RGBA_Gfx_Pt_Func pfunc; RGBA_Gfx_Pt_Func pfunc;
dx = x1 - x0; dx = x1 - x0;
@ -1219,11 +1451,20 @@ _evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x
x1 -= clx; x1 -= clx;
y1 -= cly; y1 -= cly;
if (dc->clip.mask)
{
RGBA_Image *im = dc->clip.mask;
mask_w = im->cache_entry.w;
mask = im->image.data8
+ ((cly - dc->clip.mask_y) * mask_w) + (clx - dc->clip.mask_x);
}
/* shallow: x-parametric */ /* shallow: x-parametric */
if ((dy < dx) || (dy < -dx)) if ((dy < dx) || (dy < -dx))
{ {
SETUP_LINE_SHALLOW; SETUP_LINE_SHALLOW;
if (mask) mask += (py * mask_w) + px;
while (px < rx) while (px < rx)
{ {
DATA8 aa; DATA8 aa;
@ -1233,6 +1474,7 @@ _evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x
{ {
prev_y = y; prev_y = y;
p += dh; p += dh;
if (mask) mask += mask_w;
py += dely; py += dely;
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
@ -1268,7 +1510,10 @@ _evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x
else else
# endif # endif
#endif #endif
pfunc(0, 255 - aa, color, p); {
if (mask) pfunc(0, (255 - aa) * (*mask) / 255, color, p);
else pfunc(0, 255 - aa, color, p);
}
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pixman_image_unref(aa_mask_image); pixman_image_unref(aa_mask_image);
@ -1291,7 +1536,10 @@ _evas_draw_line_aa(RGBA_Image *dst, RGBA_Draw_Context *dc, int x0, int y0, int x
else else
# endif # endif
#endif #endif
pfunc(0, aa, color, p + dstw); {
if (mask) pfunc(0, aa * (*(mask + mask_w)) / 255, color, p + dstw);
else pfunc(0, aa, color, p + dstw);
}
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pixman_image_unref(aa_mask_image); pixman_image_unref(aa_mask_image);
@ -1304,6 +1552,7 @@ next_x:
yy += dyy; yy += dyy;
px++; px++;
p++; p++;
if (mask) mask++;
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pix_x += pix_x_unit; pix_x += pix_x_unit;
@ -1315,6 +1564,7 @@ next_x:
/* steep: y-parametric */ /* steep: y-parametric */
SETUP_LINE_STEEP; SETUP_LINE_STEEP;
if (mask) mask += (py * mask_w) + px;
while (py < by) while (py < by)
{ {
@ -1326,6 +1576,7 @@ next_x:
prev_x = x; prev_x = x;
px += delx; px += delx;
p += delx; p += delx;
if (mask) mask += delx;
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pix_x += pix_x_unit; pix_x += pix_x_unit;
@ -1359,7 +1610,10 @@ next_x:
else else
# endif # endif
#endif #endif
pfunc(0, 255 - aa, color, p); {
if (mask) pfunc(0, (255 - aa) * (*mask) / 255, color, p);
else pfunc(0, 255 - aa, color, p);
}
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pixman_image_unref(aa_mask_image); pixman_image_unref(aa_mask_image);
@ -1383,7 +1637,10 @@ next_x:
else else
# endif # endif
#endif #endif
pfunc(0, aa, color, p + 1); {
if (mask) pfunc(0, aa * (*(mask + 1)) / 255, color, p + 1);
else pfunc(0, aa, color, p + 1);
}
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pixman_image_unref(aa_mask_image); pixman_image_unref(aa_mask_image);
@ -1395,6 +1652,7 @@ next_x:
xx += dxx; xx += dxx;
py++; py++;
p += dstw; p += dstw;
if (mask) mask += mask_w;
#ifdef HAVE_PIXMAN #ifdef HAVE_PIXMAN
# ifdef PIXMAN_LINE # ifdef PIXMAN_LINE
pix_y += pix_y_unit; pix_y += pix_y_unit;

View File

@ -309,6 +309,8 @@ struct _Evas_Thread_Command_Line
Eina_Bool anti_alias; Eina_Bool anti_alias;
int x1, y1; int x1, y1;
int x2, y2; int x2, y2;
void *mask;
int mask_x, mask_y;
}; };
struct _Evas_Thread_Command_Polygon struct _Evas_Thread_Command_Polygon
@ -649,7 +651,8 @@ _draw_thread_line_draw(void *data)
evas_common_line_point_draw(line->surface, evas_common_line_point_draw(line->surface,
clip_x, clip_y, clip_w, clip_h, clip_x, clip_y, clip_w, clip_h,
line->color, line->render_op, line->color, line->render_op,
line->x1, line->y1); line->x1, line->y1,
line->mask, line->mask_x, line->mask_y);
return; return;
} }
@ -659,14 +662,16 @@ _draw_thread_line_draw(void *data)
clip_x, clip_y, clip_w, clip_h, clip_x, clip_y, clip_w, clip_h,
line->color, line->render_op, line->color, line->render_op,
line->x1, line->y1, line->x1, line->y1,
line->x2, line->y2); line->x2, line->y2,
line->mask, line->mask_x, line->mask_y);
else else
evas_common_line_draw_line evas_common_line_draw_line
(line->surface, (line->surface,
clip_x, clip_y, clip_w, clip_h, clip_x, clip_y, clip_w, clip_h,
line->color, line->render_op, line->color, line->render_op,
line->x1, line->y1, line->x1, line->y1,
line->x2, line->y2); line->x2, line->y2,
line->mask, line->mask_x, line->mask_y);
eina_mempool_free(_mp_command_line, line); eina_mempool_free(_mp_command_line, line);
} }
@ -732,6 +737,9 @@ _line_draw_thread_cmd(RGBA_Image *dst, RGBA_Draw_Context *dc, int x1, int y1, in
cl->y1 = y1; cl->y1 = y1;
cl->x2 = x2; cl->x2 = x2;
cl->y2 = y2; cl->y2 = y2;
cl->mask = dc->clip.mask;
cl->mask_x = dc->clip.mask_x;
cl->mask_y = dc->clip.mask_y;
evas_thread_cmd_enqueue(_draw_thread_line_draw, cl); evas_thread_cmd_enqueue(_draw_thread_line_draw, cl);
} }