Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* The pluggable CMS context was premature over-engineering, and could never have worked as implemented. There were plenty of hardcoded dependencies on LCMS2MT, the source file with the LCMS2 functions had several other ICC-related but non-LCMS2 related functions guarded by the same ifdefs. I've made it non-pluggable, but replacable at compile time by isolating the LCMS2 specific functions to color-lcms.c. Everything else should be CMS agnostic. * I've added an LCMS2MT=1 ifdef to allow building with stock LCMS2 as well as Artifex's multi-threaded LCMS2 fork. With the stock LCMS2 trying to access the color conversion engine from multiple threads will throw an exception. * The color conversion functions were taking the half a dozen arguments in a haphazard order. I've changed all of the functions to take their arguments in the same, regularized, order: src_colorspace, src_color, dst_colorspace, dst_color, proof, params. * The color-fast.c file contains unmanaged, fast, color conversions. These are used as fallbacks when the CMS fails to create a link, or when color management is turned off with fz_disable_icc(ctx). * The colorspace struct was a half-opaque hidden in the ../fitz/colorspace-imp.h header that was included by other modules. I can make it simpler and transparent by changing the internals and how the managed/non-managed color converters work. * Indexed and separation colorspaces are now public and well defined in the header. No more PDF specific hacks. The separation tint function evaluation is done by a callback in the colorspace struct. * Converting a pixmap is done directly, not via a special pixmap converter lookup and callback. This is just simpler, and the lookup/callback mechanism is not as useful for converting images since we never did multiple images with the same converter. The lookup and callback is useful for converting multiple color samples at once (such as when converting pixmap samples in the slow fallback case, or shadings) in order to amortize the converter lookup cost. * I've removed the intermediate fz_cal_colorspace struct. We directly create an ICC-backed Cal colorspace from fz_new_cal_xxx_colorspace() instead. TODO: LCMS2 supports Cal colorspaces directly, why don't we use those functions? * The cached ICC links did not take BGR order into account. Fixed. * Passing NULL colorspaces for alpha only drawing. Some functions automatically treated a NULL colorspace as DeviceGray, but other similar functions did not. It was all a bit random and confusing. I've removed all of these hacks. Any code that wants to convert a color should have a colorspace. If you are drawing alpha only, don't bother calling the color conversion code to convert a NULL color. It is better to catch these errors early during development and do things properly than invisibly plaster over them by treating NULL as gray. * Loading embedded ICC profiles and compatibility handling. Most image loaders were doing inconsistent compatibility checking when loading an ICC profile. Now if you pass a colorspace type to the ICC profile, the colorspace constructor will check that the profile matches the expected colorspace. I've cleaned up the image loaders to behave similarly in their ICC profile loading and checking. * Do not save DeviceGray/RGB ICC profiles when writing PNG files. These profiles are completely redundant, since PNG files are already defined by spec to be in the sRGB colorspace. * Store the ICC profile buffer publicly in the fz_colorspace struct, so we don't need awkward callbacks to the CMS to get the profile data back to calling code. This simplifies PNG and PSD writing code. * Pass fz_color_params by value. This is a 4-byte struct. Passing it as a pointer poses two issues: 1) A pointer may be 8 bytes. Bloat. 2) A pointer may be NULL. This adds a lot of unnecessary NULL checks. Also use a global variable for the default color parameters, saving us a function call every time we need the defaults.
- Loading branch information