summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-08-06 02:34:39 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-08-06 02:34:39 +0200
commit70d7705aaa7a31436b50976482825e9f8c1f6c4e (patch)
treee8b641b46b3c79468809d4d2316562db84adf825
parent7926d3cbd583e45e59532fa473713e7d54424811 (diff)
downloadmupdf-70d7705aaa7a31436b50976482825e9f8c1f6c4e.tar.xz
Cosmetic style fixes.
-rw-r--r--draw/draw_affine.c4
-rw-r--r--draw/draw_device.c33
-rw-r--r--fitz/dev_list.c13
-rw-r--r--fitz/fitz.h8
-rw-r--r--fitz/res_font.c4
-rw-r--r--fitz/res_halftone.c21
-rw-r--r--fitz/res_pixmap.c63
7 files changed, 56 insertions, 90 deletions
diff --git a/draw/draw_affine.c b/draw/draw_affine.c
index 249e6215..95d28bea 100644
--- a/draw/draw_affine.c
+++ b/draw/draw_affine.c
@@ -516,8 +516,8 @@ fz_paint_image_imp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap
fd = inv.d * 65536;
/* Calculate initial texture positions. Do a half step to start. */
- u = (fa * x) + (fc * y) + inv.e * 65536 + ((fa+fc)>>1);
- v = (fb * x) + (fd * y) + inv.f * 65536 + ((fb+fd)>>1);
+ u = (fa * x) + (fc * y) + inv.e * 65536 + ((fa + fc) >> 1);
+ v = (fb * x) + (fd * y) + inv.f * 65536 + ((fb + fd) >> 1);
dp = dst->samples + ((y - dst->y) * dst->w + (x - dst->x)) * dst->n;
n = dst->n;
diff --git a/draw/draw_device.c b/draw/draw_device.c
index 3c1f8114..f8e802cd 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -76,8 +76,7 @@ static void fz_dump_blend(fz_pixmap *pix, const char *s)
static void dump_spaces(int x, const char *s)
{
int i;
-
- for (i=0; i < x; i++)
+ for (i = 0; i < x; i++)
printf(" ");
printf("%s", s);
}
@@ -112,9 +111,9 @@ static void fz_knockout_begin(void *user)
{
fz_pixmap *prev;
int i = dev->top;
- do {
+ do
prev = dev->stack[--i].dest;
- } while (prev == NULL);
+ while (prev == NULL);
fz_copy_pixmap_rect(dest, prev, bbox);
}
@@ -332,9 +331,8 @@ fz_draw_clip_path(void *user, fz_path *path, fz_rect *rect, int even_odd, fz_mat
bbox = fz_bound_gel(dev->gel);
bbox = fz_intersect_bbox(bbox, dev->scissor);
- if (rect) {
+ if (rect)
bbox = fz_intersect_bbox(bbox, fz_round_rect(*rect));
- }
if (fz_is_empty_rect(bbox) || fz_is_rect_gel(dev->gel))
{
@@ -858,7 +856,7 @@ fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int
if (ctm->a != 0 && ctm->b == 0 && ctm->c == 0 && ctm->d != 0)
{
- /* Unrotated or X flip or Yflip or XYflip */
+ /* Unrotated or X-flip or Y-flip or XY-flip */
scaled = fz_scale_pixmap_gridfit(image, ctm->e, ctm->f, ctm->a, ctm->d, gridfit);
if (scaled == NULL)
return NULL;
@@ -868,6 +866,7 @@ fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int
ctm->f = scaled->y;
return scaled;
}
+
if (ctm->a == 0 && ctm->b != 0 && ctm->c != 0 && ctm->d == 0)
{
/* Other orthogonal flip/rotation cases */
@@ -880,12 +879,14 @@ fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int
ctm->e = scaled->y;
return scaled;
}
+
/* Downscale, non rectilinear case */
if (dx > 0 && dy > 0)
{
scaled = fz_scale_pixmap(image, 0, 0, (float)dx, (float)dy);
return scaled;
}
+
return NULL;
}
@@ -930,7 +931,8 @@ fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
if (dx < image->w && dy < image->h)
{
- scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy, (alpha == 1.0f) && ((dev->flags & FZ_DRAWDEV_FLAGS_TYPE3) == 0));
+ int gridfit = alpha == 1.0f && !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3);
+ scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
if (scaled == NULL)
{
if (dx < 1)
@@ -991,7 +993,8 @@ fz_draw_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm,
dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
if (dx < image->w && dy < image->h)
{
- scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy, (alpha == 1.0f) && ((dev->flags & FZ_DRAWDEV_FLAGS_TYPE3) == 0));
+ int gridfit = alpha == 1.0f && !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3);
+ scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
if (scaled == NULL)
{
if (dx < 1)
@@ -1071,7 +1074,8 @@ fz_draw_clip_image_mask(void *user, fz_pixmap *image, fz_rect *rect, fz_matrix c
dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
if (dx < image->w && dy < image->h)
{
- scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy, (dev->flags & FZ_DRAWDEV_FLAGS_TYPE3) == 0);
+ int gridfit = !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3);
+ scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
if (scaled == NULL)
{
if (dx < 1)
@@ -1562,12 +1566,7 @@ fz_device *
fz_new_draw_device_type3(fz_glyph_cache *cache, fz_pixmap *dest)
{
fz_device *dev = fz_new_draw_device(cache, dest);
-
- if (dev)
- {
- fz_draw_device *ddev = (fz_draw_device *)dev->user;
-
- ddev->flags |= FZ_DRAWDEV_FLAGS_TYPE3;
- }
+ fz_draw_device *ddev = dev->user;
+ ddev->flags |= FZ_DRAWDEV_FLAGS_TYPE3;
return dev;
}
diff --git a/fitz/dev_list.c b/fitz/dev_list.c
index be43219c..955824f9 100644
--- a/fitz/dev_list.c
+++ b/fitz/dev_list.c
@@ -107,7 +107,8 @@ fz_clone_stroke_state(fz_stroke_state *stroke)
static void
fz_append_display_node(fz_display_list *list, fz_display_node *node)
{
- switch (node->cmd) {
+ switch (node->cmd)
+ {
case FZ_CMD_CLIP_PATH:
case FZ_CMD_CLIP_STROKE_PATH:
case FZ_CMD_CLIP_IMAGE_MASK:
@@ -130,7 +131,7 @@ fz_append_display_node(fz_display_list *list, fz_display_node *node)
break;
case FZ_CMD_BEGIN_TILE:
list->tiled++;
- if ((list->top > 0) && (list->top < STACK_SIZE))
+ if (list->top > 0 && list->top < STACK_SIZE)
{
list->stack[list->top-1].rect = fz_infinite_rect;
}
@@ -146,8 +147,7 @@ fz_append_display_node(fz_display_list *list, fz_display_node *node)
list->top--;
node->rect = fz_infinite_rect;
}
- else
- if (list->top > 0)
+ else if (list->top > 0)
{
fz_rect *update;
list->top--;
@@ -165,11 +165,10 @@ fz_append_display_node(fz_display_list *list, fz_display_node *node)
else
node->rect = fz_infinite_rect;
}
- /*@fallthrough@*/
+ /* fallthrough */
default:
- if ((list->top > 0) && (list->tiled == 0) && (list->top <= STACK_SIZE)) {
+ if (list->top > 0 && list->tiled == 0 && list->top <= STACK_SIZE)
list->stack[list->top-1].rect = fz_union_rect(list->stack[list->top-1].rect, node->rect);
- }
break;
}
if (!list->first)
diff --git a/fitz/fitz.h b/fitz/fitz.h
index cee62bc8..7187094f 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -291,7 +291,7 @@ struct fz_md5_s
};
void fz_md5_init(fz_md5 *state);
-void fz_md5_update(fz_md5 *state, const unsigned char *input, const unsigned inlen);
+void fz_md5_update(fz_md5 *state, const unsigned char *input, unsigned inlen);
void fz_md5_final(fz_md5 *state, unsigned char digest[16]);
/* sha-256 digests */
@@ -323,8 +323,8 @@ struct fz_arc4_s
unsigned char state[256];
};
-void fz_arc4_init(fz_arc4 *state, const unsigned char *key, const unsigned len);
-void fz_arc4_encrypt(fz_arc4 *state, unsigned char *dest, const unsigned char *src, const unsigned len);
+void fz_arc4_init(fz_arc4 *state, const unsigned char *key, unsigned len);
+void fz_arc4_encrypt(fz_arc4 *state, unsigned char *dest, const unsigned char *src, unsigned len);
/* AES block cipher implementation from XYSSL */
@@ -621,7 +621,7 @@ void fz_drop_pixmap(fz_pixmap *pix);
void fz_clear_pixmap(fz_pixmap *pix);
void fz_clear_pixmap_with_color(fz_pixmap *pix, int value);
void fz_clear_pixmap_rect_with_color(fz_pixmap *pix, int value, fz_bbox r);
-void fz_copy_pixmap_rect(fz_pixmap *dest, const fz_pixmap *src, fz_bbox r);
+void fz_copy_pixmap_rect(fz_pixmap *dest, fz_pixmap *src, fz_bbox r);
void fz_premultiply_pixmap(fz_pixmap *pix);
fz_pixmap *fz_alpha_from_gray(fz_pixmap *gray, int luminosity);
fz_bbox fz_bound_pixmap(fz_pixmap *pix);
diff --git a/fitz/res_font.c b/fitz/res_font.c
index 17646ea3..ffee1d46 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -535,6 +535,7 @@ fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm, fz_colorspace *model)
error = font->t3run(font->t3xref, font->t3resources, contents, dev, ctm);
if (error)
fz_catch(error, "cannot draw type3 glyph");
+
if (dev->flags & FZ_CHARPROC_MASK)
{
if (dev->flags & FZ_CHARPROC_COLOR)
@@ -551,6 +552,7 @@ fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm, fz_colorspace *model)
fz_warn("type3 glyph doesn't specify masked or colored");
model = NULL; /* Treat as masked */
}
+
fz_free_device(dev);
bbox.x0--;
@@ -558,7 +560,7 @@ fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm, fz_colorspace *model)
bbox.x1++;
bbox.y1++;
- glyph = fz_new_pixmap_with_rect((model ? model : fz_device_gray), bbox);
+ glyph = fz_new_pixmap_with_rect(model ? model : fz_device_gray, bbox);
fz_clear_pixmap(glyph);
cache = fz_new_glyph_cache();
diff --git a/fitz/res_halftone.c b/fitz/res_halftone.c
index 6a7a8f42..e45454ea 100644
--- a/fitz/res_halftone.c
+++ b/fitz/res_halftone.c
@@ -9,7 +9,7 @@ fz_new_halftone(int comps)
ht = fz_malloc(sizeof(fz_halftone) + (comps-1)*sizeof(fz_pixmap *));
ht->refs = 1;
ht->n = comps;
- for (i=0; i < comps; i++)
+ for (i = 0; i < comps; i++)
ht->comp[i] = NULL;
return ht;
@@ -29,10 +29,8 @@ fz_drop_halftone(fz_halftone *ht)
if (!ht || --ht->refs != 0)
return;
- for (i=0; i < ht->n; i++)
- {
+ for (i = 0; i < ht->n; i++)
fz_drop_pixmap(ht->comp[i]);
- }
fz_free(ht);
}
@@ -60,19 +58,8 @@ static unsigned char mono_ht[] =
fz_halftone *fz_get_default_halftone(int num_comps)
{
fz_halftone *ht = fz_new_halftone(num_comps);
-
- if (ht == NULL)
- return NULL;
-
- /* Only support 1 component for now */
- assert(num_comps == 1);
-
+ assert(num_comps == 1); /* Only support 1 component for now */
ht->comp[0] = fz_new_pixmap_with_data(NULL, 16, 16, mono_ht);
- if (ht->comp[0] == NULL)
- {
- fz_drop_halftone(ht);
- return NULL;
- }
return ht;
}
@@ -85,7 +72,7 @@ static void make_ht_line(unsigned char *buf, fz_halftone *ht, int x, int y, int
*/
int k, n;
n = ht->n;
- for (k=0; k < n; k++)
+ for (k = 0; k < n; k++)
{
fz_pixmap *tile = ht->comp[k];
unsigned char *b = buf++;
diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c
index 36180a3b..fdd5c357 100644
--- a/fitz/res_pixmap.c
+++ b/fitz/res_pixmap.c
@@ -105,6 +105,17 @@ fz_drop_pixmap(fz_pixmap *pix)
}
}
+fz_bbox
+fz_bound_pixmap(fz_pixmap *pix)
+{
+ fz_bbox bbox;
+ bbox.x0 = pix->x;
+ bbox.y0 = pix->y;
+ bbox.x1 = pix->x + pix->w;
+ bbox.y1 = pix->y + pix->h;
+ return bbox;
+}
+
void
fz_clear_pixmap(fz_pixmap *pix)
{
@@ -133,37 +144,24 @@ fz_clear_pixmap_with_color(fz_pixmap *pix, int value)
}
void
-fz_copy_pixmap_rect(fz_pixmap *dest, const fz_pixmap *src, fz_bbox r)
+fz_copy_pixmap_rect(fz_pixmap *dest, fz_pixmap *src, fz_bbox r)
{
const unsigned char *srcp;
unsigned char *destp;
int y, w, destspan, srcspan;
- if (r.x0 < dest->x)
- r.x0 = dest->x;
- if (r.x1 > dest->x+dest->w)
- r.x1 = dest->x+dest->w;
- if (r.y0 < dest->y)
- r.y0 = dest->y;
- if (r.y1 > dest->y+dest->h)
- r.y1 = dest->y+dest->h;
- if (r.x0 < src->x)
- r.x0 = src->x;
- if (r.x1 > src->x+src->w)
- r.x1 = src->x+src->w;
- if (r.y0 < src->y)
- r.y0 = src->y;
- if (r.y1 > src->y+src->h)
- r.y1 = src->y+src->h;
+ r = fz_intersect_bbox(r, fz_bound_pixmap(dest));
+ r = fz_intersect_bbox(r, fz_bound_pixmap(src));
w = r.x1 - r.x0;
y = r.y1 - r.y0;
- if ((w <= 0) || (y <= 0))
+ if (w <= 0 || y <= 0)
return;
+
w *= src->n;
srcspan = src->w * src->n;
srcp = src->samples + srcspan * (r.y0 - src->y) + src->n * (r.x0 - src->x);
destspan = dest->w * dest->n;
- destp = dest->samples + destspan * (r.y0-dest->y) + dest->n * (r.x0 - dest->x);
+ destp = dest->samples + destspan * (r.y0 - dest->y) + dest->n * (r.x0 - dest->x);
do
{
memcpy(destp, srcp, w);
@@ -179,20 +177,14 @@ fz_clear_pixmap_rect_with_color(fz_pixmap *dest, int value, fz_bbox r)
unsigned char *destp;
int x, y, w, k, destspan;
- if (r.x0 < dest->x)
- r.x0 = dest->x;
- if (r.x1 > dest->x+dest->w)
- r.x1 = dest->x+dest->w;
- if (r.y0 < dest->y)
- r.y0 = dest->y;
- if (r.y1 > dest->y+dest->h)
- r.y1 = dest->y+dest->h;
+ r = fz_intersect_bbox(r, fz_bound_pixmap(dest));
w = r.x1 - r.x0;
y = r.y1 - r.y0;
- if ((w <= 0) || (y <= 0))
+ if (w <= 0 || y <= 0)
return;
+
destspan = dest->w * dest->n;
- destp = dest->samples + destspan * (r.y0-dest->y) + dest->n * (r.x0 - dest->x);
+ destp = dest->samples + destspan * (r.y0 - dest->y) + dest->n * (r.x0 - dest->x);
if (value == 255)
do
{
@@ -201,7 +193,6 @@ fz_clear_pixmap_rect_with_color(fz_pixmap *dest, int value, fz_bbox r)
}
while (--y);
else
- {
do
{
unsigned char *s = destp;
@@ -214,7 +205,6 @@ fz_clear_pixmap_rect_with_color(fz_pixmap *dest, int value, fz_bbox r)
destp += destspan;
}
while (--y);
- }
}
void
@@ -236,17 +226,6 @@ fz_premultiply_pixmap(fz_pixmap *pix)
}
}
-fz_bbox
-fz_bound_pixmap(fz_pixmap *pix)
-{
- fz_bbox bbox;
- bbox.x0 = pix->x;
- bbox.y0 = pix->y;
- bbox.x1 = pix->x + pix->w;
- bbox.y1 = pix->y + pix->h;
- return bbox;
-}
-
fz_pixmap *
fz_alpha_from_gray(fz_pixmap *gray, int luminosity)
{