diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2013-09-05 18:49:09 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2013-09-08 08:21:19 -0500 |
commit | dc45e762170a9b642af588d1c067757ae6a6c683 (patch) | |
tree | ea4a127ffadb100a1dc4e2783366041d4fdda5b1 | |
parent | 3408b6a59145df4389f38ba75e095c39bc1c699e (diff) | |
download | mupdf-dc45e762170a9b642af588d1c067757ae6a6c683.tar.xz |
Separate command and coordinate arrays in fz_path structure.
-rw-r--r-- | include/mupdf/fitz/path.h | 28 | ||||
-rw-r--r-- | source/fitz/draw-path.c | 87 | ||||
-rw-r--r-- | source/fitz/path.c | 285 | ||||
-rw-r--r-- | source/fitz/svg-device.c | 26 | ||||
-rw-r--r-- | source/fitz/trace-device.c | 27 | ||||
-rw-r--r-- | source/pdf/pdf-device.c | 26 |
6 files changed, 213 insertions, 266 deletions
diff --git a/include/mupdf/fitz/path.h b/include/mupdf/fitz/path.h index b2bc67ce..22b81c6e 100644 --- a/include/mupdf/fitz/path.h +++ b/include/mupdf/fitz/path.h @@ -17,14 +17,12 @@ typedef struct fz_path_s fz_path; typedef struct fz_stroke_state_s fz_stroke_state; -typedef union fz_path_item_s fz_path_item; - -typedef enum fz_path_item_kind_e +typedef enum fz_path_command_e { - FZ_MOVETO, - FZ_LINETO, - FZ_CURVETO, - FZ_CLOSE_PATH + FZ_MOVETO = 'M', + FZ_LINETO = 'L', + FZ_CURVETO = 'C', + FZ_CLOSE_PATH = 'Z', } fz_path_item_kind; typedef enum fz_linecap_e @@ -43,17 +41,15 @@ typedef enum fz_linejoin_e FZ_LINEJOIN_MITER_XPS = 3 } fz_linejoin; -union fz_path_item_s -{ - fz_path_item_kind k; - float v; -}; - struct fz_path_s { - int len, cap; - fz_path_item *items; - int last; + int cmd_len, cmd_cap; + unsigned char *cmds; + int coord_len, coord_cap; + float *coords; + fz_point current; + fz_point begin; + int last_cmd; }; struct fz_stroke_state_s diff --git a/source/fitz/draw-path.c b/source/fitz/draw-path.c index 31b038b1..1d2d7500 100644 --- a/source/fitz/draw-path.c +++ b/source/fitz/draw-path.c @@ -75,37 +75,37 @@ fz_flatten_fill_path(fz_gel *gel, fz_path *path, const fz_matrix *ctm, float fla float cy = 0; float bx = 0; float by = 0; - int i = 0; + int i = 0, k = 0; - while (i < path->len) + while (i < path->cmd_len) { - switch (path->items[i++].k) + switch (path->cmds[i++]) { case FZ_MOVETO: /* implicit closepath before moveto */ if (cx != bx || cy != by) line(gel, ctm, cx, cy, bx, by); - x1 = path->items[i++].v; - y1 = path->items[i++].v; + x1 = path->coords[k++]; + y1 = path->coords[k++]; cx = bx = x1; cy = by = y1; break; case FZ_LINETO: - x1 = path->items[i++].v; - y1 = path->items[i++].v; + x1 = path->coords[k++]; + y1 = path->coords[k++]; line(gel, ctm, cx, cy, x1, y1); cx = x1; cy = y1; break; case FZ_CURVETO: - x1 = path->items[i++].v; - y1 = path->items[i++].v; - x2 = path->items[i++].v; - y2 = path->items[i++].v; - x3 = path->items[i++].v; - y3 = path->items[i++].v; + x1 = path->coords[k++]; + y1 = path->coords[k++]; + x2 = path->coords[k++]; + y2 = path->coords[k++]; + x3 = path->coords[k++]; + y3 = path->coords[k++]; bezier(gel, ctm, flatness, cx, cy, x1, y1, x2, y2, x3, y3, 0); cx = x3; cy = y3; @@ -546,7 +546,7 @@ fz_flatten_stroke_path(fz_gel *gel, fz_path *path, const fz_stroke_state *stroke { struct sctx s; fz_point p0, p1, p2, p3; - int i; + int i, k; s.gel = gel; s.ctm = ctm; @@ -568,39 +568,38 @@ fz_flatten_stroke_path(fz_gel *gel, fz_path *path, const fz_stroke_state *stroke s.cap = stroke->start_cap; - i = 0; - - if (path->len > 0 && path->items[0].k != FZ_MOVETO) + if (path->cmd_len > 0 && path->cmds[0] != FZ_MOVETO) return; p0.x = p0.y = 0; - while (i < path->len) + i = k = 0; + while (i < path->cmd_len) { - switch (path->items[i++].k) + switch (path->cmds[i++]) { case FZ_MOVETO: - p1.x = path->items[i++].v; - p1.y = path->items[i++].v; + p1.x = path->coords[k++]; + p1.y = path->coords[k++]; fz_stroke_flush(&s, stroke->start_cap, stroke->end_cap); fz_stroke_moveto(&s, p1); p0 = p1; break; case FZ_LINETO: - p1.x = path->items[i++].v; - p1.y = path->items[i++].v; + p1.x = path->coords[k++]; + p1.y = path->coords[k++]; fz_stroke_lineto(&s, p1, 0); p0 = p1; break; case FZ_CURVETO: - p1.x = path->items[i++].v; - p1.y = path->items[i++].v; - p2.x = path->items[i++].v; - p2.y = path->items[i++].v; - p3.x = path->items[i++].v; - p3.y = path->items[i++].v; + p1.x = path->coords[k++]; + p1.y = path->coords[k++]; + p2.x = path->coords[k++]; + p2.y = path->coords[k++]; + p3.x = path->coords[k++]; + p3.y = path->coords[k++]; fz_stroke_bezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0); p0 = p3; break; @@ -753,7 +752,7 @@ fz_flatten_dash_path(fz_gel *gel, fz_path *path, const fz_stroke_state *stroke, struct sctx s; fz_point p0, p1, p2, p3, beg; float phase_len, max_expand; - int i; + int i, k; s.gel = gel; s.ctm = ctm; @@ -775,7 +774,7 @@ fz_flatten_dash_path(fz_gel *gel, fz_path *path, const fz_stroke_state *stroke, s.cap = stroke->start_cap; - if (path->len > 0 && path->items[0].k != FZ_MOVETO) + if (path->cmd_len > 0 && path->cmds[0] != FZ_MOVETO) return; phase_len = 0; @@ -789,33 +788,33 @@ fz_flatten_dash_path(fz_gel *gel, fz_path *path, const fz_stroke_state *stroke, } p0.x = p0.y = 0; - i = 0; + i = k = 0; - while (i < path->len) + while (i < path->cmd_len) { - switch (path->items[i++].k) + switch (path->cmds[i++]) { case FZ_MOVETO: - p1.x = path->items[i++].v; - p1.y = path->items[i++].v; + p1.x = path->coords[k++]; + p1.y = path->coords[k++]; fz_dash_moveto(&s, p1, stroke->start_cap, stroke->end_cap); beg = p0 = p1; break; case FZ_LINETO: - p1.x = path->items[i++].v; - p1.y = path->items[i++].v; + p1.x = path->coords[k++]; + p1.y = path->coords[k++]; fz_dash_lineto(&s, p1, stroke->dash_cap, 0); p0 = p1; break; case FZ_CURVETO: - p1.x = path->items[i++].v; - p1.y = path->items[i++].v; - p2.x = path->items[i++].v; - p2.y = path->items[i++].v; - p3.x = path->items[i++].v; - p3.y = path->items[i++].v; + p1.x = path->coords[k++]; + p1.y = path->coords[k++]; + p2.x = path->coords[k++]; + p2.y = path->coords[k++]; + p3.x = path->coords[k++]; + p3.y = path->coords[k++]; fz_dash_bezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0, stroke->dash_cap); p0 = p3; break; diff --git a/source/fitz/path.c b/source/fitz/path.c index cbdfc7bc..d2ad27c3 100644 --- a/source/fitz/path.c +++ b/source/fitz/path.c @@ -7,10 +7,11 @@ fz_new_path(fz_context *ctx) fz_path *path; path = fz_malloc_struct(ctx, fz_path); - path->len = 0; - path->cap = 0; - path->items = NULL; - path->last = -1; + path->last_cmd = 0; + path->current.x = 0; + path->current.y = 0; + path->begin.x = 0; + path->begin.y = 0; return path; } @@ -24,13 +25,20 @@ fz_clone_path(fz_context *ctx, fz_path *old) path = fz_malloc_struct(ctx, fz_path); fz_try(ctx) { - path->len = old->len; - path->cap = old->len; - path->items = fz_malloc_array(ctx, path->cap, sizeof(fz_path_item)); - memcpy(path->items, old->items, sizeof(fz_path_item) * path->len); + path->cmd_len = old->cmd_len; + path->cmd_cap = old->cmd_len; + path->cmds = fz_malloc_array(ctx, path->cmd_cap, sizeof(unsigned char)); + memcpy(path->cmds, old->cmds, sizeof(unsigned char) * path->cmd_len); + + path->coord_len = old->coord_len; + path->coord_cap = old->coord_len; + path->coords = fz_malloc_array(ctx, path->coord_cap, sizeof(float)); + memcpy(path->coords, old->coords, sizeof(float) * path->coord_len); } fz_catch(ctx) { + fz_free(ctx, path->cmds); + fz_free(ctx, path->coords); fz_free(ctx, path); fz_rethrow(ctx); } @@ -43,101 +51,86 @@ fz_free_path(fz_context *ctx, fz_path *path) { if (path == NULL) return; - fz_free(ctx, path->items); + fz_free(ctx, path->cmds); + fz_free(ctx, path->coords); fz_free(ctx, path); } static void -grow_path(fz_context *ctx, fz_path *path, int n) +push_cmd(fz_context *ctx, fz_path *path, int cmd) { - int newcap = path->cap; - if (path->len + n <= path->cap) + if (path->cmd_len + 1 >= path->cmd_cap) { - path->last = path->len; - return; + int new_cmd_cap = fz_maxi(16, path->cmd_cap * 2); + path->cmds = fz_resize_array(ctx, path->cmds, new_cmd_cap, sizeof(unsigned char)); + path->cmd_cap = new_cmd_cap; } - while (path->len + n > newcap) - newcap = newcap + 36; - path->items = fz_resize_array(ctx, path->items, newcap, sizeof(fz_path_item)); - path->cap = newcap; - path->last = path->len; + + path->cmds[path->cmd_len++] = cmd; + path->last_cmd = cmd; } -fz_point -fz_currentpoint(fz_context *ctx, fz_path *path) +static void +push_coord(fz_context *ctx, fz_path *path, float x, float y) { - fz_point c, m; - int i; - - c.x = c.y = m.x = m.y = 0; - i = 0; - - while (i < path->len) + if (path->coord_len + 2 >= path->coord_cap) { - switch (path->items[i++].k) - { - case FZ_MOVETO: - m.x = c.x = path->items[i++].v; - m.y = c.y = path->items[i++].v; - break; - case FZ_LINETO: - c.x = path->items[i++].v; - c.y = path->items[i++].v; - break; - case FZ_CURVETO: - i += 4; - c.x = path->items[i++].v; - c.y = path->items[i++].v; - break; - case FZ_CLOSE_PATH: - c = m; - } + int new_coord_cap = fz_maxi(32, path->coord_cap * 2); + path->coords = fz_resize_array(ctx, path->coords, new_coord_cap, sizeof(float)); + path->coord_cap = new_coord_cap; } - return c; + path->coords[path->coord_len++] = x; + path->coords[path->coord_len++] = y; + + path->current.x = x; + path->current.y = y; +} + +fz_point +fz_currentpoint(fz_context *ctx, fz_path *path) +{ + return path->current; } void fz_moveto(fz_context *ctx, fz_path *path, float x, float y) { - if (path->last >= 0 && path->items[path->last].k == FZ_MOVETO) + if (path->cmd_len > 0 && path->last_cmd == FZ_MOVETO) { - /* No point in having MOVETO then MOVETO */ - path->len = path->last; + /* Collapse moveto followed by moveto. */ + path->coords[path->coord_len-2] = x; + path->coords[path->coord_len-1] = y; + path->current.x = x; + path->current.y = y; + path->begin = path->current; + return; } - grow_path(ctx, path, 3); - path->items[path->len++].k = FZ_MOVETO; - path->items[path->len++].v = x; - path->items[path->len++].v = y; + + push_cmd(ctx, path, FZ_MOVETO); + push_coord(ctx, path, x, y); + + path->begin = path->current; } void fz_lineto(fz_context *ctx, fz_path *path, float x, float y) { - float x0, y0; + float x0 = path->current.x; + float y0 = path->current.y; - if (path->last < 0) + if (path->cmd_len == 0) { fz_warn(ctx, "lineto with no current point"); return; } - if (path->items[path->last].k == FZ_CLOSE_PATH) - { - x0 = path->items[path->last-2].v; - y0 = path->items[path->last-1].v; - } - else - { - x0 = path->items[path->len-2].v; - y0 = path->items[path->len-1].v; - } + /* Anything other than MoveTo followed by LineTo the same place is a nop */ - if (path->items[path->last].k != FZ_MOVETO && x0 == x && y0 == y) + if (path->last_cmd != FZ_MOVETO && x0 == x && y0 == y) return; - grow_path(ctx, path, 3); - path->items[path->len++].k = FZ_LINETO; - path->items[path->len++].v = x; - path->items[path->len++].v = y; + + push_cmd(ctx, path, FZ_LINETO); + push_coord(ctx, path, x, y); } void @@ -146,23 +139,14 @@ fz_curveto(fz_context *ctx, fz_path *path, float x2, float y2, float x3, float y3) { - float x0, y0; + float x0 = path->current.x; + float y0 = path->current.y; - if (path->last < 0) + if (path->cmd_len == 0) { fz_warn(ctx, "curveto with no current point"); return; } - if (path->items[path->last].k == FZ_CLOSE_PATH) - { - x0 = path->items[path->last-2].v; - y0 = path->items[path->last-1].v; - } - else - { - x0 = path->items[path->len-2].v; - y0 = path->items[path->len-1].v; - } /* Check for degenerate cases: */ if (x0 == x1 && y0 == y1) @@ -170,7 +154,7 @@ fz_curveto(fz_context *ctx, fz_path *path, if (x2 == x3 && y2 == y3) { /* If (x1,y1)==(x2,y2) and prev wasn't a moveto, then skip */ - if (x1 == x2 && y1 == y2 && path->items[path->last].k != FZ_MOVETO) + if (x1 == x2 && y1 == y2 && path->last_cmd != FZ_MOVETO) return; /* Otherwise a line will suffice */ fz_lineto(ctx, path, x3, y3); @@ -190,35 +174,24 @@ fz_curveto(fz_context *ctx, fz_path *path, return; } - grow_path(ctx, path, 7); - path->items[path->len++].k = FZ_CURVETO; - path->items[path->len++].v = x1; - path->items[path->len++].v = y1; - path->items[path->len++].v = x2; - path->items[path->len++].v = y2; - path->items[path->len++].v = x3; - path->items[path->len++].v = y3; + push_cmd(ctx, path, FZ_CURVETO); + push_coord(ctx, path, x1, y1); + push_coord(ctx, path, x2, y2); + push_coord(ctx, path, x3, y3); } void fz_curvetov(fz_context *ctx, fz_path *path, float x2, float y2, float x3, float y3) { - float x1, y1; - if (path->last < 0) + float x1 = path->current.x; + float y1 = path->current.y; + + if (path->cmd_len == 0) { fz_warn(ctx, "curvetov with no current point"); return; } - if (path->items[path->last].k == FZ_CLOSE_PATH) - { - x1 = path->items[path->last-2].v; - y1 = path->items[path->last-1].v; - } - else - { - x1 = path->items[path->len-2].v; - y1 = path->items[path->len-1].v; - } + fz_curveto(ctx, path, x1, y1, x2, y2, x3, y3); } @@ -231,16 +204,19 @@ fz_curvetoy(fz_context *ctx, fz_path *path, float x1, float y1, float x3, float void fz_closepath(fz_context *ctx, fz_path *path) { - if (path->last < 0) + if (path->cmd_len == 0) { fz_warn(ctx, "closepath with no current point"); return; } + /* CLOSE following a CLOSE is a NOP */ - if (path->items[path->last].k == FZ_CLOSE_PATH) + if (path->last_cmd == FZ_CLOSE_PATH) return; - grow_path(ctx, path, 1); - path->items[path->len++].k = FZ_CLOSE_PATH; + + push_cmd(ctx, path, FZ_CLOSE_PATH); + + path->current = path->begin; } static inline fz_rect *bound_expand(fz_rect *r, const fz_point *p) @@ -256,55 +232,51 @@ fz_rect * fz_bound_path(fz_context *ctx, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r) { fz_point p; - int i = 0; + int i = 0, k = 0; /* If the path is empty, return the empty rectangle here - don't wait - * for it to be expanded in the stroked case below. */ - if (path->len == 0) - { - *r = fz_empty_rect; - return r; - } - /* A path must start with a moveto - and if that's all there is + * for it to be expanded in the stroked case below. + * A path must start with a moveto - and if that's all there is * then the path is empty. */ - if (path->len == 3) + if (path->cmd_len == 0 || path->cmd_len == 1) { *r = fz_empty_rect; return r; } - p.x = path->items[1].v; - p.y = path->items[2].v; + /* Initial moveto point */ + p.x = path->coords[0]; + p.y = path->coords[1]; fz_transform_point(&p, ctm); r->x0 = r->x1 = p.x; r->y0 = r->y1 = p.y; - while (i < path->len) + while (i < path->cmd_len) { - switch (path->items[i++].k) + switch (path->cmds[i++]) { case FZ_CURVETO: - p.x = path->items[i++].v; - p.y = path->items[i++].v; + p.x = path->coords[k++]; + p.y = path->coords[k++]; bound_expand(r, fz_transform_point(&p, ctm)); - p.x = path->items[i++].v; - p.y = path->items[i++].v; + p.x = path->coords[k++]; + p.y = path->coords[k++]; bound_expand(r, fz_transform_point(&p, ctm)); - p.x = path->items[i++].v; - p.y = path->items[i++].v; + p.x = path->coords[k++]; + p.y = path->coords[k++]; bound_expand(r, fz_transform_point(&p, ctm)); break; case FZ_MOVETO: - if (i + 2 == path->len) + if (k + 2 == path->coord_len) { /* Trailing Moveto - cannot affect bbox */ - i += 2; + k += 2; break; } /* fallthrough */ case FZ_LINETO: - p.x = path->items[i++].v; - p.y = path->items[i++].v; + p.x = path->coords[k++]; + p.y = path->coords[k++]; bound_expand(r, fz_transform_point(&p, ctm)); break; case FZ_CLOSE_PATH: @@ -345,28 +317,9 @@ fz_adjust_rect_for_stroke(fz_rect *r, const fz_stroke_state *stroke, const fz_ma void fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm) { - int k, i = 0; - - while (i < path->len) - { - switch (path->items[i++].k) - { - case FZ_CURVETO: - for (k = 0; k < 3; k++) - { - fz_transform_point((fz_point *)(void *)&path->items[i].v, ctm); - i += 2; - } - break; - case FZ_MOVETO: - case FZ_LINETO: - fz_transform_point((fz_point *)(void *)&path->items[i].v, ctm); - i += 2; - break; - case FZ_CLOSE_PATH: - break; - } - } + int i; + for (i = 0; i < path->coord_len; i += 2) + fz_transform_point((fz_point *)&path->coords[i], ctm); } #ifndef NDEBUG @@ -374,33 +327,33 @@ void fz_print_path(fz_context *ctx, FILE *out, fz_path *path, int indent) { float x, y; - int i = 0; + int i = 0, k = 0; int n; - while (i < path->len) + while (i < path->cmd_len) { for (n = 0; n < indent; n++) fputc(' ', out); - switch (path->items[i++].k) + switch (path->cmds[i++]) { case FZ_MOVETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fprintf(out, "%g %g m\n", x, y); break; case FZ_LINETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fprintf(out, "%g %g l\n", x, y); break; case FZ_CURVETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fprintf(out, "%g %g ", x, y); - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fprintf(out, "%g %g ", x, y); - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fprintf(out, "%g %g c\n", x, y); break; case FZ_CLOSE_PATH: diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c index e328a61a..273271e6 100644 --- a/source/fitz/svg-device.c +++ b/source/fitz/svg-device.c @@ -32,31 +32,31 @@ svg_dev_path(svg_device *sdev, fz_path *path) { fz_output *out = sdev->out; float x, y; - int i = 0; + int i, k; fz_printf(out, " d=\""); - while (i < path->len) + for (i = 0, k = 0; i < path->cmd_len; i++) { - switch (path->items[i++].k) + switch (path->cmds[i]) { case FZ_MOVETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_printf(out, "M %g %g ", x, y); break; case FZ_LINETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_printf(out, "L %g %g ", x, y); break; case FZ_CURVETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_printf(out, "C %g %g ", x, y); - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_printf(out, "%g %g ", x, y); - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_printf(out, "%g %g ", x, y); break; case FZ_CLOSE_PATH: diff --git a/source/fitz/trace-device.c b/source/fitz/trace-device.c index b3cade91..d6c01323 100644 --- a/source/fitz/trace-device.c +++ b/source/fitz/trace-device.c @@ -30,33 +30,32 @@ static void fz_trace_path(fz_path *path, int indent) { float x, y; - int i = 0; - int n; - while (i < path->len) + int i = 0, k = 0, n; + while (i < path->cmd_len) { for (n = 0; n < indent; n++) putchar(' '); - switch (path->items[i++].k) + switch (path->cmds[i++]) { case FZ_MOVETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; printf("<moveto x=\"%g\" y=\"%g\"/>\n", x, y); break; case FZ_LINETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; printf("<lineto x=\"%g\" y=\"%g\"/>\n", x, y); break; case FZ_CURVETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; printf("<curveto x1=\"%g\" y1=\"%g\"", x, y); - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; printf(" x2=\"%g\" y2=\"%g\"", x, y); - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; printf(" x3=\"%g\" y3=\"%g\"/>\n", x, y); break; case FZ_CLOSE_PATH: diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c index 1ce80b17..25c8afdc 100644 --- a/source/pdf/pdf-device.c +++ b/source/pdf/pdf-device.c @@ -367,30 +367,30 @@ pdf_dev_path(pdf_device *pdev, fz_path *path) fz_context *ctx = pdev->ctx; gstate *gs = CURRENT_GSTATE(pdev); float x, y; - int i = 0; - while (i < path->len) + int i = 0, k = 0; + while (i < path->cmd_len) { - switch (path->items[i++].k) + switch (path->cmds[i++]) { case FZ_MOVETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_buffer_printf(ctx, gs->buf, "%f %f m\n", x, y); break; case FZ_LINETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_buffer_printf(ctx, gs->buf, "%f %f l\n", x, y); break; case FZ_CURVETO: - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_buffer_printf(ctx, gs->buf, "%f %f ", x, y); - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_buffer_printf(ctx, gs->buf, "%f %f ", x, y); - x = path->items[i++].v; - y = path->items[i++].v; + x = path->coords[k++]; + y = path->coords[k++]; fz_buffer_printf(ctx, gs->buf, "%f %f c\n", x, y); break; case FZ_CLOSE_PATH: |