summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'pdf')
-rw-r--r--pdf/mupdf.h4
-rw-r--r--pdf/pdf_cmap.c18
-rw-r--r--pdf/pdf_cmap_load.c2
-rw-r--r--pdf/pdf_cmap_parse.c6
-rw-r--r--pdf/pdf_colorspace.c16
-rw-r--r--pdf/pdf_crypt.c10
-rw-r--r--pdf/pdf_font.c22
-rw-r--r--pdf/pdf_function.c48
-rw-r--r--pdf/pdf_image.c4
-rw-r--r--pdf/pdf_interpret.c65
-rw-r--r--pdf/pdf_lex.c2
-rw-r--r--pdf/pdf_page.c8
-rw-r--r--pdf/pdf_parse.c4
-rw-r--r--pdf/pdf_repair.c2
-rw-r--r--pdf/pdf_shade.c38
-rw-r--r--pdf/pdf_store.c4
-rw-r--r--pdf/pdf_stream.c4
-rw-r--r--pdf/pdf_type3.c2
-rw-r--r--pdf/pdf_xref.c6
19 files changed, 137 insertions, 128 deletions
diff --git a/pdf/mupdf.h b/pdf/mupdf.h
index c2e651cc..779fb976 100644
--- a/pdf/mupdf.h
+++ b/pdf/mupdf.h
@@ -161,7 +161,7 @@ void pdf_age_store(fz_context *ctx, pdf_store *store, int maxage);
typedef struct pdf_function_s pdf_function;
fz_error pdf_load_function(pdf_function **func, pdf_xref *xref, fz_obj *ref);
-void pdf_eval_function(pdf_function *func, float *in, int inlen, float *out, int outlen);
+void pdf_eval_function(fz_context *ctx, pdf_function *func, float *in, int inlen, float *out, int outlen);
pdf_function *pdf_keep_function(pdf_function *func);
void pdf_drop_function(fz_context *ctx, pdf_function *func);
@@ -272,7 +272,7 @@ int pdf_get_wmode(pdf_cmap *cmap);
void pdf_set_wmode(pdf_cmap *cmap, int wmode);
void pdf_set_usecmap(fz_context *ctx, pdf_cmap *cmap, pdf_cmap *usecmap);
-void pdf_add_codespace(pdf_cmap *cmap, int low, int high, int n);
+void pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, int low, int high, int n);
void pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, int low, int *map, int len);
void pdf_map_range_to_range(fz_context *ctx, pdf_cmap *cmap, int srclo, int srchi, int dstlo);
void pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, int one, int *many, int len);
diff --git a/pdf/pdf_cmap.c b/pdf/pdf_cmap.c
index 3de3346b..8ae40fc5 100644
--- a/pdf/pdf_cmap.c
+++ b/pdf/pdf_cmap.c
@@ -161,11 +161,11 @@ pdf_debug_cmap(pdf_cmap *cmap)
* multi-byte encoded strings.
*/
void
-pdf_add_codespace(pdf_cmap *cmap, int low, int high, int n)
+pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, int low, int high, int n)
{
if (cmap->codespace_len + 1 == nelem(cmap->codespace))
{
- fz_warn("assert: too many code space ranges");
+ fz_warn(ctx, "assert: too many code space ranges");
return;
}
@@ -183,7 +183,7 @@ add_table(fz_context *ctx, pdf_cmap *cmap, int value)
{
if (cmap->tlen == USHRT_MAX)
{
- fz_warn("cmap table is full; ignoring additional entries");
+ fz_warn(ctx, "cmap table is full; ignoring additional entries");
return;
}
if (cmap->tlen + 1 > cmap->tcap)
@@ -229,7 +229,7 @@ pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, int low, int *table, int
int high = low + len;
int offset = cmap->tlen;
if (cmap->tlen + len >= USHRT_MAX)
- fz_warn("cannot map range to table; table is full");
+ fz_warn(ctx, "cannot map range to table; table is full");
else
{
for (i = 0; i < len; i++)
@@ -263,7 +263,7 @@ pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, int low, int *values, int l
if (len > 8)
{
- fz_warn("one to many mapping is too large (%d); truncating", len);
+ fz_warn(ctx, "one to many mapping is too large (%d); truncating", len);
len = 8;
}
@@ -271,12 +271,12 @@ pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, int low, int *values, int l
values[0] >= 0xD800 && values[0] <= 0xDBFF &&
values[1] >= 0xDC00 && values[1] <= 0xDFFF)
{
- fz_warn("ignoring surrogate pair mapping in cmap");
+ fz_warn(ctx, "ignoring surrogate pair mapping in cmap");
return;
}
if (cmap->tlen + len + 1 >= USHRT_MAX)
- fz_warn("cannot map one to many; table is full");
+ fz_warn(ctx, "cannot map one to many; table is full");
else
{
offset = cmap->tlen;
@@ -311,7 +311,7 @@ pdf_sort_cmap(fz_context *ctx, pdf_cmap *cmap)
if (cmap->tlen == USHRT_MAX)
{
- fz_warn("cmap table is full; will not combine ranges");
+ fz_warn(ctx, "cmap table is full; will not combine ranges");
return;
}
@@ -398,7 +398,7 @@ pdf_sort_cmap(fz_context *ctx, pdf_cmap *cmap)
cmap->rlen = a - cmap->ranges + 1;
- fz_flush_warnings();
+ fz_flush_warnings(ctx);
}
/*
diff --git a/pdf/pdf_cmap_load.c b/pdf/pdf_cmap_load.c
index 4329ad19..c962c6ca 100644
--- a/pdf/pdf_cmap_load.c
+++ b/pdf/pdf_cmap_load.c
@@ -86,7 +86,7 @@ pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes)
{
pdf_cmap *cmap = pdf_new_cmap(ctx);
sprintf(cmap->cmap_name, "Identity-%c", wmode ? 'V' : 'H');
- pdf_add_codespace(cmap, 0x0000, 0xffff, bytes);
+ pdf_add_codespace(ctx, cmap, 0x0000, 0xffff, bytes);
pdf_map_range_to_range(ctx, cmap, 0x0000, 0xffff, 0);
pdf_sort_cmap(ctx, cmap);
pdf_set_wmode(cmap, wmode);
diff --git a/pdf/pdf_cmap_parse.c b/pdf/pdf_cmap_parse.c
index 1e71e176..d048271f 100644
--- a/pdf/pdf_cmap_parse.c
+++ b/pdf/pdf_cmap_parse.c
@@ -78,7 +78,7 @@ pdf_parse_cmap_name(pdf_cmap *cmap, fz_stream *file)
if (tok == PDF_TOK_NAME)
fz_strlcpy(cmap->cmap_name, buf, sizeof(cmap->cmap_name));
else
- fz_warn("expected name after CMapName in cmap");
+ fz_warn(file->ctx, "expected name after CMapName in cmap");
return fz_okay;
}
@@ -98,7 +98,7 @@ pdf_parse_wmode(pdf_cmap *cmap, fz_stream *file)
if (tok == PDF_TOK_INT)
pdf_set_wmode(cmap, atoi(buf));
else
- fz_warn("expected integer after WMode in cmap");
+ fz_warn(file->ctx, "expected integer after WMode in cmap");
return fz_okay;
}
@@ -130,7 +130,7 @@ pdf_parse_codespace_range(pdf_cmap *cmap, fz_stream *file)
if (tok == PDF_TOK_STRING)
{
hi = pdf_code_from_string(buf, len);
- pdf_add_codespace(cmap, lo, hi, len);
+ pdf_add_codespace(file->ctx, cmap, lo, hi, len);
}
else break;
}
diff --git a/pdf/pdf_colorspace.c b/pdf/pdf_colorspace.c
index 1a2e79b3..4c4368cc 100644
--- a/pdf/pdf_colorspace.c
+++ b/pdf/pdf_colorspace.c
@@ -30,7 +30,7 @@ static inline float fung(float x)
}
static void
-lab_to_rgb(fz_colorspace *cs, float *lab, float *rgb)
+lab_to_rgb(fz_context *ctx, fz_colorspace *cs, float *lab, float *rgb)
{
/* input is in range (0..100, -128..127, -128..127) not (0..1, 0..1, 0..1) */
float lstar, astar, bstar, l, m, n, x, y, z, r, g, b;
@@ -52,9 +52,9 @@ lab_to_rgb(fz_colorspace *cs, float *lab, float *rgb)
}
static void
-rgb_to_lab(fz_colorspace *cs, float *rgb, float *lab)
+rgb_to_lab(fz_context *ctx, fz_colorspace *cs, float *rgb, float *lab)
{
- fz_warn("cannot convert into L*a*b colorspace");
+ fz_warn(ctx, "cannot convert into L*a*b colorspace");
lab[0] = rgb[0];
lab[1] = rgb[1];
lab[2] = rgb[2];
@@ -72,12 +72,12 @@ struct separation
};
static void
-separation_to_rgb(fz_colorspace *cs, float *color, float *rgb)
+separation_to_rgb(fz_context *ctx, fz_colorspace *cs, float *color, float *rgb)
{
struct separation *sep = cs->data;
float alt[FZ_MAX_COLORS];
- pdf_eval_function(sep->tint, color, cs->n, alt, sep->base->n);
- sep->base->to_rgb(sep->base, alt, rgb);
+ pdf_eval_function(ctx, sep->tint, color, cs->n, alt, sep->base->n);
+ sep->base->to_rgb(ctx, sep->base, alt, rgb);
}
static void
@@ -145,7 +145,7 @@ struct indexed
};
static void
-indexed_to_rgb(fz_colorspace *cs, float *color, float *rgb)
+indexed_to_rgb(fz_context *ctx, fz_colorspace *cs, float *color, float *rgb)
{
struct indexed *idx = cs->data;
float alt[FZ_MAX_COLORS];
@@ -154,7 +154,7 @@ indexed_to_rgb(fz_colorspace *cs, float *color, float *rgb)
i = CLAMP(i, 0, idx->high);
for (k = 0; k < idx->base->n; k++)
alt[k] = idx->lookup[i * idx->base->n + k] / 255.0f;
- idx->base->to_rgb(idx->base, alt, rgb);
+ idx->base->to_rgb(ctx, idx->base, alt, rgb);
}
static void
diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c
index 7d5b7902..523fabc1 100644
--- a/pdf/pdf_crypt.c
+++ b/pdf/pdf_crypt.c
@@ -191,7 +191,7 @@ pdf_new_crypt(fz_context *ctx, pdf_crypt **cryptp, fz_obj *dict, fz_obj *id)
memcpy(crypt->u, fz_to_str_buf(obj), 48);
else if (fz_is_string(obj) && fz_to_str_len(obj) < 32)
{
- fz_warn("encryption password key too short (%d)", fz_to_str_len(obj));
+ fz_warn(ctx, "encryption password key too short (%d)", fz_to_str_len(obj));
memcpy(crypt->u, fz_to_str_buf(obj), fz_to_str_len(obj));
}
else
@@ -242,7 +242,7 @@ pdf_new_crypt(fz_context *ctx, pdf_crypt **cryptp, fz_obj *dict, fz_obj *id)
crypt->id = fz_keep_obj(obj);
}
else
- fz_warn("missing file identifier, may not be able to do decryption");
+ fz_warn(ctx, "missing file identifier, may not be able to do decryption");
*cryptp = crypt;
return fz_okay;
@@ -298,7 +298,7 @@ pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, fz_obj *cf_obj, ch
else if (!strcmp(fz_to_name(obj), "AESV3"))
cf->method = PDF_CRYPT_AESV3;
else
- fz_error_make("unknown encryption method: %s", fz_to_name(obj));
+ fz_warn(ctx, "unknown encryption method: %s", fz_to_name(obj));
}
obj = fz_dict_gets(dict, "Length");
@@ -731,7 +731,7 @@ pdf_crypt_obj_imp(fz_context *ctx, pdf_crypt *crypt, fz_obj *obj, unsigned char
if (crypt->strf.method == PDF_CRYPT_AESV2 || crypt->strf.method == PDF_CRYPT_AESV3)
{
if (n & 15 || n < 32)
- fz_warn("invalid string length for aes encryption");
+ fz_warn(ctx, "invalid string length for aes encryption");
else
{
unsigned char iv[16];
@@ -741,7 +741,7 @@ pdf_crypt_obj_imp(fz_context *ctx, pdf_crypt *crypt, fz_obj *obj, unsigned char
aes_crypt_cbc(&aes, AES_DECRYPT, n - 16, iv, s + 16, s);
/* delete space used for iv and padding bytes at end */
if (s[n - 17] < 1 || s[n - 17] > 16)
- fz_warn("aes padding out of range");
+ fz_warn(ctx, "aes padding out of range");
else
fz_set_str_len(obj, n - 16 - s[n - 17]);
}
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c
index e1cae007..2bb69528 100644
--- a/pdf/pdf_font.c
+++ b/pdf/pdf_font.c
@@ -144,14 +144,14 @@ pdf_font_cid_to_gid(pdf_font_desc *fontdesc, int cid)
return cid;
}
-static int ft_width(pdf_font_desc *fontdesc, int cid)
+static int ft_width(fz_context *ctx, pdf_font_desc *fontdesc, int cid)
{
int gid = ft_cid_to_gid(fontdesc, cid);
int fterr = FT_Load_Glyph(fontdesc->font->ft_face, gid,
FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM);
if (fterr)
{
- fz_warn("freetype load glyph (gid %d): %s", gid, ft_error_string(fterr));
+ fz_warn(ctx, "freetype load glyph (gid %d): %s", gid, ft_error_string(fterr));
return 0;
}
return ((FT_Face)fontdesc->font->ft_face)->glyph->advance.x;
@@ -448,7 +448,7 @@ pdf_load_simple_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict)
break;
if (cp936fonts[i])
{
- fz_warn("workaround for S22PDF lying about chinese font encodings");
+ fz_warn(ctx, "workaround for S22PDF lying about chinese font encodings");
pdf_drop_font(ctx, fontdesc);
fontdesc = pdf_new_font_desc(ctx);
error = pdf_load_font_descriptor(fontdesc, xref, descriptor, "Adobe-GB1", cp936fonts[i+1]);
@@ -499,10 +499,10 @@ pdf_load_simple_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict)
{
fterr = FT_Set_Charmap(face, cmap);
if (fterr)
- fz_warn("freetype could not set cmap: %s", ft_error_string(fterr));
+ fz_warn(ctx, "freetype could not set cmap: %s", ft_error_string(fterr));
}
else
- fz_warn("freetype could not find any cmaps");
+ fz_warn(ctx, "freetype could not find any cmaps");
etable = fz_malloc_array(ctx, 256, sizeof(unsigned short));
for (i = 0; i < 256; i++)
@@ -633,7 +633,7 @@ pdf_load_simple_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict)
{
fterr = FT_Get_Glyph_Name(face, etable[i], ebuffer[i], 32);
if (fterr)
- fz_warn("freetype get glyph name (gid %d): %s", etable[i], ft_error_string(fterr));
+ fz_warn(ctx, "freetype get glyph name (gid %d): %s", etable[i], ft_error_string(fterr));
if (ebuffer[i][0])
estrings[i] = ebuffer[i];
}
@@ -679,10 +679,10 @@ skip_encoding:
{
fterr = FT_Set_Char_Size(face, 1000, 1000, 72, 72);
if (fterr)
- fz_warn("freetype set character size: %s", ft_error_string(fterr));
+ fz_warn(ctx, "freetype set character size: %s", ft_error_string(fterr));
for (i = 0; i < 256; i++)
{
- pdf_add_hmtx(ctx, fontdesc, i, i, ft_width(fontdesc, i));
+ pdf_add_hmtx(ctx, fontdesc, i, i, ft_width(ctx, fontdesc, i));
}
}
@@ -1112,17 +1112,17 @@ pdf_load_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *di
error = pdf_load_type3_font(fontdescp, xref, rdb, dict);
else if (charprocs)
{
- fz_warn("unknown font format, guessing type3.");
+ fz_warn(ctx, "unknown font format, guessing type3.");
error = pdf_load_type3_font(fontdescp, xref, rdb, dict);
}
else if (dfonts)
{
- fz_warn("unknown font format, guessing type0.");
+ fz_warn(ctx, "unknown font format, guessing type0.");
error = pdf_load_type0_font(fontdescp, xref, dict);
}
else
{
- fz_warn("unknown font format, guessing type1 or truetype.");
+ fz_warn(ctx, "unknown font format, guessing type1 or truetype.");
error = pdf_load_simple_font(fontdescp, xref, dict);
}
if (error)
diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c
index 50b09926..9078c65a 100644
--- a/pdf/pdf_function.c
+++ b/pdf/pdf_function.c
@@ -295,7 +295,7 @@ ps_index(ps_stack *st, int n)
}
static void
-ps_run(psobj *code, ps_stack *st, int pc)
+ps_run(fz_context *ctx, psobj *code, ps_stack *st, int pc)
{
int i1, i2;
float r1, r2;
@@ -642,16 +642,16 @@ ps_run(psobj *code, ps_stack *st, int pc)
case PS_OP_IF:
b1 = ps_pop_bool(st);
if (b1)
- ps_run(code, st, code[pc + 1].u.block);
+ ps_run(ctx, code, st, code[pc + 1].u.block);
pc = code[pc + 2].u.block;
break;
case PS_OP_IFELSE:
b1 = ps_pop_bool(st);
if (b1)
- ps_run(code, st, code[pc + 1].u.block);
+ ps_run(ctx, code, st, code[pc + 1].u.block);
else
- ps_run(code, st, code[pc + 0].u.block);
+ ps_run(ctx, code, st, code[pc + 0].u.block);
pc = code[pc + 2].u.block;
break;
@@ -659,13 +659,13 @@ ps_run(psobj *code, ps_stack *st, int pc)
return;
default:
- fz_warn("foreign operator in calculator function");
+ fz_warn(ctx, "foreign operator in calculator function");
return;
}
break;
default:
- fz_warn("foreign object in calculator function");
+ fz_warn(ctx, "foreign object in calculator function");
return;
}
}
@@ -866,7 +866,7 @@ load_postscript_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num,
}
static void
-eval_postscript_func(pdf_function *func, float *in, float *out)
+eval_postscript_func(fz_context *ctx, pdf_function *func, float *in, float *out)
{
ps_stack st;
float x;
@@ -880,7 +880,7 @@ eval_postscript_func(pdf_function *func, float *in, float *out)
ps_push_real(&st, x);
}
- ps_run(func->u.p.code, &st, 0);
+ ps_run(ctx, func->u.p.code, &st, 0);
for (i = func->n - 1; i >= 0; i--)
{
@@ -896,13 +896,13 @@ eval_postscript_func(pdf_function *func, float *in, float *out)
static fz_error
load_sample_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen)
{
+ fz_context *ctx = xref->ctx;
fz_error error;
fz_stream *stream;
fz_obj *obj;
int samplecount;
int bps;
int i;
- fz_context *ctx = xref->ctx;
func->u.sa.samples = NULL;
@@ -1040,7 +1040,7 @@ interpolate_sample(pdf_function *func, int *scale, int *e0, int *e1, float *efra
}
static void
-eval_sample_func(pdf_function *func, float *in, float *out)
+eval_sample_func(fz_context *ctx, pdf_function *func, float *in, float *out)
{
int e0[MAXM], e1[MAXM], scale[MAXM];
float efrac[MAXM];
@@ -1155,7 +1155,7 @@ load_exponential_func(fz_context *ctx, pdf_function *func, fz_obj *dict)
}
static void
-eval_exponential_func(pdf_function *func, float in, float *out)
+eval_exponential_func(fz_context *ctx, pdf_function *func, float in, float *out)
{
float x = in;
float tmp;
@@ -1166,7 +1166,7 @@ eval_exponential_func(pdf_function *func, float in, float *out)
/* constraint */
if ((func->u.e.n != (int)func->u.e.n && x < 0) || (func->u.e.n < 0 && x == 0))
{
- fz_warn("constraint error");
+ fz_warn(ctx, "constraint error");
return;
}
@@ -1186,6 +1186,7 @@ eval_exponential_func(pdf_function *func, float in, float *out)
static fz_error
load_stitching_func(pdf_function *func, pdf_xref *xref, fz_obj *dict)
{
+ fz_context *ctx = xref->ctx;
pdf_function **funcs;
fz_error error;
fz_obj *obj;
@@ -1193,7 +1194,6 @@ load_stitching_func(pdf_function *func, pdf_xref *xref, fz_obj *dict)
fz_obj *num;
int k;
int i;
- fz_context *ctx = xref->ctx;
func->u.st.k = 0;
@@ -1247,7 +1247,7 @@ load_stitching_func(pdf_function *func, pdf_xref *xref, fz_obj *dict)
if (k != 1 && (func->domain[0][0] > func->u.st.bounds[0] ||
func->domain[0][1] < func->u.st.bounds[k-2]))
- fz_warn("malformed shading function bounds (domain mismatch), proceeding anyway.");
+ fz_warn(ctx, "malformed shading function bounds (domain mismatch), proceeding anyway.");
}
obj = fz_dict_gets(dict, "Encode");
@@ -1267,7 +1267,7 @@ load_stitching_func(pdf_function *func, pdf_xref *xref, fz_obj *dict)
}
static void
-eval_stitching_func(pdf_function *func, float in, float *out)
+eval_stitching_func(fz_context *ctx, pdf_function *func, float in, float *out)
{
float low, high;
int k = func->u.st.k;
@@ -1305,7 +1305,7 @@ eval_stitching_func(pdf_function *func, float in, float *out)
in = lerp(in, low, high, func->u.st.encode[i*2+0], func->u.st.encode[i*2+1]);
- pdf_eval_function(func->u.st.funcs[i], &in, 1, out, func->n);
+ pdf_eval_function(ctx, func->u.st.funcs[i], &in, 1, out, func->n);
}
/*
@@ -1350,11 +1350,11 @@ pdf_drop_function(fz_context *ctx, pdf_function *func)
fz_error
pdf_load_function(pdf_function **funcp, pdf_xref *xref, fz_obj *dict)
{
+ fz_context *ctx = xref->ctx;
fz_error error;
pdf_function *func;
fz_obj *obj;
int i;
- fz_context *ctx = xref->ctx;
if ((*funcp = pdf_find_item(ctx, xref->store, (pdf_store_drop_fn *)pdf_drop_function, dict)))
{
@@ -1452,27 +1452,27 @@ pdf_load_function(pdf_function **funcp, pdf_xref *xref, fz_obj *dict)
}
void
-pdf_eval_function(pdf_function *func, float *in, int inlen, float *out, int outlen)
+pdf_eval_function(fz_context *ctx, pdf_function *func, float *in, int inlen, float *out, int outlen)
{
memset(out, 0, sizeof(float) * outlen);
if (inlen != func->m)
{
- fz_warn("tried to evaluate function with wrong number of inputs");
+ fz_warn(ctx, "tried to evaluate function with wrong number of inputs");
return;
}
if (func->n != outlen)
{
- fz_warn("tried to evaluate function with wrong number of outputs");
+ fz_warn(ctx, "tried to evaluate function with wrong number of outputs");
return;
}
switch(func->type)
{
- case SAMPLE: eval_sample_func(func, in, out); break;
- case EXPONENTIAL: eval_exponential_func(func, *in, out); break;
- case STITCHING: eval_stitching_func(func, *in, out); break;
- case POSTSCRIPT: eval_postscript_func(func, in, out); break;
+ case SAMPLE: eval_sample_func(ctx, func, in, out); break;
+ case EXPONENTIAL: eval_exponential_func(ctx, func, *in, out); break;
+ case STITCHING: eval_stitching_func(ctx, func, *in, out); break;
+ case POSTSCRIPT: eval_postscript_func(ctx, func, in, out); break;
}
}
diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c
index c5242b72..31104b9f 100644
--- a/pdf/pdf_image.c
+++ b/pdf/pdf_image.c
@@ -210,7 +210,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
if (tlen < 0)
fz_error_handle(tlen, "ignoring error at end of image");
if (tlen > 0)
- fz_warn("ignoring garbage at end of image");
+ fz_warn(ctx, "ignoring garbage at end of image");
}
fz_close(stm);
@@ -218,7 +218,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
/* Pad truncated images */
if (len < stride * h)
{
- fz_warn("padding truncated image (%d 0 R)", fz_to_num(dict));
+ fz_warn(ctx, "padding truncated image (%d 0 R)", fz_to_num(dict));
memset(samples + len, 0, stride * h - len);
}
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c
index e3272edf..cc320894 100644
--- a/pdf/pdf_interpret.c
+++ b/pdf/pdf_interpret.c
@@ -254,10 +254,10 @@ static void pdf_show_clip(pdf_csi *csi, int even_odd)
static void
pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
fz_path *path;
fz_rect bbox;
- fz_context *ctx = csi->dev->ctx;
path = csi->path;
csi->path = fz_new_path(ctx);
@@ -452,6 +452,7 @@ pdf_flush_text(pdf_csi *csi)
static void
pdf_show_char(pdf_csi *csi, int cid)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
pdf_font_desc *fontdesc = gstate->font;
fz_matrix tsm, trm;
@@ -462,7 +463,6 @@ pdf_show_char(pdf_csi *csi, int cid)
int ucsbuf[8];
int ucslen;
int i;
- fz_context *ctx = csi->dev->ctx;
tsm.a = gstate->size * gstate->scale;
tsm.b = 0;
@@ -540,12 +540,13 @@ pdf_show_char(pdf_csi *csi, int cid)
static void
pdf_show_space(pdf_csi *csi, float tadj)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
pdf_font_desc *fontdesc = gstate->font;
if (!fontdesc)
{
- fz_warn("cannot draw text since font and size not set");
+ fz_warn(ctx, "cannot draw text since font and size not set");
return;
}
@@ -558,6 +559,7 @@ pdf_show_space(pdf_csi *csi, float tadj)
static void
pdf_show_string(pdf_csi *csi, unsigned char *buf, int len)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
pdf_font_desc *fontdesc = gstate->font;
unsigned char *end = buf + len;
@@ -565,7 +567,7 @@ pdf_show_string(pdf_csi *csi, unsigned char *buf, int len)
if (!fontdesc)
{
- fz_warn("cannot draw text since font and size not set");
+ fz_warn(ctx, "cannot draw text since font and size not set");
return;
}
@@ -576,7 +578,7 @@ pdf_show_string(pdf_csi *csi, unsigned char *buf, int len)
if (cid >= 0)
pdf_show_char(csi, cid);
else
- fz_warn("cannot encode character with code point %#x", cpt);
+ fz_warn(ctx, "cannot encode character with code point %#x", cpt);
if (cpt == 32)
pdf_show_space(csi, gstate->word_space);
}
@@ -733,11 +735,12 @@ pdf_drop_material(fz_context *ctx, pdf_material *mat)
static void
pdf_gsave(pdf_csi *csi)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gs = csi->gstate + csi->gtop;
if (csi->gtop == nelem(csi->gstate) - 1)
{
- fz_warn("gstate overflow in content stream");
+ fz_warn(ctx, "gstate overflow in content stream");
return;
}
@@ -756,13 +759,13 @@ pdf_gsave(pdf_csi *csi)
static void
pdf_grestore(pdf_csi *csi)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gs = csi->gstate + csi->gtop;
int clip_depth = gs->clip_depth;
- fz_context *ctx = csi->dev->ctx;
if (csi->gtop == 0)
{
- fz_warn("gstate underflow in content stream");
+ fz_warn(ctx, "gstate underflow in content stream");
return;
}
@@ -816,6 +819,7 @@ pdf_free_csi(pdf_csi *csi)
static void
pdf_set_colorspace(pdf_csi *csi, int what, fz_colorspace *colorspace)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
@@ -823,7 +827,7 @@ pdf_set_colorspace(pdf_csi *csi, int what, fz_colorspace *colorspace)
mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
- fz_drop_colorspace(csi->dev->ctx, mat->colorspace);
+ fz_drop_colorspace(ctx, mat->colorspace);
mat->kind = PDF_MAT_COLOR;
mat->colorspace = fz_keep_colorspace(colorspace);
@@ -837,6 +841,7 @@ pdf_set_colorspace(pdf_csi *csi, int what, fz_colorspace *colorspace)
static void
pdf_set_color(pdf_csi *csi, int what, float *v)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
int i;
@@ -859,13 +864,14 @@ pdf_set_color(pdf_csi *csi, int what, float *v)
mat->v[i] = v[i];
break;
default:
- fz_warn("color incompatible with material");
+ fz_warn(ctx, "color incompatible with material");
}
}
static void
pdf_set_shade(pdf_csi *csi, int what, fz_shade *shade)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
@@ -874,7 +880,7 @@ pdf_set_shade(pdf_csi *csi, int what, fz_shade *shade)
mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
if (mat->shade)
- fz_drop_shade(csi->dev->ctx, mat->shade);
+ fz_drop_shade(ctx, mat->shade);
mat->kind = PDF_MAT_SHADE;
mat->shade = fz_keep_shade(shade);
@@ -883,6 +889,7 @@ pdf_set_shade(pdf_csi *csi, int what, fz_shade *shade)
static void
pdf_set_pattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
@@ -891,7 +898,7 @@ pdf_set_pattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v)
mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
if (mat->pattern)
- pdf_drop_pattern(csi->dev->ctx, mat->pattern);
+ pdf_drop_pattern(ctx, mat->pattern);
mat->kind = PDF_MAT_PATTERN;
if (pat)
@@ -906,13 +913,14 @@ pdf_set_pattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v)
static void
pdf_unset_pattern(pdf_csi *csi, int what)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gs = csi->gstate + csi->gtop;
pdf_material *mat;
mat = what == PDF_FILL ? &gs->fill : &gs->stroke;
if (mat->kind == PDF_MAT_PATTERN)
{
if (mat->pattern)
- pdf_drop_pattern(csi->dev->ctx, mat->pattern);
+ pdf_drop_pattern(ctx, mat->pattern);
mat->pattern = NULL;
mat->kind = PDF_MAT_COLOR;
}
@@ -925,13 +933,13 @@ pdf_unset_pattern(pdf_csi *csi, int what)
static void
pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate;
fz_matrix ptm, invptm;
fz_matrix oldtopctm;
fz_error error;
int x0, y0, x1, y1;
int oldtop;
- fz_context *ctx = csi->dev->ctx;
pdf_gsave(csi);
gstate = csi->gstate + csi->gtop;
@@ -1030,12 +1038,12 @@ cleanup:
static fz_error
pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform)
{
+ fz_context *ctx = csi->dev->ctx;
fz_error error;
pdf_gstate *gstate;
fz_matrix oldtopctm;
int oldtop;
int popmask;
- fz_context *ctx = csi->dev->ctx;
pdf_gsave(csi);
@@ -1121,10 +1129,10 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr
static fz_error
pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
fz_colorspace *colorspace;
int i, k, n;
- fz_context *ctx = csi->dev->ctx;
pdf_flush_text(csi);
@@ -1255,7 +1263,7 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
else if (!strcmp(s, "TR"))
{
if (fz_is_name(val) && strcmp(fz_to_name(val), "Identity"))
- fz_warn("ignoring transfer function");
+ fz_warn(ctx, "ignoring transfer function");
}
}
@@ -1272,13 +1280,13 @@ static void pdf_run_BDC(pdf_csi *csi)
static fz_error pdf_run_BI(pdf_csi *csi, fz_obj *rdb, fz_stream *file)
{
+ fz_context *ctx = csi->dev->ctx;
int ch;
fz_error error;
char *buf = csi->xref->scratch;
int buflen = sizeof(csi->xref->scratch);
fz_pixmap *img;
fz_obj *obj;
- fz_context *ctx = csi->dev->ctx;
error = pdf_parse_dict(&obj, csi->xref, file, buf, buflen);
if (error)
@@ -1338,10 +1346,10 @@ static void pdf_run_Bstar(pdf_csi *csi)
static fz_error pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
{
+ fz_context *ctx = csi->dev->ctx;
fz_colorspace *colorspace;
fz_obj *obj, *dict;
fz_error error;
- fz_context *ctx = csi->dev->ctx;
if (!strcmp(csi->name, "Pattern"))
{
@@ -1397,11 +1405,11 @@ static void pdf_run_DP(pdf_csi *csi)
static fz_error pdf_run_Do(pdf_csi *csi, fz_obj *rdb)
{
+ fz_context *ctx = csi->dev->ctx;
fz_obj *dict;
fz_obj *obj;
fz_obj *subtype;
fz_error error;
- fz_context *ctx = csi->dev->ctx;
dict = fz_dict_gets(rdb, "XObject");
if (!dict)
@@ -1455,7 +1463,7 @@ static fz_error pdf_run_Do(pdf_csi *csi, fz_obj *rdb)
else if (!strcmp(fz_to_name(subtype), "PS"))
{
- fz_warn("ignoring XObject with subtype PS");
+ fz_warn(ctx, "ignoring XObject with subtype PS");
}
else
@@ -1535,12 +1543,12 @@ static void pdf_run_S(pdf_csi *csi)
static fz_error pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material *mat)
{
+ fz_context *ctx = csi->dev->ctx;
fz_error error;
fz_obj *patterntype;
fz_obj *dict;
fz_obj *obj;
int kind;
- fz_context *ctx = csi->dev->ctx;
kind = mat->kind;
if (csi->name[0])
@@ -1643,11 +1651,11 @@ static void pdf_run_TL(pdf_csi *csi)
static fz_error pdf_run_Tf(pdf_csi *csi, fz_obj *rdb)
{
+ fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
fz_error error;
fz_obj *dict;
fz_obj *obj;
- fz_context *ctx = csi->dev->ctx;
gstate->size = csi->stack[0];
if (gstate->font)
@@ -1889,8 +1897,8 @@ static void pdf_run_q(pdf_csi *csi)
static void pdf_run_re(pdf_csi *csi)
{
- float x, y, w, h;
fz_context *ctx = csi->dev->ctx;
+ float x, y, w, h;
x = csi->stack[0];
y = csi->stack[1];
@@ -1921,11 +1929,11 @@ static void pdf_run(pdf_csi *csi)
static fz_error pdf_run_sh(pdf_csi *csi, fz_obj *rdb)
{
+ fz_context *ctx = csi->dev->ctx;
fz_obj *dict;
fz_obj *obj;
fz_shade *shd;
fz_error error;
- fz_context *ctx = csi->dev->ctx;
dict = fz_dict_gets(rdb, "Shading");
if (!dict)
@@ -2013,6 +2021,7 @@ static void pdf_run_dquote(pdf_csi *csi)
static fz_error
pdf_run_keyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
{
+ fz_context *ctx = csi->dev->ctx;
fz_error error;
int key;
@@ -2123,7 +2132,7 @@ pdf_run_keyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
case A('y'): pdf_run_y(csi); break;
default:
if (!csi->xbalance)
- fz_warn("unknown keyword: '%s'", buf);
+ fz_warn(ctx, "unknown keyword: '%s'", buf);
break;
}
@@ -2133,9 +2142,9 @@ pdf_run_keyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
static fz_error
pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen)
{
+ fz_context *ctx = csi->dev->ctx;
fz_error error;
int tok, len, in_array;
- fz_context *ctx = csi->dev->ctx;
/* make sure we have a clean slate if we come here from flush_text */
pdf_clear_stack(csi);
@@ -2168,7 +2177,7 @@ pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen
else if (tok == PDF_TOK_KEYWORD)
{
if (!strcmp(buf, "Tw") || !strcmp(buf, "Tc"))
- fz_warn("ignoring keyword '%s' inside array", buf);
+ fz_warn(ctx, "ignoring keyword '%s' inside array", buf);
else
return fz_error_make("syntax error in array");
}
diff --git a/pdf/pdf_lex.c b/pdf/pdf_lex.c
index 84f584b0..d34b2b6f 100644
--- a/pdf/pdf_lex.c
+++ b/pdf/pdf_lex.c
@@ -333,7 +333,7 @@ lex_hex_string(fz_stream *f, char *buf, int n)
case EOF:
goto end;
default:
- fz_warn("ignoring invalid character in hex string: '%c'", c);
+ fz_warn(f->ctx, "ignoring invalid character in hex string: '%c'", c);
}
}
end:
diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c
index 7c8fb88e..9c67edf0 100644
--- a/pdf/pdf_page.c
+++ b/pdf/pdf_page.c
@@ -83,7 +83,7 @@ pdf_load_page_tree_node(pdf_xref *xref, fz_obj *node, struct info info)
if (xref->page_len == xref->page_cap)
{
- fz_warn("found more pages than expected");
+ fz_warn(ctx, "found more pages than expected");
xref->page_cap ++;
xref->page_refs = fz_resize_array(ctx, xref->page_refs, xref->page_cap, sizeof(fz_obj*));
xref->page_objs = fz_resize_array(ctx, xref->page_objs, xref->page_cap, sizeof(fz_obj*));
@@ -263,7 +263,7 @@ pdf_load_page_contents(fz_buffer **bufp, pdf_xref *xref, fz_obj *obj)
}
else
{
- fz_warn("page contents missing, leaving page blank");
+ fz_warn(ctx, "page contents missing, leaving page blank");
*bufp = fz_new_buffer(ctx, 0);
}
@@ -302,7 +302,7 @@ pdf_load_page(pdf_page **pagep, pdf_xref *xref, int number)
bbox = fz_round_rect(pdf_to_rect(ctx, obj));
if (fz_is_empty_rect(pdf_to_rect(ctx, obj)))
{
- fz_warn("cannot find page size for page %d", number + 1);
+ fz_warn(ctx, "cannot find page size for page %d", number + 1);
bbox.x0 = 0;
bbox.y0 = 0;
bbox.x1 = 612;
@@ -323,7 +323,7 @@ pdf_load_page(pdf_page **pagep, pdf_xref *xref, int number)
if (page->mediabox.x1 - page->mediabox.x0 < 1 || page->mediabox.y1 - page->mediabox.y0 < 1)
{
- fz_warn("invalid page size in page %d", number + 1);
+ fz_warn(ctx, "invalid page size in page %d", number + 1);
page->mediabox = fz_unit_rect;
}
diff --git a/pdf/pdf_parse.c b/pdf/pdf_parse.c
index b1f22e46..5a243289 100644
--- a/pdf/pdf_parse.c
+++ b/pdf/pdf_parse.c
@@ -581,7 +581,7 @@ skip:
{
c = fz_peek_byte(file);
if (c != '\n')
- fz_warn("line feed missing after stream begin marker (%d %d R)", num, gen);
+ fz_warn(ctx, "line feed missing after stream begin marker (%d %d R)", num, gen);
else
fz_read_byte(file);
}
@@ -593,7 +593,7 @@ skip:
}
else
{
- fz_warn("expected 'endobj' or 'stream' keyword (%d %d R)", num, gen);
+ fz_warn(ctx, "expected 'endobj' or 'stream' keyword (%d %d R)", num, gen);
stm_ofs = 0;
}
diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c
index 461fd4de..969683d4 100644
--- a/pdf/pdf_repair.c
+++ b/pdf/pdf_repair.c
@@ -119,7 +119,7 @@ atobjend:
if (error)
return fz_error_note(error, "cannot scan for endobj token");
if (tok != PDF_TOK_ENDOBJ)
- fz_warn("object missing 'endobj' token");
+ fz_warn(file->ctx, "object missing 'endobj' token");
}
return fz_okay;
diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c
index 45fefba5..1c8897f6 100644
--- a/pdf/pdf_shade.c
+++ b/pdf/pdf_shade.c
@@ -322,7 +322,7 @@ pdf_make_tensor_patch(pdf_tensor_patch *p, int type, fz_point *pt)
/* Sample various functions into lookup tables */
static void
-pdf_sample_composite_shade_function(fz_shade *shade, pdf_function *func, float t0, float t1)
+pdf_sample_composite_shade_function(fz_context *ctx, fz_shade *shade, pdf_function *func, float t0, float t1)
{
int i;
float t;
@@ -330,13 +330,13 @@ pdf_sample_composite_shade_function(fz_shade *shade, pdf_function *func, float t
for (i = 0; i < 256; i++)
{
t = t0 + (i / 255.0f) * (t1 - t0);
- pdf_eval_function(func, &t, 1, shade->function[i], shade->colorspace->n);
+ pdf_eval_function(ctx, func, &t, 1, shade->function[i], shade->colorspace->n);
shade->function[i][shade->colorspace->n] = 1;
}
}
static void
-pdf_sample_component_shade_function(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1)
+pdf_sample_component_shade_function(fz_context *ctx, fz_shade *shade, int funcs, pdf_function **func, float t0, float t1)
{
int i, k;
float t;
@@ -345,19 +345,19 @@ pdf_sample_component_shade_function(fz_shade *shade, int funcs, pdf_function **f
{
t = t0 + (i / 255.0f) * (t1 - t0);
for (k = 0; k < funcs; k++)
- pdf_eval_function(func[k], &t, 1, &shade->function[i][k], 1);
+ pdf_eval_function(ctx, func[k], &t, 1, &shade->function[i][k], 1);
shade->function[i][k] = 1;
}
}
static void
-pdf_sample_shade_function(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1)
+pdf_sample_shade_function(fz_context *ctx, fz_shade *shade, int funcs, pdf_function **func, float t0, float t1)
{
shade->use_function = 1;
if (funcs == 1)
- pdf_sample_composite_shade_function(shade, func[0], t0, t1);
+ pdf_sample_composite_shade_function(ctx, shade, func[0], t0, t1);
else
- pdf_sample_component_shade_function(shade, funcs, func, t0, t1);
+ pdf_sample_component_shade_function(ctx, shade, funcs, func, t0, t1);
}
/* Type 1-3 -- Function-based, axial and radial shadings */
@@ -413,7 +413,7 @@ pdf_load_function_based_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, p
fv[0] = v[i].x;
fv[1] = v[i].y;
- pdf_eval_function(func, fv, 2, v[i].c, shade->colorspace->n);
+ pdf_eval_function(ctx, func, fv, 2, v[i].c, shade->colorspace->n);
pt.x = v[i].x;
pt.y = v[i].y;
@@ -460,7 +460,7 @@ pdf_load_axial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs,
e1 = fz_to_bool(fz_array_get(obj, 1));
}
- pdf_sample_shade_function(shade, funcs, func, d0, d1);
+ pdf_sample_shade_function(ctx, shade, funcs, func, d0, d1);
shade->type = FZ_LINEAR;
@@ -513,7 +513,7 @@ pdf_load_radial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs
e1 = fz_to_bool(fz_array_get(obj, 1));
}
- pdf_sample_shade_function(shade, funcs, func, d0, d1);
+ pdf_sample_shade_function(ctx, shade, funcs, func, d0, d1);
shade->type = FZ_RADIAL;
@@ -606,19 +606,19 @@ static void
pdf_load_type4_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
int funcs, pdf_function **func, fz_stream *stream)
{
+ fz_context *ctx = xref->ctx;
struct mesh_params p;
struct vertex va, vb, vc, vd;
int ncomp;
int flag;
int i;
- fz_context *ctx = xref->ctx;
pdf_load_mesh_params(xref, dict, &p);
if (funcs > 0)
{
ncomp = 1;
- pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]);
+ pdf_sample_shade_function(ctx, shade, funcs, func, p.c0[0], p.c1[0]);
}
else
ncomp = shade->colorspace->n;
@@ -671,19 +671,19 @@ static void
pdf_load_type5_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
int funcs, pdf_function **func, fz_stream *stream)
{
+ fz_context *ctx = xref->ctx;
struct mesh_params p;
struct vertex *buf, *ref;
int first;
int ncomp;
int i, k;
- fz_context *ctx = xref->ctx;
pdf_load_mesh_params(xref, dict, &p);
if (funcs > 0)
{
ncomp = 1;
- pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]);
+ pdf_sample_shade_function(ctx, shade, funcs, func, p.c0[0], p.c1[0]);
}
else
ncomp = shade->colorspace->n;
@@ -721,20 +721,20 @@ static void
pdf_load_type6_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
int funcs, pdf_function **func, fz_stream *stream)
{
+ fz_context *ctx = xref->ctx;
struct mesh_params p;
int haspatch, hasprevpatch;
float prevc[4][FZ_MAX_COLORS];
fz_point prevp[12];
int ncomp;
int i, k;
- fz_context *ctx = xref->ctx;
pdf_load_mesh_params(xref, dict, &p);
if (funcs > 0)
{
ncomp = 1;
- pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]);
+ pdf_sample_shade_function(ctx, shade, funcs, func, p.c0[0], p.c1[0]);
}
else
ncomp = shade->colorspace->n;
@@ -840,20 +840,20 @@ static void
pdf_load_type7_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict,
int funcs, pdf_function **func, fz_stream *stream)
{
+ fz_context *ctx = xref->ctx;
struct mesh_params p;
int haspatch, hasprevpatch;
float prevc[4][FZ_MAX_COLORS];
fz_point prevp[16];
int ncomp;
int i, k;
- fz_context *ctx = xref->ctx;
pdf_load_mesh_params(xref, dict, &p);
if (funcs > 0)
{
ncomp = 1;
- pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]);
+ pdf_sample_shade_function(ctx, shade, funcs, func, p.c0[0], p.c1[0]);
}
else
ncomp = shade->colorspace->n;
@@ -1122,7 +1122,7 @@ pdf_load_shading(fz_shade **shadep, pdf_xref *xref, fz_obj *dict)
{
if (fz_dict_gets(obj, "CA") || fz_dict_gets(obj, "ca"))
{
- fz_warn("shading with alpha not supported");
+ fz_warn(ctx, "shading with alpha not supported");
}
}
diff --git a/pdf/pdf_store.c b/pdf/pdf_store.c
index c8b8ba1c..4d20e859 100644
--- a/pdf/pdf_store.c
+++ b/pdf/pdf_store.c
@@ -56,7 +56,7 @@ pdf_store_item(fz_context *ctx, pdf_store *store, pdf_store_keep_fn *keep_func,
refkey.drop_func = drop_func;
refkey.num = fz_to_num(key);
refkey.gen = fz_to_gen(key);
- fz_hash_insert(ctx, store->hash, &refkey, item);
+ fz_hash_insert(store->hash, &refkey, item);
}
else
{
@@ -191,7 +191,7 @@ void
pdf_free_store(fz_context *ctx, pdf_store *store)
{
pdf_age_store(ctx, store, 0);
- fz_free_hash(ctx, store->hash);
+ fz_free_hash(store->hash);
fz_free(ctx, store);
}
diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c
index ccf96da9..c7259bc3 100644
--- a/pdf/pdf_stream.c
+++ b/pdf/pdf_stream.c
@@ -119,7 +119,7 @@ build_filter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num,
if (!xref->crypt)
{
- fz_warn("crypt filter in unencrypted document");
+ fz_warn(ctx, "crypt filter in unencrypted document");
return chain;
}
@@ -130,7 +130,7 @@ build_filter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num,
return chain;
}
- fz_warn("unknown filter name (%s)", s);
+ fz_warn(ctx, "unknown filter name (%s)", s);
return chain;
}
diff --git a/pdf/pdf_type3.c b/pdf/pdf_type3.c
index b6306b47..d2523ae6 100644
--- a/pdf/pdf_type3.c
+++ b/pdf/pdf_type3.c
@@ -121,7 +121,7 @@ pdf_load_type3_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_o
if (fontdesc->font->t3resources)
fz_keep_obj(fontdesc->font->t3resources);
if (!fontdesc->font->t3resources)
- fz_warn("no resource dictionary for type 3 font!");
+ fz_warn(ctx, "no resource dictionary for type 3 font!");
fontdesc->font->t3xref = xref;
fontdesc->font->t3run = pdf_run_glyph_func;
diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c
index b514c193..37bbc977 100644
--- a/pdf/pdf_xref.c
+++ b/pdf/pdf_xref.c
@@ -213,14 +213,14 @@ pdf_read_old_xref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap)
/* broken pdfs where the section is not on a separate line */
if (s && *s != '\0')
{
- fz_warn("broken xref section. proceeding anyway.");
+ fz_warn(xref->ctx, "broken xref section. proceeding anyway.");
fz_seek(xref->file, -(2 + (int)strlen(s)), 1);
}
/* broken pdfs where size in trailer undershoots entries in xref sections */
if (ofs + len > xref->len)
{
- fz_warn("broken xref section, proceeding anyway.");
+ fz_warn(xref->ctx, "broken xref section, proceeding anyway.");
pdf_resize_xref(xref, ofs + len);
}
@@ -908,7 +908,7 @@ pdf_update_object(pdf_xref *xref, int num, int gen, fz_obj *newobj)
if (num < 0 || num >= xref->len)
{
- fz_warn("object out of range (%d %d R); xref size %d", num, gen, xref->len);
+ fz_warn(xref->ctx, "object out of range (%d %d R); xref size %d", num, gen, xref->len);
return;
}