From 5f161e45d5daacb696d02b8fad23d0c23f5bc8bc Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 5 Mar 2015 17:31:05 -0700 Subject: 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. --- source/xps/xps-path.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'source/xps') diff --git a/source/xps/xps-path.c b/source/xps/xps-path.c index e1245a9a..8c352272 100644 --- a/source/xps/xps-path.c +++ b/source/xps/xps-path.c @@ -397,15 +397,11 @@ xps_parse_abbreviated_geometry(fz_context *ctx, xps_document *doc, char *geom, i case 'Q': if (i + 3 >= n) break; - pt = fz_currentpoint(ctx, path); x1 = fz_atof(args[i+0]); y1 = fz_atof(args[i+1]); x2 = fz_atof(args[i+2]); y2 = fz_atof(args[i+3]); - fz_curveto(ctx, path, - (pt.x + 2 * x1) / 3, (pt.y + 2 * y1) / 3, - (x2 + 2 * x1) / 3, (y2 + 2 * y1) / 3, - x2, y2); + fz_quadto(ctx, path, x1, y1, x2, y2); i += 4; break; case 'q': @@ -415,10 +411,7 @@ xps_parse_abbreviated_geometry(fz_context *ctx, xps_document *doc, char *geom, i y1 = fz_atof(args[i+1]) + pt.y; x2 = fz_atof(args[i+2]) + pt.x; y2 = fz_atof(args[i+3]) + pt.y; - fz_curveto(ctx, path, - (pt.x + 2 * x1) / 3, (pt.y + 2 * y1) / 3, - (x2 + 2 * x1) / 3, (y2 + 2 * y1) / 3, - x2, y2); + fz_quadto(ctx, path, x1, y1, x2, y2); i += 4; break; -- cgit v1.2.3