summaryrefslogtreecommitdiff
path: root/source/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-06-25 13:15:50 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-07-05 15:32:34 +0200
commit4a99615a609eec2b84bb2341d74fac46a5998137 (patch)
tree486eacff07448e4c655df1fa1bcb20df709dd8df /source/fitz
parent2aa62902447760764e7a763dea322145d9c4808c (diff)
downloadmupdf-4a99615a609eec2b84bb2341d74fac46a5998137.tar.xz
Pass rect and matrix by value in geometry functions.
Several things irk me about passing values as const pointers: * They can be NULL, which is not a valid value. * They require explicit temporary variables for storage. * They don't compose easily in a legible manner, requiring weird pointer passing semantics where the variable being assigned is hidden as an argument in the innermost function call. * We can't change the value through the pointer, requiring yet more local variables to hold copies of the input value. In the device interface where we pass a matrix to a function, we often find ourselves making a local copy of the matrix so we can concatenate other transforms to it. This copying is a lot of unnecessary busywork that I hope to eventually avoid by laying the groundwork with this commit. This is a rather large API change, so I apologize for the inconvenience, but I hope the end result and gain in legibility will be worth the pain.
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/bbox-device.c52
-rw-r--r--source/fitz/colorspace.c6
-rw-r--r--source/fitz/device.c18
-rw-r--r--source/fitz/document.c28
-rw-r--r--source/fitz/draw-affine.c185
-rw-r--r--source/fitz/draw-blend.c14
-rw-r--r--source/fitz/draw-device.c347
-rw-r--r--source/fitz/draw-glyph.c2
-rw-r--r--source/fitz/draw-imp.h6
-rw-r--r--source/fitz/draw-mesh.c10
-rw-r--r--source/fitz/draw-paint.c35
-rw-r--r--source/fitz/draw-path.c22
-rw-r--r--source/fitz/draw-rasterize.c60
-rw-r--r--source/fitz/draw-scale-simple.c2
-rw-r--r--source/fitz/font.c73
-rw-r--r--source/fitz/geometry.c571
-rw-r--r--source/fitz/glyph.c26
-rw-r--r--source/fitz/image.c7
-rw-r--r--source/fitz/link.c4
-rw-r--r--source/fitz/list-device.c93
-rw-r--r--source/fitz/path.c127
-rw-r--r--source/fitz/pixmap.c89
-rw-r--r--source/fitz/separation.c2
-rw-r--r--source/fitz/shade.c169
-rw-r--r--source/fitz/stext-device.c76
-rw-r--r--source/fitz/stext-output.c2
-rw-r--r--source/fitz/svg-device.c55
-rw-r--r--source/fitz/test-device.c2
-rw-r--r--source/fitz/text.c49
-rw-r--r--source/fitz/util.c56
30 files changed, 1005 insertions, 1183 deletions
diff --git a/source/fitz/bbox-device.c b/source/fitz/bbox-device.c
index 37778741..7238936a 100644
--- a/source/fitz/bbox-device.c
+++ b/source/fitz/bbox-device.c
@@ -16,22 +16,21 @@ typedef struct fz_bbox_device_s
} fz_bbox_device;
static void
-fz_bbox_add_rect(fz_context *ctx, fz_device *dev, const fz_rect *rect, int clip)
+fz_bbox_add_rect(fz_context *ctx, fz_device *dev, fz_rect rect, int clip)
{
fz_bbox_device *bdev = (fz_bbox_device*)dev;
- fz_rect r = *rect;
if (0 < bdev->top && bdev->top <= STACK_SIZE)
{
- fz_intersect_rect(&r, &bdev->stack[bdev->top-1]);
+ rect = fz_intersect_rect(rect, bdev->stack[bdev->top-1]);
}
if (!clip && bdev->top <= STACK_SIZE && !bdev->ignore)
{
- fz_union_rect(bdev->result, &r);
+ *bdev->result = fz_union_rect(*bdev->result, rect);
}
if (clip && ++bdev->top <= STACK_SIZE)
{
- bdev->stack[bdev->top-1] = r;
+ bdev->stack[bdev->top-1] = rect;
}
}
@@ -39,89 +38,77 @@ static void
fz_bbox_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, *ctm), 0);
}
static void
fz_bbox_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke,
const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, *ctm), 0);
}
static void
fz_bbox_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, *ctm), 0);
}
static void
fz_bbox_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke,
const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, *ctm), 0);
}
static void
fz_bbox_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_shade(ctx, shade, ctm, &r), 0);
+ fz_bbox_add_rect(ctx, dev, fz_bound_shade(ctx, shade, *ctm), 0);
}
static void
fz_bbox_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
- fz_rect r = fz_unit_rect;
- fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 0);
+ fz_bbox_add_rect(ctx, dev, fz_transform_rect(fz_unit_rect, *ctm), 0);
}
static void
fz_bbox_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect r = fz_unit_rect;
- fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 0);
+ fz_bbox_add_rect(ctx, dev, fz_transform_rect(fz_unit_rect, *ctm), 0);
}
static void
fz_bbox_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, ctm, &r), 1);
+ fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, NULL, *ctm), 1);
}
static void
fz_bbox_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, ctm, &r), 1);
+ fz_bbox_add_rect(ctx, dev, fz_bound_path(ctx, path, stroke, *ctm), 1);
}
static void
fz_bbox_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, ctm, &r), 1);
+ fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, NULL, *ctm), 1);
}
static void
fz_bbox_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r;
- fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, ctm, &r), 1);
+ fz_bbox_add_rect(ctx, dev, fz_bound_text(ctx, text, stroke, *ctm), 1);
}
static void
fz_bbox_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect r = fz_unit_rect;
- fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 1);
+ fz_bbox_add_rect(ctx, dev, fz_transform_rect(fz_unit_rect, *ctm), 1);
}
static void
@@ -138,7 +125,7 @@ static void
fz_bbox_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *rect, int luminosity, fz_colorspace *colorspace, const float *color, const fz_color_params *color_params)
{
fz_bbox_device *bdev = (fz_bbox_device*)dev;
- fz_bbox_add_rect(ctx, dev, rect, 1);
+ fz_bbox_add_rect(ctx, dev, *rect, 1);
bdev->ignore++;
}
@@ -153,7 +140,7 @@ fz_bbox_end_mask(fz_context *ctx, fz_device *dev)
static void
fz_bbox_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *rect, fz_colorspace *cs, int isolated, int knockout, int blendmode, float alpha)
{
- fz_bbox_add_rect(ctx, dev, rect, 1);
+ fz_bbox_add_rect(ctx, dev, *rect, 1);
}
static void
@@ -166,8 +153,7 @@ static int
fz_bbox_begin_tile(fz_context *ctx, fz_device *dev, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm, int id)
{
fz_bbox_device *bdev = (fz_bbox_device*)dev;
- fz_rect r = *area;
- fz_bbox_add_rect(ctx, dev, fz_transform_rect(&r, ctm), 0);
+ fz_bbox_add_rect(ctx, dev, fz_transform_rect(*area, *ctm), 0);
bdev->ignore++;
return 0;
}
diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c
index 4cfeeb3e..54435743 100644
--- a/source/fitz/colorspace.c
+++ b/source/fitz/colorspace.c
@@ -2810,7 +2810,6 @@ icc_base_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorsp
int i, j;
unsigned char *inputpos, *outputpos;
fz_pixmap *base;
- fz_irect bbox;
int h, len;
float src_f[FZ_MAX_COLORS], des_f[FZ_MAX_COLORS];
int sn = src->n;
@@ -2819,7 +2818,7 @@ icc_base_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorsp
int stride_base;
int bn, bc;
- base = fz_new_pixmap_with_bbox(ctx, base_cs, fz_pixmap_bbox(ctx, src, &bbox), src->seps, src->alpha);
+ base = fz_new_pixmap_with_bbox(ctx, base_cs, fz_pixmap_bbox(ctx, src), src->seps, src->alpha);
bn = base->n;
bc = base->n - base->alpha - base->s;
stride_base = base->stride - base->w * bn;
@@ -3563,7 +3562,6 @@ fz_expand_indexed_pixmap(fz_context *ctx, const fz_pixmap *src, int alpha)
unsigned char *d;
int y, x, k, n, high;
unsigned char *lookup;
- fz_irect bbox;
int s_line_inc, d_line_inc;
assert(src->colorspace->to_ccs == indexed_to_rgb || src->colorspace->to_ccs == indexed_to_alt);
@@ -3574,7 +3572,7 @@ fz_expand_indexed_pixmap(fz_context *ctx, const fz_pixmap *src, int alpha)
lookup = idx->lookup;
n = idx->base->n;
- dst = fz_new_pixmap_with_bbox(ctx, idx->base, fz_pixmap_bbox(ctx, src, &bbox), src->seps, alpha);
+ dst = fz_new_pixmap_with_bbox(ctx, idx->base, fz_pixmap_bbox(ctx, src), src->seps, alpha);
s = src->samples;
d = dst->samples;
s_line_inc = src->stride - src->w * src->n;
diff --git a/source/fitz/device.c b/source/fitz/device.c
index 42377030..2cc4a2e7 100644
--- a/source/fitz/device.c
+++ b/source/fitz/device.c
@@ -99,8 +99,7 @@ push_clip_stack(fz_context *ctx, fz_device *dev, const fz_rect *rect, int flags)
dev->container[0].scissor = *rect;
else
{
- dev->container[dev->container_len].scissor = dev->container[dev->container_len-1].scissor;
- fz_intersect_rect(&dev->container[dev->container_len].scissor, rect);
+ dev->container[dev->container_len].scissor = fz_intersect_rect(dev->container[dev->container_len-1].scissor, *rect);
}
dev->container[dev->container_len].flags = flags;
dev->container[dev->container_len].user = 0;
@@ -149,8 +148,7 @@ fz_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd,
{
if (scissor == NULL)
{
- fz_rect bbox;
- fz_bound_path(ctx, path, NULL, ctm, &bbox);
+ fz_rect bbox = fz_bound_path(ctx, path, NULL, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_path);
}
else
@@ -182,8 +180,7 @@ fz_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const
{
if (scissor == NULL)
{
- fz_rect bbox;
- fz_bound_path(ctx, path, stroke, ctm, &bbox);
+ fz_rect bbox = fz_bound_path(ctx, path, stroke, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_stroke_path);
}
else
@@ -235,8 +232,7 @@ fz_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matr
{
if (scissor == NULL)
{
- fz_rect bbox;
- fz_bound_text(ctx, text, NULL, ctm, &bbox);
+ fz_rect bbox = fz_bound_text(ctx, text, NULL, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_text);
}
else
@@ -268,8 +264,7 @@ fz_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
{
if (scissor == NULL)
{
- fz_rect bbox;
- fz_bound_text(ctx, text, stroke, ctm, &bbox);
+ fz_rect bbox = fz_bound_text(ctx, text, stroke, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_stroke_text);
}
else
@@ -354,8 +349,7 @@ fz_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
{
if (scissor == NULL)
{
- fz_rect bbox = fz_unit_rect;
- fz_transform_rect(&bbox, ctm);
+ fz_rect bbox = fz_transform_rect(fz_unit_rect, *ctm);
push_clip_stack(ctx, dev, &bbox, fz_device_container_stack_is_clip_image_mask);
}
else
diff --git a/source/fitz/document.c b/source/fitz/document.c
index b74f7de5..3dc41a75 100644
--- a/source/fitz/document.c
+++ b/source/fitz/document.c
@@ -328,25 +328,23 @@ fz_load_page(fz_context *ctx, fz_document *doc, int number)
fz_link *
fz_load_links(fz_context *ctx, fz_page *page)
{
- if (page && page->load_links && page)
+ if (page && page->load_links)
return page->load_links(ctx, page);
return NULL;
}
-fz_rect *
-fz_bound_page(fz_context *ctx, fz_page *page, fz_rect *r)
+fz_rect
+fz_bound_page(fz_context *ctx, fz_page *page)
{
- if (page && page->bound_page && page && r)
- return page->bound_page(ctx, page, r);
- if (r)
- *r = fz_empty_rect;
- return r;
+ if (page && page->bound_page)
+ return page->bound_page(ctx, page);
+ return fz_empty_rect;
}
fz_annot *
fz_first_annot(fz_context *ctx, fz_page *page)
{
- if (page && page->first_annot && page)
+ if (page && page->first_annot)
return page->first_annot(ctx, page);
return NULL;
}
@@ -359,14 +357,12 @@ fz_next_annot(fz_context *ctx, fz_annot *annot)
return NULL;
}
-fz_rect *
-fz_bound_annot(fz_context *ctx, fz_annot *annot, fz_rect *rect)
+fz_rect
+fz_bound_annot(fz_context *ctx, fz_annot *annot)
{
- if (annot && annot->bound_annot && rect)
- return annot->bound_annot(ctx, annot, rect);
- if (rect)
- *rect = fz_empty_rect;
- return rect;
+ if (annot && annot->bound_annot)
+ return annot->bound_annot(ctx, annot);
+ return fz_empty_rect;
}
void
diff --git a/source/fitz/draw-affine.c b/source/fitz/draw-affine.c
index 129dfeb4..9f626415 100644
--- a/source/fitz/draw-affine.c
+++ b/source/fitz/draw-affine.c
@@ -3693,175 +3693,176 @@ fz_paint_affine_color_near_spots(int da, int sa, int fa, int fb, int dn, int sn,
* would not be safe in the general case, but gives less distortion across
* neighbouring images when tiling is used. We use this for .gproof files.
*/
-void
-fz_gridfit_matrix(int as_tiled, fz_matrix *m)
+fz_matrix
+fz_gridfit_matrix(int as_tiled, fz_matrix m)
{
- if (fabsf(m->b) < FLT_EPSILON && fabsf(m->c) < FLT_EPSILON)
+ if (fabsf(m.b) < FLT_EPSILON && fabsf(m.c) < FLT_EPSILON)
{
if (as_tiled)
{
float f;
/* Nearest boundary for left */
- f = (float)(int)(m->e + 0.5f);
- m->a += m->e - f; /* Adjust width for change */
- m->e = f;
+ f = (float)(int)(m.e + 0.5f);
+ m.a += m.e - f; /* Adjust width for change */
+ m.e = f;
/* Nearest boundary for right (width really) */
- m->a = (float)(int)(m->a + 0.5f);
+ m.a = (float)(int)(m.a + 0.5f);
}
- else if (m->a > 0)
+ else if (m.a > 0)
{
float f;
/* Adjust left hand side onto pixel boundary */
- f = (float)(int)(m->e);
- if (f - m->e > MY_EPSILON)
+ f = (float)(int)(m.e);
+ if (f - m.e > MY_EPSILON)
f -= 1.0f; /* Ensure it moves left */
- m->a += m->e - f; /* width gets wider as f <= m.e */
- m->e = f;
+ m.a += m.e - f; /* width gets wider as f <= m.e */
+ m.e = f;
/* Adjust right hand side onto pixel boundary */
- f = (float)(int)(m->a);
- if (m->a - f > MY_EPSILON)
+ f = (float)(int)(m.a);
+ if (m.a - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves right */
- m->a = f;
+ m.a = f;
}
- else if (m->a < 0)
+ else if (m.a < 0)
{
float f;
/* Adjust right hand side onto pixel boundary */
- f = (float)(int)(m->e);
- if (m->e - f > MY_EPSILON)
+ f = (float)(int)(m.e);
+ if (m.e - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves right */
- m->a += m->e - f; /* width gets wider (more -ve) */
- m->e = f;
+ m.a += m.e - f; /* width gets wider (more -ve) */
+ m.e = f;
/* Adjust left hand side onto pixel boundary */
- f = (float)(int)(m->a);
- if (f - m->a > MY_EPSILON)
+ f = (float)(int)(m.a);
+ if (f - m.a > MY_EPSILON)
f -= 1.0f; /* Ensure it moves left */
- m->a = f;
+ m.a = f;
}
if (as_tiled)
{
float f;
/* Nearest boundary for top */
- f = (float)(int)(m->f + 0.5f);
- m->d += m->f - f; /* Adjust width for change */
- m->f = f;
+ f = (float)(int)(m.f + 0.5f);
+ m.d += m.f - f; /* Adjust width for change */
+ m.f = f;
/* Nearest boundary for bottom (height really) */
- m->d = (float)(int)(m->d + 0.5f);
+ m.d = (float)(int)(m.d + 0.5f);
}
- else if (m->d > 0)
+ else if (m.d > 0)
{
float f;
/* Adjust top onto pixel boundary */
- f = (float)(int)(m->f);
- if (f - m->f > MY_EPSILON)
+ f = (float)(int)(m.f);
+ if (f - m.f > MY_EPSILON)
f -= 1.0f; /* Ensure it moves upwards */
- m->d += m->f - f; /* width gets wider as f <= m.f */
- m->f = f;
+ m.d += m.f - f; /* width gets wider as f <= m.f */
+ m.f = f;
/* Adjust bottom onto pixel boundary */
- f = (float)(int)(m->d);
- if (m->d - f > MY_EPSILON)
+ f = (float)(int)(m.d);
+ if (m.d - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves down */
- m->d = f;
+ m.d = f;
}
- else if (m->d < 0)
+ else if (m.d < 0)
{
float f;
/* Adjust bottom onto pixel boundary */
- f = (float)(int)(m->f);
- if (m->f - f > MY_EPSILON)
+ f = (float)(int)(m.f);
+ if (m.f - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves down */
- m->d += m->f - f; /* width gets wider (more -ve) */
- m->f = f;
+ m.d += m.f - f; /* width gets wider (more -ve) */
+ m.f = f;
/* Adjust top onto pixel boundary */
- f = (float)(int)(m->d);
- if (f - m->d > MY_EPSILON)
+ f = (float)(int)(m.d);
+ if (f - m.d > MY_EPSILON)
f -= 1.0f; /* Ensure it moves up */
- m->d = f;
+ m.d = f;
}
}
- else if (fabsf(m->a) < FLT_EPSILON && fabsf(m->d) < FLT_EPSILON)
+ else if (fabsf(m.a) < FLT_EPSILON && fabsf(m.d) < FLT_EPSILON)
{
if (as_tiled)
{
float f;
/* Nearest boundary for left */
- f = (float)(int)(m->e + 0.5f);
- m->b += m->e - f; /* Adjust width for change */
- m->e = f;
+ f = (float)(int)(m.e + 0.5f);
+ m.b += m.e - f; /* Adjust width for change */
+ m.e = f;
/* Nearest boundary for right (width really) */
- m->b = (float)(int)(m->b + 0.5f);
+ m.b = (float)(int)(m.b + 0.5f);
}
- else if (m->b > 0)
+ else if (m.b > 0)
{
float f;
/* Adjust left hand side onto pixel boundary */
- f = (float)(int)(m->f);
- if (f - m->f > MY_EPSILON)
+ f = (float)(int)(m.f);
+ if (f - m.f > MY_EPSILON)
f -= 1.0f; /* Ensure it moves left */
- m->b += m->f - f; /* width gets wider as f <= m.f */
- m->f = f;
+ m.b += m.f - f; /* width gets wider as f <= m.f */
+ m.f = f;
/* Adjust right hand side onto pixel boundary */
- f = (float)(int)(m->b);
- if (m->b - f > MY_EPSILON)
+ f = (float)(int)(m.b);
+ if (m.b - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves right */
- m->b = f;
+ m.b = f;
}
- else if (m->b < 0)
+ else if (m.b < 0)
{
float f;
/* Adjust right hand side onto pixel boundary */
- f = (float)(int)(m->f);
- if (m->f - f > MY_EPSILON)
+ f = (float)(int)(m.f);
+ if (m.f - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves right */
- m->b += m->f - f; /* width gets wider (more -ve) */
- m->f = f;
+ m.b += m.f - f; /* width gets wider (more -ve) */
+ m.f = f;
/* Adjust left hand side onto pixel boundary */
- f = (float)(int)(m->b);
- if (f - m->b > MY_EPSILON)
+ f = (float)(int)(m.b);
+ if (f - m.b > MY_EPSILON)
f -= 1.0f; /* Ensure it moves left */
- m->b = f;
+ m.b = f;
}
if (as_tiled)
{
float f;
/* Nearest boundary for left */
- f = (float)(int)(m->f + 0.5f);
- m->c += m->f - f; /* Adjust width for change */
- m->f = f;
+ f = (float)(int)(m.f + 0.5f);
+ m.c += m.f - f; /* Adjust width for change */
+ m.f = f;
/* Nearest boundary for right (width really) */
- m->c = (float)(int)(m->c + 0.5f);
+ m.c = (float)(int)(m.c + 0.5f);
}
- else if (m->c > 0)
+ else if (m.c > 0)
{
float f;
/* Adjust top onto pixel boundary */
- f = (float)(int)(m->e);
- if (f - m->e > MY_EPSILON)
+ f = (float)(int)(m.e);
+ if (f - m.e > MY_EPSILON)
f -= 1.0f; /* Ensure it moves upwards */
- m->c += m->e - f; /* width gets wider as f <= m.e */
- m->e = f;
+ m.c += m.e - f; /* width gets wider as f <= m.e */
+ m.e = f;
/* Adjust bottom onto pixel boundary */
- f = (float)(int)(m->c);
- if (m->c - f > MY_EPSILON)
+ f = (float)(int)(m.c);
+ if (m.c - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves down */
- m->c = f;
+ m.c = f;
}
- else if (m->c < 0)
+ else if (m.c < 0)
{
float f;
/* Adjust bottom onto pixel boundary */
- f = (float)(int)(m->e);
- if (m->e - f > MY_EPSILON)
+ f = (float)(int)(m.e);
+ if (m.e - f > MY_EPSILON)
f += 1.0f; /* Ensure it moves down */
- m->c += m->e - f; /* width gets wider (more -ve) */
- m->e = f;
+ m.c += m.e - f; /* width gets wider (more -ve) */
+ m.e = f;
/* Adjust top onto pixel boundary */
- f = (float)(int)(m->c);
- if (f - m->c > MY_EPSILON)
+ f = (float)(int)(m.c);
+ if (f - m.c > MY_EPSILON)
f -= 1.0f; /* Ensure it moves up */
- m->c = f;
+ m.c = f;
}
}
+ return m;
}
/* Draw an image with an affine transform on destination */
@@ -3876,19 +3877,18 @@ fz_paint_image_imp(fz_pixmap * FZ_RESTRICT dst, const fz_irect *scissor, fz_pixm
fz_irect bbox;
int dolerp;
paintfn_t *paintfn;
- fz_matrix local_ctm = *ctm;
- fz_rect rect;
+ fz_matrix local_ctm;
int is_rectilinear;
if (alpha == 0)
return;
/* grid fit the image */
- fz_gridfit_matrix(as_tiled, &local_ctm);
+ local_ctm = fz_gridfit_matrix(as_tiled, *ctm);
/* turn on interpolation for upscaled and non-rectilinear transforms */
dolerp = 0;
- is_rectilinear = fz_is_rectilinear(&local_ctm);
+ is_rectilinear = fz_is_rectilinear(local_ctm);
if (!is_rectilinear)
dolerp = lerp_allowed;
if (sqrtf(local_ctm.a * local_ctm.a + local_ctm.b * local_ctm.b) > img->w)
@@ -3905,9 +3905,8 @@ fz_paint_image_imp(fz_pixmap * FZ_RESTRICT dst, const fz_irect *scissor, fz_pixm
dolerp = 0;
}
- rect = fz_unit_rect;
- fz_irect_from_rect(&bbox, fz_transform_rect(&rect, &local_ctm));
- fz_intersect_irect(&bbox, scissor);
+ bbox = fz_irect_from_rect(fz_transform_rect(fz_unit_rect, local_ctm));
+ bbox = fz_intersect_irect(bbox, *scissor);
x = bbox.x0;
if (shape && shape->x > x)
@@ -3935,8 +3934,8 @@ fz_paint_image_imp(fz_pixmap * FZ_RESTRICT dst, const fz_irect *scissor, fz_pixm
return;
/* map from screen space (x,y) to image space (u,v) */
- fz_pre_scale(&local_ctm, 1.0f / img->w, 1.0f / img->h);
- fz_invert_matrix(&local_ctm, &local_ctm);
+ local_ctm = fz_pre_scale(local_ctm, 1.0f / img->w, 1.0f / img->h);
+ local_ctm = fz_invert_matrix(local_ctm);
fa = (int)(local_ctm.a *= 65536.0f);
fb = (int)(local_ctm.b *= 65536.0f);
diff --git a/source/fitz/draw-blend.c b/source/fitz/draw-blend.c
index 79f82046..21705a90 100644
--- a/source/fitz/draw-blend.c
+++ b/source/fitz/draw-blend.c
@@ -1073,7 +1073,6 @@ fz_blend_pixmap(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, fz_pixmap * FZ_RES
unsigned char *sp;
unsigned char *dp;
fz_irect bbox;
- fz_irect bbox2;
int x, y, w, h, n;
int da, sa;
int complement;
@@ -1098,9 +1097,7 @@ fz_blend_pixmap(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, fz_pixmap * FZ_RES
}
}
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
+ bbox = fz_intersect_irect(fz_pixmap_bbox(ctx, src), fz_pixmap_bbox(ctx, dst));
x = bbox.x0;
y = bbox.y0;
@@ -1298,15 +1295,14 @@ fz_blend_pixmap_knockout(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, fz_pixmap
{
unsigned char *sp;
unsigned char *dp;
- fz_irect bbox;
- fz_irect bbox2;
+ fz_irect sbox, dbox, bbox;
int x, y, w, h, n;
int da, sa;
const unsigned char *hp;
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
+ dbox = fz_pixmap_bbox_no_ctx(dst);
+ sbox = fz_pixmap_bbox_no_ctx(src);
+ bbox = fz_intersect_irect(dbox, sbox);
x = bbox.x0;
y = bbox.y0;
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index f497949a..63b20f67 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -209,14 +209,14 @@ fz_knockout_begin(fz_context *ctx, fz_draw_device *dev)
state = push_stack(ctx, dev);
STACK_PUSHED("knockout");
- fz_pixmap_bbox(ctx, state->dest, &bbox);
- fz_intersect_irect(&bbox, &state->scissor);
- dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, &bbox, state->dest->seps, state->dest->alpha);
+ bbox = fz_pixmap_bbox(ctx, state->dest);
+ bbox = fz_intersect_irect(bbox, state->scissor);
+ dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, bbox, state->dest->seps, state->dest->alpha);
if (state[0].group_alpha)
{
- fz_pixmap_bbox(ctx, state->group_alpha, &ga_bbox);
- fz_intersect_irect(&ga_bbox, &state->scissor);
- ga = fz_new_pixmap_with_bbox(ctx, state->group_alpha->colorspace, &ga_bbox, state->group_alpha->seps, state->group_alpha->alpha);
+ ga_bbox = fz_pixmap_bbox(ctx, state->group_alpha);
+ ga_bbox = fz_intersect_irect(ga_bbox, state->scissor);
+ ga = fz_new_pixmap_with_bbox(ctx, state->group_alpha->colorspace, ga_bbox, state->group_alpha->seps, state->group_alpha->alpha);
}
if (isolated)
@@ -238,11 +238,11 @@ fz_knockout_begin(fz_context *ctx, fz_draw_device *dev)
}
if (prev->dest)
{
- fz_copy_pixmap_rect(ctx, dest, prev->dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, dest, prev->dest, bbox, dev->default_cs);
if (ga)
{
if (prev->group_alpha)
- fz_copy_pixmap_rect(ctx, ga, prev->group_alpha, &ga_bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, ga, prev->group_alpha, ga_bbox, dev->default_cs);
else
fz_clear_pixmap(ctx, ga);
}
@@ -256,7 +256,7 @@ fz_knockout_begin(fz_context *ctx, fz_draw_device *dev)
}
/* Knockout groups (and only knockout groups) rely on shape */
- shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top-1, "");
@@ -341,13 +341,6 @@ static void fz_knockout_end(fz_context *ctx, fz_draw_device *dev)
#endif
}
-static inline fz_matrix concat(const fz_matrix *one, const fz_matrix *two)
-{
- fz_matrix ctm;
- fz_concat(&ctm, one, two);
- return ctm;
-}
-
static int
colors_supported(fz_context *ctx, fz_colorspace *cs, fz_pixmap *dest)
{
@@ -612,10 +605,10 @@ fz_draw_fill_path(fz_context *ctx, fz_device *devp, const fz_path *path, int eve
fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_rasterizer *rast = dev->rast;
fz_colorspace *colorspace = fz_default_colorspace(ctx, dev->default_cs, colorspace_in);
- float expansion = fz_matrix_expansion(&ctm);
+ float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
unsigned char colorbv[FZ_MAX_COLORS + 1];
fz_irect bbox;
@@ -629,7 +622,7 @@ fz_draw_fill_path(fz_context *ctx, fz_device *devp, const fz_path *path, int eve
if (flatness < 0.001f)
flatness = 0.001f;
- fz_intersect_irect(fz_pixmap_bbox_no_ctx(state->dest, &bbox), &state->scissor);
+ bbox = fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest), state->scissor);
if (fz_flatten_fill_path(ctx, rast, path, &ctm, flatness, &bbox, &bbox))
return;
@@ -665,10 +658,10 @@ fz_draw_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const
fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_rasterizer *rast = dev->rast;
fz_colorspace *colorspace = fz_default_colorspace(ctx, dev->default_cs, colorspace_in);
- float expansion = fz_matrix_expansion(&ctm);
+ float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
float linewidth = stroke->linewidth;
unsigned char colorbv[FZ_MAX_COLORS + 1];
@@ -689,7 +682,7 @@ fz_draw_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const
if (flatness < 0.001f)
flatness = 0.001f;
- fz_intersect_irect(fz_pixmap_bbox_no_ctx(state->dest, &bbox), &state->scissor);
+ bbox = fz_intersect_irect(fz_pixmap_bbox_no_ctx(state->dest), state->scissor);
if (fz_flatten_stroke_path(ctx, rast, path, stroke, &ctm, flatness, linewidth, &bbox, &bbox))
return;
@@ -742,12 +735,12 @@ static void
fz_draw_clip_path(fz_context *ctx, fz_device *devp, const fz_path *path, int even_odd, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_rasterizer *rast = dev->rast;
- float expansion = fz_matrix_expansion(&ctm);
+ float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
- fz_irect bbox, pixmap_bbox;
+ fz_irect bbox;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model;
@@ -763,16 +756,13 @@ fz_draw_clip_path(fz_context *ctx, fz_device *devp, const fz_path *path, int eve
if (scissor)
{
- fz_rect rect = *scissor;
- fz_transform_rect(&rect, &dev->transform);
- fz_irect_from_rect(&bbox, &rect);
- fz_intersect_irect(&bbox, &state->scissor);
- fz_intersect_irect(&bbox, fz_pixmap_bbox(ctx, state->dest, &pixmap_bbox));
+ bbox = fz_irect_from_rect(fz_transform_rect(*scissor, dev->transform));
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox(ctx, state->dest));
+ bbox = fz_intersect_irect(bbox, state->scissor);
}
else
{
- bbox = state->scissor;
- fz_intersect_irect(&bbox, fz_pixmap_bbox(ctx, state->dest, &pixmap_bbox));
+ bbox = fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest), state->scissor);
}
if (fz_flatten_fill_path(ctx, rast, path, &ctm, flatness, &bbox, &bbox) || fz_is_rect_rasterizer(ctx, rast))
@@ -787,18 +777,18 @@ fz_draw_clip_path(fz_context *ctx, fz_device *devp, const fz_path *path, int eve
fz_try(ctx)
{
- state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].mask);
- state[1].dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
- fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, &bbox, dev->default_cs);
+ state[1].dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
+ fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, bbox, dev->default_cs);
if (state[1].shape)
{
- state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].shape);
}
if (state[1].group_alpha)
{
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
@@ -819,13 +809,13 @@ static void
fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_rasterizer *rast = dev->rast;
- float expansion = fz_matrix_expansion(&ctm);
+ float expansion = fz_matrix_expansion(ctm);
float flatness = 0.3f / expansion;
float linewidth = stroke->linewidth;
- fz_irect bbox, pixmap_bbox;
+ fz_irect bbox;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model;
float aa_level = 2.0f/(fz_rasterizer_graphics_aa_level(rast)+2);
@@ -847,19 +837,15 @@ fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path,
if (scissor)
{
- fz_rect rect = *scissor;
- fz_transform_rect(&rect, &dev->transform);
- fz_irect_from_rect(&bbox, &rect);
- fz_intersect_irect(&bbox, &state->scissor);
- fz_intersect_irect(&bbox, fz_pixmap_bbox(ctx, state->dest, &pixmap_bbox));
+ bbox = fz_irect_from_rect(fz_transform_rect(*scissor, dev->transform));
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox(ctx, state->dest));
+ bbox = fz_intersect_irect(bbox, state->scissor);
}
else
{
- bbox = state->scissor;
- fz_intersect_irect(&bbox, fz_pixmap_bbox(ctx, state->dest, &pixmap_bbox));
+ bbox = fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest), state->scissor);
}
-
if (fz_flatten_stroke_path(ctx, rast, path, stroke, &ctm, flatness, linewidth, &bbox, &bbox))
{
state[1].scissor = bbox;
@@ -872,25 +858,25 @@ fz_draw_clip_stroke_path(fz_context *ctx, fz_device *devp, const fz_path *path,
fz_try(ctx)
{
- state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].mask);
/* When there is no alpha in the current destination (state[0].dest->alpha == 0)
* we have a choice. We can either create the new destination WITH alpha, or
* we can copy the old pixmap contents in. We opt for the latter here, but
* may want to revisit this decision in the future. */
- state[1].dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
+ state[1].dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
if (state[0].dest->alpha)
fz_clear_pixmap(ctx, state[1].dest);
else
- fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, bbox, dev->default_cs);
if (state->shape)
{
- state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].shape);
}
if (state->group_alpha)
{
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
@@ -913,16 +899,17 @@ draw_glyph(unsigned char *colorbv, fz_pixmap *dst, fz_glyph *glyph,
int xorig, int yorig, const fz_irect *scissor, fz_overprint *eop)
{
unsigned char *dp;
- fz_irect bbox, bbox2;
+ fz_irect bbox;
int x, y, w, h;
int skip_x, skip_y;
fz_pixmap *msk;
- fz_glyph_bbox_no_ctx(glyph, &bbox);
- fz_translate_irect(&bbox, xorig, yorig);
- fz_intersect_irect(&bbox, scissor); /* scissor < dst */
+ bbox = fz_glyph_bbox_no_ctx(glyph);
+ bbox = fz_translate_irect(bbox, xorig, yorig);
+ bbox = fz_intersect_irect(bbox, *scissor); /* scissor < dst */
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(dst));
- if (fz_is_empty_irect(fz_intersect_irect(&bbox, fz_pixmap_bbox_no_ctx(dst, &bbox2))))
+ if (fz_is_empty_irect(bbox))
return;
x = bbox.x0;
@@ -982,7 +969,7 @@ fz_draw_fill_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
unsigned char colorbv[FZ_MAX_COLORS + 1];
@@ -1029,7 +1016,7 @@ fz_draw_fill_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, &ctm);
+ trm = fz_concat(tm, ctm);
glyph = fz_render_glyph(ctx, span->font, gid, &trm, model, &state->scissor, state->dest->alpha, fz_rasterizer_text_aa_level(rast));
if (glyph)
@@ -1079,7 +1066,7 @@ fz_draw_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text, const
const fz_matrix *in_ctm, fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_draw_state *state = &dev->stack[dev->top];
unsigned char colorbv[FZ_MAX_COLORS + 1];
unsigned char solid = 255;
@@ -1118,7 +1105,7 @@ fz_draw_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text, const
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, &ctm);
+ trm = fz_concat(tm, ctm);
glyph = fz_render_stroked_glyph(ctx, span->font, gid, &trm, &ctm, stroke, &state->scissor, aa);
if (glyph)
@@ -1156,7 +1143,7 @@ static void
fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_irect bbox;
fz_pixmap *mask, *dest, *shape, *group_alpha;
fz_matrix tm, trm;
@@ -1165,7 +1152,6 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
fz_draw_state *state;
fz_colorspace *model;
fz_text_span *span;
- fz_rect rect;
fz_rasterizer *rast = dev->rast;
if (dev->top == 0 && dev->resolve_spots)
@@ -1176,39 +1162,37 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
model = state->dest->colorspace;
/* make the mask the exact size needed */
- fz_irect_from_rect(&bbox, fz_bound_text(ctx, text, NULL, &ctm, &rect));
- fz_intersect_irect(&bbox, &state->scissor);
+ bbox = fz_irect_from_rect(fz_bound_text(ctx, text, NULL, ctm));
+ bbox = fz_intersect_irect(bbox, state->scissor);
if (scissor)
{
- fz_irect bbox2;
- fz_rect tscissor = *scissor;
- fz_transform_rect(&tscissor, &dev->transform);
- fz_intersect_irect(&bbox, fz_irect_from_rect(&bbox2, &tscissor));
+ fz_rect tscissor = fz_transform_rect(*scissor, dev->transform);
+ bbox = fz_intersect_irect(bbox, fz_irect_from_rect(tscissor));
}
fz_try(ctx)
{
- mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, mask);
/* When there is no alpha in the current destination (state[0].dest->alpha == 0)
* we have a choice. We can either create the new destination WITH alpha, or
* we can copy the old pixmap contents in. We opt for the latter here, but
* may want to revisit this decision in the future. */
- dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
+ dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
if (state[0].dest->alpha)
fz_clear_pixmap(ctx, dest);
else
- fz_copy_pixmap_rect(ctx, dest, state[0].dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, dest, state[0].dest, bbox, dev->default_cs);
if (state->shape)
{
- shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
}
else
shape = NULL;
if (state->group_alpha)
{
- group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, group_alpha);
}
else
@@ -1224,7 +1208,7 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
dump_spaces(dev->top-1, "Clip (text) begin\n");
#endif
- if (!fz_is_empty_irect(&bbox) && mask)
+ if (!fz_is_empty_irect(bbox) && mask)
{
for (span = text->head; span; span = span->next)
{
@@ -1238,7 +1222,7 @@ fz_draw_clip_text(fz_context *ctx, fz_device *devp, const fz_text *text, const f
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, &ctm);
+ trm = fz_concat(tm, ctm);
glyph = fz_render_glyph(ctx, span->font, gid, &trm, model, &state->scissor, state[1].dest->alpha, fz_rasterizer_text_aa_level(rast));
if (glyph)
@@ -1297,7 +1281,7 @@ static void
fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_irect bbox;
fz_pixmap *mask, *dest, *shape, *group_alpha;
fz_matrix tm, trm;
@@ -1306,47 +1290,45 @@ fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text,
fz_draw_state *state = push_stack(ctx, dev);
fz_colorspace *model = state->dest->colorspace;
fz_text_span *span;
- fz_rect rect;
int aa = fz_rasterizer_text_aa_level(dev->rast);
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, fz_default_color_params(ctx)/* FIXME */, dev->default_cs);
STACK_PUSHED("clip stroke text");
+
/* make the mask the exact size needed */
- fz_irect_from_rect(&bbox, fz_bound_text(ctx, text, stroke, &ctm, &rect));
- fz_intersect_irect(&bbox, &state->scissor);
+ bbox = fz_irect_from_rect(fz_bound_text(ctx, text, stroke, ctm));
+ bbox = fz_intersect_irect(bbox, state->scissor);
if (scissor)
{
- fz_irect bbox2;
- fz_rect tscissor = *scissor;
- fz_transform_rect(&tscissor, &dev->transform);
- fz_intersect_irect(&bbox, fz_irect_from_rect(&bbox2, &tscissor));
+ fz_rect tscissor = fz_transform_rect(*scissor, dev->transform);
+ bbox = fz_intersect_irect(bbox, fz_irect_from_rect(tscissor));
}
fz_try(ctx)
{
- state[1].mask = mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].mask = mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, mask);
/* When there is no alpha in the current destination (state[0].dest->alpha == 0)
* we have a choice. We can either create the new destination WITH alpha, or
* we can copy the old pixmap contents in. We opt for the latter here, but
* may want to revisit this decision in the future. */
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
if (state[0].dest->alpha)
fz_clear_pixmap(ctx, state[1].dest);
else
- fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, bbox, dev->default_cs);
if (state->shape)
{
- state[1].shape = shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
}
else
shape = state->shape;
if (state->group_alpha)
{
- state[1].group_alpha = group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, group_alpha);
}
else
@@ -1358,7 +1340,7 @@ fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text,
dump_spaces(dev->top-1, "Clip (stroke text) begin\n");
#endif
- if (!fz_is_empty_irect(&bbox))
+ if (!fz_is_empty_irect(bbox))
{
for (span = text->head; span; span = span->next)
{
@@ -1372,7 +1354,7 @@ fz_draw_clip_stroke_text(fz_context *ctx, fz_device *devp, const fz_text *text,
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, &ctm);
+ trm = fz_concat(tm, ctm);
glyph = fz_render_stroked_glyph(ctx, span->font, gid, &trm, &ctm, stroke, &state->scissor, aa);
if (glyph)
@@ -1437,8 +1419,7 @@ static void
fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_matrix *in_ctm, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
- fz_rect bounds;
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_irect bbox, scissor;
fz_pixmap *dest, *shape, *group_alpha;
unsigned char colorbv[FZ_MAX_COLORS + 1];
@@ -1451,11 +1432,11 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, color_params, dev->default_cs);
- fz_bound_shade(ctx, shade, &ctm, &bounds);
scissor = state->scissor;
- fz_intersect_irect(fz_irect_from_rect(&bbox, &bounds), &scissor);
+ bbox = fz_irect_from_rect(fz_bound_shade(ctx, shade, ctm));
+ bbox = fz_intersect_irect(bbox, scissor);
- if (fz_is_empty_irect(&bbox))
+ if (fz_is_empty_irect(bbox))
return;
if (color_params == NULL)
@@ -1470,19 +1451,19 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
if (alpha < 1)
{
- dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, &bbox, state->dest->seps, state->dest->alpha);
+ dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, bbox, state->dest->seps, state->dest->alpha);
if (state->dest->alpha)
fz_clear_pixmap(ctx, dest);
else
- fz_copy_pixmap_rect(ctx, dest, state[0].dest, &bbox, dev->default_cs);
+ fz_copy_pixmap_rect(ctx, dest, state[0].dest, bbox, dev->default_cs);
if (shape)
{
- shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
}
if (group_alpha)
{
- group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, group_alpha);
}
}
@@ -1563,9 +1544,9 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
fz_paint_shade(ctx, shade, colorspace, &ctm, dest, color_params, &bbox, eop);
if (shape)
- fz_clear_pixmap_rect_with_value(ctx, shape, 255, &bbox);
+ fz_clear_pixmap_rect_with_value(ctx, shape, 255, bbox);
if (group_alpha)
- fz_clear_pixmap_rect_with_value(ctx, group_alpha, 255, &bbox);
+ fz_clear_pixmap_rect_with_value(ctx, group_alpha, 255, bbox);
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top, "");
@@ -1609,7 +1590,7 @@ fz_transform_pixmap(fz_context *ctx, fz_draw_device *dev, const fz_pixmap *image
fz_matrix m = *ctm;
if (gridfit)
{
- fz_gridfit_matrix(dev->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, &m);
+ m = fz_gridfit_matrix(dev->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, m);
}
scaled = fz_scale_pixmap_cached(ctx, image, m.e, m.f, m.a, m.d, clip, dev->cache_x, dev->cache_y);
if (!scaled)
@@ -1627,7 +1608,7 @@ fz_transform_pixmap(fz_context *ctx, fz_draw_device *dev, const fz_pixmap *image
fz_matrix m = *ctm;
fz_irect rclip;
if (gridfit)
- fz_gridfit_matrix(dev->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, &m);
+ m = fz_gridfit_matrix(dev->flags & FZ_DEVFLAG_GRIDFIT_AS_TILED, m);
if (clip)
{
rclip.x0 = clip->y0;
@@ -1704,7 +1685,7 @@ static void
fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_matrix *in_ctm, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix local_ctm = concat(in_ctm, &dev->transform);
+ fz_matrix local_ctm = fz_concat(*in_ctm, dev->transform);
fz_pixmap *pixmap;
int after;
int dx, dy;
@@ -1724,7 +1705,7 @@ fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_m
state = push_group_for_separations(ctx, dev, color_params, dev->default_cs);
model = state->dest->colorspace;
- fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest, &clip), &state->scissor);
+ clip = fz_intersect_irect(fz_pixmap_bbox(ctx, state->dest), state->scissor);
if (image->w == 0 || image->h == 0)
return;
@@ -1735,7 +1716,7 @@ fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_m
/* ctm maps the image (expressed as the unit square) onto the
* destination device. Reverse that to get a mapping from
* the destination device to the source pixels. */
- if (fz_try_invert_matrix(&inverse, &local_ctm))
+ if (fz_try_invert_matrix(&inverse, local_ctm))
{
/* Not invertible. Could just bail? Use the whole image
* for now. */
@@ -1750,20 +1731,20 @@ fz_draw_fill_image(fz_context *ctx, fz_device *devp, fz_image *image, const fz_m
fz_rect rect;
fz_irect sane;
/* We want to scale from image coords, not from unit square */
- fz_post_scale(&inverse, image->w, image->h);
+ inverse = fz_post_scale(inverse, image->w, image->h);
/* Are we scaling up or down? exp < 1 means scaling down. */
- exp = fz_matrix_max_expansion(&inverse);
- fz_rect_from_irect(&rect, &clip);
- fz_transform_rect(&rect, &inverse);
+ exp = fz_matrix_max_expansion(inverse);
+ rect = fz_rect_from_irect(clip);
+ rect = fz_transform_rect(rect, inverse);
/* Allow for support requirements for scalers. */
- fz_expand_rect(&rect, fz_max(exp, 1) * 4);
- fz_irect_from_rect(&src_area, &rect);
+ rect = fz_expand_rect(rect, fz_max(exp, 1) * 4);
+ src_area = fz_irect_from_rect(rect);
sane.x0 = 0;
sane.y0 = 0;
sane.x1 = image->w;
sane.y1 = image->h;
- fz_intersect_irect(&src_area, &sane);
- if (fz_is_empty_irect(&src_area))
+ src_area = fz_intersect_irect(src_area, sane);
+ if (fz_is_empty_irect(src_area))
return;
}
@@ -1852,7 +1833,7 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
fz_colorspace *colorspace_in, const float *color, float alpha, const fz_color_params *color_params)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix local_ctm = concat(in_ctm, &dev->transform);
+ fz_matrix local_ctm = fz_concat(*in_ctm, dev->transform);
unsigned char colorbv[FZ_MAX_COLORS + 1];
fz_pixmap *scaled = NULL;
fz_pixmap *pixmap;
@@ -1874,8 +1855,8 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
if (colorspace_in)
colorspace = fz_default_colorspace(ctx, dev->default_cs, colorspace_in);
- fz_pixmap_bbox(ctx, state->dest, &clip);
- fz_intersect_irect(&clip, &state->scissor);
+ clip = fz_pixmap_bbox(ctx, state->dest);
+ clip = fz_intersect_irect(clip, state->scissor);
if (image->w == 0 || image->h == 0)
return;
@@ -1883,7 +1864,7 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
/* ctm maps the image (expressed as the unit square) onto the
* destination device. Reverse that to get a mapping from
* the destination device to the source pixels. */
- if (fz_try_invert_matrix(&inverse, &local_ctm))
+ if (fz_try_invert_matrix(&inverse, local_ctm))
{
/* Not invertible. Could just bail? Use the whole image
* for now. */
@@ -1898,20 +1879,20 @@ fz_draw_fill_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
fz_rect rect;
fz_irect sane;
/* We want to scale from image coords, not from unit square */
- fz_post_scale(&inverse, image->w, image->h);
+ inverse = fz_post_scale(inverse, image->w, image->h);
/* Are we scaling up or down? exp < 1 means scaling down. */
- exp = fz_matrix_max_expansion(&inverse);
- fz_rect_from_irect(&rect, &clip);
- fz_transform_rect(&rect, &inverse);
+ exp = fz_matrix_max_expansion(inverse);
+ rect = fz_rect_from_irect(clip);
+ rect = fz_transform_rect(rect, inverse);
/* Allow for support requirements for scalers. */
- fz_expand_rect(&rect, fz_max(exp, 1) * 4);
- fz_irect_from_rect(&src_area, &rect);
+ rect = fz_expand_rect(rect, fz_max(exp, 1) * 4);
+ src_area = fz_irect_from_rect(rect);
sane.x0 = 0;
sane.y0 = 0;
sane.x1 = image->w;
sane.y1 = image->h;
- fz_intersect_irect(&src_area, &sane);
- if (fz_is_empty_irect(&src_area))
+ src_area = fz_intersect_irect(src_area, sane);
+ if (fz_is_empty_irect(src_area))
return;
}
@@ -1960,7 +1941,7 @@ static void
fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const fz_matrix *in_ctm, const fz_rect *scissor)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix local_ctm = concat(in_ctm, &dev->transform);
+ fz_matrix local_ctm = fz_concat(*in_ctm, dev->transform);
fz_irect bbox;
fz_pixmap *scaled = NULL;
fz_pixmap *pixmap = NULL;
@@ -1968,14 +1949,13 @@ fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
fz_draw_state *state = push_stack(ctx, dev);
fz_colorspace *model = state->dest->colorspace;
fz_irect clip;
- fz_rect urect;
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, fz_default_color_params(ctx)/* FIXME */, dev->default_cs);
STACK_PUSHED("clip image mask");
- fz_pixmap_bbox(ctx, state->dest, &clip);
- fz_intersect_irect(&clip, &state->scissor);
+ clip = fz_pixmap_bbox(ctx, state->dest);
+ clip = fz_intersect_irect(clip, state->scissor);
if (image->w == 0 || image->h == 0)
{
@@ -1991,34 +1971,31 @@ fz_draw_clip_image_mask(fz_context *ctx, fz_device *devp, fz_image *image, const
dump_spaces(dev->top-1, "Clip (image mask) begin\n");
#endif
- urect = fz_unit_rect;
- fz_irect_from_rect(&bbox, fz_transform_rect(&urect, &local_ctm));
- fz_intersect_irect(&bbox, &state->scissor);
+ bbox = fz_irect_from_rect(fz_transform_rect(fz_unit_rect, local_ctm));
+ bbox = fz_intersect_irect(bbox, state->scissor);
if (scissor)
{
- fz_irect bbox2;
- fz_rect tscissor = *scissor;
- fz_transform_rect(&tscissor, &dev->transform);
- fz_intersect_irect(&bbox, fz_irect_from_rect(&bbox2, &tscissor));
+ fz_rect tscissor = fz_transform_rect(*scissor, dev->transform);
+ bbox = fz_intersect_irect(bbox, fz_irect_from_rect(tscissor));
}
pixmap = fz_get_pixmap_from_image(ctx, image, NULL, &local_ctm, &dx, &dy);
fz_try(ctx)
{
- state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].mask = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].mask);
- state[1].dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha);
- fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, &bbox, dev->default_cs);
+ state[1].dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha);
+ fz_copy_pixmap_rect(ctx, state[1].dest, state[0].dest, bbox, dev->default_cs);
if (state[0].shape)
{
- state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].shape);
}
if (state[0].group_alpha)
{
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
@@ -2145,7 +2122,7 @@ fz_draw_begin_mask(fz_context *ctx, fz_device *devp, const fz_rect *rect, int lu
fz_draw_state *state = push_stack(ctx, dev);
fz_pixmap *shape = state->shape;
fz_pixmap *group_alpha = state->group_alpha;
- fz_rect trect = *rect;
+ fz_rect trect;
fz_colorspace *colorspace = NULL;
if (dev->top == 0 && dev->resolve_spots)
@@ -2158,8 +2135,8 @@ fz_draw_begin_mask(fz_context *ctx, fz_device *devp, const fz_rect *rect, int lu
color_params = fz_default_color_params(ctx);
STACK_PUSHED("mask");
- fz_transform_rect(&trect, &dev->transform);
- fz_intersect_irect(fz_irect_from_rect(&bbox, &trect), &state->scissor);
+ trect = fz_transform_rect(*rect, dev->transform);
+ bbox = fz_intersect_irect(fz_irect_from_rect(trect), state->scissor);
/* Reset the blendmode for the mask rendering. In particular,
* don't carry forward knockout or isolated. */
@@ -2171,9 +2148,9 @@ fz_draw_begin_mask(fz_context *ctx, fz_device *devp, const fz_rect *rect, int lu
* If !luminosity, then we generate a mask from the alpha value of the shapes.
*/
if (luminosity)
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, fz_device_gray(ctx), &bbox, NULL, 0);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, fz_device_gray(ctx), bbox, NULL, 0);
else
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
if (state->shape)
{
/* FIXME: If we ever want to support AIS true, then
@@ -2268,9 +2245,9 @@ fz_draw_end_mask(fz_context *ctx, fz_device *devp)
#endif
/* create new dest scratch buffer */
- fz_pixmap_bbox(ctx, temp, &bbox);
- dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, &bbox, state->dest->seps, state->dest->alpha);
- fz_copy_pixmap_rect(ctx, dest, state->dest, &bbox, dev->default_cs);
+ bbox = fz_pixmap_bbox(ctx, temp);
+ dest = fz_new_pixmap_with_bbox(ctx, state->dest->colorspace, bbox, state->dest->seps, state->dest->alpha);
+ fz_copy_pixmap_rect(ctx, dest, state->dest, bbox, dev->default_cs);
/* push soft mask as clip mask */
state[1].dest = dest;
@@ -2279,12 +2256,12 @@ fz_draw_end_mask(fz_context *ctx, fz_device *devp)
* clip mask when we pop. So create a new shape now. */
if (state[0].shape)
{
- state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].shape);
}
if (state[0].group_alpha)
{
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
state[1].scissor = bbox;
@@ -2303,7 +2280,7 @@ fz_draw_begin_group(fz_context *ctx, fz_device *devp, const fz_rect *rect, fz_co
fz_pixmap *dest;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
- fz_rect trect = *rect;
+ fz_rect trect;
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, fz_default_color_params(ctx)/* FIXME */, dev->default_cs);
@@ -2316,8 +2293,8 @@ fz_draw_begin_group(fz_context *ctx, fz_device *devp, const fz_rect *rect, fz_co
state = push_stack(ctx, dev);
STACK_PUSHED("group");
- fz_transform_rect(&trect, &dev->transform);
- fz_intersect_irect(fz_irect_from_rect(&bbox, &trect), &state->scissor);
+ trect = fz_transform_rect(*rect, dev->transform);
+ bbox = fz_intersect_irect(fz_irect_from_rect(trect), state->scissor);
fz_try(ctx)
{
@@ -2326,7 +2303,7 @@ fz_draw_begin_group(fz_context *ctx, fz_device *devp, const fz_rect *rect, fz_co
isolated = 1;
#endif
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, state[0].dest->alpha || isolated);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, state[0].dest->alpha || isolated);
if (isolated)
{
@@ -2335,8 +2312,8 @@ fz_draw_begin_group(fz_context *ctx, fz_device *devp, const fz_rect *rect, fz_co
}
else
{
- fz_copy_pixmap_rect(ctx, dest, state[0].dest, &bbox, dev->default_cs);
- state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ fz_copy_pixmap_rect(ctx, dest, state[0].dest, bbox, dev->default_cs);
+ state[1].group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, state[1].group_alpha);
}
@@ -2607,13 +2584,13 @@ static int
fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *in_ctm, int id)
{
fz_draw_device *dev = (fz_draw_device*)devp;
- fz_matrix ctm = concat(in_ctm, &dev->transform);
+ fz_matrix ctm = fz_concat(*in_ctm, dev->transform);
fz_pixmap *dest = NULL;
fz_pixmap *shape, *group_alpha;
fz_irect bbox;
fz_draw_state *state = &dev->stack[dev->top];
fz_colorspace *model = state->dest->colorspace;
- fz_rect local_view = *view;
+ fz_rect local_view;
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, fz_default_color_params(ctx)/* FIXME */, dev->default_cs);
@@ -2626,7 +2603,8 @@ fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const
state = push_stack(ctx, dev);
STACK_PUSHED("tile");
- fz_irect_from_rect(&bbox, fz_transform_rect(&local_view, &ctm));
+ local_view = fz_transform_rect(*view, ctm);
+ bbox = fz_irect_from_rect(local_view);
/* We should never have a bbox that entirely covers our destination.
* If we do, then the check for only 1 tile being visible above has
* failed. Actually, this *can* fail due to the round_rect, at extreme
@@ -2658,7 +2636,7 @@ fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const
state[1].ystep = ystep;
state[1].id = id;
state[1].encache = 0;
- fz_irect_from_rect(&state[1].area, area);
+ state[1].area = fz_irect_from_rect(*area);
state[1].ctm = ctm;
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top-1, "Tile begin (cached)\n");
@@ -2673,18 +2651,18 @@ fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const
fz_try(ctx)
{
/* Patterns can be transparent, so we need to have an alpha here. */
- state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, &bbox, state[0].dest->seps, 1);
+ state[1].dest = dest = fz_new_pixmap_with_bbox(ctx, model, bbox, state[0].dest->seps, 1);
fz_clear_pixmap(ctx, dest);
shape = state[0].shape;
if (shape)
{
- state[1].shape = shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].shape = shape = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, shape);
}
group_alpha = state[0].group_alpha;
if (group_alpha)
{
- state[1].group_alpha = group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, &bbox, NULL, 1);
+ state[1].group_alpha = group_alpha = fz_new_pixmap_with_bbox(ctx, NULL, bbox, NULL, 1);
fz_clear_pixmap(ctx, group_alpha);
}
state[1].blendmode |= FZ_BLEND_ISOLATED;
@@ -2692,7 +2670,7 @@ fz_draw_begin_tile(fz_context *ctx, fz_device *devp, const fz_rect *area, const
state[1].ystep = ystep;
state[1].id = id;
state[1].encache = 1;
- fz_irect_from_rect(&state[1].area, area);
+ state[1].area = fz_irect_from_rect(*area);
state[1].ctm = ctm;
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top-1, "Tile begin\n");
@@ -2737,16 +2715,20 @@ fz_draw_end_tile(fz_context *ctx, fz_device *devp)
/* Fudge the scissor bbox a little to allow for inaccuracies in the
* matrix inversion. */
- fz_rect_from_irect(&scissor_tmp, &state[0].scissor);
- fz_transform_rect(fz_expand_rect(&scissor_tmp, 1), fz_invert_matrix(&ttm, &ctm));
- fz_intersect_irect(&area, fz_irect_from_rect(&scissor, &scissor_tmp));
+ ttm = fz_invert_matrix(ctm);
+ scissor_tmp = fz_rect_from_irect(state[0].scissor);
+ scissor_tmp = fz_expand_rect(scissor_tmp, 1);
+ scissor_tmp = fz_transform_rect(scissor_tmp, ttm);
+ scissor = fz_irect_from_rect(scissor_tmp);
+ area = fz_intersect_irect(area, scissor);
tile_bbox.x0 = state[1].dest->x;
tile_bbox.y0 = state[1].dest->y;
tile_bbox.x1 = state[1].dest->w + tile_bbox.x0;
tile_bbox.y1 = state[1].dest->h + tile_bbox.y0;
- fz_rect_from_irect(&tile_tmp, &tile_bbox);
- fz_transform_rect(fz_expand_rect(&tile_tmp, 1), &ttm);
+ tile_tmp = fz_rect_from_irect(tile_bbox);
+ tile_tmp = fz_expand_rect(tile_tmp, 1);
+ tile_tmp = fz_transform_rect(tile_tmp, ttm);
/* FIXME: area is a bbox, so FP not appropriate here */
/* In PDF files xstep/ystep can be smaller than view (the area of a
@@ -2807,8 +2789,7 @@ fz_draw_end_tile(fz_context *ctx, fz_device *devp)
{
for (x = x0; x < x1; x++)
{
- ttm = ctm;
- fz_pre_translate(&ttm, x * xstep, y * ystep);
+ ttm = fz_pre_translate(ctm, x * xstep, y * ystep);
dest->x = ttm.e;
dest->y = ttm.f;
/* Check for overflow due to float -> int conversions */
@@ -2819,16 +2800,14 @@ fz_draw_end_tile(fz_context *ctx, fz_device *devp)
fz_paint_pixmap_with_bbox(state[0].dest, dest, 255, state[0].scissor);
if (shape)
{
- ttm = shapectm;
- fz_pre_translate(&ttm, x * xstep, y * ystep);
+ ttm = fz_pre_translate(shapectm, x * xstep, y * ystep);
shape->x = ttm.e;
shape->y = ttm.f;
fz_paint_pixmap_with_bbox(state[0].shape, shape, 255, state[0].scissor);
}
if (group_alpha)
{
- ttm = gactm;
- fz_pre_translate(&ttm, x * xstep, y * ystep);
+ ttm = fz_pre_translate(gactm, x * xstep, y * ystep);
group_alpha->x = ttm.e;
group_alpha->y = ttm.f;
fz_paint_pixmap_with_bbox(state[0].group_alpha, group_alpha, 255, state[0].scissor);
@@ -3251,9 +3230,9 @@ fz_new_draw_device_with_options(fz_context *ctx, const fz_draw_options *opts, co
fz_set_rasterizer_graphics_aa_level(ctx, &aa, opts->graphics);
fz_set_rasterizer_text_aa_level(ctx, &aa, opts->text);
- fz_pre_rotate(fz_scale(&transform, x_zoom, y_zoom), opts->rotate);
+ transform = fz_pre_rotate(fz_scale(x_zoom, y_zoom), opts->rotate);
bounds = *mediabox;
- fz_round_rect(&ibounds, fz_transform_rect(&bounds, &transform));
+ ibounds = fz_round_rect(fz_transform_rect(bounds, transform));
/* If width or height are set, we may need to adjust the transform */
if (w || h)
@@ -3277,13 +3256,13 @@ fz_new_draw_device_with_options(fz_context *ctx, const fz_draw_options *opts, co
}
if (scalex != 1 || scaley != 1)
{
- fz_pre_scale(&transform, scalex, scaley);
+ transform = fz_pre_scale(transform, scalex, scaley);
bounds = *mediabox;
- fz_round_rect(&ibounds, fz_transform_rect(&bounds, &transform));
+ ibounds = fz_round_rect(fz_transform_rect(bounds, transform));
}
}
- *pixmap = fz_new_pixmap_with_bbox(ctx, opts->colorspace, &ibounds, NULL/* FIXME */, opts->alpha);
+ *pixmap = fz_new_pixmap_with_bbox(ctx, opts->colorspace, ibounds, NULL/* FIXME */, opts->alpha);
fz_try(ctx)
{
fz_set_pixmap_resolution(ctx, *pixmap, opts->x_resolution, opts->y_resolution);
diff --git a/source/fitz/draw-glyph.c b/source/fitz/draw-glyph.c
index 75bfd616..7696a59c 100644
--- a/source/fitz/draw-glyph.c
+++ b/source/fitz/draw-glyph.c
@@ -138,7 +138,7 @@ fz_keep_glyph_cache(fz_context *ctx)
float
fz_subpixel_adjust(fz_context *ctx, fz_matrix *ctm, fz_matrix *subpix_ctm, unsigned char *qe, unsigned char *qf)
{
- float size = fz_matrix_expansion(ctm);
+ float size = fz_matrix_expansion(*ctm);
int q;
float pix_e, pix_f, r;
diff --git a/source/fitz/draw-imp.h b/source/fitz/draw-imp.h
index 9c160e6e..eb3e36d2 100644
--- a/source/fitz/draw-imp.h
+++ b/source/fitz/draw-imp.h
@@ -267,7 +267,7 @@ static inline void fz_drop_rasterizer(fz_context *ctx, fz_rasterizer *r)
After this, the edges should be 'inserted' into the rasterizer.
*/
-int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *r, const fz_irect *clip);
+int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *r, fz_irect clip);
/*
fz_insert_rasterizer: Insert an edge into a rasterizer.
@@ -342,13 +342,13 @@ static inline void fz_postindex_rasterizer(fz_context *ctx, fz_rasterizer *r)
fz_bound_rasterizer: Once a set of edges has been fed into a
rasterizer, the (device space) bounding box can be retrieved.
*/
-fz_irect *fz_bound_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_irect *bbox);
+fz_irect fz_bound_rasterizer(fz_context *ctx, const fz_rasterizer *rast);
/*
fz_scissor_rasterizer: Retrieve the clipping box with which the
rasterizer was reset.
*/
-fz_rect *fz_scissor_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_rect *r);
+fz_rect fz_scissor_rasterizer(fz_context *ctx, const fz_rasterizer *rast);
/*
fz_convert_rasterizer: Convert the set of edges that have
diff --git a/source/fitz/draw-mesh.c b/source/fitz/draw-mesh.c
index a248170e..5a3bef40 100644
--- a/source/fitz/draw-mesh.c
+++ b/source/fitz/draw-mesh.c
@@ -230,13 +230,13 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *colorspace, cons
fz_try(ctx)
{
- fz_concat(&local_ctm, &shade->matrix, ctm);
+ local_ctm = fz_concat(shade->matrix, *ctm);
if (shade->use_function)
{
/* We need to use alpha = 1 here, because the shade might not fill
* the bbox. */
- temp = fz_new_pixmap_with_bbox(ctx, fz_device_gray(ctx), bbox, NULL, 1);
+ temp = fz_new_pixmap_with_bbox(ctx, fz_device_gray(ctx), *bbox, NULL, 1);
fz_clear_pixmap(ctx, temp);
}
else
@@ -249,7 +249,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *colorspace, cons
ptd.bbox = bbox;
fz_init_cached_color_converter(ctx, &ptd.cc, NULL, temp->colorspace, colorspace, color_params);
- fz_process_shade(ctx, shade, &local_ctm, prepare_mesh_vertex, &do_paint_tri, &ptd);
+ fz_process_shade(ctx, shade, local_ctm, prepare_mesh_vertex, &do_paint_tri, &ptd);
if (shade->use_function)
{
@@ -275,7 +275,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *colorspace, cons
int n = fz_colorspace_n(ctx, colorspace);
/* alpha = 1 here for the same reason as earlier */
- conv = fz_new_pixmap_with_bbox(ctx, colorspace, bbox, NULL, 1);
+ conv = fz_new_pixmap_with_bbox(ctx, colorspace, *bbox, NULL, 1);
d = conv->samples;
while (hh--)
{
@@ -322,7 +322,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *colorspace, cons
}
fz_drop_color_converter(ctx, &cc);
- conv = fz_new_pixmap_with_bbox(ctx, dest->colorspace, bbox, dest->seps, 1);
+ conv = fz_new_pixmap_with_bbox(ctx, dest->colorspace, *bbox, dest->seps, 1);
d = conv->samples;
da = conv->alpha;
while (hh--)
diff --git a/source/fitz/draw-paint.c b/source/fitz/draw-paint.c
index 9485565d..027fe538 100644
--- a/source/fitz/draw-paint.c
+++ b/source/fitz/draw-paint.c
@@ -2171,7 +2171,6 @@ fz_paint_pixmap_with_bbox(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_REST
const unsigned char *sp;
unsigned char *dp;
int x, y, w, h, n, da, sa;
- fz_irect bbox2;
fz_span_painter_t *fn;
assert(dst->n - dst->alpha == src->n - src->alpha);
@@ -2179,10 +2178,8 @@ fz_paint_pixmap_with_bbox(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_REST
if (alpha == 0)
return;
- fz_pixmap_bbox_no_ctx(dst, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(dst));
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(src));
x = bbox.x0;
y = bbox.y0;
@@ -2217,7 +2214,6 @@ fz_paint_pixmap(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_RESTRICT src,
const unsigned char *sp;
unsigned char *dp;
fz_irect bbox;
- fz_irect bbox2;
int x, y, w, h, n, da, sa;
fz_span_painter_t *fn;
@@ -2231,10 +2227,7 @@ fz_paint_pixmap(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_RESTRICT src,
}
assert(dst->n - dst->alpha == src->n - src->alpha);
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
-
+ bbox = fz_intersect_irect(fz_pixmap_bbox_no_ctx(src), fz_pixmap_bbox_no_ctx(dst));
x = bbox.x0;
y = bbox.y0;
w = bbox.x1 - bbox.x0;
@@ -2300,7 +2293,6 @@ fz_paint_pixmap_alpha(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_RESTRICT
const unsigned char *sp;
unsigned char *dp;
fz_irect bbox;
- fz_irect bbox2;
int x, y, w, h, n;
if (alpha == 0)
@@ -2308,10 +2300,7 @@ fz_paint_pixmap_alpha(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_RESTRICT
assert(dst->n == 1 && dst->alpha == 1 && src->n >= 1 && src->alpha == 1);
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
-
+ bbox = fz_intersect_irect(fz_pixmap_bbox_no_ctx(src), fz_pixmap_bbox_no_ctx(dst));
x = bbox.x0;
y = bbox.y0;
w = bbox.x1 - bbox.x0;
@@ -2349,7 +2338,6 @@ fz_paint_pixmap_with_overprint(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ
const unsigned char *sp;
unsigned char *dp;
fz_irect bbox;
- fz_irect bbox2;
int x, y, w, h, n, da, sa;
fz_span_painter_t *fn;
@@ -2360,10 +2348,7 @@ fz_paint_pixmap_with_overprint(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ
}
assert(dst->n - dst->alpha == src->n - src->alpha);
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
-
+ bbox = fz_intersect_irect(fz_pixmap_bbox_no_ctx(src), fz_pixmap_bbox_no_ctx(dst));
x = bbox.x0;
y = bbox.y0;
w = bbox.x1 - bbox.x0;
@@ -2396,18 +2381,16 @@ fz_paint_pixmap_with_mask(fz_pixmap * FZ_RESTRICT dst, const fz_pixmap * FZ_REST
{
const unsigned char *sp, *mp;
unsigned char *dp;
- fz_irect bbox, bbox2;
+ fz_irect bbox;
int x, y, w, h, n, sa, da;
fz_span_mask_painter_t *fn;
assert(dst->n == src->n);
assert(msk->n == 1);
- fz_pixmap_bbox_no_ctx(dst, &bbox);
- fz_pixmap_bbox_no_ctx(src, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
- fz_pixmap_bbox_no_ctx(msk, &bbox2);
- fz_intersect_irect(&bbox, &bbox2);
+ bbox = fz_pixmap_bbox_no_ctx(dst);
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(src));
+ bbox = fz_intersect_irect(bbox, fz_pixmap_bbox_no_ctx(msk));
x = bbox.x0;
y = bbox.y0;
diff --git a/source/fitz/draw-path.c b/source/fitz/draw-path.c
index 52c4af2f..74456df5 100644
--- a/source/fitz/draw-path.c
+++ b/source/fitz/draw-path.c
@@ -268,9 +268,8 @@ int
fz_flatten_fill_path(fz_context *ctx, fz_rasterizer *rast, const fz_path *path, const fz_matrix *ctm, float flatness, const fz_irect *scissor, fz_irect *bbox)
{
flatten_arg arg;
- fz_irect local_bbox;
- if (fz_reset_rasterizer(ctx, rast, scissor))
+ if (fz_reset_rasterizer(ctx, rast, *scissor))
{
arg.rast = rast;
arg.ctm = ctm;
@@ -300,9 +299,8 @@ fz_flatten_fill_path(fz_context *ctx, fz_rasterizer *rast, const fz_path *path,
if (!bbox)
return 0;
- local_bbox = *scissor;
- fz_bound_rasterizer(ctx, rast, bbox);
- return fz_is_empty_irect(fz_intersect_irect(bbox, &local_bbox));
+ *bbox = fz_bound_rasterizer(ctx, rast);
+ return fz_is_empty_irect(fz_intersect_irect(*bbox, *scissor));
}
enum {
@@ -1456,16 +1454,16 @@ do_flatten_stroke(fz_context *ctx, fz_rasterizer *rast, const fz_path *path, con
if (s.dash_total == 0)
return 1;
- fz_scissor_rasterizer(ctx, rast, &s.rect);
- if (fz_try_invert_matrix(&inv, ctm))
+ s.rect = fz_scissor_rasterizer(ctx, rast);
+ if (fz_try_invert_matrix(&inv, *ctm))
return 1;
- fz_transform_rect(&s.rect, &inv);
+ s.rect = fz_transform_rect(s.rect, inv);
s.rect.x0 -= linewidth;
s.rect.x1 += linewidth;
s.rect.y0 -= linewidth;
s.rect.y1 += linewidth;
- max_expand = fz_matrix_max_expansion(ctm);
+ max_expand = fz_matrix_max_expansion(*ctm);
if (s.dash_total >= 0.01f && s.dash_total * max_expand >= 0.5f)
{
proc = &dash_proc;
@@ -1481,14 +1479,14 @@ do_flatten_stroke(fz_context *ctx, fz_rasterizer *rast, const fz_path *path, con
if (!bbox)
return 0;
- return fz_is_empty_irect(fz_bound_rasterizer(ctx, rast, bbox));
+ *bbox = fz_bound_rasterizer(ctx, rast);
+ return fz_is_empty_irect(*bbox);
}
int
fz_flatten_stroke_path(fz_context *ctx, fz_rasterizer *rast, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, float flatness, float linewidth, const fz_irect *scissor, fz_irect *bbox)
{
-
- if (fz_reset_rasterizer(ctx, rast, scissor))
+ if (fz_reset_rasterizer(ctx, rast, *scissor))
{
if (do_flatten_stroke(ctx, rast, path, stroke, ctm, flatness, linewidth, scissor, bbox))
return 1;
diff --git a/source/fitz/draw-rasterize.c b/source/fitz/draw-rasterize.c
index 8a094c80..793d813a 100644
--- a/source/fitz/draw-rasterize.c
+++ b/source/fitz/draw-rasterize.c
@@ -188,53 +188,56 @@ fz_rasterizer_graphics_min_line_width(fz_rasterizer *ras)
return ras->aa.min_line_width;
}
-fz_irect *
-fz_bound_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_irect *bbox)
+fz_irect
+fz_bound_rasterizer(fz_context *ctx, const fz_rasterizer *rast)
{
+ fz_irect bbox;
const int hscale = fz_rasterizer_aa_hscale(rast);
const int vscale = fz_rasterizer_aa_vscale(rast);
if (rast->bbox.x1 < rast->bbox.x0 || rast->bbox.y1 < rast->bbox.y0)
{
- *bbox = fz_empty_irect;
+ bbox = fz_empty_irect;
}
else
{
- bbox->x0 = fz_idiv(rast->bbox.x0, hscale);
- bbox->y0 = fz_idiv(rast->bbox.y0, vscale);
- bbox->x1 = fz_idiv_up(rast->bbox.x1, hscale);
- bbox->y1 = fz_idiv_up(rast->bbox.y1, vscale);
+ bbox.x0 = fz_idiv(rast->bbox.x0, hscale);
+ bbox.y0 = fz_idiv(rast->bbox.y0, vscale);
+ bbox.x1 = fz_idiv_up(rast->bbox.x1, hscale);
+ bbox.y1 = fz_idiv_up(rast->bbox.y1, vscale);
}
return bbox;
}
-fz_rect *fz_scissor_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_rect *r)
+fz_rect fz_scissor_rasterizer(fz_context *ctx, const fz_rasterizer *rast)
{
+ fz_rect r;
const int hscale = fz_rasterizer_aa_hscale(rast);
const int vscale = fz_rasterizer_aa_vscale(rast);
- r->x0 = ((float)rast->clip.x0) / hscale;
- r->y0 = ((float)rast->clip.y0) / vscale;
- r->x1 = ((float)rast->clip.x1) / hscale;
- r->y1 = ((float)rast->clip.y1) / vscale;
+ r.x0 = ((float)rast->clip.x0) / hscale;
+ r.y0 = ((float)rast->clip.y0) / vscale;
+ r.x1 = ((float)rast->clip.x1) / hscale;
+ r.y1 = ((float)rast->clip.y1) / vscale;
return r;
}
-static fz_irect *fz_clip_rasterizer(fz_context *ctx, const fz_rasterizer *rast, fz_irect *r)
+static fz_irect fz_clip_rasterizer(fz_context *ctx, const fz_rasterizer *rast)
{
+ fz_irect r;
const int hscale = fz_rasterizer_aa_hscale(rast);
const int vscale = fz_rasterizer_aa_vscale(rast);
- r->x0 = fz_idiv(rast->clip.x0, hscale);
- r->y0 = fz_idiv(rast->clip.y0, vscale);
- r->x1 = fz_idiv_up(rast->clip.x1, hscale);
- r->y1 = fz_idiv_up(rast->clip.y1, vscale);
+ r.x0 = fz_idiv(rast->clip.x0, hscale);
+ r.y0 = fz_idiv(rast->clip.y0, vscale);
+ r.x1 = fz_idiv_up(rast->clip.x1, hscale);
+ r.y1 = fz_idiv_up(rast->clip.y1, vscale);
return r;
}
-int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *rast, const fz_irect *clip)
+int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *rast, fz_irect clip)
{
const int hscale = fz_rasterizer_aa_hscale(rast);
const int vscale = fz_rasterizer_aa_vscale(rast);
@@ -245,10 +248,10 @@ int fz_reset_rasterizer(fz_context *ctx, fz_rasterizer *rast, const fz_irect *cl
rast->clip.x1 = rast->clip.y1 = BBOX_MAX;
}
else {
- rast->clip.x0 = clip->x0 * hscale;
- rast->clip.x1 = clip->x1 * hscale;
- rast->clip.y0 = clip->y0 * vscale;
- rast->clip.y1 = clip->y1 * vscale;
+ rast->clip.x0 = clip.x0 * hscale;
+ rast->clip.x1 = clip.x1 * hscale;
+ rast->clip.y0 = clip.y0 * vscale;
+ rast->clip.y1 = clip.y1 * vscale;
}
rast->bbox.x0 = rast->bbox.y0 = BBOX_MAX;
@@ -299,12 +302,9 @@ fz_rasterizer *fz_new_rasterizer(fz_context *ctx, const fz_aa_context *aa)
void fz_convert_rasterizer(fz_context *ctx, fz_rasterizer *r, int eofill, fz_pixmap *pix, unsigned char *colorbv, fz_overprint *eop)
{
- fz_irect clip, scissor;
- fz_irect pixmap_clip;
-
- if (fz_is_empty_irect(fz_intersect_irect(fz_bound_rasterizer(ctx, r, &clip), fz_pixmap_bbox_no_ctx(pix, &pixmap_clip))))
- return;
- if (fz_is_empty_irect(fz_intersect_irect(&clip, fz_clip_rasterizer(ctx, r, &scissor))))
- return;
- r->fns.convert(ctx, r, eofill, &clip, pix, colorbv, eop);
+ fz_irect clip = fz_bound_rasterizer(ctx, r);
+ clip = fz_intersect_irect(clip, fz_pixmap_bbox_no_ctx(pix));
+ clip = fz_intersect_irect(clip, fz_clip_rasterizer(ctx, r));
+ if (!fz_is_empty_irect(clip))
+ r->fns.convert(ctx, r, eofill, &clip, pix, colorbv, eop);
}
diff --git a/source/fitz/draw-scale-simple.c b/source/fitz/draw-scale-simple.c
index fdc79817..54c0114d 100644
--- a/source/fitz/draw-scale-simple.c
+++ b/source/fitz/draw-scale-simple.c
@@ -1526,7 +1526,7 @@ adjust_alpha_edges(fz_pixmap * FZ_RESTRICT pix, const fz_weights * FZ_RESTRICT r
}
fz_pixmap *
-fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_irect *clip)
+fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, const fz_irect *clip)
{
return fz_scale_pixmap_cached(ctx, src, x, y, w, h, clip, NULL, NULL);
}
diff --git a/source/fitz/font.c b/source/fitz/font.c
index c39174ee..d7c58d0d 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -752,7 +752,7 @@ fz_adjust_ft_glyph_width(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm
/* Sanity check scaling in case of broken metrics. */
if (realw > 0 && subw > 0)
- fz_pre_scale(trm, subw / realw, 1);
+ *trm = fz_pre_scale(*trm, subw / realw, 1);
}
return trm;
@@ -786,12 +786,12 @@ do_ft_render_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm
FT_Error fterr;
fz_matrix local_trm = *trm;
- float strength = fz_matrix_expansion(trm) * 0.02f;
+ float strength = fz_matrix_expansion(*trm) * 0.02f;
fz_adjust_ft_glyph_width(ctx, font, gid, &local_trm);
if (font->flags.fake_italic)
- fz_pre_shear(&local_trm, SHEAR, 0);
+ local_trm = fz_pre_shear(local_trm, SHEAR, 0);
/*
Freetype mutilates complex glyphs if they are loaded
@@ -817,7 +817,7 @@ do_ft_render_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm
if (aa == 0)
{
/* enable grid fitting for non-antialiased rendering */
- float scale = fz_matrix_expansion(&local_trm);
+ float scale = fz_matrix_expansion(local_trm);
m.xx = local_trm.a * 65536 / scale;
m.yx = local_trm.b * 65536 / scale;
m.xy = local_trm.c * 65536 / scale;
@@ -923,7 +923,7 @@ static FT_Glyph
do_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state, int aa)
{
FT_Face face = font->ft_face;
- float expansion = fz_matrix_expansion(ctm);
+ float expansion = fz_matrix_expansion(*ctm);
int linewidth = state->linewidth * expansion * 64 / 2;
FT_Matrix m;
FT_Vector v;
@@ -937,7 +937,7 @@ do_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_mat
fz_adjust_ft_glyph_width(ctx, font, gid, &local_trm);
if (font->flags.fake_italic)
- fz_pre_shear(&local_trm, SHEAR, 0);
+ local_trm = fz_pre_shear(local_trm, SHEAR, 0);
m.xx = local_trm.a * 64; /* should be 65536 */
m.yx = local_trm.b * 64;
@@ -1094,7 +1094,7 @@ fz_bound_ft_glyph(fz_context *ctx, fz_font *font, int gid)
fz_adjust_ft_glyph_width(ctx, font, gid, &local_trm);
if (font->flags.fake_italic)
- fz_pre_shear(&local_trm, SHEAR, 0);
+ local_trm = fz_pre_shear(local_trm, SHEAR, 0);
m.xx = local_trm.a * 65536;
m.yx = local_trm.b * 65536;
@@ -1135,7 +1135,7 @@ fz_bound_ft_glyph(fz_context *ctx, fz_font *font, int gid)
bounds->x1 = cbox.xMax * recip;
bounds->y1 = cbox.yMax * recip;
- if (fz_is_empty_rect(bounds))
+ if (fz_is_empty_rect(*bounds))
{
bounds->x0 = bounds->x1 = local_trm.e;
bounds->y0 = bounds->y1 = local_trm.f;
@@ -1159,7 +1159,7 @@ static int move_to(const FT_Vector *p, void *cc_)
fz_path *path = cc->path;
fz_point pt;
- fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
+ pt = fz_transform_point_xy(p->x, p->y, cc->trm);
fz_moveto(ctx, path, pt.x, pt.y);
return 0;
}
@@ -1171,7 +1171,7 @@ static int line_to(const FT_Vector *p, void *cc_)
fz_path *path = cc->path;
fz_point pt;
- fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
+ pt = fz_transform_point_xy(p->x, p->y, cc->trm);
fz_lineto(ctx, path, pt.x, pt.y);
return 0;
}
@@ -1183,8 +1183,8 @@ static int conic_to(const FT_Vector *c, const FT_Vector *p, void *cc_)
fz_path *path = cc->path;
fz_point ct, pt;
- fz_transform_point_xy(&ct, &cc->trm, c->x, c->y);
- fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
+ ct = fz_transform_point_xy(c->x, c->y, cc->trm);
+ pt = fz_transform_point_xy(p->x, p->y, cc->trm);
fz_quadto(ctx, path, ct.x, ct.y, pt.x, pt.y);
return 0;
@@ -1197,9 +1197,9 @@ static int cubic_to(const FT_Vector *c1, const FT_Vector *c2, const FT_Vector *p
fz_path *path = cc->path;
fz_point c1t, c2t, pt;
- fz_transform_point_xy(&c1t, &cc->trm, c1->x, c1->y);
- fz_transform_point_xy(&c2t, &cc->trm, c2->x, c2->y);
- fz_transform_point_xy(&pt, &cc->trm, p->x, p->y);
+ c1t = fz_transform_point_xy(c1->x, c1->y, cc->trm);
+ c2t = fz_transform_point_xy(c2->x, c2->y, cc->trm);
+ pt = fz_transform_point_xy(p->x, p->y, cc->trm);
fz_curveto(ctx, path, c1t.x, c1t.y, c2t.x, c2t.y, pt.x, pt.y);
return 0;
@@ -1224,7 +1224,7 @@ fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *tr
fz_adjust_ft_glyph_width(ctx, font, gid, &local_trm);
if (font->flags.fake_italic)
- fz_pre_shear(&local_trm, SHEAR, 0);
+ local_trm = fz_pre_shear(local_trm, SHEAR, 0);
fz_lock(ctx, FZ_LOCK_FREETYPE);
@@ -1247,7 +1247,7 @@ fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *tr
{
cc.ctx = ctx;
cc.path = fz_new_path(ctx);
- fz_concat(&cc.trm, fz_scale(&cc.trm, recip, recip), &local_trm);
+ cc.trm = fz_concat(fz_scale(recip, recip), local_trm);
fz_moveto(ctx, cc.path, cc.trm.e, cc.trm.f);
FT_Outline_Decompose(&face->glyph->outline, &outline_funcs, &cc);
fz_closepath(ctx, cc.path);
@@ -1271,7 +1271,7 @@ fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *tr
*/
fz_font *
-fz_new_type3_font(fz_context *ctx, const char *name, const fz_matrix *matrix)
+fz_new_type3_font(fz_context *ctx, const char *name, fz_matrix matrix)
{
fz_font *font;
@@ -1289,7 +1289,7 @@ fz_new_type3_font(fz_context *ctx, const char *name, const fz_matrix *matrix)
fz_rethrow(ctx);
}
- font->t3matrix = *matrix;
+ font->t3matrix = matrix;
return font;
}
@@ -1324,7 +1324,7 @@ fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid)
/* Update font bbox with glyph's computed bbox if the font bbox is invalid */
if (font->flags.invalid_bbox)
- fz_union_rect(&font->bbox, &font->bbox_table[gid]);
+ font->bbox = fz_union_rect(font->bbox, font->bbox_table[gid]);
}
void
@@ -1341,7 +1341,7 @@ fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth)
/* We've not already loaded this one! */
assert(font->t3lists[gid] == NULL);
- font->t3lists[gid] = fz_new_display_list(ctx, &font->bbox);
+ font->t3lists[gid] = fz_new_display_list(ctx, font->bbox);
dev = fz_new_list_device(ctx, font->t3lists[gid]);
dev->flags = FZ_DEVFLAG_FILLCOLOR_UNDEFINED |
@@ -1376,10 +1376,9 @@ fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth)
{
assert(font->bbox_table != NULL);
assert(font->glyph_count > gid);
- font->bbox_table[gid] = d1_rect;
- fz_transform_rect(&font->bbox_table[gid], &font->t3matrix);
+ font->bbox_table[gid] = fz_transform_rect(d1_rect, font->t3matrix);
- if (font->flags.invalid_bbox || !fz_contains_rect(&font->bbox, &d1_rect))
+ if (font->flags.invalid_bbox || !fz_contains_rect(font->bbox, d1_rect))
{
/* Either the font bbox is invalid, or the d1_rect returned is
* incompatible with it. Either way, don't trust the d1 rect
@@ -1404,7 +1403,7 @@ fz_run_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, f
if (!list)
return;
- fz_concat(&ctm, &font->t3matrix, trm);
+ ctm = fz_concat(font->t3matrix, *trm);
fz_run_display_list(ctx, list, dev, &ctm, &fz_infinite_rect, NULL);
}
@@ -1442,12 +1441,12 @@ fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matr
model = NULL; /* Treat as masked */
}
- fz_expand_rect(fz_bound_glyph(ctx, font, gid, trm, &bounds), 1);
- fz_irect_from_rect(&bbox, &bounds);
- fz_intersect_irect(&bbox, scissor);
+ bounds = fz_expand_rect(fz_bound_glyph(ctx, font, gid, *trm), 1);
+ bbox = fz_irect_from_rect(bounds);
+ bbox = fz_intersect_irect(bbox, *scissor);
/* Glyphs must always have alpha */
- glyph = fz_new_pixmap_with_bbox(ctx, model, &bbox, NULL/* FIXME */, 1);
+ glyph = fz_new_pixmap_with_bbox(ctx, model, bbox, NULL/* FIXME */, 1);
fz_var(dev);
fz_try(ctx)
@@ -1521,16 +1520,17 @@ fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gi
fz_warn(ctx, "type3 glyph doesn't specify masked or colored");
}
- fz_concat(&ctm, &font->t3matrix, trm);
+ ctm = fz_concat(font->t3matrix, *trm);
font->t3run(ctx, font->t3doc, font->t3resources, contents, dev, &ctm, gstate, nested_depth, def_cs);
}
-fz_rect *
-fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_rect *rect)
+fz_rect
+fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm)
{
+ fz_rect rect;
if (font->bbox_table && gid < font->glyph_count)
{
- if (fz_is_infinite_rect(&font->bbox_table[gid]))
+ if (fz_is_infinite_rect(font->bbox_table[gid]))
{
if (font->ft_face)
fz_bound_ft_glyph(ctx, font, gid);
@@ -1539,16 +1539,15 @@ fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz
else
font->bbox_table[gid] = fz_empty_rect;
}
- *rect = font->bbox_table[gid];
+ rect = font->bbox_table[gid];
if (fz_is_empty_rect(rect))
- *rect = font->bbox;
+ rect = font->bbox;
}
else
{
/* fall back to font bbox */
- *rect = font->bbox;
+ rect = font->bbox;
}
-
return fz_transform_rect(rect, trm);
}
diff --git a/source/fitz/geometry.c b/source/fitz/geometry.c
index 7cced024..e31a9435 100644
--- a/source/fitz/geometry.c
+++ b/source/fitz/geometry.c
@@ -29,75 +29,77 @@
const fz_matrix fz_identity = { 1, 0, 0, 1, 0, 0 };
-fz_matrix *
-fz_concat(fz_matrix *dst, const fz_matrix *one, const fz_matrix *two)
-{
- fz_matrix dst2;
- dst2.a = one->a * two->a + one->b * two->c;
- dst2.b = one->a * two->b + one->b * two->d;
- dst2.c = one->c * two->a + one->d * two->c;
- dst2.d = one->c * two->b + one->d * two->d;
- dst2.e = one->e * two->a + one->f * two->c + two->e;
- dst2.f = one->e * two->b + one->f * two->d + two->f;
- *dst = dst2;
+fz_matrix
+fz_concat(fz_matrix one, fz_matrix two)
+{
+ fz_matrix dst;
+ dst.a = one.a * two.a + one.b * two.c;
+ dst.b = one.a * two.b + one.b * two.d;
+ dst.c = one.c * two.a + one.d * two.c;
+ dst.d = one.c * two.b + one.d * two.d;
+ dst.e = one.e * two.a + one.f * two.c + two.e;
+ dst.f = one.e * two.b + one.f * two.d + two.f;
return dst;
}
-fz_matrix *
-fz_scale(fz_matrix *m, float sx, float sy)
+fz_matrix
+fz_scale(float sx, float sy)
{
- m->a = sx; m->b = 0;
- m->c = 0; m->d = sy;
- m->e = 0; m->f = 0;
+ fz_matrix m;
+ m.a = sx; m.b = 0;
+ m.c = 0; m.d = sy;
+ m.e = 0; m.f = 0;
return m;
}
-fz_matrix *
-fz_pre_scale(fz_matrix *mat, float sx, float sy)
+fz_matrix
+fz_pre_scale(fz_matrix m, float sx, float sy)
{
- mat->a *= sx;
- mat->b *= sx;
- mat->c *= sy;
- mat->d *= sy;
- return mat;
+ m.a *= sx;
+ m.b *= sx;
+ m.c *= sy;
+ m.d *= sy;
+ return m;
}
-fz_matrix *
-fz_post_scale(fz_matrix *mat, float sx, float sy)
+fz_matrix
+fz_post_scale(fz_matrix m, float sx, float sy)
{
- mat->a *= sx;
- mat->b *= sy;
- mat->c *= sx;
- mat->d *= sy;
- mat->e *= sx;
- mat->f *= sy;
- return mat;
+ m.a *= sx;
+ m.b *= sy;
+ m.c *= sx;
+ m.d *= sy;
+ m.e *= sx;
+ m.f *= sy;
+ return m;
}
-fz_matrix *
-fz_shear(fz_matrix *mat, float h, float v)
+fz_matrix
+fz_shear(float h, float v)
{
- mat->a = 1; mat->b = v;
- mat->c = h; mat->d = 1;
- mat->e = 0; mat->f = 0;
- return mat;
+ fz_matrix m;
+ m.a = 1; m.b = v;
+ m.c = h; m.d = 1;
+ m.e = 0; m.f = 0;
+ return m;
}
-fz_matrix *
-fz_pre_shear(fz_matrix *mat, float h, float v)
+fz_matrix
+fz_pre_shear(fz_matrix m, float h, float v)
{
- float a = mat->a;
- float b = mat->b;
- mat->a += v * mat->c;
- mat->b += v * mat->d;
- mat->c += h * a;
- mat->d += h * b;
- return mat;
+ float a = m.a;
+ float b = m.b;
+ m.a += v * m.c;
+ m.b += v * m.d;
+ m.c += h * a;
+ m.d += h * b;
+ return m;
}
-fz_matrix *
-fz_rotate(fz_matrix *m, float theta)
+fz_matrix
+fz_rotate(float theta)
{
+ fz_matrix m;
float s;
float c;
@@ -132,14 +134,14 @@ fz_rotate(fz_matrix *m, float theta)
c = cosf(theta * FZ_PI / 180);
}
- m->a = c; m->b = s;
- m->c = -s; m->d = c;
- m->e = 0; m->f = 0;
+ m.a = c; m.b = s;
+ m.c = -s; m.d = c;
+ m.e = 0; m.f = 0;
return m;
}
-fz_matrix *
-fz_pre_rotate(fz_matrix *m, float theta)
+fz_matrix
+fz_pre_rotate(fz_matrix m, float theta)
{
while (theta < 0)
theta += 360;
@@ -152,90 +154,90 @@ fz_pre_rotate(fz_matrix *m, float theta)
}
else if (fabsf(90.0f - theta) < FLT_EPSILON)
{
- float a = m->a;
- float b = m->b;
- m->a = m->c;
- m->b = m->d;
- m->c = -a;
- m->d = -b;
+ float a = m.a;
+ float b = m.b;
+ m.a = m.c;
+ m.b = m.d;
+ m.c = -a;
+ m.d = -b;
}
else if (fabsf(180.0f - theta) < FLT_EPSILON)
{
- m->a = -m->a;
- m->b = -m->b;
- m->c = -m->c;
- m->d = -m->d;
+ m.a = -m.a;
+ m.b = -m.b;
+ m.c = -m.c;
+ m.d = -m.d;
}
else if (fabsf(270.0f - theta) < FLT_EPSILON)
{
- float a = m->a;
- float b = m->b;
- m->a = -m->c;
- m->b = -m->d;
- m->c = a;
- m->d = b;
+ float a = m.a;
+ float b = m.b;
+ m.a = -m.c;
+ m.b = -m.d;
+ m.c = a;
+ m.d = b;
}
else
{
float s = sinf(theta * FZ_PI / 180);
float c = cosf(theta * FZ_PI / 180);
- float a = m->a;
- float b = m->b;
- m->a = c * a + s * m->c;
- m->b = c * b + s * m->d;
- m->c =-s * a + c * m->c;
- m->d =-s * b + c * m->d;
+ float a = m.a;
+ float b = m.b;
+ m.a = c * a + s * m.c;
+ m.b = c * b + s * m.d;
+ m.c =-s * a + c * m.c;
+ m.d =-s * b + c * m.d;
}
return m;
}
-fz_matrix *
-fz_translate(fz_matrix *m, float tx, float ty)
+fz_matrix
+fz_translate(float tx, float ty)
{
- m->a = 1; m->b = 0;
- m->c = 0; m->d = 1;
- m->e = tx; m->f = ty;
+ fz_matrix m;
+ m.a = 1; m.b = 0;
+ m.c = 0; m.d = 1;
+ m.e = tx; m.f = ty;
return m;
}
-fz_matrix *
-fz_pre_translate(fz_matrix *mat, float tx, float ty)
+fz_matrix
+fz_pre_translate(fz_matrix m, float tx, float ty)
{
- mat->e += tx * mat->a + ty * mat->c;
- mat->f += tx * mat->b + ty * mat->d;
- return mat;
+ m.e += tx * m.a + ty * m.c;
+ m.f += tx * m.b + ty * m.d;
+ return m;
}
-fz_matrix *
-fz_invert_matrix(fz_matrix *dst, const fz_matrix *src)
+fz_matrix
+fz_invert_matrix(fz_matrix src)
{
- /* Be careful to cope with dst == src */
- float a = src->a;
- float det = a * src->d - src->b * src->c;
+ float a = src.a;
+ float det = a * src.d - src.b * src.c;
if (det < -FLT_EPSILON || det > FLT_EPSILON)
{
+ fz_matrix dst;
float rdet = 1 / det;
- dst->a = src->d * rdet;
- dst->b = -src->b * rdet;
- dst->c = -src->c * rdet;
- dst->d = a * rdet;
- a = -src->e * dst->a - src->f * dst->c;
- dst->f = -src->e * dst->b - src->f * dst->d;
- dst->e = a;
+ dst.a = src.d * rdet;
+ dst.b = -src.b * rdet;
+ dst.c = -src.c * rdet;
+ dst.d = a * rdet;
+ a = -src.e * dst.a - src.f * dst.c;
+ dst.f = -src.e * dst.b - src.f * dst.d;
+ dst.e = a;
+ return dst;
}
- else
- *dst = *src;
- return dst;
+ return src;
}
int
-fz_try_invert_matrix(fz_matrix *dst, const fz_matrix *src)
+fz_try_invert_matrix(fz_matrix *dst, fz_matrix src)
{
- double sa = (double)src->a;
- double sb = (double)src->b;
- double sc = (double)src->c;
- double sd = (double)src->d;
+ double sa = (double)src.a;
+ double sb = (double)src.b;
+ double sc = (double)src.c;
+ double sd = (double)src.d;
double da, db, dc, dd;
double det = sa * sd - sb * sc;
if (det >= -DBL_EPSILON && det <= DBL_EPSILON)
@@ -249,77 +251,79 @@ fz_try_invert_matrix(fz_matrix *dst, const fz_matrix *src)
dst->c = (float)dc;
dd = sa * det;
dst->d = (float)dd;
- da = -src->e * da - src->f * dc;
- dst->f = (float)(-src->e * db - src->f * dd);
+ da = -src.e * da - src.f * dc;
+ dst->f = (float)(-src.e * db - src.f * dd);
dst->e = (float)da;
return 0;
}
int
-fz_is_rectilinear(const fz_matrix *m)
+fz_is_rectilinear(fz_matrix m)
{
- return (fabsf(m->b) < FLT_EPSILON && fabsf(m->c) < FLT_EPSILON) ||
- (fabsf(m->a) < FLT_EPSILON && fabsf(m->d) < FLT_EPSILON);
+ return (fabsf(m.b) < FLT_EPSILON && fabsf(m.c) < FLT_EPSILON) ||
+ (fabsf(m.a) < FLT_EPSILON && fabsf(m.d) < FLT_EPSILON);
}
float
-fz_matrix_expansion(const fz_matrix *m)
+fz_matrix_expansion(fz_matrix m)
{
- return sqrtf(fabsf(m->a * m->d - m->b * m->c));
+ return sqrtf(fabsf(m.a * m.d - m.b * m.c));
}
float
-fz_matrix_max_expansion(const fz_matrix *m)
+fz_matrix_max_expansion(fz_matrix m)
{
- float max = fabsf(m->a);
- float x = fabsf(m->b);
+ float max = fabsf(m.a);
+ float x = fabsf(m.b);
if (max < x)
max = x;
- x = fabsf(m->c);
+ x = fabsf(m.c);
if (max < x)
max = x;
- x = fabsf(m->d);
+ x = fabsf(m.d);
if (max < x)
max = x;
return max;
}
-fz_point *
-fz_transform_point(fz_point *p, const fz_matrix *m)
+fz_point
+fz_transform_point(fz_point p, fz_matrix m)
{
- float x = p->x;
- p->x = x * m->a + p->y * m->c + m->e;
- p->y = x * m->b + p->y * m->d + m->f;
+ float x = p.x;
+ p.x = x * m.a + p.y * m.c + m.e;
+ p.y = x * m.b + p.y * m.d + m.f;
return p;
}
-fz_point *
-fz_transform_point_xy(fz_point *p, const fz_matrix *m, float x, float y)
+fz_point
+fz_transform_point_xy(float x, float y, fz_matrix m)
{
- p->x = x * m->a + y * m->c + m->e;
- p->y = x * m->b + y * m->d + m->f;
+ fz_point p;
+ p.x = x * m.a + y * m.c + m.e;
+ p.y = x * m.b + y * m.d + m.f;
return p;
}
-fz_point *
-fz_transform_vector(fz_point *p, const fz_matrix *m)
+fz_point
+fz_transform_vector(fz_point p, fz_matrix m)
{
- float x = p->x;
- p->x = x * m->a + p->y * m->c;
- p->y = x * m->b + p->y * m->d;
+ float x = p.x;
+ p.x = x * m.a + p.y * m.c;
+ p.y = x * m.b + p.y * m.d;
return p;
}
-void
-fz_normalize_vector(fz_point *p)
+fz_point
+fz_normalize_vector(fz_point p)
{
- float len = p->x * p->x + p->y * p->y;
+ float len = p.x * p.x + p.y * p.y;
if (len != 0)
{
len = sqrtf(len);
- p->x /= len;
- p->y /= len;
+ p.x /= len;
+ p.y /= len;
}
+ return p;
}
/* Rectangles and bounding boxes */
@@ -336,246 +340,229 @@ const fz_irect fz_infinite_irect = { 1, 1, -1, -1 };
const fz_irect fz_empty_irect = { 0, 0, 0, 0 };
const fz_irect fz_unit_bbox = { 0, 0, 1, 1 };
-fz_irect *
-fz_irect_from_rect(fz_irect *b, const fz_rect *r)
+fz_irect
+fz_irect_from_rect(fz_rect r)
{
+ fz_irect b;
if (fz_is_empty_rect(r))
{
- b->x0 = 0;
- b->y0 = 0;
- b->x1 = 0;
- b->y1 = 0;
+ b.x0 = 0;
+ b.y0 = 0;
+ b.x1 = 0;
+ b.y1 = 0;
}
else
{
- b->x0 = fz_clamp(floorf(r->x0), MIN_SAFE_INT, MAX_SAFE_INT);
- b->y0 = fz_clamp(floorf(r->y0), MIN_SAFE_INT, MAX_SAFE_INT);
- b->x1 = fz_clamp(ceilf(r->x1), MIN_SAFE_INT, MAX_SAFE_INT);
- b->y1 = fz_clamp(ceilf(r->y1), MIN_SAFE_INT, MAX_SAFE_INT);
+ b.x0 = fz_clamp(floorf(r.x0), MIN_SAFE_INT, MAX_SAFE_INT);
+ b.y0 = fz_clamp(floorf(r.y0), MIN_SAFE_INT, MAX_SAFE_INT);
+ b.x1 = fz_clamp(ceilf(r.x1), MIN_SAFE_INT, MAX_SAFE_INT);
+ b.y1 = fz_clamp(ceilf(r.y1), MIN_SAFE_INT, MAX_SAFE_INT);
}
return b;
}
-fz_rect *
-fz_rect_from_irect(fz_rect *r, const fz_irect *a)
+fz_rect
+fz_rect_from_irect(fz_irect a)
{
- r->x0 = a->x0;
- r->y0 = a->y0;
- r->x1 = a->x1;
- r->y1 = a->y1;
+ fz_rect r;
+ r.x0 = a.x0;
+ r.y0 = a.y0;
+ r.x1 = a.x1;
+ r.y1 = a.y1;
return r;
}
-fz_irect *
-fz_round_rect(fz_irect * b, const fz_rect *r)
+fz_irect
+fz_round_rect(fz_rect r)
{
+ fz_irect b;
int i;
- i = floorf(r->x0 + 0.001f);
- b->x0 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
- i = floorf(r->y0 + 0.001f);
- b->y0 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
- i = ceilf(r->x1 - 0.001f);
- b->x1 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
- i = ceilf(r->y1 - 0.001f);
- b->y1 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
+ i = floorf(r.x0 + 0.001f);
+ b.x0 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
+ i = floorf(r.y0 + 0.001f);
+ b.y0 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
+ i = ceilf(r.x1 - 0.001f);
+ b.x1 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
+ i = ceilf(r.y1 - 0.001f);
+ b.y1 = fz_clamp(i, MIN_SAFE_INT, MAX_SAFE_INT);
return b;
}
-fz_rect *
-fz_intersect_rect(fz_rect *a, const fz_rect *b)
+fz_rect
+fz_intersect_rect(fz_rect a, fz_rect b)
{
/* Check for empty box before infinite box */
- if (fz_is_empty_rect(a)) return a;
- if (fz_is_empty_rect(b)) {
- *a = fz_empty_rect;
- return a;
- }
+ if (fz_is_empty_rect(a)) return fz_empty_rect;
+ if (fz_is_empty_rect(b)) return fz_empty_rect;
if (fz_is_infinite_rect(b)) return a;
- if (fz_is_infinite_rect(a)) {
- *a = *b;
- return a;
- }
- if (a->x0 < b->x0)
- a->x0 = b->x0;
- if (a->y0 < b->y0)
- a->y0 = b->y0;
- if (a->x1 > b->x1)
- a->x1 = b->x1;
- if (a->y1 > b->y1)
- a->y1 = b->y1;
- if (a->x1 < a->x0 || a->y1 < a->y0)
- *a = fz_empty_rect;
+ if (fz_is_infinite_rect(a)) return b;
+ if (a.x0 < b.x0)
+ a.x0 = b.x0;
+ if (a.y0 < b.y0)
+ a.y0 = b.y0;
+ if (a.x1 > b.x1)
+ a.x1 = b.x1;
+ if (a.y1 > b.y1)
+ a.y1 = b.y1;
+ if (a.x1 < a.x0 || a.y1 < a.y0)
+ return fz_empty_rect;
return a;
}
-fz_irect *
-fz_intersect_irect(fz_irect *a, const fz_irect *b)
+fz_irect
+fz_intersect_irect(fz_irect a, fz_irect b)
{
/* Check for empty box before infinite box */
- if (fz_is_empty_irect(a)) return a;
- if (fz_is_empty_irect(b))
- {
- *a = fz_empty_irect;
- return a;
- }
+ if (fz_is_empty_irect(a)) return fz_empty_irect;
+ if (fz_is_empty_irect(b)) return fz_empty_irect;
if (fz_is_infinite_irect(b)) return a;
- if (fz_is_infinite_irect(a))
- {
- *a = *b;
- return a;
- }
- if (a->x0 < b->x0)
- a->x0 = b->x0;
- if (a->y0 < b->y0)
- a->y0 = b->y0;
- if (a->x1 > b->x1)
- a->x1 = b->x1;
- if (a->y1 > b->y1)
- a->y1 = b->y1;
- if (a->x1 < a->x0 || a->y1 < a->y0)
- *a = fz_empty_irect;
+ if (fz_is_infinite_irect(a)) return b;
+ if (a.x0 < b.x0)
+ a.x0 = b.x0;
+ if (a.y0 < b.y0)
+ a.y0 = b.y0;
+ if (a.x1 > b.x1)
+ a.x1 = b.x1;
+ if (a.y1 > b.y1)
+ a.y1 = b.y1;
+ if (a.x1 < a.x0 || a.y1 < a.y0)
+ return fz_empty_irect;
return a;
}
-fz_rect *
-fz_union_rect(fz_rect *a, const fz_rect *b)
+fz_rect
+fz_union_rect(fz_rect a, fz_rect b)
{
/* Check for empty box before infinite box */
if (fz_is_empty_rect(b)) return a;
- if (fz_is_empty_rect(a)) {
- *a = *b;
- return a;
- }
+ if (fz_is_empty_rect(a)) return b;
if (fz_is_infinite_rect(a)) return a;
- if (fz_is_infinite_rect(b)) {
- *a = *b;
- return a;
- }
- if (a->x0 > b->x0)
- a->x0 = b->x0;
- if (a->y0 > b->y0)
- a->y0 = b->y0;
- if (a->x1 < b->x1)
- a->x1 = b->x1;
- if (a->y1 < b->y1)
- a->y1 = b->y1;
+ if (fz_is_infinite_rect(b)) return b;
+ if (a.x0 > b.x0)
+ a.x0 = b.x0;
+ if (a.y0 > b.y0)
+ a.y0 = b.y0;
+ if (a.x1 < b.x1)
+ a.x1 = b.x1;
+ if (a.y1 < b.y1)
+ a.y1 = b.y1;
return a;
}
-fz_rect *
-fz_translate_rect(fz_rect *a, float xoff, float yoff)
+fz_rect
+fz_translate_rect(fz_rect a, float xoff, float yoff)
{
if (fz_is_empty_rect(a)) return a;
if (fz_is_infinite_rect(a)) return a;
- a->x0 += xoff;
- a->y0 += yoff;
- a->x1 += xoff;
- a->y1 += yoff;
+ a.x0 += xoff;
+ a.y0 += yoff;
+ a.x1 += xoff;
+ a.y1 += yoff;
return a;
}
-fz_irect *
-fz_translate_irect(fz_irect *a, int xoff, int yoff)
+fz_irect
+fz_translate_irect(fz_irect a, int xoff, int yoff)
{
int t;
if (fz_is_empty_irect(a)) return a;
if (fz_is_infinite_irect(a)) return a;
- a->x0 = ADD_WITH_SAT(t, a->x0, xoff);
- a->y0 = ADD_WITH_SAT(t, a->y0, yoff);
- a->x1 = ADD_WITH_SAT(t, a->x1, xoff);
- a->y1 = ADD_WITH_SAT(t, a->y1, yoff);
+ a.x0 = ADD_WITH_SAT(t, a.x0, xoff);
+ a.y0 = ADD_WITH_SAT(t, a.y0, yoff);
+ a.x1 = ADD_WITH_SAT(t, a.x1, xoff);
+ a.y1 = ADD_WITH_SAT(t, a.y1, yoff);
return a;
}
-fz_rect *
-fz_transform_rect(fz_rect *r, const fz_matrix *m)
+fz_rect
+fz_transform_rect(fz_rect r, fz_matrix m)
{
fz_point s, t, u, v;
if (fz_is_infinite_rect(r))
return r;
- if (fabsf(m->b) < FLT_EPSILON && fabsf(m->c) < FLT_EPSILON)
+ if (fabsf(m.b) < FLT_EPSILON && fabsf(m.c) < FLT_EPSILON)
{
- if (m->a < 0)
+ if (m.a < 0)
{
- float f = r->x0;
- r->x0 = r->x1;
- r->x1 = f;
+ float f = r.x0;
+ r.x0 = r.x1;
+ r.x1 = f;
}
- if (m->d < 0)
+ if (m.d < 0)
{
- float f = r->y0;
- r->y0 = r->y1;
- r->y1 = f;
+ float f = r.y0;
+ r.y0 = r.y1;
+ r.y1 = f;
}
- fz_transform_point(fz_rect_min(r), m);
- fz_transform_point(fz_rect_max(r), m);
+ s = fz_transform_point_xy(r.x0, r.y0, m);
+ t = fz_transform_point_xy(r.x1, r.y1, m);
+ r.x0 = s.x; r.y0 = s.y;
+ r.x1 = t.x; r.y1 = t.y;
return r;
}
- s.x = r->x0; s.y = r->y0;
- t.x = r->x0; t.y = r->y1;
- u.x = r->x1; u.y = r->y1;
- v.x = r->x1; v.y = r->y0;
- fz_transform_point(&s, m);
- fz_transform_point(&t, m);
- fz_transform_point(&u, m);
- fz_transform_point(&v, m);
- r->x0 = MIN4(s.x, t.x, u.x, v.x);
- r->y0 = MIN4(s.y, t.y, u.y, v.y);
- r->x1 = MAX4(s.x, t.x, u.x, v.x);
- r->y1 = MAX4(s.y, t.y, u.y, v.y);
+ s.x = r.x0; s.y = r.y0;
+ t.x = r.x0; t.y = r.y1;
+ u.x = r.x1; u.y = r.y1;
+ v.x = r.x1; v.y = r.y0;
+ s = fz_transform_point(s, m);
+ t = fz_transform_point(t, m);
+ u = fz_transform_point(u, m);
+ v = fz_transform_point(v, m);
+ r.x0 = MIN4(s.x, t.x, u.x, v.x);
+ r.y0 = MIN4(s.y, t.y, u.y, v.y);
+ r.x1 = MAX4(s.x, t.x, u.x, v.x);
+ r.y1 = MAX4(s.y, t.y, u.y, v.y);
return r;
}
-fz_irect *
-fz_expand_irect(fz_irect *a, int expand)
+fz_irect
+fz_expand_irect(fz_irect a, int expand)
{
if (fz_is_infinite_irect(a)) return a;
- a->x0 -= expand;
- a->y0 -= expand;
- a->x1 += expand;
- a->y1 += expand;
+ a.x0 -= expand;
+ a.y0 -= expand;
+ a.x1 += expand;
+ a.y1 += expand;
return a;
}
-fz_rect *
-fz_expand_rect(fz_rect *a, float expand)
+fz_rect
+fz_expand_rect(fz_rect a, float expand)
{
if (fz_is_infinite_rect(a)) return a;
- a->x0 -= expand;
- a->y0 -= expand;
- a->x1 += expand;
- a->y1 += expand;
+ a.x0 -= expand;
+ a.y0 -= expand;
+ a.x1 += expand;
+ a.y1 += expand;
return a;
}
-fz_rect *fz_include_point_in_rect(fz_rect *r, const fz_point *p)
+fz_rect fz_include_point_in_rect(fz_rect r, fz_point p)
{
if (fz_is_infinite_rect(r)) return r;
- if (p->x < r->x0) r->x0 = p->x;
- if (p->x > r->x1) r->x1 = p->x;
- if (p->y < r->y0) r->y0 = p->y;
- if (p->y > r->y1) r->y1 = p->y;
+ if (p.x < r.x0) r.x0 = p.x;
+ if (p.x > r.x1) r.x1 = p.x;
+ if (p.y < r.y0) r.y0 = p.y;
+ if (p.y > r.y1) r.y1 = p.y;
return r;
}
-int fz_contains_rect(const fz_rect *a, const fz_rect *b)
+int fz_contains_rect(fz_rect a, fz_rect b)
{
- if (a == NULL || b == NULL)
- return 0;
if (fz_is_empty_rect(b))
return 1;
if (fz_is_empty_rect(a))
return 0;
- return ((a->x0 <= b->x0) &&
- (a->y0 <= b->y0) &&
- (a->x1 >= b->x1) &&
- (a->y1 >= b->y1));
+ return ((a.x0 <= b.x0) &&
+ (a.y0 <= b.y0) &&
+ (a.x1 >= b.x1) &&
+ (a.y1 >= b.y1));
}
fz_rect
@@ -589,13 +576,13 @@ fz_rect_from_quad(fz_quad q)
return r;
}
-fz_quad *
-fz_transform_quad(fz_quad *q, const fz_matrix *m)
+fz_quad
+fz_transform_quad(fz_quad q, const fz_matrix m)
{
- fz_transform_point(&q->ul, m);
- fz_transform_point(&q->ur, m);
- fz_transform_point(&q->ll, m);
- fz_transform_point(&q->lr, m);
+ q.ul = fz_transform_point(q.ul, m);
+ q.ur = fz_transform_point(q.ur, m);
+ q.ll = fz_transform_point(q.ll, m);
+ q.lr = fz_transform_point(q.lr, m);
return q;
}
diff --git a/source/fitz/glyph.c b/source/fitz/glyph.c
index 4c22b94b..f3634df1 100644
--- a/source/fitz/glyph.c
+++ b/source/fitz/glyph.c
@@ -24,23 +24,25 @@ fz_drop_glyph_imp(fz_context *ctx, fz_storable *glyph_)
fz_free(ctx, glyph);
}
-fz_irect *
-fz_glyph_bbox(fz_context *ctx, fz_glyph *glyph, fz_irect *bbox)
+fz_irect
+fz_glyph_bbox(fz_context *ctx, fz_glyph *glyph)
{
- bbox->x0 = glyph->x;
- bbox->y0 = glyph->y;
- bbox->x1 = glyph->x + glyph->w;
- bbox->y1 = glyph->y + glyph->h;
+ fz_irect bbox;
+ bbox.x0 = glyph->x;
+ bbox.y0 = glyph->y;
+ bbox.x1 = glyph->x + glyph->w;
+ bbox.y1 = glyph->y + glyph->h;
return bbox;
}
-fz_irect *
-fz_glyph_bbox_no_ctx(fz_glyph *glyph, fz_irect *bbox)
+fz_irect
+fz_glyph_bbox_no_ctx(fz_glyph *glyph)
{
- bbox->x0 = glyph->x;
- bbox->y0 = glyph->y;
- bbox->x1 = glyph->x + glyph->w;
- bbox->y1 = glyph->y + glyph->h;
+ fz_irect bbox;
+ bbox.x0 = glyph->x;
+ bbox.y0 = glyph->y;
+ bbox.x1 = glyph->x + glyph->w;
+ bbox.y1 = glyph->y + glyph->h;
return bbox;
}
diff --git a/source/fitz/image.c b/source/fitz/image.c
index 51699772..8cda9687 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -590,7 +590,7 @@ update_ctm_for_subarea(fz_matrix *ctm, const fz_irect *subarea, int w, int h)
m.d = (float) (subarea->y1 - subarea->y0) / h;
m.e = (float) subarea->x0 / w;
m.f = (float) subarea->y0 / h;
- fz_concat(ctm, &m, ctm);
+ *ctm = fz_concat(m, *ctm);
}
void fz_default_image_decode(void *arg, int w, int h, int l2factor, fz_irect *subarea)
@@ -1139,8 +1139,7 @@ display_list_image_get_pixmap(fz_context *ctx, fz_image *image_, fz_irect *subar
/* If we render the display list into pix with the image matrix, we'll get a unit
* square result. Therefore scale by w, h. */
- ctm = image->transform;
- fz_pre_scale(&ctm, w, h);
+ ctm = fz_pre_scale(image->transform, w, h);
fz_clear_pixmap(ctx, pix); /* clear to transparent */
dev = fz_new_draw_device(ctx, &ctm, pix);
@@ -1196,7 +1195,7 @@ fz_image *fz_new_image_from_display_list(fz_context *ctx, float w, float h, fz_d
display_list_image_get_size,
drop_display_list_image);
image->super.scalable = 1;
- fz_scale(&image->transform, 1 / w, 1 / h);
+ image->transform = fz_scale(1 / w, 1 / h);
image->list = fz_keep_display_list(ctx, list);
return &image->super;
diff --git a/source/fitz/link.c b/source/fitz/link.c
index b47fa9ee..0d655371 100644
--- a/source/fitz/link.c
+++ b/source/fitz/link.c
@@ -2,13 +2,13 @@
#include "fitz-imp.h"
fz_link *
-fz_new_link(fz_context *ctx, const fz_rect *bbox, void *doc, const char *uri)
+fz_new_link(fz_context *ctx, fz_rect bbox, void *doc, const char *uri)
{
fz_link *link;
link = fz_malloc_struct(ctx, fz_link);
link->refs = 1;
- link->rect = *bbox;
+ link->rect = bbox;
link->next = NULL;
link->doc = doc; /* don't take reference */
link->uri = NULL;
diff --git a/source/fitz/list-device.c b/source/fitz/list-device.c
index ca3425ab..883d6383 100644
--- a/source/fitz/list-device.c
+++ b/source/fitz/list-device.c
@@ -238,7 +238,7 @@ fz_append_display_node(
{
if (update)
{
- fz_intersect_rect(update, &writer->stack[writer->top].rect);
+ *update = fz_intersect_rect(*update, writer->stack[writer->top].rect);
local_rect = *update;
rect = &local_rect;
}
@@ -251,7 +251,7 @@ fz_append_display_node(
/* fallthrough */
default:
if (writer->top > 0 && writer->tiled == 0 && writer->top <= STACK_SIZE && rect)
- fz_union_rect(&writer->stack[writer->top-1].rect, rect);
+ writer->stack[writer->top-1].rect = fz_union_rect(writer->stack[writer->top-1].rect, *rect);
break;
}
@@ -664,9 +664,7 @@ static void
fz_list_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect rect;
-
- fz_bound_path(ctx, path, NULL, ctm, &rect);
+ fz_rect rect = fz_bound_path(ctx, path, NULL, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -687,9 +685,7 @@ static void
fz_list_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke,
const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect rect;
-
- fz_bound_path(ctx, path, stroke, ctm, &rect);
+ fz_rect rect = fz_bound_path(ctx, path, stroke, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -709,17 +705,15 @@ fz_list_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const
static void
fz_list_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect rect2;
-
- fz_bound_path(ctx, path, NULL, ctm, &rect2);
+ fz_rect rect = fz_bound_path(ctx, path, NULL, *ctm);
if (scissor)
- fz_intersect_rect(&rect2, scissor);
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
FZ_CMD_CLIP_PATH,
even_odd, /* flags */
- &rect2,
+ &rect,
path, /* path */
NULL, /* color */
NULL, /* colorspace */
@@ -733,17 +727,15 @@ fz_list_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even
static void
fz_list_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect rect2;
-
- fz_bound_path(ctx, path, stroke, ctm, &rect2);
+ fz_rect rect = fz_bound_path(ctx, path, stroke, *ctm);
if (scissor)
- fz_intersect_rect(&rect2, scissor);
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
FZ_CMD_CLIP_STROKE_PATH,
0, /* flags */
- &rect2,
+ &rect,
path, /* path */
NULL, /* color */
NULL, /* colorspace */
@@ -758,12 +750,10 @@ static void
fz_list_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, NULL, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, NULL, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -790,12 +780,10 @@ static void
fz_list_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm,
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
- fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, stroke, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, stroke, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -821,14 +809,12 @@ fz_list_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
static void
fz_list_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, NULL, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, NULL, *ctm);
if (scissor)
- fz_intersect_rect(&rect, scissor);
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
@@ -854,14 +840,12 @@ fz_list_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz
static void
fz_list_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
- fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, stroke, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, stroke, *ctm);
if (scissor)
- fz_intersect_rect(&rect, scissor);
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
@@ -887,12 +871,10 @@ fz_list_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, c
static void
fz_list_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
- fz_rect rect;
fz_text *cloned_text = fz_keep_text(ctx, text);
-
fz_try(ctx)
{
- fz_bound_text(ctx, text, NULL, ctm, &rect);
+ fz_rect rect = fz_bound_text(ctx, text, NULL, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -938,11 +920,9 @@ static void
fz_list_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
fz_shade *shade2 = fz_keep_shade(ctx, shade);
- fz_rect rect;
-
fz_try(ctx)
{
- fz_bound_shade(ctx, shade, ctm, &rect);
+ fz_rect rect = fz_bound_shade(ctx, shade, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -969,11 +949,9 @@ static void
fz_list_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
fz_image *image2 = fz_keep_image(ctx, image);
- fz_rect rect = fz_unit_rect;
-
fz_try(ctx)
{
- fz_transform_rect(&rect, ctm);
+ fz_rect rect = fz_transform_rect(fz_unit_rect, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -1001,11 +979,10 @@ fz_list_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
fz_image *image2 = fz_keep_image(ctx, image);
- fz_rect rect = fz_unit_rect;
fz_try(ctx)
{
- fz_transform_rect(&rect, ctm);
+ fz_rect rect = fz_transform_rect(fz_unit_rect, *ctm);
fz_append_display_node(
ctx,
dev,
@@ -1032,19 +1009,17 @@ static void
fz_list_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, const fz_rect *scissor)
{
fz_image *image2 = fz_keep_image(ctx, image);
- fz_rect rect2 = fz_unit_rect;
-
- fz_transform_rect(&rect2, ctm);
- if (scissor)
- fz_intersect_rect(&rect2, scissor);
fz_try(ctx)
{
+ fz_rect rect = fz_transform_rect(fz_unit_rect, *ctm);
+ if (scissor)
+ rect = fz_intersect_rect(rect, *scissor);
fz_append_display_node(
ctx,
dev,
FZ_CMD_CLIP_IMAGE_MASK,
0, /* flags */
- &rect2,
+ &rect,
NULL, /* path */
NULL, /* color */
NULL, /* colorspace */
@@ -1464,12 +1439,12 @@ fz_drop_display_list_imp(fz_context *ctx, fz_storable *list_)
}
fz_display_list *
-fz_new_display_list(fz_context *ctx, const fz_rect *mediabox)
+fz_new_display_list(fz_context *ctx, fz_rect mediabox)
{
fz_display_list *list = fz_malloc_struct(ctx, fz_display_list);
FZ_INIT_STORABLE(list, 1, fz_drop_display_list_imp);
list->list = NULL;
- list->mediabox = mediabox ? *mediabox : fz_empty_rect;
+ list->mediabox = mediabox;
list->max = 0;
list->len = 0;
return list;
@@ -1489,11 +1464,10 @@ fz_drop_display_list(fz_context *ctx, fz_display_list *list)
fz_defer_reap_end(ctx);
}
-fz_rect *
-fz_bound_display_list(fz_context *ctx, fz_display_list *list, fz_rect *bounds)
+fz_rect
+fz_bound_display_list(fz_context *ctx, fz_display_list *list)
{
- *bounds = list->mediabox;
- return bounds;
+ return list->mediabox;
}
int fz_display_list_is_empty(fz_context *ctx, const fz_display_list *list)
@@ -1682,8 +1656,7 @@ fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, cons
continue;
}
- trans_rect = rect;
- fz_transform_rect(&trans_rect, top_ctm);
+ trans_rect = fz_transform_rect(rect, *top_ctm);
/* cull objects to draw using a quick visibility test */
@@ -1696,9 +1669,7 @@ fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, cons
}
else
{
- fz_rect irect = trans_rect;
- fz_intersect_rect(&irect, scissor);
- empty = fz_is_empty_rect(&irect);
+ empty = fz_is_empty_rect(fz_intersect_rect(trans_rect, *scissor));
}
if (clipped || empty)
@@ -1730,7 +1701,7 @@ fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, cons
}
visible:
- fz_concat(&trans_ctm, &ctm, top_ctm);
+ trans_ctm = fz_concat(ctm, *top_ctm);
fz_try(ctx)
{
diff --git a/source/fitz/path.c b/source/fitz/path.c
index 92af16f7..56510329 100644
--- a/source/fitz/path.c
+++ b/source/fitz/path.c
@@ -576,13 +576,12 @@ fz_rectto(fz_context *ctx, fz_path *path, float x1, float y1, float x2, float y2
path->current = path->begin;
}
-static inline fz_rect *bound_expand(fz_rect *r, const fz_point *p)
+static inline void bound_expand(fz_rect *r, fz_point p)
{
- if (p->x < r->x0) r->x0 = p->x;
- if (p->y < r->y0) r->y0 = p->y;
- if (p->x > r->x1) r->x1 = p->x;
- if (p->y > r->y1) r->y1 = p->y;
- return r;
+ if (p.x < r->x0) r->x0 = p.x;
+ if (p.y < r->y0) r->y0 = p.y;
+ if (p.x > r->x1) r->x1 = p.x;
+ if (p.y > r->y1) r->y1 = p.y;
}
void fz_walk_path(fz_context *ctx, const fz_path *path, const fz_path_walker *proc, void *arg)
@@ -834,7 +833,7 @@ void fz_walk_path(fz_context *ctx, const fz_path *path, const fz_path_walker *pr
typedef struct
{
- const fz_matrix *ctm;
+ fz_matrix ctm;
fz_rect rect;
fz_point move;
int trailing_move;
@@ -845,10 +844,7 @@ static void
bound_moveto(fz_context *ctx, void *arg_, float x, float y)
{
bound_path_arg *arg = (bound_path_arg *)arg_;
-
- arg->move.x = x;
- arg->move.y = y;
- fz_transform_point(&arg->move, arg->ctm);
+ arg->move = fz_transform_point_xy(x, y, arg->ctm);
arg->trailing_move = 1;
}
@@ -856,11 +852,7 @@ static void
bound_lineto(fz_context *ctx, void *arg_, float x, float y)
{
bound_path_arg *arg = (bound_path_arg *)arg_;
- fz_point p;
-
- p.x = x;
- p.y = y;
- fz_transform_point(&p, arg->ctm);
+ fz_point p = fz_transform_point_xy(x, y, arg->ctm);
if (arg->first)
{
arg->rect.x0 = arg->rect.x1 = p.x;
@@ -868,12 +860,11 @@ bound_lineto(fz_context *ctx, void *arg_, float x, float y)
arg->first = 0;
}
else
- bound_expand(&arg->rect, &p);
-
+ bound_expand(&arg->rect, p);
if (arg->trailing_move)
{
arg->trailing_move = 0;
- bound_expand(&arg->rect, &arg->move);
+ bound_expand(&arg->rect, arg->move);
}
}
@@ -881,11 +872,7 @@ static void
bound_curveto(fz_context *ctx, void *arg_, float x1, float y1, float x2, float y2, float x3, float y3)
{
bound_path_arg *arg = (bound_path_arg *)arg_;
- fz_point p;
-
- p.x = x1;
- p.y = y1;
- fz_transform_point(&p, arg->ctm);
+ fz_point p = fz_transform_point_xy(x1, y1, arg->ctm);
if (arg->first)
{
arg->rect.x0 = arg->rect.x1 = p.x;
@@ -893,17 +880,13 @@ bound_curveto(fz_context *ctx, void *arg_, float x1, float y1, float x2, float y
arg->first = 0;
}
else
- bound_expand(&arg->rect, &p);
- p.x = x2;
- p.y = y2;
- bound_expand(&arg->rect, fz_transform_point(&p, arg->ctm));
- p.x = x3;
- p.y = y3;
- bound_expand(&arg->rect, fz_transform_point(&p, arg->ctm));
+ bound_expand(&arg->rect, p);
+ bound_expand(&arg->rect, fz_transform_point_xy(x2, y2, arg->ctm));
+ bound_expand(&arg->rect, fz_transform_point_xy(x3, y3, arg->ctm));
if (arg->trailing_move)
{
arg->trailing_move = 0;
- bound_expand(&arg->rect, &arg->move);
+ bound_expand(&arg->rect, arg->move);
}
}
@@ -915,8 +898,8 @@ static const fz_path_walker bound_path_walker =
NULL
};
-fz_rect *
-fz_bound_path(fz_context *ctx, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r)
+fz_rect
+fz_bound_path(fz_context *ctx, const fz_path *path, const fz_stroke_state *stroke, fz_matrix ctm)
{
bound_path_arg arg;
@@ -929,15 +912,14 @@ fz_bound_path(fz_context *ctx, const fz_path *path, const fz_stroke_state *strok
if (!arg.first && stroke)
{
- fz_adjust_rect_for_stroke(ctx, &arg.rect, stroke, ctm);
+ arg.rect = fz_adjust_rect_for_stroke(ctx, arg.rect, stroke, ctm);
}
- *r = arg.rect;
- return r;
+ return arg.rect;
}
-fz_rect *
-fz_adjust_rect_for_stroke(fz_context *ctx, fz_rect *r, const fz_stroke_state *stroke, const fz_matrix *ctm)
+fz_rect
+fz_adjust_rect_for_stroke(fz_context *ctx, fz_rect r, const fz_stroke_state *stroke, fz_matrix ctm)
{
float expand;
@@ -951,15 +933,15 @@ fz_adjust_rect_for_stroke(fz_context *ctx, fz_rect *r, const fz_stroke_state *st
if ((stroke->linejoin == FZ_LINEJOIN_MITER || stroke->linejoin == FZ_LINEJOIN_MITER_XPS) && stroke->miterlimit > 1)
expand *= stroke->miterlimit;
- r->x0 -= expand;
- r->y0 -= expand;
- r->x1 += expand;
- r->y1 += expand;
+ r.x0 -= expand;
+ r.y0 -= expand;
+ r.x1 += expand;
+ r.y1 += expand;
return r;
}
void
-fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
+fz_transform_path(fz_context *ctx, fz_path *path, fz_matrix ctm)
{
int i, k, n;
fz_point p, p1, p2, p3, q, s;
@@ -967,7 +949,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
if (path->packed)
fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot transform a packed path");
- if (ctm->b == 0 && ctm->c == 0)
+ if (ctm.b == 0 && ctm.c == 0)
{
/* Simple, in place transform */
i = 0;
@@ -1008,16 +990,14 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
case FZ_HORIZTO:
case FZ_HORIZTOCLOSE:
q.x = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
n = 0;
break;
case FZ_VERTTO:
case FZ_VERTTOCLOSE:
q.y = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.y;
n = 0;
break;
@@ -1028,8 +1008,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
{
q.x = path->coords[k];
q.y = path->coords[k+1];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
path->coords[k++] = p.y;
n--;
@@ -1055,7 +1034,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
i++;
}
}
- else if (ctm->a == 0 && ctm->d == 0)
+ else if (ctm.a == 0 && ctm.d == 0)
{
/* In place transform with command rewriting */
i = 0;
@@ -1095,32 +1074,28 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
break;
case FZ_HORIZTO:
q.x = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.y;
path->cmds[i] = FZ_VERTTO;
n = 0;
break;
case FZ_HORIZTOCLOSE:
q.x = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.y;
path->cmds[i] = FZ_VERTTOCLOSE;
n = 0;
break;
case FZ_VERTTO:
q.y = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
path->cmds[i] = FZ_HORIZTO;
n = 0;
break;
case FZ_VERTTOCLOSE:
q.y = path->coords[k];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
path->cmds[i] = FZ_HORIZTOCLOSE;
n = 0;
@@ -1130,10 +1105,9 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
}
while (n > 0)
{
- p.x = path->coords[k];
- p.y = path->coords[k+1];
- q = p;
- fz_transform_point(&p, ctm);
+ q.x = path->coords[k];
+ q.y = path->coords[k+1];
+ p = fz_transform_point(q, ctm);
path->coords[k++] = p.x;
path->coords[k++] = p.y;
n--;
@@ -1240,10 +1214,10 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
p3.x = p.x;
p3.y = p2.y;
s = p;
- fz_transform_point(&p, ctm);
- fz_transform_point(&p1, ctm);
- fz_transform_point(&p2, ctm);
- fz_transform_point(&p3, ctm);
+ p = fz_transform_point(p, ctm);
+ p1 = fz_transform_point(p1, ctm);
+ p2 = fz_transform_point(p2, ctm);
+ p3 = fz_transform_point(p3, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->coords[coord_write++] = p1.x;
@@ -1260,8 +1234,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
break;
case FZ_HORIZTO:
q.x = path->coords[coord_read++];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->cmds[cmd_write-1] = FZ_LINETO;
@@ -1270,7 +1243,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
case FZ_HORIZTOCLOSE:
p.x = path->coords[coord_read++];
p.y = q.y;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(p, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->cmds[cmd_write-1] = FZ_LINETOCLOSE;
@@ -1279,8 +1252,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
break;
case FZ_VERTTO:
q.y = path->coords[coord_read++];
- p = q;
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(q, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->cmds[cmd_write-1] = FZ_LINETO;
@@ -1289,7 +1261,7 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
case FZ_VERTTOCLOSE:
p.x = q.x;
p.y = path->coords[coord_read++];
- fz_transform_point(&p, ctm);
+ p = fz_transform_point(p, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
path->cmds[cmd_write-1] = FZ_LINETOCLOSE;
@@ -1301,10 +1273,9 @@ fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *ctm)
}
while (n > 0)
{
- p.x = path->coords[coord_read++];
- p.y = path->coords[coord_read++];
- q = p;
- fz_transform_point(&p, ctm);
+ q.x = path->coords[coord_read++];
+ q.y = path->coords[coord_read++];
+ p = fz_transform_point(q, ctm);
path->coords[coord_write++] = p.x;
path->coords[coord_write++] = p.y;
n--;
diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c
index 9159fea0..a001b968 100644
--- a/source/fitz/pixmap.c
+++ b/source/fitz/pixmap.c
@@ -103,27 +103,27 @@ fz_new_pixmap(fz_context *ctx, fz_colorspace *colorspace, int w, int h, fz_separ
}
fz_pixmap *
-fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *r, fz_separations *seps, int alpha)
+fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_irect bbox, fz_separations *seps, int alpha)
{
fz_pixmap *pixmap;
- pixmap = fz_new_pixmap(ctx, colorspace, r->x1 - r->x0, r->y1 - r->y0, seps, alpha);
- pixmap->x = r->x0;
- pixmap->y = r->y0;
+ pixmap = fz_new_pixmap(ctx, colorspace, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, seps, alpha);
+ pixmap->x = bbox.x0;
+ pixmap->y = bbox.y0;
return pixmap;
}
fz_pixmap *
-fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *r, fz_separations *seps, int alpha, unsigned char *samples)
+fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_irect bbox, fz_separations *seps, int alpha, unsigned char *samples)
{
- int w = r->x1 - r->x0;
+ int w = bbox.x1 - bbox.x0;
int stride;
int s = fz_count_active_separations(ctx, seps);
fz_pixmap *pixmap;
if (!colorspace && s == 0) alpha = 1;
stride = (fz_colorspace_n(ctx, colorspace) + s + alpha) * w;
- pixmap = fz_new_pixmap_with_data(ctx, colorspace, w, r->y1 - r->y0, seps, alpha, stride, samples);
- pixmap->x = r->x0;
- pixmap->y = r->y0;
+ pixmap = fz_new_pixmap_with_data(ctx, colorspace, w, bbox.y1 - bbox.y0, seps, alpha, stride, samples);
+ pixmap->x = bbox.x0;
+ pixmap->y = bbox.y0;
return pixmap;
}
@@ -162,23 +162,25 @@ fz_pixmap *fz_new_pixmap_from_pixmap(fz_context *ctx, fz_pixmap *pixmap, const f
return subpix;
}
-fz_irect *
-fz_pixmap_bbox(fz_context *ctx, const fz_pixmap *pix, fz_irect *bbox)
+fz_irect
+fz_pixmap_bbox(fz_context *ctx, const fz_pixmap *pix)
{
- bbox->x0 = pix->x;
- bbox->y0 = pix->y;
- bbox->x1 = pix->x + pix->w;
- bbox->y1 = pix->y + pix->h;
+ fz_irect bbox;
+ bbox.x0 = pix->x;
+ bbox.y0 = pix->y;
+ bbox.x1 = pix->x + pix->w;
+ bbox.y1 = pix->y + pix->h;
return bbox;
}
-fz_irect *
-fz_pixmap_bbox_no_ctx(const fz_pixmap *pix, fz_irect *bbox)
+fz_irect
+fz_pixmap_bbox_no_ctx(const fz_pixmap *pix)
{
- bbox->x0 = pix->x;
- bbox->y0 = pix->y;
- bbox->x1 = pix->x + pix->w;
- bbox->y1 = pix->y + pix->h;
+ fz_irect bbox;
+ bbox.x0 = pix->x;
+ bbox.y0 = pix->y;
+ bbox.x1 = pix->x + pix->w;
+ bbox.y1 = pix->y + pix->h;
return bbox;
}
@@ -593,25 +595,23 @@ fz_fill_pixmap_with_color(fz_context *ctx, fz_pixmap *pix, fz_colorspace *colors
}
void
-fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, const fz_irect *b, const fz_default_colorspaces *default_cs)
+fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_irect b, const fz_default_colorspaces *default_cs)
{
unsigned char *srcp;
unsigned char *destp;
int y, w, destspan, srcspan;
- fz_irect local_b, bb;
- local_b = *b;
- fz_intersect_irect(&local_b, fz_pixmap_bbox(ctx, dest, &bb));
- fz_intersect_irect(&local_b, fz_pixmap_bbox(ctx, src, &bb));
- w = local_b.x1 - local_b.x0;
- y = local_b.y1 - local_b.y0;
+ b = fz_intersect_irect(b, fz_pixmap_bbox(ctx, dest));
+ b = fz_intersect_irect(b, fz_pixmap_bbox(ctx, src));
+ w = b.x1 - b.x0;
+ y = b.y1 - b.y0;
if (w <= 0 || y <= 0)
return;
srcspan = src->stride;
- srcp = src->samples + (unsigned int)(srcspan * (local_b.y0 - src->y) + src->n * (local_b.x0 - src->x));
+ srcp = src->samples + (unsigned int)(srcspan * (b.y0 - src->y) + src->n * (b.x0 - src->x));
destspan = dest->stride;
- destp = dest->samples + (unsigned int)(destspan * (local_b.y0 - dest->y) + dest->n * (local_b.x0 - dest->x));
+ destp = dest->samples + (unsigned int)(destspan * (b.y0 - dest->y) + dest->n * (b.x0 - dest->x));
if (src->n == dest->n)
{
@@ -629,8 +629,8 @@ fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, const fz_i
fz_pixmap_converter *pc = fz_lookup_pixmap_converter(ctx, dest->colorspace, src->colorspace);
fz_pixmap fake_src = *src;
- fake_src.x = local_b.x0;
- fake_src.y = local_b.y0;
+ fake_src.x = b.x0;
+ fake_src.y = b.y0;
fake_src.w = w;
fake_src.h = y;
fake_src.samples = srcp;
@@ -640,21 +640,19 @@ fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, const fz_i
}
void
-fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, const fz_irect *b)
+fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, fz_irect b)
{
unsigned char *destp;
int x, y, w, k, destspan;
- fz_irect bb;
- fz_irect local_b = *b;
- fz_intersect_irect(&local_b, fz_pixmap_bbox(ctx, dest, &bb));
- w = local_b.x1 - local_b.x0;
- y = local_b.y1 - local_b.y0;
+ b = fz_intersect_irect(b, fz_pixmap_bbox(ctx, dest));
+ w = b.x1 - b.x0;
+ y = b.y1 - b.y0;
if (w <= 0 || y <= 0)
return;
destspan = dest->stride;
- destp = dest->samples + (unsigned int)(destspan * (local_b.y0 - dest->y) + dest->n * (local_b.x0 - dest->x));
+ destp = dest->samples + (unsigned int)(destspan * (b.y0 - dest->y) + dest->n * (b.x0 - dest->x));
/* CMYK needs special handling (and potentially any other subtractive colorspaces) */
if (fz_colorspace_n(ctx, dest->colorspace) == 4)
@@ -733,11 +731,10 @@ fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray)
fz_pixmap *alpha;
unsigned char *sp, *dp;
int w, h, sstride, dstride;
- fz_irect bbox;
assert(gray->n == 1);
- alpha = fz_new_pixmap_with_bbox(ctx, NULL, fz_pixmap_bbox(ctx, gray, &bbox), 0, 1);
+ alpha = fz_new_pixmap_with_bbox(ctx, NULL, fz_pixmap_bbox(ctx, gray), 0, 1);
dp = alpha->samples;
dstride = alpha->stride;
sp = gray->samples;
@@ -822,15 +819,15 @@ fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix)
}
}
-void fz_invert_pixmap_rect(fz_context *ctx, fz_pixmap *image, const fz_irect *rect)
+void fz_invert_pixmap_rect(fz_context *ctx, fz_pixmap *image, fz_irect rect)
{
unsigned char *p;
int x, y, n;
- int x0 = fz_clampi(rect->x0 - image->x, 0, image->w);
- int x1 = fz_clampi(rect->x1 - image->x, 0, image->w);
- int y0 = fz_clampi(rect->y0 - image->y, 0, image->h);
- int y1 = fz_clampi(rect->y1 - image->y, 0, image->h);
+ int x0 = fz_clampi(rect.x0 - image->x, 0, image->w);
+ int x1 = fz_clampi(rect.x1 - image->x, 0, image->w);
+ int y0 = fz_clampi(rect.y0 - image->y, 0, image->h);
+ int y1 = fz_clampi(rect.y1 - image->y, 0, image->h);
for (y = y0; y < y1; y++)
{
diff --git a/source/fitz/separation.c b/source/fitz/separation.c
index c0f01f28..97822f80 100644
--- a/source/fitz/separation.c
+++ b/source/fitz/separation.c
@@ -241,7 +241,7 @@ fz_clone_pixmap_area_with_different_seps(fz_context *ctx, fz_pixmap *src, const
bbox = &local_bbox;
}
- dst = fz_new_pixmap_with_bbox(ctx, dcs, bbox, dseps, src->alpha);
+ dst = fz_new_pixmap_with_bbox(ctx, dcs, *bbox, dseps, src->alpha);
if (src->flags & FZ_PIXMAP_FLAG_INTERPOLATE)
dst->flags |= FZ_PIXMAP_FLAG_INTERPOLATE;
else
diff --git a/source/fitz/shade.c b/source/fitz/shade.c
index 13788472..faf8b67c 100644
--- a/source/fitz/shade.c
+++ b/source/fitz/shade.c
@@ -63,9 +63,9 @@ fz_prepare_color(fz_context *ctx, fz_mesh_processor *painter, fz_vertex *v, floa
}
static inline void
-fz_prepare_vertex(fz_context *ctx, fz_mesh_processor *painter, fz_vertex *v, const fz_matrix *ctm, float x, float y, float *c)
+fz_prepare_vertex(fz_context *ctx, fz_mesh_processor *painter, fz_vertex *v, fz_matrix ctm, float x, float y, float *c)
{
- fz_transform_point_xy(&v->p, ctm, x, y);
+ v->p = fz_transform_point_xy(x, y, ctm);
if (painter->prepare)
{
painter->prepare(ctx, painter->process_arg, v, c);
@@ -73,7 +73,7 @@ fz_prepare_vertex(fz_context *ctx, fz_mesh_processor *painter, fz_vertex *v, con
}
static void
-fz_process_shade_type1(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type1(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
float *p = shade->u.f.fn_vals;
int xdivs = shade->u.f.xdivs;
@@ -88,9 +88,8 @@ fz_process_shade_type1(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
fz_vertex *v = vs[0];
fz_vertex *vn = vs[1];
int n = fz_colorspace_n(ctx, shade->colorspace);
- fz_matrix local_ctm;
- fz_concat(&local_ctm, &shade->u.f.matrix, ctm);
+ ctm = fz_concat(shade->u.f.matrix, ctm);
y = y0;
for (yy = 0; yy < ydivs; yy++)
@@ -99,17 +98,17 @@ fz_process_shade_type1(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
x = x0;
- fz_prepare_vertex(ctx, painter, &v[0], &local_ctm, x, y, p);
+ fz_prepare_vertex(ctx, painter, &v[0], ctm, x, y, p);
p += n;
- fz_prepare_vertex(ctx, painter, &v[1], &local_ctm, x, yn, p + xdivs * n);
+ fz_prepare_vertex(ctx, painter, &v[1], ctm, x, yn, p + xdivs * n);
for (xx = 0; xx < xdivs; xx++)
{
x = x0 + (x1 - x0) * (xx + 1) / xdivs;
- fz_prepare_vertex(ctx, painter, &vn[0], &local_ctm, x, y, p);
+ fz_prepare_vertex(ctx, painter, &vn[0], ctm, x, y, p);
p += n;
- fz_prepare_vertex(ctx, painter, &vn[1], &local_ctm, x, yn, p + xdivs * n);
+ fz_prepare_vertex(ctx, painter, &vn[1], ctm, x, yn, p + xdivs * n);
paint_quad(ctx, painter, &v[0], &vn[0], &vn[1], &v[1]);
SWAP(v,vn);
@@ -130,7 +129,7 @@ fz_point_on_circle(fz_point p, float r, float theta)
}
static void
-fz_process_shade_type2(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type2(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_point p0, p1, dir;
fz_vertex v0, v1, v2, v3;
@@ -145,9 +144,9 @@ fz_process_shade_type2(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
p1.y = shade->u.l_or_r.coords[1][1];
dir.x = p0.y - p1.y;
dir.y = p1.x - p0.x;
- fz_transform_point(&p0, ctm);
- fz_transform_point(&p1, ctm);
- fz_transform_vector(&dir, ctm);
+ p0 = fz_transform_point(p0, ctm);
+ p1 = fz_transform_point(p1, ctm);
+ dir = fz_transform_vector(dir, ctm);
theta = atan2f(dir.y, dir.x);
v0.p = fz_point_on_circle(p0, HUGENUM, theta);
@@ -190,7 +189,7 @@ fz_process_shade_type2(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
}
static void
-fz_paint_annulus(fz_context *ctx, const fz_matrix *ctm,
+fz_paint_annulus(fz_context *ctx, fz_matrix ctm,
fz_point p0, float r0, float c0,
fz_point p1, float r1, float c1,
int count,
@@ -208,23 +207,14 @@ fz_paint_annulus(fz_context *ctx, const fz_matrix *ctm,
{
b = i * step;
- t0.p = fz_point_on_circle(p0, r0, theta + a);
- t1.p = fz_point_on_circle(p0, r0, theta + b);
- t2.p = fz_point_on_circle(p1, r1, theta + a);
- t3.p = fz_point_on_circle(p1, r1, theta + b);
- b0.p = fz_point_on_circle(p0, r0, theta - a);
- b1.p = fz_point_on_circle(p0, r0, theta - b);
- b2.p = fz_point_on_circle(p1, r1, theta - a);
- b3.p = fz_point_on_circle(p1, r1, theta - b);
-
- fz_transform_point(&t0.p, ctm);
- fz_transform_point(&t1.p, ctm);
- fz_transform_point(&t2.p, ctm);
- fz_transform_point(&t3.p, ctm);
- fz_transform_point(&b0.p, ctm);
- fz_transform_point(&b1.p, ctm);
- fz_transform_point(&b2.p, ctm);
- fz_transform_point(&b3.p, ctm);
+ t0.p = fz_transform_point(fz_point_on_circle(p0, r0, theta + a), ctm);
+ t1.p = fz_transform_point(fz_point_on_circle(p0, r0, theta + b), ctm);
+ t2.p = fz_transform_point(fz_point_on_circle(p1, r1, theta + a), ctm);
+ t3.p = fz_transform_point(fz_point_on_circle(p1, r1, theta + b), ctm);
+ b0.p = fz_transform_point(fz_point_on_circle(p0, r0, theta - a), ctm);
+ b1.p = fz_transform_point(fz_point_on_circle(p0, r0, theta - b), ctm);
+ b2.p = fz_transform_point(fz_point_on_circle(p1, r1, theta - a), ctm);
+ b3.p = fz_transform_point(fz_point_on_circle(p1, r1, theta - b), ctm);
fz_prepare_color(ctx, painter, &t0, &c0);
fz_prepare_color(ctx, painter, &t1, &c0);
@@ -243,7 +233,7 @@ fz_paint_annulus(fz_context *ctx, const fz_matrix *ctm,
}
static void
-fz_process_shade_type3(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type3(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_point p0, p1;
float r0, r1;
@@ -305,7 +295,7 @@ static inline float read_sample(fz_context *ctx, fz_stream *stream, int bits, fl
}
static void
-fz_process_shade_type4(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type4(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
fz_vertex v[4];
@@ -384,7 +374,7 @@ fz_process_shade_type4(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
}
static void
-fz_process_shade_type5(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type5(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
fz_vertex *buf = NULL;
@@ -699,7 +689,7 @@ make_tensor_patch(tensor_patch *p, int type, fz_point *pt)
#define SUBDIV 3 /* how many levels to subdivide patches */
static void
-fz_process_shade_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type6(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
float color_storage[2][4][FZ_MAX_COLORS];
@@ -747,7 +737,7 @@ fz_process_shade_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
{
v[i].x = read_sample(ctx, stream, bpcoord, x0, x1);
v[i].y = read_sample(ctx, stream, bpcoord, y0, y1);
- fz_transform_point(&v[i], ctm);
+ v[i] = fz_transform_point(v[i], ctm);
}
for (i = startcolor; i < 4; i++)
@@ -812,7 +802,7 @@ fz_process_shade_type6(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
}
static void
-fz_process_shade_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_mesh_processor *painter)
+fz_process_shade_type7(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter)
{
fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer);
int bpflag = shade->u.m.bpflag;
@@ -860,7 +850,7 @@ fz_process_shade_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
{
v[i].x = read_sample(ctx, stream, bpcoord, x0, x1);
v[i].y = read_sample(ctx, stream, bpcoord, y0, y1);
- fz_transform_point(&v[i], ctm);
+ v[i] = fz_transform_point(v[i], ctm);
}
for (i = startcolor; i < 4; i++)
@@ -925,7 +915,7 @@ fz_process_shade_type7(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, f
}
void
-fz_process_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
+fz_process_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm,
fz_shade_prepare_fn *prepare, fz_shade_process_fn *process, void *process_arg)
{
fz_mesh_processor painter;
@@ -954,28 +944,29 @@ fz_process_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
fz_throw(ctx, FZ_ERROR_GENERIC, "Unexpected mesh type %d\n", shade->type);
}
-static fz_rect *
-fz_bound_mesh_type1(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+static fz_rect
+fz_bound_mesh_type1(fz_context *ctx, fz_shade *shade)
{
- bbox->x0 = shade->u.f.domain[0][0];
- bbox->y0 = shade->u.f.domain[0][1];
- bbox->x1 = shade->u.f.domain[1][0];
- bbox->y1 = shade->u.f.domain[1][1];
- return fz_transform_rect(bbox, &shade->u.f.matrix);
+ fz_rect bbox;
+ bbox.x0 = shade->u.f.domain[0][0];
+ bbox.y0 = shade->u.f.domain[0][1];
+ bbox.x1 = shade->u.f.domain[1][0];
+ bbox.y1 = shade->u.f.domain[1][1];
+ return fz_transform_rect(bbox, shade->u.f.matrix);
}
-static fz_rect *
-fz_bound_mesh_type2(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+static fz_rect
+fz_bound_mesh_type2(fz_context *ctx, fz_shade *shade)
{
/* FIXME: If axis aligned and not extended, the bbox may only be
* infinite in one direction */
- *bbox = fz_infinite_rect;
- return bbox;
+ return fz_infinite_rect;
}
-static fz_rect *
-fz_bound_mesh_type3(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+static fz_rect
+fz_bound_mesh_type3(fz_context *ctx, fz_shade *shade)
{
+ fz_rect bbox;
fz_point p0, p1;
float r0, r1;
@@ -985,19 +976,13 @@ fz_bound_mesh_type3(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
if (shade->u.l_or_r.extend[0])
{
if (r0 >= r1)
- {
- *bbox = fz_infinite_rect;
- return bbox;
- }
+ return fz_infinite_rect;
}
if (shade->u.l_or_r.extend[1])
{
if (r0 <= r1)
- {
- *bbox = fz_infinite_rect;
- return bbox;
- }
+ return fz_infinite_rect;
}
p0.x = shade->u.l_or_r.coords[0][0];
@@ -1005,47 +990,46 @@ fz_bound_mesh_type3(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
p1.x = shade->u.l_or_r.coords[1][0];
p1.y = shade->u.l_or_r.coords[1][1];
- bbox->x0 = p0.x - r0; bbox->y0 = p0.y - r0;
- bbox->x1 = p0.x + r0; bbox->y1 = p0.x + r0;
- if (bbox->x0 > p1.x - r1)
- bbox->x0 = p1.x - r1;
- if (bbox->x1 < p1.x + r1)
- bbox->x1 = p1.x + r1;
- if (bbox->y0 > p1.y - r1)
- bbox->y0 = p1.y - r1;
- if (bbox->y1 < p1.y + r1)
- bbox->y1 = p1.y + r1;
+ bbox.x0 = p0.x - r0; bbox.y0 = p0.y - r0;
+ bbox.x1 = p0.x + r0; bbox.y1 = p0.x + r0;
+ if (bbox.x0 > p1.x - r1)
+ bbox.x0 = p1.x - r1;
+ if (bbox.x1 < p1.x + r1)
+ bbox.x1 = p1.x + r1;
+ if (bbox.y0 > p1.y - r1)
+ bbox.y0 = p1.y - r1;
+ if (bbox.y1 < p1.y + r1)
+ bbox.y1 = p1.y + r1;
return bbox;
}
-static fz_rect *
-fz_bound_mesh_type4567(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+static fz_rect
+fz_bound_mesh_type4567(fz_context *ctx, fz_shade *shade)
{
- bbox->x0 = shade->u.m.x0;
- bbox->y0 = shade->u.m.y0;
- bbox->x1 = shade->u.m.x1;
- bbox->y1 = shade->u.m.y1;
+ fz_rect bbox;
+ bbox.x0 = shade->u.m.x0;
+ bbox.y0 = shade->u.m.y0;
+ bbox.x1 = shade->u.m.x1;
+ bbox.y1 = shade->u.m.y1;
return bbox;
}
-static fz_rect *
-fz_bound_mesh(fz_context *ctx, fz_shade *shade, fz_rect *bbox)
+static fz_rect
+fz_bound_mesh(fz_context *ctx, fz_shade *shade)
{
if (shade->type == FZ_FUNCTION_BASED)
- fz_bound_mesh_type1(ctx, shade, bbox);
+ return fz_bound_mesh_type1(ctx, shade);
else if (shade->type == FZ_LINEAR)
- fz_bound_mesh_type2(ctx, shade, bbox);
+ return fz_bound_mesh_type2(ctx, shade);
else if (shade->type == FZ_RADIAL)
- fz_bound_mesh_type3(ctx, shade, bbox);
+ return fz_bound_mesh_type3(ctx, shade);
else if (shade->type == FZ_MESH_TYPE4 ||
shade->type == FZ_MESH_TYPE5 ||
shade->type == FZ_MESH_TYPE6 ||
shade->type == FZ_MESH_TYPE7)
- fz_bound_mesh_type4567(ctx, shade, bbox);
+ return fz_bound_mesh_type4567(ctx, shade);
else
fz_throw(ctx, FZ_ERROR_GENERIC, "Unexpected mesh type %d\n", shade->type);
-
- return bbox;
}
fz_shade *
@@ -1072,18 +1056,15 @@ fz_drop_shade(fz_context *ctx, fz_shade *shade)
fz_drop_storable(ctx, &shade->storable);
}
-fz_rect *
-fz_bound_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_rect *s)
+fz_rect
+fz_bound_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm)
{
- fz_matrix local_ctm;
- fz_rect rect;
-
- fz_concat(&local_ctm, &shade->matrix, ctm);
- *s = shade->bbox;
+ ctm = fz_concat(shade->matrix, ctm);
if (shade->type != FZ_LINEAR && shade->type != FZ_RADIAL)
{
- fz_bound_mesh(ctx, shade, &rect);
- fz_intersect_rect(s, &rect);
+ fz_rect rect = fz_bound_mesh(ctx, shade);
+ rect = fz_intersect_rect(rect, shade->bbox);
+ return fz_transform_rect(rect, ctm);
}
- return fz_transform_rect(s, &local_ctm);
+ return fz_transform_rect(shade->bbox, ctm);
}
diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c
index ffff886a..a4a8d002 100644
--- a/source/fitz/stext-device.c
+++ b/source/fitz/stext-device.c
@@ -34,7 +34,7 @@ const char *fz_stext_options_usage =
"\n";
fz_stext_page *
-fz_new_stext_page(fz_context *ctx, const fz_rect *mediabox)
+fz_new_stext_page(fz_context *ctx, fz_rect mediabox)
{
fz_pool *pool = fz_new_pool(ctx);
fz_stext_page *page = NULL;
@@ -42,7 +42,7 @@ fz_new_stext_page(fz_context *ctx, const fz_rect *mediabox)
{
page = fz_pool_alloc(ctx, pool, sizeof(*page));
page->pool = pool;
- page->mediabox = *mediabox;
+ page->mediabox = mediabox;
page->first_block = NULL;
page->last_block = NULL;
}
@@ -97,11 +97,7 @@ add_image_block_to_page(fz_context *ctx, fz_stext_page *page, const fz_matrix *c
block->type = FZ_STEXT_BLOCK_IMAGE;
block->u.i.transform = *ctm;
block->u.i.image = fz_keep_image(ctx, image);
- block->bbox.x0 = 0;
- block->bbox.y0 = 0;
- block->bbox.x1 = 1;
- block->bbox.y1 = 1;
- fz_transform_rect(&block->bbox, ctm);
+ block->bbox = fz_transform_rect(fz_unit_rect, *ctm);
return block;
}
@@ -125,7 +121,7 @@ add_line_to_block(fz_context *ctx, fz_stext_page *page, fz_stext_block *block, c
}
static fz_stext_char *
-add_char_to_line(fz_context *ctx, fz_stext_page *page, fz_stext_line *line, const fz_matrix *trm, fz_font *font, float size, int c, fz_point *p, fz_point *q)
+add_char_to_line(fz_context *ctx, fz_stext_page *page, fz_stext_line *line, fz_matrix trm, fz_font *font, float size, int c, fz_point *p, fz_point *q)
{
fz_stext_char *ch = fz_pool_alloc(ctx, page->pool, sizeof *line->first_char);
fz_point a, d;
@@ -158,8 +154,8 @@ add_char_to_line(fz_context *ctx, fz_stext_page *page, fz_stext_line *line, cons
a.y = 0;
d.y = 0;
}
- fz_transform_vector(&a, trm);
- fz_transform_vector(&d, trm);
+ a = fz_transform_vector(a, trm);
+ d = fz_transform_vector(d, trm);
ch->quad.ll = fz_make_point(p->x + d.x, p->y + d.y);
ch->quad.ul = fz_make_point(p->x + a.x, p->y + a.y);
@@ -209,7 +205,7 @@ vec_dot(const fz_point *a, const fz_point *b)
}
static void
-fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, int glyph, fz_matrix *trm, float adv, int wmode)
+fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, int glyph, fz_matrix trm, float adv, int wmode)
{
fz_stext_page *page = dev->page;
fz_stext_block *cur_block;
@@ -238,9 +234,8 @@ fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int
dir.x = 0;
dir.y = -1;
}
- fz_transform_vector(&dir, trm);
- ndir = dir;
- fz_normalize_vector(&ndir);
+ dir = fz_transform_vector(dir, trm);
+ ndir = fz_normalize_vector(dir);
size = fz_matrix_expansion(trm);
@@ -261,17 +256,17 @@ fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int
*/
if (wmode == 0)
{
- p.x = trm->e;
- p.y = trm->f;
- q.x = trm->e + adv * dir.x;
- q.y = trm->f + adv * dir.y;
+ p.x = trm.e;
+ p.y = trm.f;
+ q.x = trm.e + adv * dir.x;
+ q.y = trm.f + adv * dir.y;
}
else
{
- p.x = trm->e - adv * dir.x;
- p.y = trm->f - adv * dir.y;
- q.x = trm->e;
- q.y = trm->f;
+ p.x = trm.e - adv * dir.x;
+ p.y = trm.f - adv * dir.y;
+ q.x = trm.e;
+ q.y = trm.f;
}
/* Find current position to enter new text. */
@@ -391,11 +386,11 @@ fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int
dev->pen = q;
dev->new_obj = 0;
- dev->trm = *trm;
+ dev->trm = trm;
}
static void
-fz_add_stext_char(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, int glyph, fz_matrix *trm, float adv, int wmode)
+fz_add_stext_char(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, int glyph, fz_matrix trm, float adv, int wmode)
{
/* ignore when one unicode character maps to multiple glyphs */
if (c == -1)
@@ -466,7 +461,7 @@ fz_add_stext_char(fz_context *ctx, fz_stext_device *dev, fz_font *font, int c, i
}
static void
-fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, const fz_matrix *ctm)
+fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, fz_matrix ctm)
{
fz_font *font = span->font;
fz_matrix tm = span->trm;
@@ -479,14 +474,14 @@ fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, cons
tm.e = 0;
tm.f = 0;
- fz_concat(&trm, &tm, ctm);
+ trm = fz_concat(tm, ctm);
for (i = 0; i < span->len; i++)
{
/* Calculate new pen location and delta */
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, ctm);
+ trm = fz_concat(tm, ctm);
/* Calculate bounding box and new pen position based on font metrics */
if (span->items[i].gid >= 0)
@@ -494,7 +489,7 @@ fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, cons
else
adv = 0;
- fz_add_stext_char(ctx, dev, font, span->items[i].ucs, span->items[i].gid, &trm, adv, span->wmode);
+ fz_add_stext_char(ctx, dev, font, span->items[i].ucs, span->items[i].gid, trm, adv, span->wmode);
}
}
@@ -506,7 +501,7 @@ fz_stext_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const f
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
static void
@@ -517,7 +512,7 @@ fz_stext_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
static void
@@ -527,7 +522,7 @@ fz_stext_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const f
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
static void
@@ -537,7 +532,7 @@ fz_stext_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text,
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
static void
@@ -547,7 +542,7 @@ fz_stext_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
fz_text_span *span;
tdev->new_obj = 1;
for (span = text->head; span; span = span->next)
- fz_stext_extract(ctx, tdev, span, ctm);
+ fz_stext_extract(ctx, tdev, span, *ctm);
}
/* Images and shadings */
@@ -580,11 +575,11 @@ fz_new_image_from_shade(fz_context *ctx, fz_shade *shade, fz_matrix *in_out_ctm,
fz_rect bounds;
fz_irect bbox;
- fz_bound_shade(ctx, shade, &ctm, &bounds);
- fz_intersect_rect(&bounds, scissor);
- fz_irect_from_rect(&bbox, &bounds);
+ bounds = fz_bound_shade(ctx, shade, ctm);
+ bounds = fz_intersect_rect(bounds, *scissor);
+ bbox = fz_irect_from_rect(bounds);
- pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), &bbox, NULL, !shade->use_background);
+ pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), bbox, NULL, !shade->use_background);
fz_try(ctx)
{
if (shade->use_background)
@@ -638,11 +633,8 @@ fz_stext_close_device(fz_context *ctx, fz_device *dev)
for (line = block->u.t.first_line; line; line = line->next)
{
for (ch = line->first_char; ch; ch = ch->next)
- {
- fz_rect bbox = fz_rect_from_quad(ch->quad);
- fz_union_rect(&line->bbox, &bbox);
- }
- fz_union_rect(&block->bbox, &line->bbox);
+ line->bbox = fz_union_rect(line->bbox, fz_rect_from_quad(ch->quad));
+ block->bbox = fz_union_rect(block->bbox, line->bbox);
}
}
diff --git a/source/fitz/stext-output.c b/source/fitz/stext-output.c
index 66433489..d949f2d8 100644
--- a/source/fitz/stext-output.c
+++ b/source/fitz/stext-output.c
@@ -465,7 +465,7 @@ text_begin_page(fz_context *ctx, fz_document_writer *wri_, const fz_rect *mediab
wri->page = NULL;
}
- wri->page = fz_new_stext_page(ctx, mediabox);
+ wri->page = fz_new_stext_page(ctx, *mediabox);
return fz_new_stext_device(ctx, wri->page, &wri->opts);
}
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c
index c5905938..28f3a4d6 100644
--- a/source/fitz/svg-device.c
+++ b/source/fitz/svg-device.c
@@ -173,7 +173,7 @@ svg_dev_stroke_state(fz_context *ctx, svg_device *sdev, const fz_stroke_state *s
fz_output *out = sdev->out;
float exp;
- exp = fz_matrix_expansion(ctm);
+ exp = fz_matrix_expansion(*ctm);
if (exp == 0)
exp = 1;
exp = stroke_state->linewidth/exp;
@@ -269,13 +269,13 @@ find_first_char(fz_context *ctx, const fz_text_span *span, int i)
}
static int
-find_next_line_break(fz_context *ctx, const fz_text_span *span, const fz_matrix *inv_tm, int i)
+find_next_line_break(fz_context *ctx, const fz_text_span *span, fz_matrix inv_tm, int i)
{
fz_point p, old_p;
old_p.x = span->items[i].x;
old_p.y = span->items[i].y;
- fz_transform_point(&old_p, inv_tm);
+ old_p = fz_transform_point(old_p, inv_tm);
for (++i; i < span->len; ++i)
{
@@ -283,7 +283,7 @@ find_next_line_break(fz_context *ctx, const fz_text_span *span, const fz_matrix
{
p.x = span->items[i].x;
p.y = span->items[i].y;
- fz_transform_point(&p, inv_tm);
+ p = fz_transform_point(p, inv_tm);
if (span->wmode == 0)
{
if (p.y != old_p.y)
@@ -332,15 +332,15 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
}
tm = span->trm;
- font_size = fz_matrix_expansion(&tm);
+ font_size = fz_matrix_expansion(tm);
final_tm.a = tm.a / font_size;
final_tm.b = tm.b / font_size;
final_tm.c = -tm.c / font_size;
final_tm.d = -tm.d / font_size;
final_tm.e = 0;
final_tm.f = 0;
- fz_invert_matrix(&inv_tm, &final_tm);
- fz_concat(&final_tm, &final_tm, ctm);
+ inv_tm = fz_invert_matrix(final_tm);
+ final_tm = fz_concat(final_tm, *ctm);
tm.e = span->items[0].x;
tm.f = span->items[0].y;
@@ -362,11 +362,11 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
start = find_first_char(ctx, span, 0);
while (start < span->len)
{
- end = find_next_line_break(ctx, span, &inv_tm, start);
+ end = find_next_line_break(ctx, span, inv_tm, start);
p.x = span->items[start].x;
p.y = span->items[start].y;
- fz_transform_point(&p, &inv_tm);
+ p = fz_transform_point(p, inv_tm);
if (span->items[start].gid >= 0)
cluster_advance = svg_cluster_advance(ctx, span, start, end);
if (span->wmode == 0)
@@ -384,7 +384,7 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
{
p.x = it->x;
p.y = it->y;
- fz_transform_point(&p, &inv_tm);
+ p = fz_transform_point(p, inv_tm);
}
else
{
@@ -476,10 +476,10 @@ svg_dev_text_span_as_paths_defs(fz_context *ctx, fz_device *dev, fz_text_span *s
path = fz_outline_glyph(ctx, span->font, gid, &fz_identity);
if (path)
{
- fz_bound_path(ctx, path, NULL, &fz_identity, &rect);
+ rect = fz_bound_path(ctx, path, NULL, fz_identity);
shift.e = -rect.x0;
shift.f = -rect.y0;
- fz_transform_path(ctx, path, &shift);
+ fz_transform_path(ctx, path, shift);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid);
fz_write_printf(ctx, out, "<path");
@@ -489,7 +489,7 @@ svg_dev_text_span_as_paths_defs(fz_context *ctx, fz_device *dev, fz_text_span *s
}
else
{
- fz_bound_glyph(ctx, span->font, gid, &fz_identity, &rect);
+ rect = fz_bound_glyph(ctx, span->font, gid, fz_identity);
shift.e = -rect.x0;
shift.f = -rect.y0;
out = start_def(ctx, sdev);
@@ -536,8 +536,8 @@ svg_dev_text_span_as_paths_fill(fz_context *ctx, fz_device *dev, const fz_text_s
shift.f = fnt->sentlist[gid].y_off;
local_trm.e = it->x;
local_trm.f = it->y;
- fz_concat(&local_trm2, &local_trm, ctm);
- fz_concat(&local_trm2, &shift, &local_trm2);
+ local_trm2 = fz_concat(local_trm, *ctm);
+ local_trm2 = fz_concat(shift, local_trm2);
fz_write_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid);
svg_dev_ctm(ctx, sdev, &local_trm2);
svg_dev_fill_color(ctx, sdev, colorspace, color, alpha, color_params);
@@ -576,8 +576,8 @@ svg_dev_text_span_as_paths_stroke(fz_context *ctx, fz_device *dev, const fz_text
shift.f = fnt->sentlist[gid].y_off;
local_trm.e = it->x;
local_trm.f = it->y;
- fz_concat(&local_trm2, &local_trm, ctm);
- fz_concat(&local_trm2, &shift, &local_trm2);
+ local_trm2 = fz_concat(local_trm, *ctm);
+ local_trm2 = fz_concat(shift, local_trm2);
fz_write_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid);
svg_dev_stroke_state(ctx, sdev, stroke, &local_trm2);
svg_dev_ctm(ctx, sdev, &local_trm2);
@@ -649,7 +649,7 @@ svg_dev_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, c
int num = sdev->id++;
float white[3] = { 1, 1, 1 };
- fz_bound_path(ctx, path, stroke, ctm, &bounds);
+ bounds = fz_bound_path(ctx, path, stroke, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n",
@@ -732,7 +732,7 @@ svg_dev_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz
font *fnt;
fz_text_span *span;
- fz_bound_text(ctx, text, NULL, ctm, &bounds);
+ bounds = fz_bound_text(ctx, text, NULL, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"",
@@ -772,7 +772,7 @@ svg_dev_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, c
font *fnt;
fz_text_span *span;
- fz_bound_text(ctx, text, NULL, ctm, &bounds);
+ bounds = fz_bound_text(ctx, text, NULL, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"",
@@ -890,7 +890,7 @@ svg_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
scale.a = 1.0f / image->w;
scale.d = 1.0f / image->h;
- fz_concat(&local_ctm, &scale, ctm);
+ local_ctm = fz_concat(scale, *ctm);
fz_write_printf(ctx, out, "<g");
if (alpha != 1.0f)
fz_write_printf(ctx, out, " opacity=\"%g\"", alpha);
@@ -905,7 +905,6 @@ svg_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
- fz_rect rect;
fz_irect bbox;
fz_pixmap *pix;
fz_buffer *buf = NULL;
@@ -915,10 +914,10 @@ svg_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma
if (dev->container_len == 0)
return;
- fz_round_rect(&bbox, fz_intersect_rect(fz_bound_shade(ctx, shade, ctm, &rect), &dev->container[dev->container_len-1].scissor));
- if (fz_is_empty_irect(&bbox))
+ bbox = fz_round_rect(fz_intersect_rect(fz_bound_shade(ctx, shade, *ctm), dev->container[dev->container_len-1].scissor));
+ if (fz_is_empty_irect(bbox))
return;
- pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), &bbox, NULL, 1);
+ pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), bbox, NULL, 1);
fz_clear_pixmap(ctx, pix);
fz_try(ctx)
@@ -957,7 +956,7 @@ svg_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
scale.a = 1.0f / image->w;
scale.d = 1.0f / image->h;
- fz_concat(&local_ctm, &scale, ctm);
+ local_ctm = fz_concat(scale, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n", mask);
svg_send_image(ctx, sdev, image, color_params);
@@ -981,7 +980,7 @@ svg_dev_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
scale.a = 1.0f / image->w;
scale.d = 1.0f / image->h;
- fz_concat(&local_ctm, &scale, ctm);
+ local_ctm = fz_concat(scale, *ctm);
out = start_def(ctx, sdev);
fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n<g", mask);
svg_dev_ctm(ctx, sdev, &local_ctm);
@@ -1139,7 +1138,7 @@ svg_dev_end_tile(fz_context *ctx, fz_device *dev)
/* All the pattern contents will have their own ctm applied. Let's
* undo the current one to allow for this */
- fz_invert_matrix(&inverse, &t->ctm);
+ inverse = fz_invert_matrix(t->ctm);
fz_write_printf(ctx, out, "<g");
svg_dev_ctm(ctx, sdev, &inverse);
fz_write_printf(ctx, out, ">\n");
diff --git a/source/fitz/test-device.c b/source/fitz/test-device.c
index 8b2a7639..6eb1709e 100644
--- a/source/fitz/test-device.c
+++ b/source/fitz/test-device.c
@@ -177,7 +177,7 @@ fz_test_fill_shade(fz_context *ctx, fz_device *dev_, fz_shade *shade, const fz_m
arg.dev = dev;
arg.shade = shade;
arg.color_params = color_params;
- fz_process_shade(ctx, shade, ctm, prepare_vertex, NULL, &arg);
+ fz_process_shade(ctx, shade, *ctm, prepare_vertex, NULL, &arg);
}
}
}
diff --git a/source/fitz/text.c b/source/fitz/text.c
index 90698125..7fb46ae5 100644
--- a/source/fitz/text.c
+++ b/source/fitz/text.c
@@ -40,7 +40,7 @@ fz_drop_text(fz_context *ctx, const fz_text *textc)
}
static fz_text_span *
-fz_new_text_span(fz_context *ctx, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, const fz_matrix *trm)
+fz_new_text_span(fz_context *ctx, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, fz_matrix trm)
{
fz_text_span *span = fz_malloc_struct(ctx, fz_text_span);
span->font = fz_keep_font(ctx, font);
@@ -48,14 +48,14 @@ fz_new_text_span(fz_context *ctx, fz_font *font, int wmode, int bidi_level, fz_b
span->bidi_level = bidi_level;
span->markup_dir = markup_dir;
span->language = language;
- span->trm = *trm;
+ span->trm = trm;
span->trm.e = 0;
span->trm.f = 0;
return span;
}
static fz_text_span *
-fz_add_text_span(fz_context *ctx, fz_text *text, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, const fz_matrix *trm)
+fz_add_text_span(fz_context *ctx, fz_text *text, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, fz_matrix trm)
{
if (!text->tail)
{
@@ -66,10 +66,10 @@ fz_add_text_span(fz_context *ctx, fz_text *text, fz_font *font, int wmode, int b
text->tail->bidi_level != bidi_level ||
text->tail->markup_dir != markup_dir ||
text->tail->language != language ||
- text->tail->trm.a != trm->a ||
- text->tail->trm.b != trm->b ||
- text->tail->trm.c != trm->c ||
- text->tail->trm.d != trm->d)
+ text->tail->trm.a != trm.a ||
+ text->tail->trm.b != trm.b ||
+ text->tail->trm.c != trm.c ||
+ text->tail->trm.d != trm.d)
{
text->tail = text->tail->next = fz_new_text_span(ctx, font, wmode, bidi_level, markup_dir, language, trm);
}
@@ -89,7 +89,7 @@ fz_grow_text_span(fz_context *ctx, fz_text_span *span, int n)
}
void
-fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *trm, int gid, int ucs, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language lang)
+fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, fz_matrix trm, int gid, int ucs, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language lang)
{
fz_text_span *span;
@@ -102,8 +102,8 @@ fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *tr
span->items[span->len].ucs = ucs;
span->items[span->len].gid = gid;
- span->items[span->len].x = trm->e;
- span->items[span->len].y = trm->f;
+ span->items[span->len].x = trm.e;
+ span->items[span->len].y = trm.f;
span->len++;
}
@@ -118,24 +118,25 @@ fz_show_string(fz_context *ctx, fz_text *text, fz_font *user_font, fz_matrix *tr
{
s += fz_chartorune(&ucs, s);
gid = fz_encode_character_with_fallback(ctx, user_font, ucs, 0, language, &font);
- fz_show_glyph(ctx, text, font, trm, gid, ucs, wmode, bidi_level, markup_dir, language);
+ fz_show_glyph(ctx, text, font, *trm, gid, ucs, wmode, bidi_level, markup_dir, language);
adv = fz_advance_glyph(ctx, font, gid, wmode);
if (wmode == 0)
- fz_pre_translate(trm, adv, 0);
+ *trm = fz_pre_translate(*trm, adv, 0);
else
- fz_pre_translate(trm, 0, -adv);
+ *trm = fz_pre_translate(*trm, 0, -adv);
}
}
-fz_rect *
-fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *bbox)
+fz_rect
+fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, fz_matrix ctm)
{
fz_text_span *span;
fz_matrix tm, trm;
fz_rect gbox;
+ fz_rect bbox;
int i;
- *bbox = fz_empty_rect;
+ bbox = fz_empty_rect;
for (span = text->head; span; span = span->next)
{
@@ -148,9 +149,9 @@ fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *strok
{
tm.e = span->items[i].x;
tm.f = span->items[i].y;
- fz_concat(&trm, &tm, ctm);
- fz_bound_glyph(ctx, span->font, span->items[i].gid, &trm, &gbox);
- fz_union_rect(bbox, &gbox);
+ trm = fz_concat(tm, ctm);
+ gbox = fz_bound_glyph(ctx, span->font, span->items[i].gid, trm);
+ bbox = fz_union_rect(bbox, gbox);
}
}
}
@@ -159,13 +160,13 @@ fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *strok
if (!fz_is_empty_rect(bbox))
{
if (stroke)
- fz_adjust_rect_for_stroke(ctx, bbox, stroke, ctm);
+ bbox = fz_adjust_rect_for_stroke(ctx, bbox, stroke, ctm);
/* Compensate for the glyph cache limited positioning precision */
- bbox->x0 -= 1;
- bbox->y0 -= 1;
- bbox->x1 += 1;
- bbox->y1 += 1;
+ bbox.x0 -= 1;
+ bbox.y0 -= 1;
+ bbox.x1 += 1;
+ bbox.y1 += 1;
}
return bbox;
diff --git a/source/fitz/util.c b/source/fitz/util.c
index 0f935e53..ddbb36b8 100644
--- a/source/fitz/util.c
+++ b/source/fitz/util.c
@@ -6,11 +6,9 @@ fz_display_list *
fz_new_display_list_from_page(fz_context *ctx, fz_page *page)
{
fz_display_list *list;
- fz_rect bounds;
fz_device *dev = NULL;
- list = fz_new_display_list(ctx, fz_bound_page(ctx, page, &bounds));
-
+ list = fz_new_display_list(ctx, fz_bound_page(ctx, page));
fz_try(ctx)
{
dev = fz_new_list_device(ctx, list);
@@ -50,10 +48,9 @@ fz_display_list *
fz_new_display_list_from_page_contents(fz_context *ctx, fz_page *page)
{
fz_display_list *list;
- fz_rect bounds;
fz_device *dev = NULL;
- list = fz_new_display_list(ctx, fz_bound_page(ctx, page, &bounds));
+ list = fz_new_display_list(ctx, fz_bound_page(ctx, page));
fz_try(ctx)
{
@@ -78,10 +75,9 @@ fz_display_list *
fz_new_display_list_from_annot(fz_context *ctx, fz_annot *annot)
{
fz_display_list *list;
- fz_rect bounds;
fz_device *dev = NULL;
- list = fz_new_display_list(ctx, fz_bound_annot(ctx, annot, &bounds));
+ list = fz_new_display_list(ctx, fz_bound_annot(ctx, annot));
fz_try(ctx)
{
@@ -106,15 +102,15 @@ fz_pixmap *
fz_new_pixmap_from_display_list(fz_context *ctx, fz_display_list *list, const fz_matrix *ctm, fz_colorspace *cs, int alpha)
{
fz_rect rect;
- fz_irect irect;
+ fz_irect bbox;
fz_pixmap *pix;
fz_device *dev = NULL;
- fz_bound_display_list(ctx, list, &rect);
- fz_transform_rect(&rect, ctm);
- fz_round_rect(&irect, &rect);
+ rect = fz_bound_display_list(ctx, list);
+ rect = fz_transform_rect(rect, *ctm);
+ bbox = fz_round_rect(rect);
- pix = fz_new_pixmap_with_bbox(ctx, cs, &irect, 0, alpha);
+ pix = fz_new_pixmap_with_bbox(ctx, cs, bbox, 0, alpha);
if (alpha)
fz_clear_pixmap(ctx, pix);
else
@@ -143,15 +139,15 @@ fz_pixmap *
fz_new_pixmap_from_page_contents(fz_context *ctx, fz_page *page, const fz_matrix *ctm, fz_colorspace *cs, int alpha)
{
fz_rect rect;
- fz_irect irect;
+ fz_irect bbox;
fz_pixmap *pix;
fz_device *dev = NULL;
- fz_bound_page(ctx, page, &rect);
- fz_transform_rect(&rect, ctm);
- fz_round_rect(&irect, &rect);
+ rect = fz_bound_page(ctx, page);
+ rect = fz_transform_rect(rect, *ctm);
+ bbox = fz_round_rect(rect);
- pix = fz_new_pixmap_with_bbox(ctx, cs, &irect, 0, alpha);
+ pix = fz_new_pixmap_with_bbox(ctx, cs, bbox, 0, alpha);
if (alpha)
fz_clear_pixmap(ctx, pix);
else
@@ -180,15 +176,15 @@ fz_pixmap *
fz_new_pixmap_from_annot(fz_context *ctx, fz_annot *annot, const fz_matrix *ctm, fz_colorspace *cs, int alpha)
{
fz_rect rect;
- fz_irect irect;
+ fz_irect bbox;
fz_pixmap *pix;
fz_device *dev = NULL;
- fz_bound_annot(ctx, annot, &rect);
- fz_transform_rect(&rect, ctm);
- fz_round_rect(&irect, &rect);
+ rect = fz_bound_annot(ctx, annot);
+ rect = fz_transform_rect(rect, *ctm);
+ bbox = fz_round_rect(rect);
- pix = fz_new_pixmap_with_bbox(ctx, cs, &irect, 0, alpha);
+ pix = fz_new_pixmap_with_bbox(ctx, cs, bbox, 0, alpha);
if (alpha)
fz_clear_pixmap(ctx, pix);
else
@@ -217,15 +213,15 @@ fz_pixmap *
fz_new_pixmap_from_page(fz_context *ctx, fz_page *page, const fz_matrix *ctm, fz_colorspace *cs, int alpha)
{
fz_rect rect;
- fz_irect irect;
+ fz_irect bbox;
fz_pixmap *pix;
fz_device *dev = NULL;
- fz_bound_page(ctx, page, &rect);
- fz_transform_rect(&rect, ctm);
- fz_round_rect(&irect, &rect);
+ rect = fz_bound_page(ctx, page);
+ rect = fz_transform_rect(rect, *ctm);
+ bbox = fz_round_rect(rect);
- pix = fz_new_pixmap_with_bbox(ctx, cs, &irect, 0, alpha);
+ pix = fz_new_pixmap_with_bbox(ctx, cs, bbox, 0, alpha);
if (alpha)
fz_clear_pixmap(ctx, pix);
else
@@ -271,12 +267,11 @@ fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, cons
{
fz_stext_page *text;
fz_device *dev = NULL;
- fz_rect mediabox;
if (list == NULL)
return NULL;
- text = fz_new_stext_page(ctx, fz_bound_display_list(ctx, list, &mediabox));
+ text = fz_new_stext_page(ctx, fz_bound_display_list(ctx, list));
fz_try(ctx)
{
dev = fz_new_stext_device(ctx, text, options);
@@ -301,12 +296,11 @@ fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, const fz_stext_optio
{
fz_stext_page *text;
fz_device *dev = NULL;
- fz_rect mediabox;
if (page == NULL)
return NULL;
- text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox));
+ text = fz_new_stext_page(ctx, fz_bound_page(ctx, page));
fz_try(ctx)
{
dev = fz_new_stext_device(ctx, text, options);