diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2022-04-11 13:09:22 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2022-04-12 18:37:36 +0100 |
commit | d044176a8e9119c4e2b8d30c65811eb0facd9560 (patch) | |
tree | abdc6ef557b102897e8f2b338e36de38fc6a8785 /lcms2mt | |
parent | 2dbc87e52c59f3845bdb6eca5bc982c7f51564ce (diff) | |
download | ghostpdl-d044176a8e9119c4e2b8d30c65811eb0facd9560.tar.gz |
Change lcms2mt hooking into CAL.
Rather than using a plugin for the accelerated xforms, hook them
in manually within _cmsFindFormatters. This means they kick in
more often, and don't 'block' other optimisations that are already
built in.
I can't see a more "official" way of doing this.
Diffstat (limited to 'lcms2mt')
-rw-r--r-- | lcms2mt/src/cmsvirt.c | 2 | ||||
-rw-r--r-- | lcms2mt/src/cmsxform.c | 26 | ||||
-rw-r--r-- | lcms2mt/src/lcms2_internal.h | 11 |
3 files changed, 26 insertions, 13 deletions
diff --git a/lcms2mt/src/cmsvirt.c b/lcms2mt/src/cmsvirt.c index 6c0890f50..f85aa5d10 100644 --- a/lcms2mt/src/cmsvirt.c +++ b/lcms2mt/src/cmsvirt.c @@ -937,7 +937,7 @@ cmsHPROFILE CreateNamedColorDevicelink(cmsContext ContextID, cmsHTRANSFORM xform v ->OutputFormat = OutputFormat; v ->FromInput = FromInput; v ->ToOutput = ToOutput; - _cmsFindFormatter(v, InputFormat, OutputFormat, v->core->dwOriginalFlags); + _cmsFindFormatter(ContextID, v, InputFormat, OutputFormat, v->core->dwOriginalFlags); // Apply the transfor to colorants. for (i=0; i < nColors; i++) { diff --git a/lcms2mt/src/cmsxform.c b/lcms2mt/src/cmsxform.c index 7f4e15896..65254193d 100644 --- a/lcms2mt/src/cmsxform.c +++ b/lcms2mt/src/cmsxform.c @@ -1939,18 +1939,20 @@ cmsUInt32Number CMSEXPORT _cmsGetTransformFlags(struct _cmstransform_struct* CMM } void -_cmsFindFormatter(_cmsTRANSFORM* p, cmsUInt32Number InputFormat, cmsUInt32Number OutputFormat, cmsUInt32Number dwFlags) +_cmsFindFormatter(cmsContext ContextID, _cmsTRANSFORM* p, cmsUInt32Number InputFormat, cmsUInt32Number OutputFormat, cmsUInt32Number dwFlags) { + int isIdentity; if (dwFlags & cmsFLAGS_NULLTRANSFORM) { p ->xform = NullXFORM; return; } + isIdentity = ((InputFormat & ~COLORSPACE_SH(31)) == (OutputFormat & ~COLORSPACE_SH(31)) && + _cmsLutIsIdentity(p->core->Lut)); if (dwFlags & cmsFLAGS_PREMULT) { if (dwFlags & cmsFLAGS_NOCACHE) { if (dwFlags & cmsFLAGS_GAMUTCHECK) p ->xform = PrecalculatedXFORMGamutCheck_P; // Gamut check, no cache - else if ((InputFormat & ~COLORSPACE_SH(31)) == (OutputFormat & ~COLORSPACE_SH(31)) && - _cmsLutIsIdentity(p->core->Lut)) { + else if (isIdentity) { if (T_PLANAR(InputFormat)) p ->xform = PrecalculatedXFORMIdentityPlanar; else @@ -1963,8 +1965,7 @@ _cmsFindFormatter(_cmsTRANSFORM* p, cmsUInt32Number InputFormat, cmsUInt32Number p ->xform = CachedXFORMGamutCheck_P; // Gamut check, cache return; } - if ((InputFormat & ~COLORSPACE_SH(31)) == (OutputFormat & ~COLORSPACE_SH(31)) && - _cmsLutIsIdentity(p->core->Lut)) { + if (isIdentity) { /* No point in a cache here! */ if (T_PLANAR(InputFormat)) p ->xform = PrecalculatedXFORMIdentityPlanar; @@ -1976,8 +1977,7 @@ _cmsFindFormatter(_cmsTRANSFORM* p, cmsUInt32Number InputFormat, cmsUInt32Number if (dwFlags & cmsFLAGS_NOCACHE) { if (dwFlags & cmsFLAGS_GAMUTCHECK) p ->xform = PrecalculatedXFORMGamutCheck; // Gamut check, no cache - else if ((InputFormat & ~COLORSPACE_SH(31)) == (OutputFormat & ~COLORSPACE_SH(31)) && - _cmsLutIsIdentity(p->core->Lut)) { + else if (isIdentity) { if (T_PLANAR(InputFormat)) p ->xform = PrecalculatedXFORMIdentityPlanar; else @@ -1990,8 +1990,7 @@ _cmsFindFormatter(_cmsTRANSFORM* p, cmsUInt32Number InputFormat, cmsUInt32Number p ->xform = CachedXFORMGamutCheck; // Gamut check, cache return; } - if ((InputFormat & ~COLORSPACE_SH(31)) == (OutputFormat & ~COLORSPACE_SH(31)) && - _cmsLutIsIdentity(p->core->Lut)) { + if (isIdentity) { /* No point in a cache here! */ if (T_PLANAR(InputFormat)) p ->xform = PrecalculatedXFORMIdentityPlanar; @@ -1999,6 +1998,11 @@ _cmsFindFormatter(_cmsTRANSFORM* p, cmsUInt32Number InputFormat, cmsUInt32Number p ->xform = PrecalculatedXFORMIdentity; return; } +#ifdef WITH_CAL + if (cal_cms_find_formatter_and_xform(ContextID, &p->xform, InputFormat, OutputFormat, &dwFlags)) { + return; + } +#endif if (T_EXTRA(InputFormat) == 1 && T_EXTRA(OutputFormat) == 1) { if (dwFlags & cmsFLAGS_PREMULT) { if ((InputFormat & ~(COLORSPACE_SH(31)|CHANNELS_SH(7)|BYTES_SH(3)|EXTRA_SH(1))) == 0 && @@ -2329,7 +2333,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut, } - _cmsFindFormatter(p, *InputFormat, *OutputFormat, *dwFlags); + _cmsFindFormatter(ContextID, p, *InputFormat, *OutputFormat, *dwFlags); } p ->InputFormat = *InputFormat; @@ -2745,7 +2749,7 @@ cmsHTRANSFORM cmsCloneTransformChangingFormats(cmsContext ContextID, xform ->OutputFormat = OutputFormat; xform ->FromInput = FromInput; xform ->ToOutput = ToOutput; - _cmsFindFormatter(xform, InputFormat, OutputFormat, xform->core->dwOriginalFlags); + _cmsFindFormatter(ContextID, xform, InputFormat, OutputFormat, xform->core->dwOriginalFlags); (void)_cmsAdjustReferenceCount(&xform->core->refs, 1); diff --git a/lcms2mt/src/lcms2_internal.h b/lcms2mt/src/lcms2_internal.h index 504393e2b..f44e5c7a2 100644 --- a/lcms2mt/src/lcms2_internal.h +++ b/lcms2mt/src/lcms2_internal.h @@ -1116,12 +1116,21 @@ cmsBool _cmsAdaptationMatrix(cmsContext ContextID, cmsMAT3* r, const cmsMAT3* cmsBool _cmsBuildRGB2XYZtransferMatrix(cmsContext ContextID, cmsMAT3* r, const cmsCIExyY* WhitePoint, const cmsCIExyYTRIPLE* Primaries); -void _cmsFindFormatter(_cmsTRANSFORM* p, cmsUInt32Number InputFormat, cmsUInt32Number OutputFormat, cmsUInt32Number flags); +void _cmsFindFormatter(cmsContext ContextID, _cmsTRANSFORM* p, cmsUInt32Number InputFormat, cmsUInt32Number OutputFormat, cmsUInt32Number flags); cmsUInt32Number _cmsAdjustReferenceCount(cmsUInt32Number *rc, int delta); // thread-safe gettime cmsBool _cmsGetTime(struct tm* ptr_time); +// CAL extensions +#ifdef WITH_CAL +int cal_cms_find_formatter_and_xform(cmsContext ContextID, + _cmsTransform2Fn *xformPtr, + cmsUInt32Number InputFormat, + cmsUInt32Number OutputFormat, + cmsUInt32Number *dwFlags); +#endif + #define _lcms_internal_H #endif |