summaryrefslogtreecommitdiff
path: root/draw
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2013-01-30 14:05:56 +0100
committerTor Andersson <tor.andersson@artifex.com>2013-01-30 14:13:01 +0100
commit29f7d13d37022303c5d93ddd2942f6b87959f432 (patch)
tree0f1eeb4f3778713fe99b34649336aa27ddaf9a71 /draw
parent01e2ccf6ade55cc20e83b80bad81fef6627c9a05 (diff)
downloadmupdf-29f7d13d37022303c5d93ddd2942f6b87959f432.tar.xz
Always pass value structs (rect, matrix, etc) as values not by pointer.
Diffstat (limited to 'draw')
-rw-r--r--draw/draw_affine.c139
-rw-r--r--draw/draw_device.c4
2 files changed, 72 insertions, 71 deletions
diff --git a/draw/draw_affine.c b/draw/draw_affine.c
index e74bef2b..be41aa35 100644
--- a/draw/draw_affine.c
+++ b/draw/draw_affine.c
@@ -463,135 +463,136 @@ fz_paint_affine_color_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int
*/
#define MY_EPSILON 0.001
-void
-fz_gridfit_matrix(fz_matrix *m)
+fz_matrix
+fz_gridfit_matrix(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 (m->a > 0)
+ 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.0; /* 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.0; /* 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.0; /* 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.0; /* Ensure it moves left */
- m->a = f;
+ m.a = f;
}
- if (m->d > 0)
+ 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.0; /* 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.0; /* 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.0; /* 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.0; /* 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 (m->b > 0)
+ 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.0; /* 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.0; /* 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.0; /* 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.0; /* Ensure it moves left */
- m->b = f;
+ m.b = f;
}
- if (m->c > 0)
+ 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.0; /* 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.0; /* 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.0; /* 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.0; /* Ensure it moves up */
- m->c = f;
+ m.c = f;
}
}
+ return m;
}
/* Draw an image with an affine transform on destination */
@@ -609,7 +610,7 @@ fz_paint_image_imp(fz_pixmap *dst, fz_irect scissor, fz_pixmap *shape, fz_pixmap
void (*paintfn)(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha, byte *color, byte *hp);
/* grid fit the image */
- fz_gridfit_matrix(&ctm);
+ ctm = fz_gridfit_matrix(ctm);
/* turn on interpolation for upscaled and non-rectilinear transforms */
dolerp = 0;
diff --git a/draw/draw_device.c b/draw/draw_device.c
index ebca7fdc..b992ce09 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -992,7 +992,7 @@ fz_transform_pixmap(fz_draw_device *dev, fz_pixmap *image, fz_matrix *ctm, int x
/* Unrotated or X-flip or Y-flip or XY-flip */
fz_matrix m = *ctm;
if (gridfit)
- fz_gridfit_matrix(&m);
+ m = fz_gridfit_matrix(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)
return NULL;
@@ -1009,7 +1009,7 @@ fz_transform_pixmap(fz_draw_device *dev, fz_pixmap *image, fz_matrix *ctm, int x
fz_matrix m = *ctm;
fz_irect rclip;
if (gridfit)
- fz_gridfit_matrix(&m);
+ m = fz_gridfit_matrix(m);
if (clip)
{
rclip.x0 = clip->y0;