Commit d0083b5
committed
Overhaul of color management code.
* 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.1 parent a894a26 commit d0083b5
File tree
64 files changed
+3983
-4675
lines changed- include/mupdf
- fitz
- platform
- gl
- java
- win32
- source
- cbz
- fitz
- gprf
- html
- pdf
- svg
- tools
- xps
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
64 files changed
+3983
-4675
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
0 commit comments