From c7535ca8ef92af5adcb58d1b33e15933c27951c5 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 10 Oct 2018 12:53:32 +0200 Subject: Rename NO_ICC to FZ_ENABLE_ICC=0|1 to match other config.h options. --- include/mupdf/fitz/config.h | 12 +++++++++--- source/fitz/color-lcms.c | 2 +- source/fitz/colorspace.c | 40 +++++++++++++++++++++------------------- source/tools/mudraw.c | 6 +++--- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/include/mupdf/fitz/config.h b/include/mupdf/fitz/config.h index 3beb3b58..c894c577 100644 --- a/include/mupdf/fitz/config.h +++ b/include/mupdf/fitz/config.h @@ -33,6 +33,11 @@ /* #define FZ_ENABLE_EPUB 1 */ /* #define FZ_ENABLE_GPRF 1 */ +/* + Choose whether to enable ICC color profiles. +*/ +/* #define FZ_ENABLE_ICC 1 */ + /* Choose whether to enable JPEG2000 decoding. By default, it is enabled, but due to frequent security @@ -79,9 +84,6 @@ /* To skip the SIL fonts, enable: */ /* #define TOFU_SIL */ -/* To skip the ICC profiles, enable: */ -/* #define NO_ICC */ - /* To skip the Base14 fonts, enable: */ /* #define TOFU_BASE14 */ /* (You probably really don't want to do that except for measurement purposes!) */ @@ -159,6 +161,10 @@ #define FZ_ENABLE_JS 1 #endif /* FZ_ENABLE_JS */ +#ifndef FZ_ENABLE_ICC +#define FZ_ENABLE_ICC 1 +#endif /* FZ_ENABLE_ICC */ + /* If Epub and HTML are both disabled, disable SIL fonts */ #if FZ_ENABLE_HTML == 0 && FZ_ENABLE_EPUB == 0 #undef TOFU_SIL diff --git a/source/fitz/color-lcms.c b/source/fitz/color-lcms.c index f4fc1ac8..1f94c428 100644 --- a/source/fitz/color-lcms.c +++ b/source/fitz/color-lcms.c @@ -1,6 +1,6 @@ #include "mupdf/fitz.h" -#ifndef NO_ICC +#if FZ_ENABLE_ICC #include "lcms2mt.h" #include "lcms2mt_plugin.h" #include "colorspace-imp.h" diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c index de3b3578..4a957d20 100644 --- a/source/fitz/colorspace.c +++ b/source/fitz/colorspace.c @@ -147,15 +147,7 @@ void fz_cmm_fin_profile(fz_context *ctx, fz_iccprofile *profile) #define SLOWCMYK -#ifdef NO_ICC - -const unsigned char * -fz_lookup_icc(fz_context *ctx, enum fz_colorspace_type type, size_t *size) -{ - return *size = 0, NULL; -} - -#else +#if FZ_ENABLE_ICC #include "icc/gray.icc.h" #include "icc/rgb.icc.h" @@ -186,6 +178,14 @@ fz_lookup_icc(fz_context *ctx, enum fz_colorspace_type type, size_t *size) return *size = 0, NULL; } +#else + +const unsigned char * +fz_lookup_icc(fz_context *ctx, enum fz_colorspace_type type, size_t *size) +{ + return *size = 0, NULL; +} + #endif /* Same order as needed by lcms */ @@ -835,10 +835,7 @@ void fz_set_cmm_engine(fz_context *ctx, const fz_cmm_engine *engine) if (!cct) return; -#ifdef NO_ICC - if (engine) - fz_throw(ctx, FZ_ERROR_GENERIC, "ICC workflow not supported in NO_ICC build"); -#else +#if FZ_ENABLE_ICC if (cct->cmm == engine) return; @@ -885,6 +882,9 @@ void fz_set_cmm_engine(fz_context *ctx, const fz_cmm_engine *engine) } else set_no_icc(cct); +#else + if (engine) + fz_throw(ctx, FZ_ERROR_GENERIC, "ICC workflow not supported in FZ_ENABLE_ICC=0 build"); #endif } @@ -893,10 +893,10 @@ void fz_new_colorspace_context(fz_context *ctx) ctx->colorspace = fz_malloc_struct(ctx, fz_colorspace_context); ctx->colorspace->ctx_refs = 1; set_no_icc(ctx->colorspace); -#ifdef NO_ICC - fz_set_cmm_engine(ctx, NULL); -#else +#if FZ_ENABLE_ICC fz_set_cmm_engine(ctx, &fz_cmm_engine_lcms); +#else + fz_set_cmm_engine(ctx, NULL); #endif } @@ -3735,6 +3735,7 @@ const char *fz_colorspace_name(fz_context *ctx, const fz_colorspace *cs) return cs ? cs->name : ""; } +#if FZ_ENABLE_ICC static void free_icc(fz_context *ctx, fz_colorspace *cs) { @@ -3775,13 +3776,12 @@ static const char *colorspace_name_from_type(int type) case FZ_COLORSPACE_LAB: return "Lab"; } } +#endif fz_colorspace * fz_new_icc_colorspace(fz_context *ctx, enum fz_colorspace_type type, fz_buffer *buf) { -#ifdef NO_ICC - fz_throw(ctx, FZ_ERROR_GENERIC, "ICC Profiles not supported in NO_ICC build"); -#else +#if FZ_ENABLE_ICC fz_colorspace *cs = NULL; fz_iccprofile *profile; int flags = FZ_COLORSPACE_IS_ICC; @@ -3886,6 +3886,8 @@ fz_new_icc_colorspace(fz_context *ctx, enum fz_colorspace_type type, fz_buffer * fz_rethrow(ctx); } return cs; +#else + fz_throw(ctx, FZ_ERROR_GENERIC, "ICC Profiles not supported in FZ_ENABLE_ICC=0 build"); #endif } diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index bcae107d..c49ec18d 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -274,10 +274,10 @@ static int num_workers = 0; static worker_t *workers; static fz_band_writer *bander = NULL; -#ifdef NO_ICC -static fz_cmm_engine *icc_engine = NULL; -#else +#if FZ_ENABLE_ICC static fz_cmm_engine *icc_engine = &fz_cmm_engine_lcms; +#else +static fz_cmm_engine *icc_engine = NULL; #endif static const char *layer_config = NULL; -- cgit v1.2.3