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 #ifndef SkColorXform_opts_DEFINED | 8 #ifndef SkColorXform_opts_DEFINED |
9 #define SkColorXform_opts_DEFINED | 9 #define SkColorXform_opts_DEFINED |
10 | 10 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 | dstTables[1][indicesGreens[2]] << SK_G32_SHIFT | 119 | dstTables[1][indicesGreens[2]] << SK_G32_SHIFT |
120 | dstTables[2][indicesBlues [2]] << SK_B32_SHIFT | 120 | dstTables[2][indicesBlues [2]] << SK_B32_SHIFT |
121 | 0xFF << SK_A32_SHIFT; | 121 | 0xFF << SK_A32_SHIFT; |
122 dst32[3] = dstTables[0][indicesReds [3]] << SK_R32_SHIFT | 122 dst32[3] = dstTables[0][indicesReds [3]] << SK_R32_SHIFT |
123 | dstTables[1][indicesGreens[3]] << SK_G32_SHIFT | 123 | dstTables[1][indicesGreens[3]] << SK_G32_SHIFT |
124 | dstTables[2][indicesBlues [3]] << SK_B32_SHIFT | 124 | dstTables[2][indicesBlues [3]] << SK_B32_SHIFT |
125 | 0xFF << SK_A32_SHIFT; | 125 | 0xFF << SK_A32_SHIFT; |
126 | 126 |
127 dst = SkTAddOffset<void>(dst, 4 * sizeof(uint32_t)); | 127 dst = SkTAddOffset<void>(dst, 4 * sizeof(uint32_t)); |
128 } else { | 128 } else { |
129 // FIXME (msarett): | 129 Sk4h halfReds = SkFloatToHalf_finite(dstReds); |
mtklein
2016/07/19 15:37:47
Might wanna just inline these instead of naming th
msarett
2016/07/19 15:47:20
Woo cool.
| |
130 // Can we do better here? Should we store half floats as planar ? | 130 Sk4h halfGreens = SkFloatToHalf_finite(dstGreens); |
131 // Should we write Intel/Arm specific code? Should we add a tra nspose | 131 Sk4h halfBlues = SkFloatToHalf_finite(dstBlues); |
132 // function to SkNx? Should we rewrite the algorithm to be inte rleaved? | 132 Sk4h halfAlphas = Sk4h(SK_Half1); |
133 uint64_t* dst64 = (uint64_t*) dst; | |
134 dst64[0] = SkFloatToHalf_finite(Sk4f(dstReds[0], dstGreens[0], d stBlues[0], 1.0f)); | |
135 dst64[1] = SkFloatToHalf_finite(Sk4f(dstReds[1], dstGreens[1], d stBlues[1], 1.0f)); | |
136 dst64[2] = SkFloatToHalf_finite(Sk4f(dstReds[2], dstGreens[2], d stBlues[2], 1.0f)); | |
137 dst64[3] = SkFloatToHalf_finite(Sk4f(dstReds[3], dstGreens[3], d stBlues[3], 1.0f)); | |
138 | 133 |
134 Sk4h_store4(dst, halfReds, halfGreens, halfBlues, halfAlphas); | |
139 dst = SkTAddOffset<void>(dst, 4 * sizeof(uint64_t)); | 135 dst = SkTAddOffset<void>(dst, 4 * sizeof(uint64_t)); |
140 } | 136 } |
141 }; | 137 }; |
142 | 138 |
143 load_next_4(); | 139 load_next_4(); |
144 | 140 |
145 while (len >= 4) { | 141 while (len >= 4) { |
146 transform_4(); | 142 transform_4(); |
147 load_next_4(); | 143 load_next_4(); |
148 store_4(); | 144 store_4(); |
(...skipping 29 matching lines...) Expand all Loading... | |
178 | 174 |
179 Sk4i indices = Sk4f_round(scaledPixel); | 175 Sk4i indices = Sk4f_round(scaledPixel); |
180 | 176 |
181 *((uint32_t*) dst) = dstTables[0][indices[0]] << SK_R32_SHIFT | 177 *((uint32_t*) dst) = dstTables[0][indices[0]] << SK_R32_SHIFT |
182 | dstTables[1][indices[1]] << SK_G32_SHIFT | 178 | dstTables[1][indices[1]] << SK_G32_SHIFT |
183 | dstTables[2][indices[2]] << SK_B32_SHIFT | 179 | dstTables[2][indices[2]] << SK_B32_SHIFT |
184 | 0xFF << SK_A32_SHIFT; | 180 | 0xFF << SK_A32_SHIFT; |
185 | 181 |
186 dst = SkTAddOffset<void>(dst, sizeof(uint32_t)); | 182 dst = SkTAddOffset<void>(dst, sizeof(uint32_t)); |
187 } else { | 183 } else { |
188 uint64_t rgba = SkFloatToHalf_finite(dstPixel); | 184 uint64_t rgba; |
189 | 185 SkFloatToHalf_finite(dstPixel).store(&rgba); |
190 // Set alpha to 1.0 | 186 rgba |= static_cast<uint64_t>(SK_Half1) << 48; |
191 rgba |= 0x3C00000000000000; | |
192 *((uint64_t*) dst) = rgba; | 187 *((uint64_t*) dst) = rgba; |
193 dst = SkTAddOffset<void>(dst, sizeof(uint64_t)); | 188 dst = SkTAddOffset<void>(dst, sizeof(uint64_t)); |
194 } | 189 } |
195 | 190 |
196 src += 1; | 191 src += 1; |
197 len -= 1; | 192 len -= 1; |
198 } | 193 } |
199 } | 194 } |
200 | 195 |
201 static void color_xform_RGB1_to_2dot2(uint32_t* dst, const uint32_t* src, int le n, | 196 static void color_xform_RGB1_to_2dot2(uint32_t* dst, const uint32_t* src, int le n, |
(...skipping 13 matching lines...) Expand all Loading... | |
215 } | 210 } |
216 | 211 |
217 static void color_xform_RGB1_to_linear(uint64_t* dst, const uint32_t* src, int l en, | 212 static void color_xform_RGB1_to_linear(uint64_t* dst, const uint32_t* src, int l en, |
218 const float* const srcTables[3], const fl oat matrix[12]) { | 213 const float* const srcTables[3], const fl oat matrix[12]) { |
219 color_xform_RGB1<kLinear_DstGamma>(dst, src, len, srcTables, matrix, nullptr ); | 214 color_xform_RGB1<kLinear_DstGamma>(dst, src, len, srcTables, matrix, nullptr ); |
220 } | 215 } |
221 | 216 |
222 } // namespace SK_OPTS_NS | 217 } // namespace SK_OPTS_NS |
223 | 218 |
224 #endif // SkColorXform_opts_DEFINED | 219 #endif // SkColorXform_opts_DEFINED |
OLD | NEW |