From 3b425b8bf0c58e25da576ed86496171ea19240f9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 16 Nov 2004 08:58:17 +0100 Subject: removed c99-isms. improved bbox handling. --- base/md5.c | 2 +- base/rect.c | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'base') diff --git a/base/md5.c b/base/md5.c index 648532a5..03601e5b 100644 --- a/base/md5.c +++ b/base/md5.c @@ -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 +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); @@ -33,21 +40,36 @@ fz_mergerects(fz_rect a, fz_rect b) return r; } +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); -- cgit v1.2.3