summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-07-18 16:04:06 +0100
committerRobin Watts <robin.watts@artifex.com>2012-07-18 18:59:03 +0100
commitaa64c27048e9d308400058b40ee2677cfd7c5081 (patch)
tree19501467da0ea93ac00292ac040e67348c71e5cd
parent34aaac902ad9f5bc80931877102ef08c2b8b5088 (diff)
downloadmupdf-aa64c27048e9d308400058b40ee2677cfd7c5081.tar.xz
Fix missing diagram in 1522*.pdf
Since the commit to replace abs/min/max/clamp with inline versions, "1522 - diagramm missing above 88 pc zoom.pdf" has been missing a diagram. This is because the diagram contains sections like: -2147483648 -2147483648 m -2147483648 2147483647 l 2147483647 2147483647 l 2147483647 -2147483648 l These extreme values, when transformed would give floating point values that when naively cast down to int, flip sign (e.g. extreme positive when cast to int becomes extreme negative). I had been relying on the cast down giving sane results to enable me to use fz_clampi. Revert to using fz_clamp and all is fine.
-rw-r--r--draw/draw_edge.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/draw/draw_edge.c b/draw/draw_edge.c
index 48496acd..ff5dcdfc 100644
--- a/draw/draw_edge.c
+++ b/draw/draw_edge.c
@@ -356,10 +356,14 @@ fz_insert_gel(fz_gel *gel, float fx0, float fy0, float fx1, float fy1)
fy0 = floorf(fy0 * fz_aa_vscale);
fy1 = floorf(fy1 * fz_aa_vscale);
- x0 = fz_clampi(fx0, BBOX_MIN * fz_aa_hscale, BBOX_MAX * fz_aa_hscale);
- y0 = fz_clampi(fy0, BBOX_MIN * fz_aa_vscale, BBOX_MAX * fz_aa_vscale);
- x1 = fz_clampi(fx1, BBOX_MIN * fz_aa_hscale, BBOX_MAX * fz_aa_hscale);
- y1 = fz_clampi(fy1, BBOX_MIN * fz_aa_vscale, BBOX_MAX * fz_aa_vscale);
+ /* Call fz_clamp so that clamping is done in the float domain, THEN
+ * cast down to an int. Calling fz_clampi causes problems due to the
+ * implicit cast down from float to int of the first argument
+ * over/underflowing and flipping sign at extreme values. */
+ x0 = (int)fz_clamp(fx0, BBOX_MIN * fz_aa_hscale, BBOX_MAX * fz_aa_hscale);
+ y0 = (int)fz_clamp(fy0, BBOX_MIN * fz_aa_vscale, BBOX_MAX * fz_aa_vscale);
+ x1 = (int)fz_clamp(fx1, BBOX_MIN * fz_aa_hscale, BBOX_MAX * fz_aa_hscale);
+ y1 = (int)fz_clamp(fy1, BBOX_MIN * fz_aa_vscale, BBOX_MAX * fz_aa_vscale);
d = clip_lerp_y(gel->clip.y0, 0, x0, y0, x1, y1, &v);
if (d == OUTSIDE) return;