summaryrefslogtreecommitdiff
path: root/source/fitz/draw-edge.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-04-26 11:55:35 +0100
committerRobin Watts <robin.watts@artifex.com>2017-04-26 15:56:42 +0100
commitf70460b2c402ac0769018a065a7b057332373be2 (patch)
treebd1c034d7d0ffaf35503eb5116800c2b342b3aca /source/fitz/draw-edge.c
parent77e2257e7615aa9e3c35341e76666e285a3cb126 (diff)
downloadmupdf-f70460b2c402ac0769018a065a7b057332373be2.tar.xz
Tweak gel bbox calculation.
Diffstat (limited to 'source/fitz/draw-edge.c')
-rw-r--r--source/fitz/draw-edge.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/fitz/draw-edge.c b/source/fitz/draw-edge.c
index 43394fcb..bffb86d3 100644
--- a/source/fitz/draw-edge.c
+++ b/source/fitz/draw-edge.c
@@ -10,6 +10,12 @@ static inline int fz_idiv(int a, int b)
return a < 0 ? (a - b + 1) / b : a / b;
}
+/* divide and ceil towards inf */
+static inline int fz_idiv_up(int a, int b)
+{
+ return a < 0 ? a / b : (a + b - 1) / b;
+}
+
/* If AA_BITS is defined, then we assume constant N bits of antialiasing. We
* will attempt to provide at least that number of bits of accuracy in the
* antialiasing (to a maximum of 8). If it is defined to be 0 then no
@@ -353,8 +359,8 @@ fz_bound_gel(fz_context *ctx, const fz_gel *gel, fz_irect *bbox)
{
bbox->x0 = fz_idiv(gel->bbox.x0, hscale);
bbox->y0 = fz_idiv(gel->bbox.y0, vscale);
- bbox->x1 = fz_idiv(gel->bbox.x1, hscale) + 1;
- bbox->y1 = fz_idiv(gel->bbox.y1, vscale) + 1;
+ bbox->x1 = fz_idiv_up(gel->bbox.x1, hscale);
+ bbox->y1 = fz_idiv_up(gel->bbox.y1, vscale);
}
return bbox;
}
@@ -875,7 +881,7 @@ fz_scan_convert_aa(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *cli
const int vscale = fz_aa_vscale;
int xmin = fz_idiv(gel->bbox.x0, hscale);
- int xmax = fz_idiv(gel->bbox.x1, hscale) + 1;
+ int xmax = fz_idiv_up(gel->bbox.x1, hscale);
int xofs = xmin * hscale;
@@ -885,11 +891,12 @@ fz_scan_convert_aa(fz_context *ctx, fz_gel *gel, int eofill, const fz_irect *cli
if (gel->len == 0)
return;
+ assert(xmin < xmax);
assert(clip->x0 >= xmin);
assert(clip->x1 <= xmax);
alphas = fz_malloc_no_throw(ctx, xmax - xmin + 1);
- deltas = fz_malloc_no_throw(ctx, (xmax - xmin + 1) * sizeof(int));
+ deltas = fz_malloc_no_throw(ctx, (xmax - xmin + 2) * sizeof(int));
if (alphas == NULL || deltas == NULL)
{
fz_free(ctx, alphas);