diff options
author | Tor Andersson <tor@ghostscript.com> | 2004-11-16 08:58:17 +0100 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2004-11-16 08:58:17 +0100 |
commit | 3b425b8bf0c58e25da576ed86496171ea19240f9 (patch) | |
tree | 37d6feb715dd929392fb16fdde6cf994dfbc1397 /base | |
parent | 49132f70ac40b2dc7b9a0e22b33a3964af687874 (diff) | |
download | mupdf-3b425b8bf0c58e25da576ed86496171ea19240f9.tar.xz |
removed c99-isms. improved bbox handling.
Diffstat (limited to 'base')
-rw-r--r-- | base/md5.c | 2 | ||||
-rw-r--r-- | base/rect.c | 26 |
2 files changed, 25 insertions, 3 deletions
@@ -31,7 +31,7 @@ enum S11 = 7, S12 = 12, S13 = 17, S14 = 22, S21 = 5, S22 = 9, S23 = 14, S24 = 20, S31 = 4, S32 = 11, S33 = 16, S34 = 23, - S41 = 6, S42 = 10, S43 = 15, S44 = 21, + S41 = 6, S42 = 10, S43 = 15, S44 = 21 }; static void encode(unsigned char *, unsigned long *, unsigned); diff --git a/base/rect.c b/base/rect.c index cc8d0a76..a40701cc 100644 --- a/base/rect.c +++ b/base/rect.c @@ -1,5 +1,8 @@ #include <fitz.h> +static fz_rect none = { { 0, 0}, {0, 0} }; +static fz_irect inone = { { 0, 0}, {0, 0} }; + fz_rect fz_infiniterect(void) { @@ -15,17 +18,21 @@ fz_rect fz_intersectrects(fz_rect a, fz_rect b) { fz_rect r; + if (a.max.x < a.min.x) + return (b.max.x < b.min.x) ? none : b; r.min.x = MAX(a.min.x, b.min.x); r.min.y = MAX(a.min.y, b.min.y); r.max.x = MIN(a.max.x, b.max.x); r.max.y = MIN(a.max.y, b.max.y); - return r; + return (r.max.x < r.min.x || r.max.y < r.min.y) ? none : r; } fz_rect fz_mergerects(fz_rect a, fz_rect b) { fz_rect r; + if (a.max.x < a.min.x) + return (b.max.x < b.min.x) ? none : b; r.min.x = MIN(a.min.x, b.min.x); r.min.y = MIN(a.min.y, b.min.y); r.max.x = MAX(a.max.x, b.max.x); @@ -34,20 +41,35 @@ fz_mergerects(fz_rect a, fz_rect b) } fz_irect +fz_roundrect(fz_rect f) +{ + fz_irect i; + i.min.x = fz_floor(f.min.x);// - 1; + i.min.y = fz_floor(f.min.y);// - 1; + i.max.x = fz_ceil(f.max.x);// + 1; + i.max.y = fz_ceil(f.max.y);// + 1; + return i; +} + +fz_irect fz_intersectirects(fz_irect a, fz_irect b) { fz_irect r; + if (a.max.x < a.min.x) + return (b.max.x < b.min.x) ? inone : b; r.min.x = MAX(a.min.x, b.min.x); r.min.y = MAX(a.min.y, b.min.y); r.max.x = MIN(a.max.x, b.max.x); r.max.y = MIN(a.max.y, b.max.y); - return r; + return (r.max.x < r.min.x || r.max.y < r.min.y) ? inone : r; } fz_irect fz_mergeirects(fz_irect a, fz_irect b) { fz_irect r; + if (a.max.x < a.min.x) + return (b.max.x < b.min.x) ? inone : b; r.min.x = MIN(a.min.x, b.min.x); r.min.y = MIN(a.min.y, b.min.y); r.max.x = MAX(a.max.x, b.max.x); |