diff options
Diffstat (limited to 'source/fitz/path.c')
-rw-r--r-- | source/fitz/path.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/fitz/path.c b/source/fitz/path.c index 811db282..04a3a7bc 100644 --- a/source/fitz/path.c +++ b/source/fitz/path.c @@ -364,12 +364,24 @@ fz_print_path(fz_context *ctx, FILE *out, fz_path *path, int indent) } #endif +const fz_stroke_state fz_default_stroke_state = { + -2, /* -2 is the magic number we use when we have stroke states stored on the stack */ + FZ_LINECAP_BUTT, FZ_LINECAP_BUTT, FZ_LINECAP_BUTT, + FZ_LINEJOIN_MITER, + 1, 10, + 0, 0, { 0 } +}; + fz_stroke_state * fz_keep_stroke_state(fz_context *ctx, fz_stroke_state *stroke) { if (!stroke) return NULL; + /* -2 is the magic number we use when we have stroke states stored on the stack */ + if (stroke->refs == -2) + return fz_clone_stroke_state(ctx, stroke); + fz_lock(ctx, FZ_LOCK_ALLOC); if (stroke->refs > 0) stroke->refs++; @@ -423,6 +435,17 @@ fz_new_stroke_state(fz_context *ctx) } fz_stroke_state * +fz_clone_stroke_state(fz_context *ctx, fz_stroke_state *stroke) +{ + fz_stroke_state *clone = fz_new_stroke_state_with_dash_len(ctx, stroke->dash_len); + int extra = stroke->dash_len - nelem(stroke->dash_list); + int size = sizeof(*stroke) + sizeof(stroke->dash_list[0]) * extra; + memcpy(clone, stroke, size); + clone->refs = 1; + return clone; +} + +fz_stroke_state * fz_unshare_stroke_state_with_dash_len(fz_context *ctx, fz_stroke_state *shared, int len) { int single, unsize, shsize, shlen, drop; |