summaryrefslogtreecommitdiff
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
parentd8ad064b0c4bcd539c06c98af070613ff818ee0b (diff)
downloadmupdf-ddb92b7c3fdfcf9bf3d7463dde4e662ca10f79ba.tar.xz
Eliminate fz_bbox in favor of fz_rect everywhere.
-rw-r--r--android/jni/mupdf.c30
-rw-r--r--apps/mudraw.c32
-rw-r--r--apps/pdfapp.c36
-rw-r--r--apps/pdfapp.h4
-rw-r--r--doc/example.c5
-rw-r--r--doc/multi-threaded.c10
-rw-r--r--draw/draw_affine.c14
-rw-r--r--draw/draw_blend.c4
-rw-r--r--draw/draw_device.c108
-rw-r--r--draw/draw_edge.c24
-rw-r--r--draw/draw_glyph.c6
-rw-r--r--draw/draw_mesh.c6
-rw-r--r--draw/draw_paint.c16
-rw-r--r--draw/draw_scale.c6
-rw-r--r--draw/draw_simple_scale.c6
-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
-rw-r--r--ios/main.m24
24 files changed, 355 insertions, 519 deletions
diff --git a/android/jni/mupdf.c b/android/jni/mupdf.c
index a4180e54..62a45d33 100644
--- a/android/jni/mupdf.c
+++ b/android/jni/mupdf.c
@@ -61,7 +61,7 @@ struct globals_s
fz_document *doc;
int resolution;
fz_context *ctx;
- fz_bbox *hit_bbox;
+ fz_rect *hit_bbox;
int current;
char *current_path;
@@ -444,7 +444,7 @@ JNI_FN(MuPDFCore_gotoPageInternal)(JNIEnv *env, jobject thiz, int page)
int furthest_dist = -1;
float zoom;
fz_matrix ctm;
- fz_bbox bbox;
+ fz_rect bbox;
page_cache *pc;
globals *glo = get_globals(env, thiz);
fz_context *ctx = glo->ctx;
@@ -537,10 +537,10 @@ JNI_FN(MuPDFCore_drawPage)(JNIEnv *env, jobject thiz, jobject bitmap,
fz_device *dev = NULL;
float zoom;
fz_matrix ctm;
- fz_bbox bbox;
+ fz_rect bbox;
fz_pixmap *pix = NULL;
float xscale, yscale;
- fz_bbox rect;
+ fz_rect rect;
globals *glo = get_globals(env, thiz);
fz_context *ctx = glo->ctx;
fz_document *doc = glo->doc;
@@ -697,10 +697,10 @@ JNI_FN(MuPDFCore_updatePageInternal)(JNIEnv *env, jobject thiz, jobject bitmap,
fz_device *dev = NULL;
float zoom;
fz_matrix ctm;
- fz_bbox bbox;
+ fz_rect bbox;
fz_pixmap *pix = NULL;
float xscale, yscale;
- fz_bbox rect;
+ fz_rect rect;
fz_interactive *idoc;
page_cache *pc = NULL;
int hq = (patchW < pageW || patchH < pageH);
@@ -799,12 +799,12 @@ JNI_FN(MuPDFCore_updatePageInternal)(JNIEnv *env, jobject thiz, jobject bitmap,
LOGI("Start polling for updates");
while (idoc && (annot = fz_poll_changed_annot(idoc, page)) != NULL)
{
- fz_bbox abox = fz_round_rect(fz_transform_rect(ctm, fz_bound_annot(doc, annot)));
- abox = fz_intersect_bbox(abox, rect);
+ fz_rect abox = fz_round_rect(fz_transform_rect(ctm, fz_bound_annot(doc, annot)));
+ abox = fz_intersect_rect(abox, rect);
LOGI("Update rectanglefor %s - (%d, %d, %d, %d)", widget_type_string(fz_widget_get_type((fz_widget*)annot)),
abox.x0, abox.y0, abox.x1, abox.y1);
- if (!fz_is_empty_bbox(abox))
+ if (!fz_is_empty_rect(abox))
{
LOGI("And it isn't empty");
fz_clear_pixmap_rect_with_value(ctx, pix, 0xff, abox);
@@ -868,10 +868,10 @@ charat(fz_text_page *page, int idx)
return textcharat(page, idx).c;
}
-static fz_bbox
+static fz_rect
bboxcharat(fz_text_page *page, int idx)
{
- return fz_round_rect(textcharat(page, idx).bbox);
+ return textcharat(page, idx).bbox;
}
static int
@@ -1076,12 +1076,12 @@ JNI_FN(MuPDFCore_searchPage)(JNIEnv * env, jobject thiz, jstring jtext)
len = textlen(text);
for (pos = 0; pos < len; pos++)
{
- fz_bbox rr = fz_empty_bbox;
+ fz_rect rr = fz_empty_rect;
n = match(text, str, pos);
for (i = 0; i < n; i++)
- rr = fz_union_bbox(rr, bboxcharat(text, pos + i));
+ rr = fz_union_rect(rr, bboxcharat(text, pos + i));
- if (!fz_is_empty_bbox(rr) && hit_count < MAX_SEARCH_HITS)
+ if (!fz_is_empty_rect(rr) && hit_count < MAX_SEARCH_HITS)
glo->hit_bbox[hit_count++] = rr;
}
}
@@ -1421,7 +1421,7 @@ JNI_FN(MuPDFCore_getWidgetAreasInternal)(JNIEnv * env, jobject thiz, int pageNum
count = 0;
for (widget = fz_first_widget(idoc, pc->page); widget; widget = fz_next_widget(idoc, widget))
{
- fz_rect rect = fz_transform_rect(ctm, *fz_widget_bbox(widget));
+ fz_rect rect = fz_transform_rect(ctm, fz_widget_bbox(widget));
rectF = (*env)->NewObject(env, rectFClass, ctor,
(float)rect.x0, (float)rect.y0, (float)rect.x1, (float)rect.y1);
diff --git a/apps/mudraw.c b/apps/mudraw.c
index c6d329a0..84c02682 100644
--- a/apps/mudraw.c
+++ b/apps/mudraw.c
@@ -333,7 +333,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
dev = fz_new_trace_device(ctx);
printf("<page number=\"%d\">\n", pagenum);
if (list)
- fz_run_display_list(list, dev, fz_identity, fz_infinite_bbox, &cookie);
+ fz_run_display_list(list, dev, fz_identity, fz_infinite_rect, &cookie);
else
fz_run_page(doc, page, dev, fz_identity, &cookie);
printf("</page>\n");
@@ -362,7 +362,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
text = fz_new_text_page(ctx, fz_bound_page(doc, page));
dev = fz_new_text_device(ctx, sheet, text);
if (list)
- fz_run_display_list(list, dev, fz_identity, fz_infinite_bbox, &cookie);
+ fz_run_display_list(list, dev, fz_identity, fz_infinite_rect, &cookie);
else
fz_run_page(doc, page, dev, fz_identity, &cookie);
fz_free_device(dev);
@@ -402,8 +402,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
{
float zoom;
fz_matrix ctm;
- fz_rect bounds, bounds2;
- fz_bbox bbox;
+ fz_rect bounds, tbounds, ibounds;
fz_pixmap *pix = NULL;
int w, h;
@@ -413,28 +412,31 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
zoom = resolution / 72;
ctm = fz_scale(zoom, zoom);
ctm = fz_concat(ctm, fz_rotate(rotation));
- bounds2 = fz_transform_rect(ctm, bounds);
- bbox = fz_round_rect(bounds2);
+ tbounds = fz_transform_rect(ctm, bounds);
+ ibounds = fz_round_rect(tbounds); /* convert to integers */
+
/* Make local copies of our width/height */
w = width;
h = height;
+
/* If a resolution is specified, check to see whether w/h are
* exceeded; if not, unset them. */
if (res_specified)
{
int t;
- t = bbox.x1 - bbox.x0;
+ t = ibounds.x1 - ibounds.x0;
if (w && t <= w)
w = 0;
- t = bbox.y1 - bbox.y0;
+ t = ibounds.y1 - ibounds.y0;
if (h && t <= h)
h = 0;
}
- /* Now w or h will be 0 unless then need to be enforced. */
+
+ /* Now w or h will be 0 unless they need to be enforced. */
if (w || h)
{
- float scalex = w/(bounds2.x1-bounds2.x0);
- float scaley = h/(bounds2.y1-bounds2.y0);
+ float scalex = w / (tbounds.x1 - tbounds.x0);
+ float scaley = h / (tbounds.y1 - tbounds.y0);
if (fit)
{
@@ -458,15 +460,15 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
scaley = scalex;
}
ctm = fz_concat(ctm, fz_scale(scalex, scaley));
- bounds2 = fz_transform_rect(ctm, bounds);
+ tbounds = fz_transform_rect(ctm, bounds);
}
- bbox = fz_round_rect(bounds2);
+ ibounds = fz_round_rect(tbounds);
/* TODO: banded rendering and multi-page ppm */
fz_try(ctx)
{
- pix = fz_new_pixmap_with_bbox(ctx, colorspace, bbox);
+ pix = fz_new_pixmap_with_bbox(ctx, colorspace, ibounds);
if (savealpha)
fz_clear_pixmap(ctx, pix);
@@ -475,7 +477,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum)
dev = fz_new_draw_device(ctx, pix);
if (list)
- fz_run_display_list(list, dev, ctm, bbox, &cookie);
+ fz_run_display_list(list, dev, ctm, ibounds, &cookie);
else
fz_run_page(doc, page, dev, ctm, &cookie);
fz_free_device(dev);
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index 24668af7..167c118d 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -98,7 +98,7 @@ void pdfapp_init(fz_context *ctx, pdfapp_t *app)
#endif
}
-void pdfapp_invert(pdfapp_t *app, fz_bbox rect)
+void pdfapp_invert(pdfapp_t *app, fz_rect rect)
{
fz_invert_pixmap_rect(app->image, rect);
}
@@ -566,7 +566,7 @@ static void pdfapp_updatepage(pdfapp_t *app)
while ((annot = fz_poll_changed_annot(idoc, app->page)) != NULL)
{
- fz_bbox bbox = fz_round_rect(fz_transform_rect(ctm, fz_bound_annot(app->doc, annot)));
+ fz_rect bbox = fz_transform_rect(ctm, fz_bound_annot(app->doc, annot));
fz_clear_pixmap_rect_with_value(app->ctx, app->image, 255, bbox);
idev = fz_new_draw_device_with_bbox(app->ctx, app->image, bbox);
@@ -589,7 +589,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
fz_device *tdev;
fz_colorspace *colorspace;
fz_matrix ctm;
- fz_bbox bbox;
+ fz_rect bbox;
fz_cookie cookie = { 0 };
if (!app->nowaitcursor)
@@ -620,9 +620,9 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
{
tdev = fz_new_text_device(app->ctx, app->page_sheet, app->page_text);
if (app->page_list)
- fz_run_display_list(app->page_list, tdev, fz_identity, fz_infinite_bbox, &cookie);
+ fz_run_display_list(app->page_list, tdev, fz_identity, fz_infinite_rect, &cookie);
if (app->annotations_list)
- fz_run_display_list(app->annotations_list, tdev, fz_identity, fz_infinite_bbox, &cookie);
+ fz_run_display_list(app->annotations_list, tdev, fz_identity, fz_infinite_rect, &cookie);
fz_free_device(tdev);
}
}
@@ -646,7 +646,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai
wintitle(app, buf);
ctm = pdfapp_viewctm(app);
- bbox = fz_round_rect(fz_transform_rect(ctm, app->page_bbox));
+ bbox = fz_transform_rect(ctm, app->page_bbox);
/* Draw */
if (app->image)
@@ -807,21 +807,21 @@ static inline int charat(fz_text_page *page, int idx)
return textcharat(page, idx).c;
}
-static inline fz_bbox bboxcharat(fz_text_page *page, int idx)
+static inline fz_rect bboxcharat(fz_text_page *page, int idx)
{
- return fz_bbox_covering_rect(textcharat(page, idx).bbox);
+ return textcharat(page, idx).bbox;
}
void pdfapp_inverthit(pdfapp_t *app)
{
- fz_bbox hitbox, bbox;
+ fz_rect hitbox, bbox;
fz_matrix ctm;
int i;
if (app->hit < 0)
return;
- hitbox = fz_empty_bbox;
+ hitbox = fz_empty_rect;
ctm = pdfapp_viewctm(app);
for (i = app->hit; i < app->hit + app->hitlen; i++)
@@ -830,17 +830,17 @@ void pdfapp_inverthit(pdfapp_t *app)
if (fz_is_empty_rect(bbox))
{
if (!fz_is_empty_rect(hitbox))
- pdfapp_invert(app, fz_transform_bbox(ctm, hitbox));
- hitbox = fz_empty_bbox;
+ pdfapp_invert(app, fz_transform_rect(ctm, hitbox));
+ hitbox = fz_empty_rect;
}
else
{
- hitbox = fz_union_bbox(hitbox, bbox);
+ hitbox = fz_union_rect(hitbox, bbox);
}
}
if (!fz_is_empty_rect(hitbox))
- pdfapp_invert(app, fz_transform_bbox(ctm, hitbox));
+ pdfapp_invert(app, fz_transform_rect(ctm, hitbox));
}
static int match(char *s, fz_text_page *page, int n)
@@ -1336,7 +1336,7 @@ void pdfapp_onkey(pdfapp_t *app, int c)
void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int state)
{
fz_context *ctx = app->ctx;
- fz_bbox rect = fz_pixmap_bbox(app->ctx, app->image);
+ fz_rect rect = fz_pixmap_bbox(app->ctx, app->image);
fz_link *link;
fz_matrix ctm;
fz_point p;
@@ -1608,7 +1608,7 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
{
- fz_bbox hitbox;
+ fz_rect hitbox;
fz_matrix ctm;
fz_text_page *page = app->page_text;
fz_text_block *block;
@@ -1646,8 +1646,8 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
for (i = 0; i < span->len; i++)
{
- hitbox = fz_bbox_covering_rect(span->text[i].bbox);
- hitbox = fz_transform_bbox(ctm, hitbox);
+ hitbox = span->text[i].bbox;
+ hitbox = fz_transform_rect(ctm, hitbox);
c = span->text[i].c;
if (c < 32)
c = '?';
diff --git a/apps/pdfapp.h b/apps/pdfapp.h
index 22e4ba67..425ba93a 100644
--- a/apps/pdfapp.h
+++ b/apps/pdfapp.h
@@ -108,7 +108,7 @@ struct pdfapp_s
* Used in pdfapp.c:pdfapp_onmouse.
*/
int beyondy;
- fz_bbox selr;
+ fz_rect selr;
int nowaitcursor;
@@ -139,7 +139,7 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen);
void pdfapp_onresize(pdfapp_t *app, int w, int h);
void pdfapp_gotopage(pdfapp_t *app, int number);
-void pdfapp_invert(pdfapp_t *app, fz_bbox rect);
+void pdfapp_invert(pdfapp_t *app, fz_rect rect);
void pdfapp_inverthit(pdfapp_t *app);
void pdfapp_postblit(pdfapp_t *app);
diff --git a/doc/example.c b/doc/example.c
index 9ffe7023..b834e3ff 100644
--- a/doc/example.c
+++ b/doc/example.c
@@ -41,9 +41,8 @@ render(char *filename, int pagenumber, int zoom, int rotation)
// Take the page bounds and transform them by the same matrix that
// we will use to render the page.
- fz_rect rect = fz_bound_page(doc, page);
- rect = fz_transform_rect(transform, rect);
- fz_bbox bbox = fz_round_rect(rect);
+ fz_rect bbox = fz_bound_page(doc, page);
+ bbox = fz_transform_rect(transform, rect);
// Create a blank pixmap to hold the result of rendering. The
// pixmap bounds used here are the same as the transformed page
diff --git a/doc/multi-threaded.c b/doc/multi-threaded.c
index 68cd568d..b54beb81 100644
--- a/doc/multi-threaded.c
+++ b/doc/multi-threaded.c
@@ -58,7 +58,7 @@ struct data {
// The area of the page to render as obtained by the main
// thread and sent from main to rendering thread.
- fz_bbox bbox;
+ fz_rect bbox;
// This is the result, a pixmap containing the rendered page.
// It is passed first from main thread to the rendering
@@ -79,7 +79,7 @@ renderer(void *data)
int pagenumber = ((struct data *) data)->pagenumber;
fz_context *ctx = ((struct data *) data)->ctx;
fz_display_list *list = ((struct data *) data)->list;
- fz_bbox bbox = ((struct data *) data)->bbox;
+ fz_rect bbox = ((struct data *) data)->bbox;
fz_pixmap *pix = ((struct data *) data)->pix;
fprintf(stderr, "thread at page %d loading!\n", pagenumber);
@@ -180,8 +180,7 @@ int main(int argc, char **argv)
// Compute the bounding box for each page.
- fz_rect rect = fz_bound_page(doc, page);
- fz_bbox bbox = fz_round_rect(rect);
+ fz_rect bbox = fz_bound_page(doc, page);
// Create a display list that will hold the drawing
// commands for the page.
@@ -202,8 +201,7 @@ int main(int argc, char **argv)
// Create a white pixmap using the correct dimensions.
- fz_pixmap *pix = fz_new_pixmap_with_bbox(ctx,
- fz_device_rgb, bbox);
+ fz_pixmap *pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb, bbox);
fz_clear_pixmap_with_value(ctx, pix, 0xff);
// Populate the data structure to be sent to the
diff --git a/draw/draw_affine.c b/draw/draw_affine.c
index 67dbd37d..347346b9 100644
--- a/draw/draw_affine.c
+++ b/draw/draw_affine.c
@@ -597,14 +597,14 @@ fz_gridfit_matrix(fz_matrix *m)
/* Draw an image with an affine transform on destination */
static void
-fz_paint_image_imp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, byte *color, int alpha)
+fz_paint_image_imp(fz_pixmap *dst, fz_rect scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, byte *color, int alpha)
{
byte *dp, *sp, *hp;
int u, v, fa, fb, fc, fd;
int x, y, w, h;
int sw, sh, n, hw;
fz_matrix inv;
- fz_bbox bbox;
+ fz_rect bbox;
int dolerp;
void (*paintfn)(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha, byte *color, byte *hp);
@@ -629,8 +629,10 @@ fz_paint_image_imp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap
dolerp = 0;
}
- bbox = fz_bbox_covering_rect(fz_transform_rect(ctm, fz_unit_rect));
- bbox = fz_intersect_bbox(bbox, scissor);
+ bbox = fz_transform_rect(ctm, fz_unit_rect);
+ bbox = fz_intersect_rect(bbox, scissor);
+ bbox = fz_rect_covering_rect(bbox);
+
x = bbox.x0;
if (shape && shape->x > x)
x = shape->x;
@@ -729,14 +731,14 @@ fz_paint_image_imp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap
}
void
-fz_paint_image_with_color(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, byte *color)
+fz_paint_image_with_color(fz_pixmap *dst, fz_rect scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, byte *color)
{
assert(img->n == 1);
fz_paint_image_imp(dst, scissor, shape, img, ctm, color, 255);
}
void
-fz_paint_image(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, int alpha)
+fz_paint_image(fz_pixmap *dst, fz_rect scissor, fz_pixmap *shape, fz_pixmap *img, fz_matrix ctm, int alpha)
{
assert(dst->n == img->n || (dst->n == 4 && img->n == 2));
fz_paint_image_imp(dst, scissor, shape, img, ctm, NULL, alpha);
diff --git a/draw/draw_blend.c b/draw/draw_blend.c
index e70699d4..3e5dd932 100644
--- a/draw/draw_blend.c
+++ b/draw/draw_blend.c
@@ -574,7 +574,7 @@ void
fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode, int isolated, fz_pixmap *shape)
{
unsigned char *sp, *dp;
- fz_bbox bbox;
+ fz_rect bbox;
int x, y, w, h, n;
/* TODO: fix this hack! */
@@ -590,7 +590,7 @@ fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, int blendmode, int is
}
bbox = fz_pixmap_bbox_no_ctx(dst);
- bbox = fz_intersect_bbox(bbox, fz_pixmap_bbox_no_ctx(src));
+ bbox = fz_intersect_rect(bbox, fz_pixmap_bbox_no_ctx(src));
x = bbox.x0;
y = bbox.y0;
diff --git a/draw/draw_device.c b/draw/draw_device.c
index 2b6f62d8..d65d4a90 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -22,7 +22,7 @@ enum {
typedef struct fz_draw_state_s fz_draw_state;
struct fz_draw_state_s {
- fz_bbox scissor;
+ fz_rect scissor;
fz_pixmap *dest;
fz_pixmap *mask;
fz_pixmap *shape;
@@ -127,7 +127,7 @@ static fz_draw_state *
fz_knockout_begin(fz_draw_device *dev)
{
fz_context *ctx = dev->ctx;
- fz_bbox bbox;
+ fz_rect bbox;
fz_pixmap *dest, *shape;
fz_draw_state *state = &dev->stack[dev->top];
int isolated = state->blendmode & FZ_BLEND_ISOLATED;
@@ -138,7 +138,7 @@ fz_knockout_begin(fz_draw_device *dev)
state = push_stack(dev);
bbox = fz_pixmap_bbox(dev->ctx, state->dest);
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_intersect_rect(bbox, state->scissor);
dest = fz_new_pixmap_with_bbox(dev->ctx, state->dest->colorspace, bbox);
if (isolated)
@@ -246,7 +246,7 @@ fz_draw_fill_path(fz_device *devp, fz_path *path, int even_odd, fz_matrix ctm,
float flatness = 0.3f / expansion;
unsigned char colorbv[FZ_MAX_COLORS + 1];
float colorfv[FZ_MAX_COLORS];
- fz_bbox bbox;
+ fz_rect bbox;
int i;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
@@ -259,7 +259,7 @@ fz_draw_fill_path(fz_device *devp, fz_path *path, int even_odd, fz_matrix ctm,
fz_sort_gel(dev->gel);
bbox = fz_bound_gel(dev->gel);
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_intersect_rect(bbox, state->scissor);
if (fz_is_empty_rect(bbox))
return;
@@ -297,7 +297,7 @@ fz_draw_stroke_path(fz_device *devp, fz_path *path, fz_stroke_state *stroke, fz_
float linewidth = stroke->linewidth;
unsigned char colorbv[FZ_MAX_COLORS + 1];
float colorfv[FZ_MAX_COLORS];
- fz_bbox bbox;
+ fz_rect bbox;
int i;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
@@ -316,7 +316,7 @@ fz_draw_stroke_path(fz_device *devp, fz_path *path, fz_stroke_state *stroke, fz_
fz_sort_gel(dev->gel);
bbox = fz_bound_gel(dev->gel);
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_intersect_rect(bbox, state->scissor);
if (fz_is_empty_rect(bbox))
return;
@@ -353,7 +353,7 @@ fz_draw_clip_path(fz_device *devp, fz_path *path, fz_rect *rect, int even_odd, f
fz_draw_device *dev = devp->user;
float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
- fz_bbox bbox;
+ fz_rect bbox;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model;
fz_context *ctx = dev->ctx;
@@ -366,9 +366,9 @@ fz_draw_clip_path(fz_device *devp, fz_path *path, fz_rect *rect, int even_odd, f
model = state->dest->colorspace;
bbox = fz_bound_gel(dev->gel);
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_intersect_rect(bbox, state->scissor);
if (rect)
- bbox = fz_intersect_bbox(bbox, fz_bbox_covering_rect(*rect));
+ bbox = fz_intersect_rect(bbox, fz_rect_covering_rect(*rect));
if (fz_is_empty_rect(bbox) || fz_is_rect_gel(dev->gel))
{
@@ -413,7 +413,7 @@ fz_draw_clip_stroke_path(fz_device *devp, fz_path *path, fz_rect *rect, fz_strok
float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
float linewidth = stroke->linewidth;
- fz_bbox bbox;
+ fz_rect bbox;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model;
fz_context *ctx = dev->ctx;
@@ -432,9 +432,9 @@ fz_draw_clip_stroke_path(fz_device *devp, fz_path *path, fz_rect *rect, fz_strok
model = state->dest->colorspace;
bbox = fz_bound_gel(dev->gel);
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_intersect_rect(bbox, state->scissor);
if (rect)
- bbox = fz_intersect_bbox(bbox, fz_bbox_covering_rect(*rect));
+ bbox = fz_intersect_rect(bbox, fz_rect_covering_rect(*rect));
fz_try(ctx)
{
@@ -465,15 +465,15 @@ fz_draw_clip_stroke_path(fz_device *devp, fz_path *path, fz_rect *rect, fz_strok
static void
draw_glyph(unsigned char *colorbv, fz_pixmap *dst, fz_pixmap *msk,
- int xorig, int yorig, fz_bbox scissor)
+ int xorig, int yorig, fz_rect scissor)
{
unsigned char *dp, *mp;
- fz_bbox bbox;
+ fz_rect bbox;
int x, y, w, h;
bbox = fz_pixmap_bbox_no_ctx(msk);
- bbox = fz_translate_bbox(bbox, xorig, yorig);
- bbox = fz_intersect_bbox(bbox, scissor); /* scissor < dst */
+ bbox = fz_translate_rect(bbox, xorig, yorig);
+ bbox = fz_intersect_rect(bbox, scissor); /* scissor < dst */
x = bbox.x0;
y = bbox.y0;
w = bbox.x1 - bbox.x0;
@@ -508,7 +508,7 @@ fz_draw_fill_text(fz_device *devp, fz_text *text, fz_matrix ctm,
int i, x, y, gid;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
- fz_bbox scissor = state->scissor;
+ fz_rect scissor = state->scissor;
if (state->blendmode & FZ_BLEND_KNOCKOUT)
state = fz_knockout_begin(dev);
@@ -587,7 +587,7 @@ fz_draw_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke, fz_
int i, x, y, gid;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
- fz_bbox scissor = state->scissor;
+ fz_rect scissor = state->scissor;
if (state->blendmode & FZ_BLEND_KNOCKOUT)
state = fz_knockout_begin(dev);
@@ -650,7 +650,7 @@ fz_draw_clip_text(fz_device *devp, fz_text *text, fz_matrix ctm, int accumulate)
{
fz_draw_device *dev = devp->user;
fz_context *ctx = dev->ctx;
- fz_bbox bbox;
+ fz_rect bbox;
fz_pixmap *mask, *dest, *shape;
fz_matrix tm, trm, trunc_trm;
fz_pixmap *glyph;
@@ -668,8 +668,8 @@ fz_draw_clip_text(fz_device *devp, fz_text *text, fz_matrix ctm, int accumulate)
if (accumulate == 0)
{
/* make the mask the exact size needed */
- bbox = fz_bbox_covering_rect(fz_bound_text(dev->ctx, text, ctm));
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_rect_covering_rect(fz_bound_text(dev->ctx, text, ctm));
+ bbox = fz_intersect_rect(bbox, state->scissor);
}
else
{
@@ -784,7 +784,7 @@ fz_draw_clip_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke
{
fz_draw_device *dev = devp->user;
fz_context *ctx = dev->ctx;
- fz_bbox bbox;
+ fz_rect bbox;
fz_pixmap *mask, *dest, *shape;
fz_matrix tm, trm, trunc_trm;
fz_pixmap *glyph;
@@ -793,8 +793,8 @@ fz_draw_clip_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke
fz_colorspace *model = state->dest->colorspace;
/* make the mask the exact size needed */
- bbox = fz_bbox_covering_rect(fz_bound_text(dev->ctx, text, ctm));
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_rect_covering_rect(fz_bound_text(dev->ctx, text, ctm));
+ bbox = fz_intersect_rect(bbox, state->scissor);
fz_try(ctx)
{
@@ -895,7 +895,7 @@ fz_draw_fill_shade(fz_device *devp, fz_shade *shade, fz_matrix ctm, float alpha)
{
fz_draw_device *dev = devp->user;
fz_rect bounds;
- fz_bbox bbox, scissor;
+ fz_rect bbox, scissor;
fz_pixmap *dest, *shape;
float colorfv[FZ_MAX_COLORS];
unsigned char colorbv[FZ_MAX_COLORS + 1];
@@ -904,7 +904,7 @@ fz_draw_fill_shade(fz_device *devp, fz_shade *shade, fz_matrix ctm, float alpha)
bounds = fz_bound_shade(dev->ctx, shade, ctm);
scissor = state->scissor;
- bbox = fz_intersect_bbox(fz_bbox_covering_rect(bounds), scissor);
+ bbox = fz_intersect_rect(fz_rect_covering_rect(bounds), scissor);
if (fz_is_empty_rect(bbox))
return;
@@ -984,7 +984,7 @@ fz_draw_fill_shade(fz_device *devp, fz_shade *shade, fz_matrix ctm, float alpha)
}
static fz_pixmap *
-fz_transform_pixmap(fz_draw_device *dev, fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy, int gridfit, fz_bbox *clip)
+fz_transform_pixmap(fz_draw_device *dev, fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy, int gridfit, fz_rect *clip)
{
fz_pixmap *scaled;
fz_context *ctx = dev->ctx;
@@ -1009,7 +1009,7 @@ fz_transform_pixmap(fz_draw_device *dev, fz_pixmap *image, fz_matrix *ctm, int x
{
/* Other orthogonal flip/rotation cases */
fz_matrix m = *ctm;
- fz_bbox rclip;
+ fz_rect rclip;
if (gridfit)
fz_gridfit_matrix(&m);
if (clip)
@@ -1052,9 +1052,9 @@ fz_draw_fill_image(fz_device *devp, fz_image *image, fz_matrix ctm, float alpha)
fz_context *ctx = dev->ctx;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
- fz_bbox clip = fz_pixmap_bbox(ctx, state->dest);
+ fz_rect clip = fz_pixmap_bbox(ctx, state->dest);
- clip = fz_intersect_bbox(clip, state->scissor);
+ clip = fz_intersect_rect(clip, state->scissor);
fz_var(scaled);
@@ -1156,9 +1156,9 @@ fz_draw_fill_image_mask(fz_device *devp, fz_image *image, fz_matrix ctm,
fz_context *ctx = dev->ctx;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
- fz_bbox clip = fz_pixmap_bbox(ctx, state->dest);
+ fz_rect clip = fz_pixmap_bbox(ctx, state->dest);
- clip = fz_intersect_bbox(clip, state->scissor);
+ clip = fz_intersect_rect(clip, state->scissor);
if (image->w == 0 || image->h == 0)
return;
@@ -1217,7 +1217,7 @@ fz_draw_clip_image_mask(fz_device *devp, fz_image *image, fz_rect *rect, fz_matr
{
fz_draw_device *dev = devp->user;
fz_context *ctx = dev->ctx;
- fz_bbox bbox;
+ fz_rect bbox;
fz_pixmap *mask = NULL;
fz_pixmap *dest = NULL;
fz_pixmap *shape = NULL;
@@ -1227,9 +1227,9 @@ fz_draw_clip_image_mask(fz_device *devp, fz_image *image, fz_rect *rect, fz_matr
int dx, dy;
fz_draw_state *state = push_stack(dev);
fz_colorspace *model = state->dest->colorspace;
- fz_bbox clip = fz_pixmap_bbox(ctx, state->dest);
+ fz_rect clip = fz_pixmap_bbox(ctx, state->dest);
- clip = fz_intersect_bbox(clip, state->scissor);
+ clip = fz_intersect_rect(clip, state->scissor);
fz_var(mask);
fz_var(dest);
@@ -1242,7 +1242,7 @@ fz_draw_clip_image_mask(fz_device *devp, fz_image *image, fz_rect *rect, fz_matr
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top-1, "Clip (image mask) (empty) begin\n");
#endif
- state[1].scissor = fz_empty_bbox;
+ state[1].scissor = fz_empty_rect;
state[1].mask = NULL;
return;
}
@@ -1251,10 +1251,10 @@ fz_draw_clip_image_mask(fz_device *devp, fz_image *image, fz_rect *rect, fz_matr
dump_spaces(dev->top-1, "Clip (image mask) begin\n");
#endif
- bbox = fz_bbox_covering_rect(fz_transform_rect(ctm, fz_unit_rect));
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_rect_covering_rect(fz_transform_rect(ctm, fz_unit_rect));
+ bbox = fz_intersect_rect(bbox, state->scissor);
if (rect)
- bbox = fz_intersect_bbox(bbox, fz_bbox_covering_rect(*rect));
+ bbox = fz_intersect_rect(bbox, fz_rect_covering_rect(*rect));
dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b);
dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
@@ -1363,13 +1363,13 @@ fz_draw_begin_mask(fz_device *devp, fz_rect rect, int luminosity, fz_colorspace
{
fz_draw_device *dev = devp->user;
fz_pixmap *dest;
- fz_bbox bbox;
+ fz_rect bbox;
fz_draw_state *state = push_stack(dev);
fz_pixmap *shape = state->shape;
fz_context *ctx = dev->ctx;
- bbox = fz_bbox_covering_rect(rect);
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_rect_covering_rect(rect);
+ bbox = fz_intersect_rect(bbox, state->scissor);
fz_try(ctx)
{
@@ -1419,7 +1419,7 @@ fz_draw_end_mask(fz_device *devp)
{
fz_draw_device *dev = devp->user;
fz_pixmap *temp, *dest;
- fz_bbox bbox;
+ fz_rect bbox;
int luminosity;
fz_context *ctx = dev->ctx;
fz_draw_state *state;
@@ -1471,7 +1471,7 @@ static void
fz_draw_begin_group(fz_device *devp, fz_rect rect, int isolated, int knockout, int blendmode, float alpha)
{
fz_draw_device *dev = devp->user;
- fz_bbox bbox;
+ fz_rect bbox;
fz_pixmap *dest, *shape;
fz_context *ctx = dev->ctx;
fz_draw_state *state = &dev->stack[dev->top];
@@ -1481,8 +1481,8 @@ fz_draw_begin_group(fz_device *devp, fz_rect rect, int isolated, int knockout, i
fz_knockout_begin(dev);
state = push_stack(dev);
- bbox = fz_bbox_covering_rect(rect);
- bbox = fz_intersect_bbox(bbox, state->scissor);
+ bbox = fz_rect_covering_rect(rect);
+ bbox = fz_intersect_rect(bbox, state->scissor);
fz_try(ctx)
{
@@ -1594,7 +1594,7 @@ fz_draw_begin_tile(fz_device *devp, fz_rect area, fz_rect view, float xstep, flo
fz_draw_device *dev = devp->user;
fz_pixmap *dest = NULL;
fz_pixmap *shape;
- fz_bbox bbox;
+ fz_rect bbox;
fz_context *ctx = dev->ctx;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
@@ -1606,7 +1606,7 @@ fz_draw_begin_tile(fz_device *devp, fz_rect area, fz_rect view, float xstep, flo
fz_knockout_begin(dev);
state = push_stack(dev);
- bbox = fz_bbox_covering_rect(fz_transform_rect(ctm, view));
+ bbox = fz_rect_covering_rect(fz_transform_rect(ctm, view));
/* We should never have a bbox that entirely covers our destination.
* If we do, then the check for only 1 tile being visible above has
* failed. Actually, this *can* fail due to the round_rect, at extreme
@@ -1649,7 +1649,7 @@ fz_draw_end_tile(fz_device *devp)
float xstep, ystep;
fz_matrix ttm, ctm, shapectm;
fz_rect area, scissor;
- fz_bbox scissor_box;
+ fz_rect scissor_box;
int x0, y0, x1, y1, x, y;
fz_context *ctx = dev->ctx;
fz_draw_state *state;
@@ -1668,7 +1668,7 @@ fz_draw_end_tile(fz_device *devp)
/* Fudge the scissor bbox a little to allow for inaccuracies in the
* matrix inversion. */
- scissor_box = fz_expand_bbox(state[0].scissor, 1);
+ scissor_box = fz_expand_rect(state[0].scissor, 1);
scissor.x0 = (float)scissor_box.x0;
scissor.y0 = (float)scissor_box.y0;
scissor.x1 = (float)scissor_box.x1;
@@ -1711,13 +1711,13 @@ fz_draw_end_tile(fz_device *devp)
continue;
if (state[1].dest->y > 0 && state[1].dest->y + state[1].dest->h < 0)
continue;
- fz_paint_pixmap_with_rect(state[0].dest, state[1].dest, 255, state[0].scissor);
+ fz_paint_pixmap_with_bbox(state[0].dest, state[1].dest, 255, state[0].scissor);
if (state[1].shape)
{
ttm = fz_concat(fz_translate(x * xstep, y * ystep), shapectm);
state[1].shape->x = ttm.e;
state[1].shape->y = ttm.f;
- fz_paint_pixmap_with_rect(state[0].shape, state[1].shape, 255, state[0].scissor);
+ fz_paint_pixmap_with_bbox(state[0].shape, state[1].shape, 255, state[0].scissor);
}
}
}
@@ -1834,7 +1834,7 @@ fz_new_draw_device(fz_context *ctx, fz_pixmap *dest)
}
fz_device *
-fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, fz_bbox clip)
+fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, fz_rect clip)
{
fz_device *dev = fz_new_draw_device(ctx, dest);
fz_draw_device *ddev = dev->user;
diff --git a/draw/draw_edge.c b/draw/draw_edge.c
index 9fc21d97..df59ba14 100644
--- a/draw/draw_edge.c
+++ b/draw/draw_edge.c
@@ -158,8 +158,8 @@ struct fz_edge_s
struct fz_gel_s
{
- fz_bbox clip;
- fz_bbox bbox;
+ fz_rect clip;
+ fz_rect bbox;
int cap, len;
fz_edge *edges;
int acap, alen;
@@ -203,7 +203,7 @@ fz_new_gel(fz_context *ctx)
}
void
-fz_reset_gel(fz_gel *gel, fz_bbox clip)
+fz_reset_gel(fz_gel *gel, fz_rect clip)
{
fz_aa_context *ctxaa = gel->ctx->aa;
@@ -235,13 +235,13 @@ fz_free_gel(fz_gel *gel)
fz_free(gel->ctx, gel);
}
-fz_bbox
+fz_rect
fz_bound_gel(fz_gel *gel)
{
- fz_bbox bbox;
+ fz_rect bbox;
fz_aa_context *ctxaa = gel->ctx->aa;
if (gel->len == 0)
- return fz_empty_bbox;
+ return fz_empty_rect;
bbox.x0 = fz_idiv(gel->bbox.x0, fz_aa_hscale);
bbox.y0 = fz_idiv(gel->bbox.y0, fz_aa_vscale);
bbox.x1 = fz_idiv(gel->bbox.x1, fz_aa_hscale) + 1;
@@ -666,7 +666,7 @@ static inline void blit_aa(fz_pixmap *dst, int x, int y,
}
static void
-fz_scan_convert_aa(fz_gel *gel, int eofill, fz_bbox clip,
+fz_scan_convert_aa(fz_gel *gel, int eofill, fz_rect clip,
fz_pixmap *dst, unsigned char *color)
{
unsigned char *alphas;
@@ -851,7 +851,7 @@ clip_ended:
*/
static inline void blit_sharp(int x0, int x1, int y,
- fz_bbox clip, fz_pixmap *dst, unsigned char *color)
+ fz_rect clip, fz_pixmap *dst, unsigned char *color)
{
unsigned char *dp;
x0 = fz_clampi(x0, dst->x, dst->x + dst->w);
@@ -867,7 +867,7 @@ static inline void blit_sharp(int x0, int x1, int y,
}
static inline void non_zero_winding_sharp(fz_gel *gel, int y,
- fz_bbox clip, fz_pixmap *dst, unsigned char *color)
+ fz_rect clip, fz_pixmap *dst, unsigned char *color)
{
int winding = 0;
int x = 0;
@@ -883,7 +883,7 @@ static inline void non_zero_winding_sharp(fz_gel *gel, int y,
}
static inline void even_odd_sharp(fz_gel *gel, int y,
- fz_bbox clip, fz_pixmap *dst, unsigned char *color)
+ fz_rect clip, fz_pixmap *dst, unsigned char *color)
{
int even = 0;
int x = 0;
@@ -899,7 +899,7 @@ static inline void even_odd_sharp(fz_gel *gel, int y,
}
static void
-fz_scan_convert_sharp(fz_gel *gel, int eofill, fz_bbox clip,
+fz_scan_convert_sharp(fz_gel *gel, int eofill, fz_rect clip,
fz_pixmap *dst, unsigned char *color)
{
int e = 0;
@@ -955,7 +955,7 @@ fz_scan_convert_sharp(fz_gel *gel, int eofill, fz_bbox clip,
}
void
-fz_scan_convert(fz_gel *gel, int eofill, fz_bbox clip,
+fz_scan_convert(fz_gel *gel, int eofill, fz_rect clip,
fz_pixmap *dst, unsigned char *color)
{
fz_aa_context *ctxaa = gel->ctx->aa;
diff --git a/draw/draw_glyph.c b/draw/draw_glyph.c
index de2f47c2..40c71241 100644
--- a/draw/draw_glyph.c
+++ b/draw/draw_glyph.c
@@ -95,7 +95,7 @@ fz_keep_glyph_cache(fz_context *ctx)
}
fz_pixmap *
-fz_render_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *stroke, fz_bbox scissor)
+fz_render_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *stroke, fz_rect scissor)
{
if (font->ft_face)
{
@@ -116,7 +116,7 @@ fz_render_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm,
This must not be inserted into the cache.
*/
fz_pixmap *
-fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix ctm, fz_colorspace *model, fz_bbox scissor)
+fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix ctm, fz_colorspace *model, fz_rect scissor)
{
fz_glyph_cache *cache;
fz_glyph_key key;
@@ -126,7 +126,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix ctm, fz_color
if (size <= MAX_GLYPH_SIZE)
{
- scissor = fz_infinite_bbox;
+ scissor = fz_infinite_rect;
do_cache = 1;
}
else
diff --git a/draw/draw_mesh.c b/draw/draw_mesh.c
index 03d187f7..98669e17 100644
--- a/draw/draw_mesh.c
+++ b/draw/draw_mesh.c
@@ -213,7 +213,7 @@ static inline void step_edge(int *ael, int *del, int n)
}
static void
-fz_paint_triangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox bbox)
+fz_paint_triangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_rect bbox)
{
float poly[MAXV][MAXN];
float temp[MAXV][MAXN];
@@ -307,7 +307,7 @@ struct paint_tri_data
fz_context *ctx;
fz_shade *shade;
fz_pixmap *dest;
- fz_bbox bbox;
+ fz_rect bbox;
};
static void
@@ -349,7 +349,7 @@ do_paint_tri(void *arg, fz_vertex *av, fz_vertex *bv, fz_vertex *cv)
}
void
-fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox)
+fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_rect bbox)
{
unsigned char clut[256][FZ_MAX_COLORS];
fz_pixmap *temp = NULL;
diff --git a/draw/draw_paint.c b/draw/draw_paint.c
index 57e69748..2f6ef368 100644
--- a/draw/draw_paint.c
+++ b/draw/draw_paint.c
@@ -375,15 +375,15 @@ fz_paint_span(byte * restrict dp, byte * restrict sp, int n, int w, int alpha)
*/
void
-fz_paint_pixmap_with_rect(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox)
+fz_paint_pixmap_with_bbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_rect bbox)
{
unsigned char *sp, *dp;
int x, y, w, h, n;
assert(dst->n == src->n);
- bbox = fz_intersect_bbox(bbox, fz_pixmap_bbox_no_ctx(dst));
- bbox = fz_intersect_bbox(bbox, fz_pixmap_bbox_no_ctx(src));
+ bbox = fz_intersect_rect(bbox, fz_pixmap_bbox_no_ctx(dst));
+ bbox = fz_intersect_rect(bbox, fz_pixmap_bbox_no_ctx(src));
x = bbox.x0;
y = bbox.y0;
@@ -408,13 +408,13 @@ void
fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha)
{
unsigned char *sp, *dp;
- fz_bbox bbox;
+ fz_rect bbox;
int x, y, w, h, n;
assert(dst->n == src->n);
bbox = fz_pixmap_bbox_no_ctx(dst);
- bbox = fz_intersect_bbox(bbox, fz_pixmap_bbox_no_ctx(src));
+ bbox = fz_intersect_rect(bbox, fz_pixmap_bbox_no_ctx(src));
x = bbox.x0;
y = bbox.y0;
@@ -439,15 +439,15 @@ void
fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk)
{
unsigned char *sp, *dp, *mp;
- fz_bbox bbox;
+ fz_rect bbox;
int x, y, w, h, n;
assert(dst->n == src->n);
assert(msk->n == 1);
bbox = fz_pixmap_bbox_no_ctx(dst);
- bbox = fz_intersect_bbox(bbox, fz_pixmap_bbox_no_ctx(src));
- bbox = fz_intersect_bbox(bbox, fz_pixmap_bbox_no_ctx(msk));
+ bbox = fz_intersect_rect(bbox, fz_pixmap_bbox_no_ctx(src));
+ bbox = fz_intersect_rect(bbox, fz_pixmap_bbox_no_ctx(msk));
x = bbox.x0;
y = bbox.y0;
diff --git a/draw/draw_scale.c b/draw/draw_scale.c
index 34738fab..a2439216 100644
--- a/draw/draw_scale.c
+++ b/draw/draw_scale.c
@@ -1238,13 +1238,13 @@ scale_single_col(unsigned char *dst, unsigned char *src, fz_weights *weights, in
#endif /* SINGLE_PIXEL_SPECIALS */
fz_pixmap *
-fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_bbox *clip)
+fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_rect *clip)
{
return fz_scale_pixmap_cached(ctx, src, x, y, w, h, clip, NULL, NULL);
}
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_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)
{
fz_scale_filter *filter = &fz_scale_filter_simple;
fz_weights *contrib_rows = NULL;
@@ -1254,7 +1254,7 @@ fz_scale_pixmap_cached(fz_context *ctx, fz_pixmap *src, float x, float y, float
int max_row, temp_span, temp_rows, row;
int dst_w_int, dst_h_int, dst_x_int, dst_y_int;
int flip_x, flip_y;
- fz_bbox patch;
+ fz_rect patch;
fz_var(contrib_cols);
fz_var(contrib_rows);
diff --git a/draw/draw_simple_scale.c b/draw/draw_simple_scale.c
index 55c981b4..d2b69cf9 100644
--- a/draw/draw_simple_scale.c
+++ b/draw/draw_simple_scale.c
@@ -1214,13 +1214,13 @@ scale_single_col(unsigned char *dst, unsigned char *src, fz_weights *weights, in
#endif /* SINGLE_PIXEL_SPECIALS */
fz_pixmap *
-fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_bbox *clip)
+fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_rect *clip)
{
return fz_scale_pixmap_cached(ctx, src, x, y, w, h, clip, NULL, NULL);
}
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_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)
{
fz_scale_filter *filter = &fz_scale_filter_simple;
fz_weights *contrib_rows = NULL;
@@ -1230,7 +1230,7 @@ fz_scale_pixmap_cached(fz_context *ctx, fz_pixmap *src, float x, float y, float
int max_row, temp_span, temp_rows, row;
int dst_w_int, dst_h_int, dst_x_int, dst_y_int;
int flip_x, flip_y;
- fz_bbox patch;
+ fz_rect patch;
fz_var(contrib_cols);
fz_var(contrib_rows);
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++)
{
diff --git a/ios/main.m b/ios/main.m
index 56d31a50..250f6b0c 100644
--- a/ios/main.m
+++ b/ios/main.m
@@ -125,7 +125,7 @@ static fz_context *ctx = NULL;
#pragma mark -
static int hit_count = 0;
-static fz_bbox hit_bbox[500];
+static fz_rect hit_bbox[500];
static int
search_page(fz_document *doc, int number, char *needle, fz_cookie *cookie)
@@ -147,7 +147,7 @@ search_page(fz_document *doc, int number, char *needle, fz_cookie *cookie)
return hit_count;
}
-static fz_bbox
+static fz_rect
search_result_bbox(fz_document *doc, int i)
{
return hit_bbox[i];
@@ -236,7 +236,7 @@ static CGSize measurePage(fz_document *doc, fz_page *page)
static UIImage *renderPage(fz_document *doc, fz_page *page, CGSize screenSize)
{
CGSize pageSize;
- fz_bbox bbox;
+ fz_rect bbox;
fz_matrix ctm;
fz_device *dev;
fz_pixmap *pix;
@@ -248,7 +248,7 @@ static UIImage *renderPage(fz_document *doc, fz_page *page, CGSize screenSize)
pageSize = measurePage(doc, page);
scale = fitPageToScreen(pageSize, screenSize);
ctm = fz_scale(scale.width, scale.height);
- bbox = (fz_bbox){0, 0, pageSize.width * scale.width, pageSize.height * scale.height};
+ bbox = (fz_rect){0, 0, pageSize.width * scale.width, pageSize.height * scale.height};
pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb, bbox);
fz_clear_pixmap_with_value(ctx, pix, 255);
@@ -263,8 +263,7 @@ static UIImage *renderPage(fz_document *doc, fz_page *page, CGSize screenSize)
static UIImage *renderTile(fz_document *doc, fz_page *page, CGSize screenSize, CGRect tileRect, float zoom)
{
CGSize pageSize;
- fz_rect rect;
- fz_bbox bbox;
+ fz_rect bbox;
fz_matrix ctm;
fz_device *dev;
fz_pixmap *pix;
@@ -281,11 +280,10 @@ static UIImage *renderTile(fz_document *doc, fz_page *page, CGSize screenSize, C
scale = fitPageToScreen(pageSize, screenSize);
ctm = fz_scale(scale.width * zoom, scale.height * zoom);
- rect.x0 = tileRect.origin.x;
- rect.y0 = tileRect.origin.y;
- rect.x1 = tileRect.origin.x + tileRect.size.width;
- rect.y1 = tileRect.origin.y + tileRect.size.height;
- bbox = fz_round_rect(rect);
+ bbox.x0 = tileRect.origin.x;
+ bbox.y0 = tileRect.origin.y;
+ bbox.x1 = tileRect.origin.x + tileRect.size.width;
+ bbox.y1 = tileRect.origin.y + tileRect.size.height;
pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb, bbox);
fz_clear_pixmap_with_value(ctx, pix, 255);
@@ -602,7 +600,7 @@ static UIImage *renderTile(fz_document *doc, fz_page *page, CGSize screenSize, C
pageSize = CGSizeMake(100,100);
for (int i = 0; i < n && i < nelem(hitRects); i++) {
- fz_bbox bbox = search_result_bbox(doc, i); // this is thread-safe enough
+ fz_rect bbox = search_result_bbox(doc, i); // this is thread-safe enough
hitRects[i].origin.x = bbox.x0;
hitRects[i].origin.y = bbox.y0;
hitRects[i].size.width = bbox.x1 - bbox.x0;
@@ -625,7 +623,7 @@ static UIImage *renderTile(fz_document *doc, fz_page *page, CGSize screenSize, C
while (link && hitCount < nelem(hitRects)) {
if (link->dest.kind == FZ_LINK_GOTO || link->dest.kind == FZ_LINK_URI) {
- fz_bbox bbox = fz_round_rect(link->rect);
+ fz_rect bbox = link->rect;
hitRects[hitCount].origin.x = bbox.x0;
hitRects[hitCount].origin.y = bbox.y0;
hitRects[hitCount].size.width = bbox.x1 - bbox.x0;