diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-10-01 16:55:08 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-10-05 15:51:26 +0100 |
commit | 8aa48c0f5766a0d62489cb42225cd03f3d1a2a62 (patch) | |
tree | 151cd16ac806c00c2ff84f22a730bb90b83b34c8 /fitz | |
parent | 9463d7a87f46c4f50cb1074424c9c3ecda7a5da1 (diff) | |
download | mupdf-8aa48c0f5766a0d62489cb42225cd03f3d1a2a62.tar.xz |
Make shadings hold the data streams compressed.
This reduces memory use by another 10% on the 2 testfiles mentioned
in the previous commit (see bug 693330).
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/fitz-internal.h | 4 | ||||
-rw-r--r-- | fitz/res_shade.c | 10 | ||||
-rw-r--r-- | fitz/stm_comp_buf.c | 10 |
3 files changed, 17 insertions, 7 deletions
diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index 5c9270a1..b34f27f5 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -697,7 +697,9 @@ fz_bbox fz_pixmap_bbox_no_ctx(fz_pixmap *src); typedef struct fz_compression_params_s fz_compression_params; typedef struct fz_compressed_buffer_s fz_compressed_buffer; +unsigned int fz_compressed_buffer_size(fz_compressed_buffer *buffer); +fz_stream *fz_open_compressed_buffer(fz_context *ctx, fz_compressed_buffer *); fz_stream *fz_open_image_decomp_stream(fz_context *ctx, fz_compressed_buffer *, int *factor); enum @@ -1077,7 +1079,7 @@ struct fz_shade_s } f; } u; - fz_buffer *buffer; + fz_compressed_buffer *buffer; }; fz_shade *fz_keep_shade(fz_context *ctx, fz_shade *shade); diff --git a/fitz/res_shade.c b/fitz/res_shade.c index 80acbcf8..aa53a63b 100644 --- a/fitz/res_shade.c +++ b/fitz/res_shade.c @@ -249,7 +249,7 @@ static inline float read_sample(fz_stream *stream, int bits, float min, float ma static void fz_mesh_type4_process(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter) { - fz_stream *stream = fz_open_buffer(ctx, shade->buffer); + fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer); fz_vertex v[4]; fz_vertex *va = &v[0]; fz_vertex *vb = &v[1]; @@ -328,7 +328,7 @@ fz_mesh_type4_process(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_p static void fz_mesh_type5_process(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter) { - fz_stream *stream = fz_open_buffer(ctx, shade->buffer); + fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer); fz_vertex *buf = NULL; fz_vertex *ref = NULL; int first; @@ -645,7 +645,7 @@ make_tensor_patch(tensor_patch *p, int type, fz_point *pt) static void fz_mesh_type6_process(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter) { - fz_stream *stream = fz_open_buffer(ctx, shade->buffer); + fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer); int haspatch, hasprevpatch; float prevc[4][FZ_MAX_COLORS]; fz_point prevp[12]; @@ -773,7 +773,7 @@ fz_mesh_type6_process(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_p static void fz_mesh_type7_process(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_mesh_processor *painter) { - fz_stream *stream = fz_open_buffer(ctx, shade->buffer); + fz_stream *stream = fz_open_compressed_buffer(ctx, shade->buffer); int bpflag = shade->u.m.bpflag; int bpcoord = shade->u.m.bpcoord; int bpcomp = shade->u.m.bpcomp; @@ -942,7 +942,7 @@ fz_free_shade_imp(fz_context *ctx, fz_storable *shade_) fz_drop_colorspace(ctx, shade->colorspace); if (shade->type == FZ_FUNCTION_BASED) fz_free(ctx, shade->u.f.fn_vals); - fz_drop_buffer(ctx, shade->buffer); + fz_free_compressed_buffer(ctx, shade->buffer); fz_free(ctx, shade); } diff --git a/fitz/stm_comp_buf.c b/fitz/stm_comp_buf.c index 93df0ef0..54653536 100644 --- a/fitz/stm_comp_buf.c +++ b/fitz/stm_comp_buf.c @@ -60,9 +60,17 @@ fz_open_image_decomp_stream(fz_context *ctx, fz_compressed_buffer *buffer, int * } fz_stream * -fz_open_compressed_stream(fz_context *ctx, fz_compressed_buffer *buffer) +fz_open_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buffer) { int factor = 1; return fz_open_image_decomp_stream(ctx, buffer, &factor); } + +unsigned int +fz_compressed_buffer_size(fz_compressed_buffer *buffer) +{ + if (!buffer || !buffer->buffer) + return 0; + return (unsigned int)buffer->buffer->cap; +} |