| 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_store4(dst, SkFloatToHalf_finite(dstReds), |
| 130 // Can we do better here? Should we store half floats as planar
? | 130 SkFloatToHalf_finite(dstGreens), |
| 131 // Should we write Intel/Arm specific code? Should we add a tra
nspose | 131 SkFloatToHalf_finite(dstBlues), |
| 132 // function to SkNx? Should we rewrite the algorithm to be inte
rleaved? | 132 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 | |
| 139 dst = SkTAddOffset<void>(dst, 4 * sizeof(uint64_t)); | 133 dst = SkTAddOffset<void>(dst, 4 * sizeof(uint64_t)); |
| 140 } | 134 } |
| 141 }; | 135 }; |
| 142 | 136 |
| 143 load_next_4(); | 137 load_next_4(); |
| 144 | 138 |
| 145 while (len >= 4) { | 139 while (len >= 4) { |
| 146 transform_4(); | 140 transform_4(); |
| 147 load_next_4(); | 141 load_next_4(); |
| 148 store_4(); | 142 store_4(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 178 | 172 |
| 179 Sk4i indices = Sk4f_round(scaledPixel); | 173 Sk4i indices = Sk4f_round(scaledPixel); |
| 180 | 174 |
| 181 *((uint32_t*) dst) = dstTables[0][indices[0]] << SK_R32_SHIFT | 175 *((uint32_t*) dst) = dstTables[0][indices[0]] << SK_R32_SHIFT |
| 182 | dstTables[1][indices[1]] << SK_G32_SHIFT | 176 | dstTables[1][indices[1]] << SK_G32_SHIFT |
| 183 | dstTables[2][indices[2]] << SK_B32_SHIFT | 177 | dstTables[2][indices[2]] << SK_B32_SHIFT |
| 184 | 0xFF << SK_A32_SHIFT; | 178 | 0xFF << SK_A32_SHIFT; |
| 185 | 179 |
| 186 dst = SkTAddOffset<void>(dst, sizeof(uint32_t)); | 180 dst = SkTAddOffset<void>(dst, sizeof(uint32_t)); |
| 187 } else { | 181 } else { |
| 188 uint64_t rgba = SkFloatToHalf_finite(dstPixel); | 182 uint64_t rgba; |
| 189 | 183 SkFloatToHalf_finite(dstPixel).store(&rgba); |
| 190 // Set alpha to 1.0 | 184 rgba |= static_cast<uint64_t>(SK_Half1) << 48; |
| 191 rgba |= 0x3C00000000000000; | |
| 192 *((uint64_t*) dst) = rgba; | 185 *((uint64_t*) dst) = rgba; |
| 193 dst = SkTAddOffset<void>(dst, sizeof(uint64_t)); | 186 dst = SkTAddOffset<void>(dst, sizeof(uint64_t)); |
| 194 } | 187 } |
| 195 | 188 |
| 196 src += 1; | 189 src += 1; |
| 197 len -= 1; | 190 len -= 1; |
| 198 } | 191 } |
| 199 } | 192 } |
| 200 | 193 |
| 201 static void color_xform_RGB1_to_2dot2(uint32_t* dst, const uint32_t* src, int le
n, | 194 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 } | 208 } |
| 216 | 209 |
| 217 static void color_xform_RGB1_to_linear(uint64_t* dst, const uint32_t* src, int l
en, | 210 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]) { | 211 const float* const srcTables[3], const fl
oat matrix[12]) { |
| 219 color_xform_RGB1<kLinear_DstGamma>(dst, src, len, srcTables, matrix, nullptr
); | 212 color_xform_RGB1<kLinear_DstGamma>(dst, src, len, srcTables, matrix, nullptr
); |
| 220 } | 213 } |
| 221 | 214 |
| 222 } // namespace SK_OPTS_NS | 215 } // namespace SK_OPTS_NS |
| 223 | 216 |
| 224 #endif // SkColorXform_opts_DEFINED | 217 #endif // SkColorXform_opts_DEFINED |
| OLD | NEW |