diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2013-01-25 14:07:29 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2013-01-30 14:07:21 +0100 |
commit | ddb92b7c3fdfcf9bf3d7463dde4e662ca10f79ba (patch) | |
tree | f9d960048a60066ab8829af0fe6a22104ef30ee3 /apps | |
parent | d8ad064b0c4bcd539c06c98af070613ff818ee0b (diff) | |
download | mupdf-ddb92b7c3fdfcf9bf3d7463dde4e662ca10f79ba.tar.xz |
Eliminate fz_bbox in favor of fz_rect everywhere.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/mudraw.c | 32 | ||||
-rw-r--r-- | apps/pdfapp.c | 36 | ||||
-rw-r--r-- | apps/pdfapp.h | 4 |
3 files changed, 37 insertions, 35 deletions
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); |