summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2013-01-25 14:07:29 +0100
committerTor Andersson <tor.andersson@artifex.com>2013-01-30 14:07:21 +0100
commitddb92b7c3fdfcf9bf3d7463dde4e662ca10f79ba (patch)
treef9d960048a60066ab8829af0fe6a22104ef30ee3 /fitz
parentd8ad064b0c4bcd539c06c98af070613ff818ee0b (diff)
downloadmupdf-ddb92b7c3fdfcf9bf3d7463dde4e662ca10f79ba.tar.xz
Eliminate fz_bbox in favor of fz_rect everywhere.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/base_geometry.c155
-rw-r--r--fitz/dev_bbox.c37
-rw-r--r--fitz/dev_list.c26
-rw-r--r--fitz/doc_search.c58
-rw-r--r--fitz/fitz-internal.h28
-rw-r--r--fitz/fitz.h168
-rw-r--r--fitz/res_font.c27
-rw-r--r--fitz/res_pixmap.c44
8 files changed, 190 insertions, 353 deletions
diff --git a/fitz/base_geometry.c b/fitz/base_geometry.c
index ef22a6fa..1486279f 100644
--- a/fitz/base_geometry.c
+++ b/fitz/base_geometry.c
@@ -3,24 +3,6 @@
#define MAX4(a,b,c,d) fz_max(fz_max(a,b), fz_max(c,d))
#define MIN4(a,b,c,d) fz_min(fz_min(a,b), fz_min(c,d))
-/* A useful macro to add with overflow detection and clamping.
-
- We want to do "b = a + x", but to allow for overflow. Consider the
- top bits, and the cases in which overflow occurs:
-
- overflow a x b ~a^x a^b (~a^x)&(a^b)
- no 0 0 0 1 0 0
- yes 0 0 1 1 1 1
- no 0 1 0 0 0 0
- no 0 1 1 0 1 0
- no 1 0 0 0 1 0
- no 1 0 1 0 0 0
- yes 1 1 0 1 1 1
- no 1 1 1 1 0 0
-*/
-#define ADD_WITH_SAT(b,a,x) \
- ((b) = (a) + (x), (b) = (((~(a)^(x))&((a)^(b))) < 0 ? ((x) < 0 ? INT_MIN : INT_MAX) : (b)))
-
/* Matrices, points and affine transformations */
const fz_matrix fz_identity = { 1, 0, 0, 1, 0, 0 };
@@ -180,43 +162,44 @@ fz_transform_vector(fz_matrix m, fz_point p)
/* Rectangles and bounding boxes */
+/* biggest and smallest integers that a float can represent perfectly (i.e. 24 bits) */
+#define MAX_SAFE_INT 16777216
+#define MIN_SAFE_INT -16777216
+
const fz_rect fz_infinite_rect = { 1, 1, -1, -1 };
const fz_rect fz_empty_rect = { 0, 0, 0, 0 };
const fz_rect fz_unit_rect = { 0, 0, 1, 1 };
-const fz_bbox fz_infinite_bbox = { 1, 1, -1, -1 };
-const fz_bbox fz_empty_bbox = { 0, 0, 0, 0 };
-const fz_bbox fz_unit_bbox = { 0, 0, 1, 1 };
-
-#define SAFE_INT(f) ((f > INT_MAX) ? INT_MAX : ((f < INT_MIN) ? INT_MIN : (int)f))
-fz_bbox
-fz_bbox_covering_rect(fz_rect f)
+fz_rect
+fz_rect_covering_rect(fz_rect f)
{
- fz_bbox i;
f.x0 = floorf(f.x0);
f.y0 = floorf(f.y0);
f.x1 = ceilf(f.x1);
f.y1 = ceilf(f.y1);
- i.x0 = SAFE_INT(f.x0);
- i.y0 = SAFE_INT(f.y0);
- i.x1 = SAFE_INT(f.x1);
- i.y1 = SAFE_INT(f.y1);
- return i;
+
+ /* check for integer overflow */
+ f.x0 = fz_clamp(f.x0, MIN_SAFE_INT, MAX_SAFE_INT);
+ f.y0 = fz_clamp(f.y0, MIN_SAFE_INT, MAX_SAFE_INT);
+ f.x1 = fz_clamp(f.x1, MIN_SAFE_INT, MAX_SAFE_INT);
+ f.y1 = fz_clamp(f.y1, MIN_SAFE_INT, MAX_SAFE_INT);
+ return f;
}
-fz_bbox
+fz_rect
fz_round_rect(fz_rect f)
{
- fz_bbox i;
f.x0 = floorf(f.x0 + 0.001);
f.y0 = floorf(f.y0 + 0.001);
f.x1 = ceilf(f.x1 - 0.001);
f.y1 = ceilf(f.y1 - 0.001);
- i.x0 = SAFE_INT(f.x0);
- i.y0 = SAFE_INT(f.y0);
- i.x1 = SAFE_INT(f.x1);
- i.y1 = SAFE_INT(f.y1);
- return i;
+
+ /* check for integer overflow */
+ f.x0 = fz_clamp(f.x0, MIN_SAFE_INT, MAX_SAFE_INT);
+ f.y0 = fz_clamp(f.y0, MIN_SAFE_INT, MAX_SAFE_INT);
+ f.x1 = fz_clamp(f.x1, MIN_SAFE_INT, MAX_SAFE_INT);
+ f.y1 = fz_clamp(f.y1, MIN_SAFE_INT, MAX_SAFE_INT);
+ return f;
}
fz_rect
@@ -251,52 +234,6 @@ fz_union_rect(fz_rect a, fz_rect b)
return r;
}
-fz_bbox
-fz_intersect_bbox(fz_bbox a, fz_bbox b)
-{
- fz_bbox r;
- /* Check for empty box before infinite box */
- if (fz_is_empty_rect(a)) return fz_empty_bbox;
- if (fz_is_empty_rect(b)) return fz_empty_bbox;
- if (fz_is_infinite_rect(a)) return b;
- if (fz_is_infinite_rect(b)) return a;
- r.x0 = fz_maxi(a.x0, b.x0);
- r.y0 = fz_maxi(a.y0, b.y0);
- r.x1 = fz_mini(a.x1, b.x1);
- r.y1 = fz_mini(a.y1, b.y1);
- return (r.x1 < r.x0 || r.y1 < r.y0) ? fz_empty_bbox : r;
-}
-
-fz_bbox
-fz_translate_bbox(fz_bbox a, int xoff, int yoff)
-{
- fz_bbox b;
-
- if (fz_is_empty_rect(a)) return a;
- if (fz_is_infinite_rect(a)) return a;
- ADD_WITH_SAT(b.x0, a.x0, xoff);
- ADD_WITH_SAT(b.y0, a.y0, yoff);
- ADD_WITH_SAT(b.x1, a.x1, xoff);
- ADD_WITH_SAT(b.y1, a.y1, yoff);
- return b;
-}
-
-fz_bbox
-fz_union_bbox(fz_bbox a, fz_bbox b)
-{
- fz_bbox r;
- /* Check for empty box before infinite box */
- if (fz_is_empty_rect(a)) return b;
- if (fz_is_empty_rect(b)) return a;
- if (fz_is_infinite_rect(a)) return a;
- if (fz_is_infinite_rect(b)) return b;
- r.x0 = fz_mini(a.x0, b.x0);
- r.y0 = fz_mini(a.y0, b.y0);
- r.x1 = fz_maxi(a.x1, b.x1);
- r.y1 = fz_maxi(a.y1, b.y1);
- return r;
-}
-
fz_rect
fz_transform_rect(fz_matrix m, fz_rect r)
{
@@ -320,42 +257,28 @@ fz_transform_rect(fz_matrix m, fz_rect r)
return r;
}
-fz_bbox
-fz_transform_bbox(fz_matrix m, fz_bbox b)
+fz_rect
+fz_translate_rect(fz_rect a, float xoff, float yoff)
{
- fz_point s, t, u, v;
-
- if (fz_is_infinite_bbox(b))
- return b;
-
- s.x = b.x0; s.y = b.y0;
- t.x = b.x0; t.y = b.y1;
- u.x = b.x1; u.y = b.y1;
- v.x = b.x1; v.y = b.y0;
- s = fz_transform_point(m, s);
- t = fz_transform_point(m, t);
- u = fz_transform_point(m, u);
- v = fz_transform_point(m, v);
- b.x0 = MIN4(s.x, t.x, u.x, v.x);
- b.y0 = MIN4(s.y, t.y, u.y, v.y);
- b.x1 = MAX4(s.x, t.x, u.x, v.x);
- b.y1 = MAX4(s.y, t.y, u.y, v.y);
+ fz_rect b;
+ if (fz_is_empty_rect(a)) return a;
+ if (fz_is_infinite_rect(a)) return a;
+ b.x0 = a.x0 + xoff;
+ b.y0 = a.y0 + yoff;
+ b.x1 = a.x1 + xoff;
+ b.y1 = a.y1 + yoff;
return b;
-
}
-fz_bbox
-fz_expand_bbox(fz_bbox a, int expand)
+fz_rect
+fz_expand_rect(fz_rect a, float expand)
{
- fz_bbox b;
-
- if (fz_is_infinite_bbox(a))
- return a;
-
- ADD_WITH_SAT(b.x0, a.x0, -expand);
- ADD_WITH_SAT(b.y0, a.y0, -expand);
- ADD_WITH_SAT(b.x1, a.x1, expand);
- ADD_WITH_SAT(b.y1, a.y1, expand);
+ fz_rect b;
+ if (fz_is_empty_rect(a)) return a;
+ if (fz_is_infinite_rect(a)) return a;
+ b.x0 = a.x0 - expand;
+ b.y0 = a.y0 - expand;
+ b.x1 = a.x1 + expand;
+ b.y1 = a.y1 + expand;
return b;
-
}
diff --git a/fitz/dev_bbox.c b/fitz/dev_bbox.c
index 87cb4dca..6c910afb 100644
--- a/fitz/dev_bbox.c
+++ b/fitz/dev_bbox.c
@@ -6,63 +6,58 @@ static void
fz_bbox_fill_path(fz_device *dev, fz_path *path, int even_odd, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_bbox *result = dev->user;
- fz_bbox bbox = fz_bbox_covering_rect(fz_bound_path(dev->ctx, path, NULL, ctm));
- *result = fz_union_bbox(*result, bbox);
+ fz_rect *result = dev->user;
+ *result = fz_union_rect(*result, fz_bound_path(dev->ctx, path, NULL, ctm));
}
static void
fz_bbox_stroke_path(fz_device *dev, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_bbox *result = dev->user;
- fz_bbox bbox = fz_bbox_covering_rect(fz_bound_path(dev->ctx, path, stroke, ctm));
- *result = fz_union_bbox(*result, bbox);
+ fz_rect *result = dev->user;
+ *result = fz_union_rect(*result, fz_bound_path(dev->ctx, path, stroke, ctm));
}
static void
fz_bbox_fill_text(fz_device *dev, fz_text *text, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_bbox *result = dev->user;
- fz_bbox bbox = fz_bbox_covering_rect(fz_bound_text(dev->ctx, text, ctm));
- *result = fz_union_bbox(*result, bbox);
+ fz_rect *result = dev->user;
+ *result = fz_union_rect(*result, fz_bound_text(dev->ctx, text, ctm));
}
static void
fz_bbox_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_bbox *result = dev->user;
- fz_bbox bbox = fz_bbox_covering_rect(fz_bound_text(dev->ctx, text, ctm));
- *result = fz_union_bbox(*result, bbox);
+ fz_rect *result = dev->user;
+ *result = fz_union_rect(*result, fz_bound_text(dev->ctx, text, ctm));
}
static void
fz_bbox_fill_shade(fz_device *dev, fz_shade *shade, fz_matrix ctm, float alpha)
{
- fz_bbox *result = dev->user;
- fz_bbox bbox = fz_bbox_covering_rect(fz_bound_shade(dev->ctx, shade, ctm));
- *result = fz_union_bbox(*result, bbox);
+ fz_rect *result = dev->user;
+ *result = fz_union_rect(*result, fz_bound_shade(dev->ctx, shade, ctm));
}
static void
fz_bbox_fill_image(fz_device *dev, fz_image *image, fz_matrix ctm, float alpha)
{
- fz_bbox *result = dev->user;
- fz_bbox bbox = fz_bbox_covering_rect(fz_transform_rect(ctm, fz_unit_rect));
- *result = fz_union_bbox(*result, bbox);
+ fz_rect *result = dev->user;
+ *result = fz_union_rect(*result, fz_transform_rect(ctm, fz_unit_rect));
}
static void
fz_bbox_fill_image_mask(fz_device *dev, fz_image *image, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
- fz_bbox_fill_image(dev, image, ctm, alpha);
+ fz_rect *result = dev->user;
+ *result = fz_union_rect(*result, fz_transform_rect(ctm, fz_unit_rect));
}
fz_device *
-fz_new_bbox_device(fz_context *ctx, fz_bbox *result)
+fz_new_bbox_device(fz_context *ctx, fz_rect *result)
{
fz_device *dev;
@@ -76,7 +71,7 @@ fz_new_bbox_device(fz_context *ctx, fz_bbox *result)
dev->fill_image = fz_bbox_fill_image;
dev->fill_image_mask = fz_bbox_fill_image_mask;
- *result = fz_empty_bbox;
+ *result = fz_empty_rect;
return dev;
}
diff --git a/fitz/dev_list.c b/fitz/dev_list.c
index e49f694b..26693e0f 100644
--- a/fitz/dev_list.c
+++ b/fitz/dev_list.c
@@ -588,12 +588,10 @@ fz_free_display_list(fz_context *ctx, fz_display_list *list)
}
void
-fz_run_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm, fz_bbox scissor, fz_cookie *cookie)
+fz_run_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm, fz_rect scissor, fz_cookie *cookie)
{
fz_display_node *node;
fz_matrix ctm;
- fz_rect rect;
- fz_bbox bbox;
int clipped = 0;
int tiled = 0;
int empty;
@@ -624,9 +622,7 @@ fz_run_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm, fz
}
else
{
- bbox = fz_bbox_covering_rect(fz_transform_rect(top_ctm, node->rect));
- bbox = fz_intersect_bbox(bbox, scissor);
- empty = fz_is_empty_bbox(bbox);
+ empty = fz_is_empty_rect(fz_intersect_rect(fz_transform_rect(top_ctm, node->rect), scissor));
}
if (clipped || empty)
@@ -725,30 +721,36 @@ visible:
fz_pop_clip(dev);
break;
case FZ_CMD_BEGIN_MASK:
- rect = fz_transform_rect(top_ctm, node->rect);
- fz_begin_mask(dev, rect, node->flag, node->colorspace, node->color);
+ {
+ fz_rect trect = fz_transform_rect(top_ctm, node->rect);
+ fz_begin_mask(dev, trect, node->flag, node->colorspace, node->color);
break;
+ }
case FZ_CMD_END_MASK:
fz_end_mask(dev);
break;
case FZ_CMD_BEGIN_GROUP:
- rect = fz_transform_rect(top_ctm, node->rect);
- fz_begin_group(dev, rect,
+ {
+ fz_rect trect = fz_transform_rect(top_ctm, node->rect);
+ fz_begin_group(dev, trect,
(node->flag & ISOLATED) != 0, (node->flag & KNOCKOUT) != 0,
node->item.blendmode, node->alpha);
break;
+ }
case FZ_CMD_END_GROUP:
fz_end_group(dev);
break;
case FZ_CMD_BEGIN_TILE:
+ {
+ fz_rect rect;
tiled++;
rect.x0 = node->color[2];
rect.y0 = node->color[3];
rect.x1 = node->color[4];
rect.y1 = node->color[5];
- fz_begin_tile(dev, node->rect, rect,
- node->color[0], node->color[1], ctm);
+ fz_begin_tile(dev, node->rect, rect, node->color[0], node->color[1], ctm);
break;
+ }
case FZ_CMD_END_TILE:
tiled--;
fz_end_tile(dev);
diff --git a/fitz/doc_search.c b/fitz/doc_search.c
index 53cf7486..76e5e9dc 100644
--- a/fitz/doc_search.c
+++ b/fitz/doc_search.c
@@ -42,9 +42,9 @@ static int charat(fz_text_page *page, int idx)
return textcharat(page, idx).c;
}
-static fz_bbox bboxat(fz_text_page *page, int idx)
+static fz_rect bboxat(fz_text_page *page, int idx)
{
- return fz_round_rect(textcharat(page, idx).bbox);
+ return textcharat(page, idx).bbox;
}
static int textlen(fz_text_page *page)
@@ -88,7 +88,7 @@ static int match(fz_text_page *page, const char *s, int n)
}
int
-fz_search_text_page(fz_context *ctx, fz_text_page *text, char *needle, fz_bbox *hit_bbox, int hit_max)
+fz_search_text_page(fz_context *ctx, fz_text_page *text, char *needle, fz_rect *hit_bbox, int hit_max)
{
int pos, len, i, n, hit_count;
@@ -102,25 +102,25 @@ fz_search_text_page(fz_context *ctx, fz_text_page *text, char *needle, fz_bbox *
n = match(text, needle, pos);
if (n)
{
- fz_bbox linebox = fz_empty_bbox;
+ fz_rect linebox = fz_empty_rect;
for (i = 0; i < n; i++)
{
- fz_bbox charbox = bboxat(text, pos + i);
- if (!fz_is_empty_bbox(charbox))
+ fz_rect charbox = bboxat(text, pos + i);
+ if (!fz_is_empty_rect(charbox))
{
- if (charbox.y0 != linebox.y0 || fz_absi(charbox.x0 - linebox.x1) > 5)
+ if (charbox.y0 != linebox.y0 || fz_abs(charbox.x0 - linebox.x1) > 5)
{
- if (!fz_is_empty_bbox(linebox) && hit_count < hit_max)
+ if (!fz_is_empty_rect(linebox) && hit_count < hit_max)
hit_bbox[hit_count++] = linebox;
linebox = charbox;
}
else
{
- linebox = fz_union_bbox(linebox, charbox);
+ linebox = fz_union_rect(linebox, charbox);
}
}
}
- if (!fz_is_empty_bbox(linebox) && hit_count < hit_max)
+ if (!fz_is_empty_rect(linebox) && hit_count < hit_max)
hit_bbox[hit_count++] = linebox;
}
}
@@ -129,18 +129,18 @@ fz_search_text_page(fz_context *ctx, fz_text_page *text, char *needle, fz_bbox *
}
int
-fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_bbox rect, fz_bbox *hit_bbox, int hit_max)
+fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_rect rect, fz_rect *hit_bbox, int hit_max)
{
- fz_bbox linebox, charbox;
+ fz_rect linebox, charbox;
fz_text_block *block;
fz_text_line *line;
fz_text_span *span;
int i, hit_count;
- int x0 = rect.x0;
- int x1 = rect.x1;
- int y0 = rect.y0;
- int y1 = rect.y1;
+ float x0 = rect.x0;
+ float x1 = rect.x1;
+ float y0 = rect.y0;
+ float y1 = rect.y1;
hit_count = 0;
@@ -148,28 +148,28 @@ fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_bbox rect, fz_bbo
{
for (line = block->lines; line < block->lines + block->len; line++)
{
- linebox = fz_empty_bbox;
+ linebox = fz_empty_rect;
for (span = line->spans; span < line->spans + line->len; span++)
{
for (i = 0; i < span->len; i++)
{
- charbox = fz_bbox_covering_rect(span->text[i].bbox);
+ charbox = span->text[i].bbox;
if (charbox.x1 >= x0 && charbox.x0 <= x1 && charbox.y1 >= y0 && charbox.y0 <= y1)
{
- if (charbox.y0 != linebox.y0 || fz_absi(charbox.x0 - linebox.x1) > 5)
+ if (charbox.y0 != linebox.y0 || fz_abs(charbox.x0 - linebox.x1) > 5)
{
- if (!fz_is_empty_bbox(linebox) && hit_count < hit_max)
+ if (!fz_is_empty_rect(linebox) && hit_count < hit_max)
hit_bbox[hit_count++] = linebox;
linebox = charbox;
}
else
{
- linebox = fz_union_bbox(linebox, charbox);
+ linebox = fz_union_rect(linebox, charbox);
}
}
}
}
- if (!fz_is_empty_bbox(linebox) && hit_count < hit_max)
+ if (!fz_is_empty_rect(linebox) && hit_count < hit_max)
hit_bbox[hit_count++] = linebox;
}
}
@@ -178,20 +178,20 @@ fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_bbox rect, fz_bbo
}
char *
-fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_bbox rect)
+fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_rect rect)
{
fz_buffer *buffer;
- fz_bbox hitbox;
+ fz_rect hitbox;
fz_text_block *block;
fz_text_line *line;
fz_text_span *span;
int c, i, seen = 0;
char *s;
- int x0 = rect.x0;
- int x1 = rect.x1;
- int y0 = rect.y0;
- int y1 = rect.y1;
+ float x0 = rect.x0;
+ float x1 = rect.x1;
+ float y0 = rect.y0;
+ float y1 = rect.y1;
buffer = fz_new_buffer(ctx, 1024);
@@ -210,7 +210,7 @@ fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_bbox rect)
for (i = 0; i < span->len; i++)
{
- hitbox = fz_bbox_covering_rect(span->text[i].bbox);
+ hitbox = span->text[i].bbox;
c = span->text[i].c;
if (c < 32)
c = '?';
diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h
index e853188d..0ac4c93a 100644
--- a/fitz/fitz-internal.h
+++ b/fitz/fitz-internal.h
@@ -872,22 +872,22 @@ struct fz_pixmap_s
void fz_free_pixmap_imp(fz_context *ctx, fz_storable *pix);
-void fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_bbox r);
+void fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_rect r);
void fz_premultiply_pixmap(fz_context *ctx, fz_pixmap *pix);
fz_pixmap *fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray, int luminosity);
unsigned int fz_pixmap_size(fz_context *ctx, fz_pixmap *pix);
-fz_pixmap *fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_bbox *clip);
+fz_pixmap *fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_rect *clip);
typedef struct fz_scale_cache_s fz_scale_cache;
fz_scale_cache *fz_new_scale_cache(fz_context *ctx);
void fz_free_scale_cache(fz_context *ctx, fz_scale_cache *cache);
-fz_pixmap *fz_scale_pixmap_cached(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_bbox *clip, fz_scale_cache *cache_x, fz_scale_cache *cache_y);
+fz_pixmap *fz_scale_pixmap_cached(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_rect *clip, fz_scale_cache *cache_x, fz_scale_cache *cache_y);
void fz_subsample_pixmap(fz_context *ctx, fz_pixmap *tile, int factor);
-fz_bbox fz_pixmap_bbox_no_ctx(fz_pixmap *src);
+fz_rect fz_pixmap_bbox_no_ctx(fz_pixmap *src);
typedef struct fz_compression_params_s fz_compression_params;
@@ -1187,10 +1187,10 @@ void fz_purge_glyph_cache(fz_context *ctx);
fz_path *fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm);
fz_path *fz_outline_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix ctm);
fz_pixmap *fz_render_ft_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, int aa);
-fz_pixmap *fz_render_t3_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, fz_colorspace *model, fz_bbox scissor);
+fz_pixmap *fz_render_t3_glyph(fz_context *ctx, fz_font *font, int cid, fz_matrix trm, fz_colorspace *model, fz_rect scissor);
fz_pixmap *fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *state);
-fz_pixmap *fz_render_glyph(fz_context *ctx, fz_font*, int, fz_matrix, fz_colorspace *model, fz_bbox scissor);
-fz_pixmap *fz_render_stroked_glyph(fz_context *ctx, fz_font*, int, fz_matrix, fz_matrix, fz_stroke_state *stroke, fz_bbox scissor);
+fz_pixmap *fz_render_glyph(fz_context *ctx, fz_font*, int, fz_matrix, fz_colorspace *model, fz_rect scissor);
+fz_pixmap *fz_render_stroked_glyph(fz_context *ctx, fz_font*, int, fz_matrix, fz_matrix, fz_stroke_state *stroke, fz_rect scissor);
void fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gid, fz_matrix trm, void *gstate, int nestedDepth);
void fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nestedDepth);
@@ -1300,7 +1300,7 @@ void fz_drop_shade(fz_context *ctx, fz_shade *shade);
void fz_free_shade_imp(fz_context *ctx, fz_storable *shade);
fz_rect fz_bound_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm);
-void fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox);
+void fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_rect bbox);
/*
* Handy routine for processing mesh based shades
@@ -1339,13 +1339,13 @@ typedef struct fz_gel_s fz_gel;
fz_gel *fz_new_gel(fz_context *ctx);
void fz_insert_gel(fz_gel *gel, float x0, float y0, float x1, float y1);
-void fz_reset_gel(fz_gel *gel, fz_bbox clip);
+void fz_reset_gel(fz_gel *gel, fz_rect clip);
void fz_sort_gel(fz_gel *gel);
-fz_bbox fz_bound_gel(fz_gel *gel);
+fz_rect fz_bound_gel(fz_gel *gel);
void fz_free_gel(fz_gel *gel);
int fz_is_rect_gel(fz_gel *gel);
-void fz_scan_convert(fz_gel *gel, int eofill, fz_bbox clip, fz_pixmap *pix, unsigned char *colorbv);
+void fz_scan_convert(fz_gel *gel, int eofill, fz_rect clip, fz_pixmap *pix, unsigned char *colorbv);
void fz_flatten_fill_path(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness);
void fz_flatten_stroke_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth);
@@ -1458,12 +1458,12 @@ void fz_paint_solid_color(unsigned char * restrict dp, int n, int w, unsigned ch
void fz_paint_span(unsigned char * restrict dp, unsigned char * restrict sp, int n, int w, int alpha);
void fz_paint_span_with_color(unsigned char * restrict dp, unsigned char * restrict mp, int n, int w, unsigned char *color);
-void fz_paint_image(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, int alpha);
-void fz_paint_image_with_color(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, unsigned char *colorbv);
+void fz_paint_image(fz_pixmap *dst, fz_rect scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, int alpha);
+void fz_paint_image_with_color(fz_pixmap *dst, fz_rect scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, unsigned char *colorbv);
void fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha);
void fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk);
-void fz_paint_pixmap_with_rect(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox);
+void fz_paint_pixmap_with_bbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_rect bbox);
void fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode, int isolated, fz_pixmap *shape);
void fz_blend_pixel(unsigned char dp[3], unsigned char bp[3], unsigned char sp[3], int blendmode);
diff --git a/fitz/fitz.h b/fitz/fitz.h
index bb4d3831..7243c341 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -734,8 +734,7 @@ struct fz_point_s
defined to be infinite.
To check for empty or infinite rectangles use fz_is_empty_rect
- and fz_is_infinite_rect. Compare to fz_bbox which has corners
- at integer coordinates.
+ and fz_is_infinite_rect.
x0, y0: The top left corner.
@@ -749,23 +748,6 @@ struct fz_rect_s
};
/*
- fz_bbox is a bounding box similar to a fz_rect, except that
- all corner coordinates are rounded to integer coordinates.
- To check for empty or infinite bounding boxes use
- fz_is_empty_bbox and fz_is_infinite_bbox.
-
- x0, y0: The top left corner.
-
- x1, y1: The bottom right corner.
-*/
-typedef struct fz_bbox_s fz_bbox;
-struct fz_bbox_s
-{
- int x0, y0;
- int x1, y1;
-};
-
-/*
A rectangle with sides of length one.
The bottom left corner is at (0, 0) and the top right corner
@@ -774,11 +756,6 @@ struct fz_bbox_s
extern const fz_rect fz_unit_rect;
/*
- A bounding box with sides of length one. See fz_unit_rect.
-*/
-extern const fz_bbox fz_unit_bbox;
-
-/*
An empty rectangle with an area equal to zero.
Both the top left and bottom right corner are at (0, 0).
@@ -786,11 +763,6 @@ extern const fz_bbox fz_unit_bbox;
extern const fz_rect fz_empty_rect;
/*
- An empty bounding box. See fz_empty_rect.
-*/
-extern const fz_bbox fz_empty_bbox;
-
-/*
An infinite rectangle with negative area.
The corner (x0, y0) is at (1, 1) while the corner (x1, y1) is
@@ -799,11 +771,6 @@ extern const fz_bbox fz_empty_bbox;
extern const fz_rect fz_infinite_rect;
/*
- An infinite bounding box. See fz_infinite_rect.
-*/
-extern const fz_bbox fz_infinite_bbox;
-
-/*
fz_is_empty_rect: Check if rectangle is empty.
An empty rectangle is defined as one whose area is zero.
@@ -811,14 +778,6 @@ extern const fz_bbox fz_infinite_bbox;
#define fz_is_empty_rect(r) ((r).x0 == (r).x1 || (r).y0 == (r).y1)
/*
- fz_is_empty_bbox: Check if bounding box is empty.
-
- Same definition of empty bounding boxes as for empty
- rectangles. See fz_is_empty_rect.
-*/
-#define fz_is_empty_bbox(b) ((b).x0 == (b).x1 || (b).y0 == (b).y1)
-
-/*
fz_is_infinite: Check if rectangle is infinite.
An infinite rectangle is defined as one where either of the
@@ -827,14 +786,6 @@ extern const fz_bbox fz_infinite_bbox;
#define fz_is_infinite_rect(r) ((r).x0 > (r).x1 || (r).y0 > (r).y1)
/*
- fz_is_infinite_bbox: Check if bounding box is infinite.
-
- Same definition of infinite bounding boxes as for infinite
- rectangles. See fz_is_infinite_rect.
-*/
-#define fz_is_infinite_bbox(b) ((b).x0 > (b).x1 || (b).y0 > (b).y1)
-
-/*
fz_matrix is a a row-major 3x3 matrix used for representing
transformations of coordinates throughout MuPDF.
@@ -949,39 +900,6 @@ int fz_is_rectilinear(fz_matrix m);
float fz_matrix_expansion(fz_matrix m); /* sumatrapdf */
/*
- fz_bbox_covering_rect: Convert a rect into the minimal bounding box
- that covers the rectangle.
-
- Coordinates in a bounding box are integers, so rounding of the
- rects coordinates takes place. The top left corner is rounded
- upwards and left while the bottom right corner is rounded
- downwards and to the right. Overflows or underflowing
- coordinates are clamped to INT_MIN/INT_MAX.
-
- Does not throw exceptions.
-*/
-fz_bbox fz_bbox_covering_rect(fz_rect rect);
-
-/*
- fz_round_rect: Convert a rect into a bounding box.
-
- Coordinates in a bounding box are integers, so rounding of the
- rects coordinates takes place. The top left corner is rounded
- upwards and left while the bottom right corner is rounded
- downwards and to the right. Overflows or underflowing
- coordinates are clamped to INT_MIN/INT_MAX.
-
- This differs from fz_bbox_covering_rect, in that fz_bbox_covering_rect
- slavishly follows the numbers (i.e any slight over/under calculations
- can cause whole extra pixels to be added). fz_round_rect
- allows for a small amount of rounding error when calculating
- the bbox.
-
- Does not throw exceptions.
-*/
-fz_bbox fz_round_rect(fz_rect rect);
-
-/*
fz_intersect_rect: Compute intersection of two rectangles.
Compute the largest axis-aligned rectangle that covers the
@@ -996,16 +914,6 @@ fz_bbox fz_round_rect(fz_rect rect);
fz_rect fz_intersect_rect(fz_rect a, fz_rect b);
/*
- fz_intersect_bbox: Compute intersection of two bounding boxes.
-
- Similar to fz_intersect_rect but operates on two bounding
- boxes instead of two rectangles.
-
- Does not throw exceptions.
-*/
-fz_bbox fz_intersect_bbox(fz_bbox a, fz_bbox b);
-
-/*
fz_union_rect: Compute union of two rectangles.
Compute the smallest axis-aligned rectangle that encompasses
@@ -1019,30 +927,52 @@ fz_bbox fz_intersect_bbox(fz_bbox a, fz_bbox b);
fz_rect fz_union_rect(fz_rect a, fz_rect b);
/*
- fz_union_bbox: Compute union of two bounding boxes.
+ fz_rect_covering_rect: Convert a rect into the minimal bounding box
+ that covers the rectangle.
+
+ Coordinates in a bounding box are integers, so rounding of the
+ rects coordinates takes place. The top left corner is rounded
+ upwards and left while the bottom right corner is rounded
+ downwards and to the right.
+
+ Does not throw exceptions.
+*/
+
+fz_rect fz_rect_covering_rect(fz_rect rect);
+
+/*
+ fz_round_rect: Round rectangle coordinates.
- Similar to fz_union_rect but operates on two bounding boxes
- instead of two rectangles.
+ Coordinates in a bounding box are integers, so rounding of the
+ rects coordinates takes place. The top left corner is rounded
+ upwards and left while the bottom right corner is rounded
+ downwards and to the right.
+
+ This differs from fz_rect_covering_rect, in that fz_rect_covering_rect
+ slavishly follows the numbers (i.e any slight over/under calculations
+ can cause whole extra pixels to be added). fz_round_rect
+ allows for a small amount of rounding error when calculating
+ the bbox.
Does not throw exceptions.
*/
-fz_bbox fz_union_bbox(fz_bbox a, fz_bbox b);
+fz_rect fz_round_rect(fz_rect rect);
/*
- fz_expand_bbox: Expand a bbox by a given amount in all directions.
+ fz_expand_rect: Expand a bbox by a given amount in all directions.
Does not throw exceptions.
*/
-fz_bbox fz_expand_bbox(fz_bbox b, int expand);
+fz_rect fz_expand_rect(fz_rect b, float expand);
/*
- fz_translate_bbox: Translate bounding box.
+ fz_translate_rect: Translate bounding box.
Translate a bbox by a given x and y offset. Allows for overflow.
Does not throw exceptions.
*/
-fz_bbox fz_translate_bbox(fz_bbox a, int xoff, int yoff);
+fz_rect fz_translate_rect(fz_rect a, float xoff, float yoff);
/*
fz_transform_point: Apply a transformation to a point.
@@ -1086,16 +1016,6 @@ fz_point fz_transform_vector(fz_matrix transform, fz_point vector);
fz_rect fz_transform_rect(fz_matrix transform, fz_rect rect);
/*
- fz_transform_bbox: Transform a given bounding box.
-
- Similar to fz_transform_rect, but operates on a bounding box
- instead of a rectangle.
-
- Does not throw exceptions.
-*/
-fz_bbox fz_transform_bbox(fz_matrix matrix, fz_bbox bbox);
-
-/*
fz_buffer is a wrapper around a dynamically allocated array of bytes.
Buffers have a capacity (the number of bytes storage immediately
@@ -1323,11 +1243,9 @@ extern fz_colorspace *fz_device_cmyk;
typedef struct fz_pixmap_s fz_pixmap;
/*
- fz_pixmap_bbox: Return a bounding box for a pixmap.
-
- Returns an exact bounding box for the supplied pixmap.
+ fz_pixmap_bbox: Return the bounding box for a pixmap.
*/
-fz_bbox fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix);
+fz_rect fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix);
/*
fz_pixmap_width: Return the width of the pixmap in pixels.
@@ -1371,7 +1289,7 @@ fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h);
Returns a pointer to the new pixmap. Throws exception on failure to
allocate.
*/
-fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_bbox bbox);
+fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_rect bbox);
/*
fz_new_pixmap_with_data: Create a new pixmap, with it's origin at
@@ -1410,7 +1328,7 @@ fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, i
Returns a pointer to the new pixmap. Throws exception on failure to
allocate.
*/
-fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_bbox bbox, unsigned char *samples);
+fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_rect rect, unsigned char *samples);
/*
fz_keep_pixmap: Take a reference to a pixmap.
@@ -1478,7 +1396,7 @@ void fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value);
Does not throw exceptions.
*/
-void fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *pix, int value, fz_bbox r);
+void fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *pix, int value, fz_rect r);
/*
fz_clear_pixmap_with_value: Sets all components (including alpha) of
@@ -1505,7 +1423,7 @@ void fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix);
Does not throw exceptions.
*/
-void fz_invert_pixmap_rect(fz_pixmap *image, fz_bbox rect);
+void fz_invert_pixmap_rect(fz_pixmap *image, fz_rect rect);
/*
fz_gamma_pixmap: Apply gamma correction to a pixmap. All components
@@ -1681,7 +1599,7 @@ fz_device *fz_new_trace_device(fz_context *ctx);
The returned bounding box will be the union of all bounding
boxes of all objects on a page.
*/
-fz_device *fz_new_bbox_device(fz_context *ctx, fz_bbox *bboxp);
+fz_device *fz_new_bbox_device(fz_context *ctx, fz_rect *rectp);
/*
fz_new_draw_device: Create a device to draw on a pixmap.
@@ -1706,7 +1624,7 @@ fz_device *fz_new_draw_device(fz_context *ctx, fz_pixmap *dest);
clip: Bounding box to restrict any marking operations of the
draw device.
*/
-fz_device *fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, fz_bbox clip);
+fz_device *fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, fz_rect clip);
/*
Text extraction device: Used for searching, format conversion etc.
@@ -1875,21 +1793,21 @@ void fz_print_text_page(fz_context *ctx, FILE *out, fz_text_page *page);
NOTE: This is an experimental interface and subject to change without notice.
*/
-int fz_search_text_page(fz_context *ctx, fz_text_page *text, char *needle, fz_bbox *hit_bbox, int hit_max);
+int fz_search_text_page(fz_context *ctx, fz_text_page *text, char *needle, fz_rect *hit_bbox, int hit_max);
/*
fz_highlight_selection: Return a list of rectangles to highlight given a selection rectangle.
NOTE: This is an experimental interface and subject to change without notice.
*/
-int fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_bbox rect, fz_bbox *hit_bbox, int hit_max);
+int fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_rect rect, fz_rect *hit_bbox, int hit_max);
/*
fz_copy_selection: Return a newly allocated UTF-8 string with the text for a given selection rectangle.
NOTE: This is an experimental interface and subject to change without notice.
*/
-char *fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_bbox rect);
+char *fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_rect rect);
/*
Cookie support - simple communication channel between app/library.
@@ -2006,7 +1924,7 @@ fz_device *fz_new_list_device(fz_context *ctx, fz_display_list *list);
progress information back to the caller. The fields inside
cookie are continually updated while the page is being run.
*/
-void fz_run_display_list(fz_display_list *list, fz_device *dev, fz_matrix ctm, fz_bbox area, fz_cookie *cookie);
+void fz_run_display_list(fz_display_list *list, fz_device *dev, fz_matrix ctm, fz_rect area, fz_cookie *cookie);
/*
fz_free_display_list: Frees a display list.
diff --git a/fitz/res_font.c b/fitz/res_font.c
index b790d198..1b07d060 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -872,7 +872,6 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
fz_display_list *list;
fz_matrix ctm;
fz_rect bounds;
- fz_bbox bbox;
fz_device *dev;
list = font->t3lists[gid];
@@ -880,23 +879,19 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
return fz_transform_rect(trm, fz_empty_rect);
ctm = fz_concat(font->t3matrix, trm);
- dev = fz_new_bbox_device(ctx, &bbox);
- fz_run_display_list(list, dev, ctm, fz_infinite_bbox, NULL);
+ dev = fz_new_bbox_device(ctx, &bounds);
+ fz_run_display_list(list, dev, ctm, fz_infinite_rect, NULL);
fz_free_device(dev);
- bounds.x0 = bbox.x0;
- bounds.y0 = bbox.y0;
- bounds.x1 = bbox.x1;
- bounds.y1 = bbox.y1;
return bounds;
}
fz_pixmap *
-fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_colorspace *model, fz_bbox scissor)
+fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_colorspace *model, fz_rect scissor)
{
fz_display_list *list;
fz_matrix ctm;
- fz_bbox bbox;
+ fz_rect bbox;
fz_device *dev;
fz_pixmap *glyph;
fz_pixmap *result;
@@ -925,20 +920,20 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_co
model = NULL; /* Treat as masked */
}
- bbox = fz_bbox_covering_rect(fz_bound_glyph(ctx, font, gid, trm));
- bbox.x0--;
- bbox.y0--;
- bbox.x1++;
- bbox.y1++;
+ bbox = fz_bound_glyph(ctx, font, gid, trm);
+ bbox.x0 -= 1;
+ bbox.y0 -= 1;
+ bbox.x1 += 1;
+ bbox.y1 += 1;
- bbox = fz_intersect_bbox(bbox, scissor);
+ bbox = fz_intersect_rect(bbox, scissor);
glyph = fz_new_pixmap_with_bbox(ctx, model ? model : fz_device_gray, bbox);
fz_clear_pixmap(ctx, glyph);
ctm = fz_concat(font->t3matrix, trm);
dev = fz_new_draw_device_type3(ctx, glyph);
- fz_run_display_list(list, dev, ctm, fz_infinite_bbox, NULL);
+ fz_run_display_list(list, dev, ctm, fz_infinite_rect, NULL);
fz_free_device(dev);
if (!model)
diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c
index 7c6fbcc1..eb5d58ef 100644
--- a/fitz/res_pixmap.c
+++ b/fitz/res_pixmap.c
@@ -83,29 +83,29 @@ fz_new_pixmap(fz_context *ctx, fz_colorspace *colorspace, int w, int h)
}
fz_pixmap *
-fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_bbox r)
+fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_rect rf)
{
- fz_pixmap *pixmap;
- pixmap = fz_new_pixmap(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0);
+ fz_rect r = fz_round_rect(rf);
+ fz_pixmap *pixmap = fz_new_pixmap(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0);
pixmap->x = r.x0;
pixmap->y = r.y0;
return pixmap;
}
fz_pixmap *
-fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_bbox r, unsigned char *samples)
+fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_rect rf, unsigned char *samples)
{
- fz_pixmap *pixmap;
- pixmap = fz_new_pixmap_with_data(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0, samples);
+ fz_rect r = fz_round_rect(rf);
+ fz_pixmap *pixmap = fz_new_pixmap_with_data(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0, samples);
pixmap->x = r.x0;
pixmap->y = r.y0;
return pixmap;
}
-fz_bbox
+fz_rect
fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix)
{
- fz_bbox bbox;
+ fz_rect bbox;
bbox.x0 = pix->x;
bbox.y0 = pix->y;
bbox.x1 = pix->x + pix->w;
@@ -113,10 +113,10 @@ fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix)
return bbox;
}
-fz_bbox
+fz_rect
fz_pixmap_bbox_no_ctx(fz_pixmap *pix)
{
- fz_bbox bbox;
+ fz_rect bbox;
bbox.x0 = pix->x;
bbox.y0 = pix->y;
bbox.x1 = pix->x + pix->w;
@@ -166,14 +166,15 @@ fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value)
}
void
-fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_bbox r)
+fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_rect r)
{
const unsigned char *srcp;
unsigned char *destp;
int x, y, w, destspan, srcspan;
- r = fz_intersect_bbox(r, fz_pixmap_bbox(ctx, dest));
- r = fz_intersect_bbox(r, fz_pixmap_bbox(ctx, src));
+ r = fz_round_rect(r);
+ r = fz_intersect_rect(r, fz_pixmap_bbox(ctx, dest));
+ r = fz_intersect_rect(r, fz_pixmap_bbox(ctx, src));
w = r.x1 - r.x0;
y = r.y1 - r.y0;
if (w <= 0 || y <= 0)
@@ -266,12 +267,13 @@ fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_bbox r)
}
void
-fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, fz_bbox r)
+fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, fz_rect r)
{
unsigned char *destp;
int x, y, w, k, destspan;
- r = fz_intersect_bbox(r, fz_pixmap_bbox(ctx, dest));
+ r = fz_round_rect(r);
+ r = fz_intersect_rect(r, fz_pixmap_bbox(ctx, dest));
w = r.x1 - r.x0;
y = r.y1 - r.y0;
if (w <= 0 || y <= 0)
@@ -382,15 +384,17 @@ fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix)
}
}
-void fz_invert_pixmap_rect(fz_pixmap *image, fz_bbox rect)
+void fz_invert_pixmap_rect(fz_pixmap *image, fz_rect r)
{
unsigned char *p;
+ int x0, x1, y0, y1;
int x, y, n;
- int x0 = fz_clampi(rect.x0 - image->x, 0, image->w - 1);
- int x1 = fz_clampi(rect.x1 - image->x, 0, image->w - 1);
- int y0 = fz_clampi(rect.y0 - image->y, 0, image->h - 1);
- int y1 = fz_clampi(rect.y1 - image->y, 0, image->h - 1);
+ r = fz_round_rect(r);
+ x0 = fz_clampi(r.x0 - image->x, 0, image->w - 1);
+ x1 = fz_clampi(r.x1 - image->x, 0, image->w - 1);
+ y0 = fz_clampi(r.y0 - image->y, 0, image->h - 1);
+ y1 = fz_clampi(r.y1 - image->y, 0, image->h - 1);
for (y = y0; y < y1; y++)
{