summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz/path.h
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-03-05 17:31:05 -0700
committerRobin Watts <robin.watts@artifex.com>2015-03-24 19:50:00 +0000
commit5f161e45d5daacb696d02b8fad23d0c23f5bc8bc (patch)
tree6e8d84a383d580ee38b23dfb345bc96d0ba1e63e /include/mupdf/fitz/path.h
parent563c482145d65c4006f5842c8860ab1b09f5a229 (diff)
downloadmupdf-5f161e45d5daacb696d02b8fad23d0c23f5bc8bc.tar.xz
Path rework for improved memory usage.
Firstly, we make the definition of the path structures local to path.c. This is achieved by using an fz_path_processor function to step through paths enumerating each section using callback functions. Next, we extend the internal path representation to include other section types, including quads, beziers with common control points rectangles, horizontal, vertical and degenerate lines. We also roll close path sections up into the previous sections commands. The hairiest part of this is that fz_transform_path has to cope with changing the path commands depending on the matrix. This is a relatively rare operation though.
Diffstat (limited to 'include/mupdf/fitz/path.h')
-rw-r--r--include/mupdf/fitz/path.h37
1 files changed, 17 insertions, 20 deletions
diff --git a/include/mupdf/fitz/path.h b/include/mupdf/fitz/path.h
index 23dc0838..1bca1858 100644
--- a/include/mupdf/fitz/path.h
+++ b/include/mupdf/fitz/path.h
@@ -17,14 +17,6 @@
typedef struct fz_path_s fz_path;
typedef struct fz_stroke_state_s fz_stroke_state;
-typedef enum fz_path_command_e
-{
- FZ_MOVETO = 'M',
- FZ_LINETO = 'L',
- FZ_CURVETO = 'C',
- FZ_CLOSE_PATH = 'Z',
-} fz_path_item_kind;
-
typedef enum fz_linecap_e
{
FZ_LINECAP_BUTT = 0,
@@ -41,18 +33,6 @@ typedef enum fz_linejoin_e
FZ_LINEJOIN_MITER_XPS = 3
} fz_linejoin;
-struct fz_path_s
-{
- int refs;
- 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
{
int refs;
@@ -65,6 +45,21 @@ struct fz_stroke_state_s
float dash_list[32];
};
+typedef struct
+{
+ void (*moveto)(fz_context *ctx, void *arg, float x, float y);
+ void (*lineto)(fz_context *ctx, void *arg, float x, float y);
+ void (*curveto)(fz_context *ctx, void *arg, float x1, float y1, float x2, float y2, float x3, float y3);
+ void (*close)(fz_context *ctx, void *arg);
+ /* Optional ones */
+ void (*quadto)(fz_context *ctx, void *arg, float x1, float y1, float x2, float y2);
+ void (*curvetov)(fz_context *ctx, void *arg, float x2, float y2, float x3, float y3);
+ void (*curvetoy)(fz_context *ctx, void *arg, float x1, float y1, float x3, float y3);
+ void (*rectto)(fz_context *ctx, void *arg, float x1, float y1, float x2, float y2);
+} fz_path_processor;
+
+void fz_process_path(fz_context *ctx, const fz_path_processor *proc, void *arg, const fz_path *path);
+
fz_path *fz_new_path(fz_context *ctx);
fz_path *fz_keep_path(fz_context *ctx, fz_path *path);
void fz_drop_path(fz_context *ctx, fz_path *path);
@@ -73,6 +68,8 @@ void fz_trim_path(fz_context *ctx, fz_path *path);
fz_point fz_currentpoint(fz_context *ctx, fz_path *path);
void fz_moveto(fz_context*, fz_path*, float x, float y);
void fz_lineto(fz_context*, fz_path*, float x, float y);
+void fz_quadto(fz_context*, fz_path*, float x1, float y1, float x2, float y2);
+void fz_rectto(fz_context*, fz_path*, float x1, float y1, float x2, float y2);
void fz_curveto(fz_context*,fz_path*, float, float, float, float, float, float);
void fz_curvetov(fz_context*,fz_path*, float, float, float, float);
void fz_curvetoy(fz_context*,fz_path*, float, float, float, float);