| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 (kSRGB_DstGamma == kDstGamma) ? sk_linear_to_srgb : line
ar_to_2dot2; | 77 (kSRGB_DstGamma == kDstGamma) ? sk_linear_to_srgb : line
ar_to_2dot2; |
| 78 | 78 |
| 79 dstReds = linear_to_curve(dstReds); | 79 dstReds = linear_to_curve(dstReds); |
| 80 dstGreens = linear_to_curve(dstGreens); | 80 dstGreens = linear_to_curve(dstGreens); |
| 81 dstBlues = linear_to_curve(dstBlues); | 81 dstBlues = linear_to_curve(dstBlues); |
| 82 | 82 |
| 83 dstReds = clamp_0_to_255(dstReds); | 83 dstReds = clamp_0_to_255(dstReds); |
| 84 dstGreens = clamp_0_to_255(dstGreens); | 84 dstGreens = clamp_0_to_255(dstGreens); |
| 85 dstBlues = clamp_0_to_255(dstBlues); | 85 dstBlues = clamp_0_to_255(dstBlues); |
| 86 | 86 |
| 87 auto rgba = (SkNx_cast<int>(dstReds) ) | 87 auto rgba = (Sk4f_round(dstReds) ) |
| 88 | (SkNx_cast<int>(dstGreens) << 8) | 88 | (Sk4f_round(dstGreens) << 8) |
| 89 | (SkNx_cast<int>(dstBlues) << 16) | 89 | (Sk4f_round(dstBlues) << 16) |
| 90 | (Sk4i{ 0xFF << 24}); | 90 | (Sk4i{ 0xFF << 24}); |
| 91 rgba.store(dst); | 91 rgba.store(dst); |
| 92 } else { | 92 } else { |
| 93 Sk4f scaledReds = Sk4f::Min(Sk4f::Max(1023.0f * dstReds, 0.0
f), 1023.0f); | 93 Sk4f scaledReds = Sk4f::Min(Sk4f::Max(1023.0f * dstReds, 0.0
f), 1023.0f); |
| 94 Sk4f scaledGreens = Sk4f::Min(Sk4f::Max(1023.0f * dstGreens, 0.0
f), 1023.0f); | 94 Sk4f scaledGreens = Sk4f::Min(Sk4f::Max(1023.0f * dstGreens, 0.0
f), 1023.0f); |
| 95 Sk4f scaledBlues = Sk4f::Min(Sk4f::Max(1023.0f * dstBlues, 0.0
f), 1023.0f); | 95 Sk4f scaledBlues = Sk4f::Min(Sk4f::Max(1023.0f * dstBlues, 0.0
f), 1023.0f); |
| 96 | 96 |
| 97 Sk4i indicesReds = SkNx_cast<int>(scaledReds + 0.5f); | 97 Sk4i indicesReds = Sk4f_round(scaledReds); |
| 98 Sk4i indicesGreens = SkNx_cast<int>(scaledGreens + 0.5f); | 98 Sk4i indicesGreens = Sk4f_round(scaledGreens); |
| 99 Sk4i indicesBlues = SkNx_cast<int>(scaledBlues + 0.5f); | 99 Sk4i indicesBlues = Sk4f_round(scaledBlues); |
| 100 | 100 |
| 101 dst[0] = dstTables[0][indicesReds [0]] | 101 dst[0] = dstTables[0][indicesReds [0]] |
| 102 | dstTables[1][indicesGreens[0]] << 8 | 102 | dstTables[1][indicesGreens[0]] << 8 |
| 103 | dstTables[2][indicesBlues [0]] << 16 | 103 | dstTables[2][indicesBlues [0]] << 16 |
| 104 | 0xFF << 24; | 104 | 0xFF << 24; |
| 105 dst[1] = dstTables[0][indicesReds [1]] | 105 dst[1] = dstTables[0][indicesReds [1]] |
| 106 | dstTables[1][indicesGreens[1]] << 8 | 106 | dstTables[1][indicesGreens[1]] << 8 |
| 107 | dstTables[2][indicesBlues [1]] << 16 | 107 | dstTables[2][indicesBlues [1]] << 16 |
| 108 | 0xFF << 24; | 108 | 0xFF << 24; |
| 109 dst[2] = dstTables[0][indicesReds [2]] | 109 dst[2] = dstTables[0][indicesReds [2]] |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 if (kSRGB_DstGamma == kDstGamma || k2Dot2_DstGamma == kDstGamma) { | 143 if (kSRGB_DstGamma == kDstGamma || k2Dot2_DstGamma == kDstGamma) { |
| 144 Sk4f (*linear_to_curve)(const Sk4f&) = | 144 Sk4f (*linear_to_curve)(const Sk4f&) = |
| 145 (kSRGB_DstGamma == kDstGamma) ? sk_linear_to_srgb : linear_t
o_2dot2; | 145 (kSRGB_DstGamma == kDstGamma) ? sk_linear_to_srgb : linear_t
o_2dot2; |
| 146 | 146 |
| 147 dstPixel = linear_to_curve(dstPixel); | 147 dstPixel = linear_to_curve(dstPixel); |
| 148 | 148 |
| 149 dstPixel = clamp_0_to_255(dstPixel); | 149 dstPixel = clamp_0_to_255(dstPixel); |
| 150 | 150 |
| 151 uint32_t rgba; | 151 uint32_t rgba; |
| 152 SkNx_cast<uint8_t>(dstPixel).store(&rgba); | 152 SkNx_cast<uint8_t>(Sk4f_round(dstPixel)).store(&rgba); |
| 153 rgba |= 0xFF000000; | 153 rgba |= 0xFF000000; |
| 154 *dst = rgba; | 154 *dst = rgba; |
| 155 } else { | 155 } else { |
| 156 Sk4f scaledPixel = Sk4f::Min(Sk4f::Max(1023.0f * dstPixel, 0.0f), 10
23.0f); | 156 Sk4f scaledPixel = Sk4f::Min(Sk4f::Max(1023.0f * dstPixel, 0.0f), 10
23.0f); |
| 157 | 157 |
| 158 Sk4i indices = SkNx_cast<int>(scaledPixel + 0.5f); | 158 Sk4i indices = Sk4f_round(scaledPixel); |
| 159 | 159 |
| 160 *dst = dstTables[0][indices[0]] | 160 *dst = dstTables[0][indices[0]] |
| 161 | dstTables[1][indices[1]] << 8 | 161 | dstTables[1][indices[1]] << 8 |
| 162 | dstTables[2][indices[2]] << 16 | 162 | dstTables[2][indices[2]] << 16 |
| 163 | 0xFF << 24; | 163 | 0xFF << 24; |
| 164 } | 164 } |
| 165 | 165 |
| 166 dst += 1; | 166 dst += 1; |
| 167 src += 1; | 167 src += 1; |
| 168 len -= 1; | 168 len -= 1; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 181 | 181 |
| 182 static void color_xform_RGB1_to_table(uint32_t* dst, const uint32_t* src, int le
n, | 182 static void color_xform_RGB1_to_table(uint32_t* dst, const uint32_t* src, int le
n, |
| 183 const float* const srcTables[3], const flo
at matrix[16], | 183 const float* const srcTables[3], const flo
at matrix[16], |
| 184 const uint8_t* const dstTables[3]) { | 184 const uint8_t* const dstTables[3]) { |
| 185 color_xform_RGB1<kTable_DstGamma>(dst, src, len, srcTables, matrix, dstTable
s); | 185 color_xform_RGB1<kTable_DstGamma>(dst, src, len, srcTables, matrix, dstTable
s); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace SK_OPTS_NS | 188 } // namespace SK_OPTS_NS |
| 189 | 189 |
| 190 #endif // SkColorXform_opts_DEFINED | 190 #endif // SkColorXform_opts_DEFINED |
| OLD | NEW |