OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkPM4fPriv.h" | 8 #include "SkPM4fPriv.h" |
9 #include "SkUtils.h" | 9 #include "SkUtils.h" |
10 #include "SkXfermode.h" | 10 #include "SkXfermode.h" |
11 | 11 |
12 struct XferProcPair { | |
13 SkXfermode::PM4fProc1 fP1; | |
14 SkXfermode::PM4fProcN fPN; | |
15 }; | |
16 | |
17 enum DstType { | 12 enum DstType { |
18 kLinear_Dst, | 13 kLinear_Dst, |
19 kSRGB_Dst, | 14 kSRGB_Dst, |
20 }; | 15 }; |
21 | 16 |
22 static Sk4f scale_by_coverage(const Sk4f& x4, uint8_t coverage) { | 17 static Sk4f scale_by_coverage(const Sk4f& x4, uint8_t coverage) { |
23 return x4 * Sk4f(coverage * (1/255.0f)); | 18 return x4 * Sk4f(coverage * (1/255.0f)); |
24 } | 19 } |
25 | 20 |
26 static Sk4f lerp(const Sk4f& src, const Sk4f& dst, uint8_t srcCoverage) { | 21 static Sk4f lerp(const Sk4f& src, const Sk4f& dst, uint8_t srcCoverage) { |
(...skipping 11 matching lines...) Expand all Loading... |
38 template <DstType D> uint32_t store_dst(const Sk4f& x4) { | 33 template <DstType D> uint32_t store_dst(const Sk4f& x4) { |
39 return (D == kSRGB_Dst) ? Sk4f_toS32(x4) : Sk4f_toL32(x4); | 34 return (D == kSRGB_Dst) ? Sk4f_toS32(x4) : Sk4f_toL32(x4); |
40 } | 35 } |
41 | 36 |
42 static Sk4f linear_unit_to_srgb_255f(const Sk4f& l4) { | 37 static Sk4f linear_unit_to_srgb_255f(const Sk4f& l4) { |
43 return linear_to_srgb(l4) * Sk4f(255) + Sk4f(0.5f); | 38 return linear_to_srgb(l4) * Sk4f(255) + Sk4f(0.5f); |
44 } | 39 } |
45 | 40 |
46 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 41 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
47 | 42 |
48 template <DstType D> void general_1(const SkXfermode::PM4fState& state, uint32_t
dst[], | 43 template <DstType D> void general_1(const SkXfermode* xfer, uint32_t dst[], |
49 const SkPM4f& src, int count, const SkAlpha
aa[]) { | 44 const SkPM4f* src, int count, const SkAlpha
aa[]) { |
50 SkXfermodeProc4f proc = state.fXfer->getProc4f(); | 45 SkXfermodeProc4f proc = xfer->getProc4f(); |
51 SkPM4f d; | 46 SkPM4f d; |
52 if (aa) { | 47 if (aa) { |
53 for (int i = 0; i < count; ++i) { | 48 for (int i = 0; i < count; ++i) { |
54 Sk4f d4 = load_dst<D>(dst[i]); | 49 Sk4f d4 = load_dst<D>(dst[i]); |
55 d4.store(d.fVec); | 50 d4.store(d.fVec); |
56 Sk4f r4 = Sk4f::Load(proc(src, d).fVec); | 51 Sk4f r4 = Sk4f::Load(proc(*src, d).fVec); |
57 dst[i] = store_dst<D>(lerp(r4, d4, aa[i])); | 52 dst[i] = store_dst<D>(lerp(r4, d4, aa[i])); |
58 } | 53 } |
59 } else { | 54 } else { |
60 for (int i = 0; i < count; ++i) { | 55 for (int i = 0; i < count; ++i) { |
61 load_dst<D>(dst[i]).store(d.fVec); | 56 load_dst<D>(dst[i]).store(d.fVec); |
62 Sk4f r4 = Sk4f::Load(proc(src, d).fVec); | 57 Sk4f r4 = Sk4f::Load(proc(*src, d).fVec); |
63 dst[i] = store_dst<D>(r4); | 58 dst[i] = store_dst<D>(r4); |
64 } | 59 } |
65 } | 60 } |
66 } | 61 } |
67 | 62 |
68 template <DstType D> void general_n(const SkXfermode::PM4fState& state, uint32_t
dst[], | 63 template <DstType D> void general_n(const SkXfermode* xfer, uint32_t dst[], |
69 const SkPM4f src[], int count, const SkAlpha
aa[]) { | 64 const SkPM4f src[], int count, const SkAlpha
aa[]) { |
70 SkXfermodeProc4f proc = state.fXfer->getProc4f(); | 65 SkXfermodeProc4f proc = xfer->getProc4f(); |
71 SkPM4f d; | 66 SkPM4f d; |
72 if (aa) { | 67 if (aa) { |
73 for (int i = 0; i < count; ++i) { | 68 for (int i = 0; i < count; ++i) { |
74 Sk4f d4 = load_dst<D>(dst[i]); | 69 Sk4f d4 = load_dst<D>(dst[i]); |
75 d4.store(d.fVec); | 70 d4.store(d.fVec); |
76 Sk4f r4 = Sk4f::Load(proc(src[i], d).fVec); | 71 Sk4f r4 = Sk4f::Load(proc(src[i], d).fVec); |
77 dst[i] = store_dst<D>(lerp(r4, d4, aa[i])); | 72 dst[i] = store_dst<D>(lerp(r4, d4, aa[i])); |
78 } | 73 } |
79 } else { | 74 } else { |
80 for (int i = 0; i < count; ++i) { | 75 for (int i = 0; i < count; ++i) { |
81 load_dst<D>(dst[i]).store(d.fVec); | 76 load_dst<D>(dst[i]).store(d.fVec); |
82 Sk4f r4 = Sk4f::Load(proc(src[i], d).fVec); | 77 Sk4f r4 = Sk4f::Load(proc(src[i], d).fVec); |
83 dst[i] = store_dst<D>(r4); | 78 dst[i] = store_dst<D>(r4); |
84 } | 79 } |
85 } | 80 } |
86 } | 81 } |
87 | 82 |
88 const XferProcPair gProcs_General[] = { | 83 const SkXfermode::D32Proc gProcs_General[] = { |
89 { general_1<kLinear_Dst>, general_n<kLinear_Dst> }, // linear alpha | 84 general_n<kLinear_Dst>, general_n<kLinear_Dst>, |
90 { general_1<kLinear_Dst>, general_n<kLinear_Dst> }, // linear opaque | 85 general_1<kLinear_Dst>, general_1<kLinear_Dst>, |
91 { general_1<kSRGB_Dst>, general_n<kSRGB_Dst> }, // srgb alpha | 86 general_n<kSRGB_Dst>, general_n<kSRGB_Dst>, |
92 { general_1<kSRGB_Dst>, general_n<kSRGB_Dst> }, // srgb opaque | 87 general_1<kSRGB_Dst>, general_1<kSRGB_Dst>, |
93 }; | 88 }; |
94 | 89 |
95 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 90 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
96 | 91 |
97 static void clear_linear_n(const SkXfermode::PM4fState& state, uint32_t dst[], c
onst SkPM4f[], | 92 static void clear_linear(const SkXfermode*, uint32_t dst[], const SkPM4f[], |
98 int count, const SkAlpha aa[]) { | 93 int count, const SkAlpha aa[]) { |
99 if (aa) { | 94 if (aa) { |
100 for (int i = 0; i < count; ++i) { | 95 for (int i = 0; i < count; ++i) { |
101 unsigned a = aa[i]; | 96 unsigned a = aa[i]; |
102 if (a) { | 97 if (a) { |
103 SkPMColor dstC = dst[i]; | 98 SkPMColor dstC = dst[i]; |
104 SkPMColor C = 0; | 99 SkPMColor C = 0; |
105 if (0xFF != a) { | 100 if (0xFF != a) { |
106 C = SkFourByteInterp(C, dstC, a); | 101 C = SkFourByteInterp(C, dstC, a); |
107 } | 102 } |
108 dst[i] = C; | 103 dst[i] = C; |
109 } | 104 } |
110 } | 105 } |
111 } else { | 106 } else { |
112 sk_bzero(dst, count * sizeof(SkPMColor)); | 107 sk_memset32(dst, 0, count); |
113 } | 108 } |
114 } | 109 } |
115 | 110 |
116 static void clear_linear_1(const SkXfermode::PM4fState& state, uint32_t dst[], c
onst SkPM4f&, | 111 static void clear_srgb(const SkXfermode*, uint32_t dst[], const SkPM4f[], |
117 int count, const SkAlpha coverage[]) { | 112 int count, const SkAlpha aa[]) { |
118 clear_linear_n(state, dst, nullptr, count, coverage); | |
119 } | |
120 | |
121 static void clear_srgb_n(const SkXfermode::PM4fState& state, uint32_t dst[], con
st SkPM4f[], | |
122 int count, const SkAlpha aa[]) { | |
123 if (aa) { | 113 if (aa) { |
124 for (int i = 0; i < count; ++i) { | 114 for (int i = 0; i < count; ++i) { |
125 unsigned a = aa[i]; | 115 if (aa[i]) { |
126 if (a) { | 116 Sk4f d = Sk4f_fromS32(dst[i]) * Sk4f((255 - aa[i]) * (1/255.0f))
; |
127 Sk4f d = Sk4f_fromS32(dst[i]) * Sk4f((255 - a) * (1/255.0f)); | |
128 dst[i] = Sk4f_toS32(d); | 117 dst[i] = Sk4f_toS32(d); |
129 } | 118 } |
130 } | 119 } |
131 } else { | 120 } else { |
132 sk_bzero(dst, count * sizeof(SkPMColor)); | 121 sk_memset32(dst, 0, count); |
133 } | 122 } |
134 } | 123 } |
135 | 124 |
136 static void clear_srgb_1(const SkXfermode::PM4fState& state, uint32_t dst[], con
st SkPM4f&, | 125 const SkXfermode::D32Proc gProcs_Clear[] = { |
137 int count, const SkAlpha coverage[]) { | 126 clear_linear, clear_linear, |
138 clear_srgb_n(state, dst, nullptr, count, coverage); | 127 clear_linear, clear_linear, |
139 } | 128 clear_srgb, clear_srgb, |
140 | 129 clear_srgb, clear_srgb, |
141 const XferProcPair gProcs_Clear[] = { | |
142 { clear_linear_1, clear_linear_n }, // linear [alpha] | |
143 { clear_linear_1, clear_linear_n }, // linear [opaque] | |
144 { clear_srgb_1, clear_srgb_n }, // srgb [alpha] | |
145 { clear_srgb_1, clear_srgb_n }, // srgb [opaque] | |
146 }; | 130 }; |
147 | 131 |
148 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 132 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
149 | 133 |
150 template <DstType D> void src_n(const SkXfermode::PM4fState& state, uint32_t dst
[], | 134 template <DstType D> void src_n(const SkXfermode*, uint32_t dst[], |
151 const SkPM4f src[], int count, const SkAlpha aa[
]) { | 135 const SkPM4f src[], int count, const SkAlpha aa[
]) { |
152 for (int i = 0; i < count; ++i) { | 136 for (int i = 0; i < count; ++i) { |
153 unsigned a = 0xFF; | 137 unsigned a = 0xFF; |
154 if (aa) { | 138 if (aa) { |
155 a = aa[i]; | 139 a = aa[i]; |
156 if (0 == a) { | 140 if (0 == a) { |
157 continue; | 141 continue; |
158 } | 142 } |
159 } | 143 } |
160 Sk4f r4 = Sk4f::Load(src[i].fVec); // src always overrides dst | 144 Sk4f r4 = Sk4f::Load(src[i].fVec); // src always overrides dst |
161 if (a != 0xFF) { | 145 if (a != 0xFF) { |
162 Sk4f d4 = load_dst<D>(dst[i]); | 146 Sk4f d4 = load_dst<D>(dst[i]); |
163 r4 = lerp(r4, d4, a); | 147 r4 = lerp(r4, d4, a); |
164 } | 148 } |
165 dst[i] = store_dst<D>(r4); | 149 dst[i] = store_dst<D>(r4); |
166 } | 150 } |
167 } | 151 } |
168 | 152 |
169 static Sk4f lerp(const Sk4f& src, const Sk4f& dst, const Sk4f& src_scale) { | 153 static Sk4f lerp(const Sk4f& src, const Sk4f& dst, const Sk4f& src_scale) { |
170 return dst + (src - dst) * src_scale; | 154 return dst + (src - dst) * src_scale; |
171 } | 155 } |
172 | 156 |
173 template <DstType D> void src_1(const SkXfermode::PM4fState& state, uint32_t dst
[], | 157 template <DstType D> void src_1(const SkXfermode*, uint32_t dst[], |
174 const SkPM4f& src, int count, const SkAlpha aa[]
) { | 158 const SkPM4f* src, int count, const SkAlpha aa[]
) { |
175 const Sk4f s4 = Sk4f::Load(src.fVec); | 159 const Sk4f s4 = Sk4f::Load(src->fVec); |
176 | 160 |
177 if (aa) { | 161 if (aa) { |
178 if (D == kLinear_Dst) { | 162 if (D == kLinear_Dst) { |
179 // operate in bias-255 space for src and dst | 163 // operate in bias-255 space for src and dst |
180 const Sk4f& s4_255 = s4 * Sk4f(255); | 164 const Sk4f& s4_255 = s4 * Sk4f(255); |
181 while (count >= 4) { | 165 while (count >= 4) { |
182 Sk4f aa4 = SkNx_cast<float>(Sk4b::Load(aa)) * Sk4f(1/255.f); | 166 Sk4f aa4 = SkNx_cast<float>(Sk4b::Load(aa)) * Sk4f(1/255.f); |
183 Sk4f r0 = lerp(s4_255, to_4f(dst[0]), Sk4f(aa4[0])) + Sk4f(0.5f)
; | 167 Sk4f r0 = lerp(s4_255, to_4f(dst[0]), Sk4f(aa4[0])) + Sk4f(0.5f)
; |
184 Sk4f r1 = lerp(s4_255, to_4f(dst[1]), Sk4f(aa4[1])) + Sk4f(0.5f)
; | 168 Sk4f r1 = lerp(s4_255, to_4f(dst[1]), Sk4f(aa4[1])) + Sk4f(0.5f)
; |
185 Sk4f r2 = lerp(s4_255, to_4f(dst[2]), Sk4f(aa4[2])) + Sk4f(0.5f)
; | 169 Sk4f r2 = lerp(s4_255, to_4f(dst[2]), Sk4f(aa4[2])) + Sk4f(0.5f)
; |
(...skipping 30 matching lines...) Expand all Loading... |
216 for (int i = 0; i < count; ++i) { | 200 for (int i = 0; i < count; ++i) { |
217 unsigned a = aa[i]; | 201 unsigned a = aa[i]; |
218 Sk4f d4 = load_dst<D>(dst[i]); | 202 Sk4f d4 = load_dst<D>(dst[i]); |
219 dst[i] = store_dst<D>(lerp(s4, d4, a)); | 203 dst[i] = store_dst<D>(lerp(s4, d4, a)); |
220 } | 204 } |
221 } else { | 205 } else { |
222 sk_memset32(dst, store_dst<D>(s4), count); | 206 sk_memset32(dst, store_dst<D>(s4), count); |
223 } | 207 } |
224 } | 208 } |
225 | 209 |
226 const XferProcPair gProcs_Src[] = { | 210 const SkXfermode::D32Proc gProcs_Src[] = { |
227 { src_1<kLinear_Dst>, src_n<kLinear_Dst> }, // linear [alpha] | 211 src_n<kLinear_Dst>, src_n<kLinear_Dst>, |
228 { src_1<kLinear_Dst>, src_n<kLinear_Dst> }, // linear [opaque] | 212 src_1<kLinear_Dst>, src_1<kLinear_Dst>, |
229 { src_1<kSRGB_Dst>, src_n<kSRGB_Dst> }, // srgb [alpha] | 213 src_n<kSRGB_Dst>, src_n<kSRGB_Dst>, |
230 { src_1<kSRGB_Dst>, src_n<kSRGB_Dst> }, // srgb [opaque] | 214 src_1<kSRGB_Dst>, src_1<kSRGB_Dst>, |
231 }; | 215 }; |
232 | 216 |
233 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 217 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
234 | 218 |
235 static void dst_n(const SkXfermode::PM4fState& state, uint32_t dst[], const SkPM
4f[], | 219 static void dst(const SkXfermode*, uint32_t dst[], const SkPM4f[], int count, co
nst SkAlpha aa[]) {} |
236 int count, const SkAlpha aa[]) {} | |
237 | 220 |
238 static void dst_1(const SkXfermode::PM4fState& state, uint32_t dst[], const SkPM
4f&, | 221 const SkXfermode::D32Proc gProcs_Dst[] = { |
239 int count, const SkAlpha coverage[]) {} | 222 dst, dst, dst, dst, dst, dst, dst, dst, |
240 | |
241 const XferProcPair gProcs_Dst[] = { | |
242 { dst_1, dst_n }, | |
243 { dst_1, dst_n }, | |
244 { dst_1, dst_n }, | |
245 { dst_1, dst_n }, | |
246 }; | 223 }; |
247 | 224 |
248 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 225 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
249 | 226 |
250 template <DstType D> void srcover_n(const SkXfermode::PM4fState& state, uint32_t
dst[], | 227 template <DstType D> void srcover_n(const SkXfermode*, uint32_t dst[], |
251 const SkPM4f src[], int count, const SkAlpha
aa[]) { | 228 const SkPM4f src[], int count, const SkAlpha
aa[]) { |
252 if (aa) { | 229 if (aa) { |
253 for (int i = 0; i < count; ++i) { | 230 for (int i = 0; i < count; ++i) { |
254 unsigned a = aa[i]; | 231 unsigned a = aa[i]; |
255 if (0 == a) { | 232 if (0 == a) { |
256 continue; | 233 continue; |
257 } | 234 } |
258 Sk4f s4 = Sk4f::Load(src[i].fVec); | 235 Sk4f s4 = Sk4f::Load(src[i].fVec); |
259 Sk4f d4 = load_dst<D>(dst[i]); | 236 Sk4f d4 = load_dst<D>(dst[i]); |
260 if (a != 0xFF) { | 237 if (a != 0xFF) { |
261 s4 = scale_by_coverage(s4, a); | 238 s4 = scale_by_coverage(s4, a); |
262 } | 239 } |
263 Sk4f r4 = s4 + d4 * Sk4f(1 - get_alpha(s4)); | 240 Sk4f r4 = s4 + d4 * Sk4f(1 - get_alpha(s4)); |
264 dst[i] = store_dst<D>(r4); | 241 dst[i] = store_dst<D>(r4); |
265 } | 242 } |
266 } else { | 243 } else { |
267 for (int i = 0; i < count; ++i) { | 244 for (int i = 0; i < count; ++i) { |
268 Sk4f s4 = Sk4f::Load(src[i].fVec); | 245 Sk4f s4 = Sk4f::Load(src[i].fVec); |
269 Sk4f d4 = load_dst<D>(dst[i]); | 246 Sk4f d4 = load_dst<D>(dst[i]); |
270 Sk4f r4 = s4 + d4 * Sk4f(1 - get_alpha(s4)); | 247 Sk4f r4 = s4 + d4 * Sk4f(1 - get_alpha(s4)); |
271 dst[i] = store_dst<D>(r4); | 248 dst[i] = store_dst<D>(r4); |
272 } | 249 } |
273 } | 250 } |
274 } | 251 } |
275 | 252 |
276 static void srcover_linear_dst_1(const SkXfermode::PM4fState& state, uint32_t ds
t[], | 253 static void srcover_linear_dst_1(const SkXfermode*, uint32_t dst[], |
277 const SkPM4f& src, int count, const SkAlpha aa[
]) { | 254 const SkPM4f* src, int count, const SkAlpha aa[
]) { |
278 const Sk4f s4 = Sk4f::Load(src.fVec); | 255 const Sk4f s4 = Sk4f::Load(src->fVec); |
279 const Sk4f dst_scale = Sk4f(1 - get_alpha(s4)); | 256 const Sk4f dst_scale = Sk4f(1 - get_alpha(s4)); |
280 | 257 |
281 if (aa) { | 258 if (aa) { |
282 for (int i = 0; i < count; ++i) { | 259 for (int i = 0; i < count; ++i) { |
283 unsigned a = aa[i]; | 260 unsigned a = aa[i]; |
284 if (0 == a) { | 261 if (0 == a) { |
285 continue; | 262 continue; |
286 } | 263 } |
287 Sk4f d4 = Sk4f_fromL32(dst[i]); | 264 Sk4f d4 = Sk4f_fromL32(dst[i]); |
288 Sk4f r4; | 265 Sk4f r4; |
(...skipping 20 matching lines...) Expand all Loading... |
309 dst += 4; | 286 dst += 4; |
310 count -= 4; | 287 count -= 4; |
311 } | 288 } |
312 for (int i = 0; i < count; ++i) { | 289 for (int i = 0; i < count; ++i) { |
313 Sk4f d4 = to_4f(dst[i]); | 290 Sk4f d4 = to_4f(dst[i]); |
314 dst[i] = to_4b(s4_255 + d4 * dst_scale); | 291 dst[i] = to_4b(s4_255 + d4 * dst_scale); |
315 } | 292 } |
316 } | 293 } |
317 } | 294 } |
318 | 295 |
319 static void srcover_srgb_dst_1(const SkXfermode::PM4fState& state, uint32_t dst[
], | 296 static void srcover_srgb_dst_1(const SkXfermode*, uint32_t dst[], |
320 const SkPM4f& src, int count, const SkAlpha aa[])
{ | 297 const SkPM4f* src, int count, const SkAlpha aa[])
{ |
321 Sk4f s4 = Sk4f::Load(src.fVec); | 298 Sk4f s4 = Sk4f::Load(src->fVec); |
322 Sk4f dst_scale = Sk4f(1 - get_alpha(s4)); | 299 Sk4f dst_scale = Sk4f(1 - get_alpha(s4)); |
323 | 300 |
324 if (aa) { | 301 if (aa) { |
325 for (int i = 0; i < count; ++i) { | 302 for (int i = 0; i < count; ++i) { |
326 unsigned a = aa[i]; | 303 unsigned a = aa[i]; |
327 if (0 == a) { | 304 if (0 == a) { |
328 continue; | 305 continue; |
329 } | 306 } |
330 Sk4f d4 = srgb_4b_to_linear_unit(dst[i]); | 307 Sk4f d4 = srgb_4b_to_linear_unit(dst[i]); |
331 Sk4f r4; | 308 Sk4f r4; |
(...skipping 19 matching lines...) Expand all Loading... |
351 dst += 4; | 328 dst += 4; |
352 count -= 4; | 329 count -= 4; |
353 } | 330 } |
354 for (int i = 0; i < count; ++i) { | 331 for (int i = 0; i < count; ++i) { |
355 Sk4f d4 = srgb_4b_to_linear_unit(dst[i]); | 332 Sk4f d4 = srgb_4b_to_linear_unit(dst[i]); |
356 dst[i] = to_4b(linear_unit_to_srgb_255f(s4 + d4 * dst_scale)); | 333 dst[i] = to_4b(linear_unit_to_srgb_255f(s4 + d4 * dst_scale)); |
357 } | 334 } |
358 } | 335 } |
359 } | 336 } |
360 | 337 |
361 const XferProcPair gProcs_SrcOver[] = { | 338 const SkXfermode::D32Proc gProcs_SrcOver[] = { |
362 { srcover_linear_dst_1, srcover_n<kLinear_Dst> }, // linear alpha | 339 srcover_n<kLinear_Dst>, src_n<kLinear_Dst>, |
363 { src_1<kLinear_Dst>, src_n<kLinear_Dst> }, // linear opaque [ we
are src-mode ] | 340 srcover_linear_dst_1, src_1<kLinear_Dst>, |
364 { srcover_srgb_dst_1, srcover_n<kSRGB_Dst> }, // srgb alpha | 341 |
365 { src_1<kSRGB_Dst>, src_n<kSRGB_Dst> }, // srgb opaque [ we
are src-mode ] | 342 srcover_n<kSRGB_Dst>, src_n<kSRGB_Dst>, |
| 343 srcover_srgb_dst_1, src_1<kSRGB_Dst>, |
366 }; | 344 }; |
367 | 345 |
368 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 346 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
369 | 347 |
370 static XferProcPair find_procs(SkXfermode::Mode mode, uint32_t flags) { | 348 static SkXfermode::D32Proc find_proc(SkXfermode::Mode mode, uint32_t flags) { |
371 SkASSERT(0 == (flags & ~3)); | 349 SkASSERT(0 == (flags & ~7)); |
372 flags &= 3; | 350 flags &= 7; |
373 | 351 |
374 switch (mode) { | 352 switch (mode) { |
375 case SkXfermode::kClear_Mode: return gProcs_Clear[flags]; | 353 case SkXfermode::kClear_Mode: return gProcs_Clear[flags]; |
376 case SkXfermode::kSrc_Mode: return gProcs_Src[flags]; | 354 case SkXfermode::kSrc_Mode: return gProcs_Src[flags]; |
377 case SkXfermode::kDst_Mode: return gProcs_Dst[flags]; | 355 case SkXfermode::kDst_Mode: return gProcs_Dst[flags]; |
378 case SkXfermode::kSrcOver_Mode: return gProcs_SrcOver[flags]; | 356 case SkXfermode::kSrcOver_Mode: return gProcs_SrcOver[flags]; |
379 default: | 357 default: |
380 break; | 358 break; |
381 } | 359 } |
382 return gProcs_General[flags]; | 360 return gProcs_General[flags]; |
383 } | 361 } |
384 | 362 |
385 SkXfermode::PM4fProc1 SkXfermode::GetPM4fProc1(Mode mode, uint32_t flags) { | 363 SkXfermode::D32Proc SkXfermode::onGetD32Proc(uint32_t flags) const { |
386 return find_procs(mode, flags).fP1; | 364 SkASSERT(0 == (flags & ~7)); |
| 365 flags &= 7; |
| 366 |
| 367 Mode mode; |
| 368 return this->asMode(&mode) ? find_proc(mode, flags) : gProcs_General[flags]; |
387 } | 369 } |
388 | 370 |
389 SkXfermode::PM4fProcN SkXfermode::GetPM4fProcN(Mode mode, uint32_t flags) { | 371 SkXfermode::D32Proc SkXfermode::GetD32Proc(SkXfermode* xfer, uint32_t flags) { |
390 return find_procs(mode, flags).fPN; | 372 return xfer ? xfer->onGetD32Proc(flags) : find_proc(SkXfermode::kSrcOver_Mod
e, flags); |
391 } | |
392 | |
393 SkXfermode::PM4fProc1 SkXfermode::getPM4fProc1(uint32_t flags) const { | |
394 SkASSERT(0 == (flags & ~3)); | |
395 flags &= 3; | |
396 | |
397 Mode mode; | |
398 return this->asMode(&mode) ? GetPM4fProc1(mode, flags) : gProcs_General[flag
s].fP1; | |
399 } | |
400 | |
401 SkXfermode::PM4fProcN SkXfermode::getPM4fProcN(uint32_t flags) const { | |
402 SkASSERT(0 == (flags & ~3)); | |
403 flags &= 3; | |
404 | |
405 Mode mode; | |
406 return this->asMode(&mode) ? GetPM4fProcN(mode, flags) : gProcs_General[flag
s].fPN; | |
407 } | 373 } |
408 | 374 |
409 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 375 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
410 #include "SkColorPriv.h" | 376 #include "SkColorPriv.h" |
411 | 377 |
412 static Sk4f lcd16_to_unit_4f(uint16_t rgb) { | 378 static Sk4f lcd16_to_unit_4f(uint16_t rgb) { |
413 #ifdef SK_PMCOLOR_IS_RGBA | 379 #ifdef SK_PMCOLOR_IS_RGBA |
414 Sk4i rgbi = Sk4i(SkGetPackedR16(rgb), SkGetPackedG16(rgb), SkGetPackedB16(rg
b), 0); | 380 Sk4i rgbi = Sk4i(SkGetPackedR16(rgb), SkGetPackedG16(rgb), SkGetPackedB16(rg
b), 0); |
415 #else | 381 #else |
416 Sk4i rgbi = Sk4i(SkGetPackedB16(rgb), SkGetPackedG16(rgb), SkGetPackedR16(rg
b), 0); | 382 Sk4i rgbi = Sk4i(SkGetPackedB16(rgb), SkGetPackedG16(rgb), SkGetPackedR16(rg
b), 0); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 | 463 |
498 const LCD32Proc procs[] = { | 464 const LCD32Proc procs[] = { |
499 srcover_n_lcd<kSRGB_Dst>, src_n_lcd<kSRGB_Dst>, | 465 srcover_n_lcd<kSRGB_Dst>, src_n_lcd<kSRGB_Dst>, |
500 srcover_1_lcd<kSRGB_Dst>, src_1_lcd<kSRGB_Dst>, | 466 srcover_1_lcd<kSRGB_Dst>, src_1_lcd<kSRGB_Dst>, |
501 | 467 |
502 srcover_n_lcd<kLinear_Dst>, src_n_lcd<kLinear_Dst>, | 468 srcover_n_lcd<kLinear_Dst>, src_n_lcd<kLinear_Dst>, |
503 srcover_1_lcd<kLinear_Dst>, src_1_lcd<kLinear_Dst>, | 469 srcover_1_lcd<kLinear_Dst>, src_1_lcd<kLinear_Dst>, |
504 }; | 470 }; |
505 return procs[flags]; | 471 return procs[flags]; |
506 } | 472 } |
OLD | NEW |