Mostly cosmetic tweaks around clipping checks
This commit is contained in:
parent
30b4cbb009
commit
c56b66f9c1
|
@ -1807,6 +1807,11 @@ __imlib_BlendImageToImage(ImlibImage * im_src, ImlibImage * im_dst,
|
|||
if (__imlib_LoadImageData(im_dst))
|
||||
return;
|
||||
|
||||
/* don't do anything if we have a 0 width or height image to render */
|
||||
/* if the input rect size < 0 don't render either */
|
||||
if (ssw <= 0 || ssh <= 0 || ddw == 0 || ddh == 0)
|
||||
return;
|
||||
|
||||
if ((ssw == ddw) && (ssh == ddh))
|
||||
{
|
||||
if (!IM_FLAG_ISSET(im_dst, F_HAS_ALPHA))
|
||||
|
@ -1824,14 +1829,12 @@ __imlib_BlendImageToImage(ImlibImage * im_src, ImlibImage * im_dst,
|
|||
px = ddx;
|
||||
py = ddy;
|
||||
CLIP(ddx, ddy, ddw, ddh, clx, cly, clw, clh);
|
||||
if (ddw <= 0 || ddh <= 0)
|
||||
return;
|
||||
px = ddx - px;
|
||||
py = ddy - py;
|
||||
ssx += px;
|
||||
ssy += py;
|
||||
if ((ssw < 1) || (ssh < 1))
|
||||
return;
|
||||
if ((ddw < 1) || (ddh < 1))
|
||||
return;
|
||||
}
|
||||
|
||||
__imlib_BlendRGBAToData(im_src->data, im_src->w, im_src->h,
|
||||
|
@ -1856,16 +1859,15 @@ __imlib_BlendImageToImage(ImlibImage * im_src, ImlibImage * im_dst,
|
|||
dy = ddy;
|
||||
dw = abs(ddw);
|
||||
dh = abs(ddh);
|
||||
/* don't do anything if we have a 0 width or height image to render */
|
||||
/* if the input rect size < 0 don't render either */
|
||||
if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
|
||||
return;
|
||||
|
||||
/* clip the source rect to be within the actual image */
|
||||
psx = sx;
|
||||
psy = sy;
|
||||
psw = sw;
|
||||
psh = sh;
|
||||
CLIP(sx, sy, sw, sh, 0, 0, im_src->w, im_src->h);
|
||||
if (sw <= 0 || sh <= 0)
|
||||
return;
|
||||
if (psx != sx)
|
||||
dx += ((sx - psx) * abs(ddw)) / ssw;
|
||||
if (psy != sy)
|
||||
|
@ -1874,10 +1876,9 @@ __imlib_BlendImageToImage(ImlibImage * im_src, ImlibImage * im_dst,
|
|||
dw = (dw * sw) / psw;
|
||||
if (psh != sh)
|
||||
dh = (dh * sh) / psh;
|
||||
if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (dw <= 0 || dh <= 0)
|
||||
return;
|
||||
|
||||
/* clip output coords to clipped input coords */
|
||||
psx = dx;
|
||||
psy = dy;
|
||||
|
@ -1886,12 +1887,12 @@ __imlib_BlendImageToImage(ImlibImage * im_src, ImlibImage * im_dst,
|
|||
x2 = sx;
|
||||
y2 = sy;
|
||||
CLIP(dx, dy, dw, dh, 0, 0, im_dst->w, im_dst->h);
|
||||
if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
|
||||
if (dw <= 0 || dh <= 0)
|
||||
return;
|
||||
if (clw)
|
||||
{
|
||||
CLIP(dx, dy, dw, dh, clx, cly, clw, clh);
|
||||
if ((dw < 1) || (dh < 1))
|
||||
if (dw <= 0 || dh <= 0)
|
||||
return;
|
||||
}
|
||||
if (psw != dw)
|
||||
|
@ -1903,17 +1904,16 @@ __imlib_BlendImageToImage(ImlibImage * im_src, ImlibImage * im_dst,
|
|||
dxx += (x2 * abs(ddw)) / ssw;
|
||||
dyy += (y2 * abs(ddh)) / ssh;
|
||||
|
||||
if ((dw > 0) && (sw == 0))
|
||||
if (sw == 0)
|
||||
sw = 1;
|
||||
if ((dh > 0) && (sh == 0))
|
||||
if (sh == 0)
|
||||
sh = 1;
|
||||
/* do a second check to see if we now have invalid coords */
|
||||
/* don't do anything if we have a 0 width or height image to render */
|
||||
/* if the input rect size < 0 don't render either */
|
||||
if ((dw <= 0) || (dh <= 0) || (sw <= 0) || (sh <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (sw <= 0 || sh <= 0)
|
||||
return;
|
||||
|
||||
scaleinfo = __imlib_CalcScaleInfo(im_src, ssw, ssh, ddw, ddh, aa);
|
||||
if (!scaleinfo)
|
||||
return;
|
||||
|
@ -1925,6 +1925,7 @@ __imlib_BlendImageToImage(ImlibImage * im_src, ImlibImage * im_dst,
|
|||
__imlib_FreeScaleInfo(scaleinfo);
|
||||
return;
|
||||
}
|
||||
|
||||
/* setup h */
|
||||
h = dh;
|
||||
if (!IM_FLAG_ISSET(im_dst, F_HAS_ALPHA))
|
||||
|
@ -1935,6 +1936,7 @@ __imlib_BlendImageToImage(ImlibImage * im_src, ImlibImage * im_dst,
|
|||
if (merge_alpha)
|
||||
blend = 1;
|
||||
}
|
||||
|
||||
/* scale in LINESIZE Y chunks and convert to depth */
|
||||
for (y = 0; y < dh; y += LINESIZE)
|
||||
{
|
||||
|
|
|
@ -688,18 +688,18 @@ __imlib_Ellipse_DrawToImage(int xc, int yc, int a, int b, DATA32 color,
|
|||
}
|
||||
if (blend && (!A_VAL(&color)))
|
||||
return;
|
||||
if (clw < 0)
|
||||
return;
|
||||
|
||||
if (clw == 0)
|
||||
{
|
||||
clx = cly = 0;
|
||||
clw = im->w;
|
||||
clx = 0;
|
||||
clh = im->h;
|
||||
cly = 0;
|
||||
}
|
||||
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
if ((clw < 1) || (clh < 1))
|
||||
else
|
||||
{
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
}
|
||||
if (clw <= 0 || clh <= 0)
|
||||
return;
|
||||
|
||||
if (a < 0)
|
||||
|
@ -724,7 +724,7 @@ __imlib_Ellipse_DrawToImage(int xc, int yc, int a, int b, DATA32 color,
|
|||
}
|
||||
|
||||
CLIP(x, y, w, h, clx, cly, clw, clh);
|
||||
if ((w < 1) || (h < 1))
|
||||
if (w <= 0 || h <= 0)
|
||||
return;
|
||||
|
||||
if (blend && IM_FLAG_ISSET(im, F_HAS_ALPHA))
|
||||
|
@ -756,18 +756,18 @@ __imlib_Ellipse_FillToImage(int xc, int yc, int a, int b, DATA32 color,
|
|||
}
|
||||
if (blend && (!A_VAL(&color)))
|
||||
return;
|
||||
if (clw < 0)
|
||||
return;
|
||||
|
||||
if (clw == 0)
|
||||
{
|
||||
clx = cly = 0;
|
||||
clw = im->w;
|
||||
clx = 0;
|
||||
clh = im->h;
|
||||
cly = 0;
|
||||
}
|
||||
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
if ((clw < 1) || (clh < 1))
|
||||
else
|
||||
{
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
}
|
||||
if (clw <= 0 || clh <= 0)
|
||||
return;
|
||||
|
||||
if (a < 0)
|
||||
|
@ -792,7 +792,7 @@ __imlib_Ellipse_FillToImage(int xc, int yc, int a, int b, DATA32 color,
|
|||
}
|
||||
|
||||
CLIP(x, y, w, h, clx, cly, clw, clh);
|
||||
if ((w < 1) || (h < 1))
|
||||
if (w <= 0 || h <= 0)
|
||||
return;
|
||||
|
||||
if (blend && IM_FLAG_ISSET(im, F_HAS_ALPHA))
|
||||
|
|
|
@ -284,7 +284,7 @@ _DrawGradient(ImlibImage * im, int x, int y, int w, int h,
|
|||
px = x;
|
||||
py = y;
|
||||
CLIP(x, y, w, h, clx, cly, clw, clh);
|
||||
if ((w < 1) || (h < 1))
|
||||
if (w <= 0 || h <= 0)
|
||||
return;
|
||||
xoff += (x - px);
|
||||
yoff += (y - py);
|
||||
|
|
|
@ -673,19 +673,18 @@ __imlib_Line_DrawToImage(int x0, int y0, int x1, int y1, DATA32 color,
|
|||
|
||||
if (blend && (!A_VAL(&color)))
|
||||
return NULL;
|
||||
if (clw < 0)
|
||||
return NULL;
|
||||
|
||||
if (clw == 0)
|
||||
{
|
||||
clx = cly = 0;
|
||||
clw = im->w;
|
||||
clx = 0;
|
||||
clh = im->h;
|
||||
cly = 0;
|
||||
}
|
||||
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
if ((clw < 1) || (clh < 1))
|
||||
else
|
||||
{
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
}
|
||||
if (clw <= 0 || clh <= 0)
|
||||
return NULL;
|
||||
|
||||
if ((x0 < clx) && (x1 < clx))
|
||||
|
@ -740,7 +739,7 @@ __imlib_Line_DrawToImage(int x0, int y0, int x1, int y1, DATA32 color,
|
|||
}
|
||||
|
||||
CLIP(cl_x0, cl_y0, w, h, clx, cly, clw, clh);
|
||||
if ((w < 1) || (h < 1))
|
||||
if (w <= 0 || h <= 0)
|
||||
return NULL;
|
||||
|
||||
return __imlib_AddUpdate(NULL, cl_x0, cl_y0, w, h);
|
||||
|
|
|
@ -1066,14 +1066,15 @@ __imlib_Polygon_DrawToImage(ImlibPoly * poly, char close, DATA32 color,
|
|||
|
||||
if (clw == 0)
|
||||
{
|
||||
clx = cly = 0;
|
||||
clw = im->w;
|
||||
clx = 0;
|
||||
clh = im->h;
|
||||
cly = 0;
|
||||
}
|
||||
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
if ((clw < 1) || (clh < 1))
|
||||
else
|
||||
{
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
}
|
||||
if (clw <= 0 || clh <= 0)
|
||||
return;
|
||||
|
||||
if (blend && IM_FLAG_ISSET(im, F_HAS_ALPHA))
|
||||
|
@ -1821,14 +1822,15 @@ __imlib_Polygon_FillToImage(ImlibPoly * poly, DATA32 color,
|
|||
|
||||
if (clw == 0)
|
||||
{
|
||||
clx = cly = 0;
|
||||
clw = im->w;
|
||||
clx = 0;
|
||||
clh = im->h;
|
||||
cly = 0;
|
||||
}
|
||||
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
if ((clw < 1) || (clh < 1))
|
||||
else
|
||||
{
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
}
|
||||
if (clw <= 0 || clh <= 0)
|
||||
return;
|
||||
|
||||
if (blend && IM_FLAG_ISSET(im, F_HAS_ALPHA))
|
||||
|
|
|
@ -101,7 +101,7 @@ __imlib_Rectangle_FillToData(int x, int y, int rw, int rh, DATA32 color,
|
|||
y -= cly;
|
||||
|
||||
CLIP(x, y, rw, rh, 0, 0, clw, clh);
|
||||
if ((rw < 1) || (rh < 1))
|
||||
if (rw <= 0 || rh <= 0)
|
||||
return;
|
||||
|
||||
p = dst + (dstw * y) + x;
|
||||
|
@ -117,9 +117,7 @@ __imlib_Rectangle_DrawToImage(int x, int y, int w, int h, DATA32 color,
|
|||
ImlibImage * im, int clx, int cly, int clw,
|
||||
int clh, ImlibOp op, char blend)
|
||||
{
|
||||
if ((w < 1) || (h < 1) || (clw < 0))
|
||||
return;
|
||||
if ((w == 1) || (h == 1))
|
||||
if (w == 1 || h == 1)
|
||||
{
|
||||
(void)__imlib_Line_DrawToImage(x, y, x + w - 1, y + h - 1, color,
|
||||
im, clx, cly, clw, clh, op, blend, 0, 0);
|
||||
|
@ -130,18 +128,19 @@ __imlib_Rectangle_DrawToImage(int x, int y, int w, int h, DATA32 color,
|
|||
|
||||
if (clw == 0)
|
||||
{
|
||||
clx = cly = 0;
|
||||
clw = im->w;
|
||||
clx = 0;
|
||||
clh = im->h;
|
||||
cly = 0;
|
||||
}
|
||||
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
if ((clw < 1) || (clh < 1))
|
||||
else
|
||||
{
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
}
|
||||
if (clw <= 0 || clh <= 0)
|
||||
return;
|
||||
|
||||
CLIP(clx, cly, clw, clh, x, y, w, h);
|
||||
if ((clw < 1) || (clh < 1))
|
||||
if (clw <= 0 || clh <= 0)
|
||||
return;
|
||||
|
||||
if (blend && IM_FLAG_ISSET(im, F_HAS_ALPHA))
|
||||
|
@ -157,9 +156,7 @@ __imlib_Rectangle_FillToImage(int x, int y, int w, int h, DATA32 color,
|
|||
ImlibImage * im, int clx, int cly, int clw,
|
||||
int clh, ImlibOp op, char blend)
|
||||
{
|
||||
if ((w < 1) || (h < 1) || (clw < 0))
|
||||
return;
|
||||
if ((w == 1) || (h == 1))
|
||||
if (w == 1 || h == 1)
|
||||
{
|
||||
(void)__imlib_Line_DrawToImage(x, y, x + w - 1, y + h - 1, color,
|
||||
im, clx, cly, clw, clh, op, blend, 0, 0);
|
||||
|
@ -170,18 +167,19 @@ __imlib_Rectangle_FillToImage(int x, int y, int w, int h, DATA32 color,
|
|||
|
||||
if (clw == 0)
|
||||
{
|
||||
clx = cly = 0;
|
||||
clw = im->w;
|
||||
clx = 0;
|
||||
clh = im->h;
|
||||
cly = 0;
|
||||
}
|
||||
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
if ((clw < 1) || (clh < 1))
|
||||
else
|
||||
{
|
||||
CLIP(clx, cly, clw, clh, 0, 0, im->w, im->h);
|
||||
}
|
||||
if (clw <= 0 || clh <= 0)
|
||||
return;
|
||||
|
||||
CLIP(clx, cly, clw, clh, x, y, w, h);
|
||||
if ((clw < 1) || (clh < 1))
|
||||
if (clw <= 0 || clh <= 0)
|
||||
return;
|
||||
|
||||
if (blend && IM_FLAG_ISSET(im, F_HAS_ALPHA))
|
||||
|
|
Loading…
Reference in New Issue