OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBlitRow.h" | 8 #include "SkBlitRow.h" |
9 #include "SkBlitMask.h" | 9 #include "SkBlitMask.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // It's not quite perfect, but it's never wrong in the interesting edge cases, | 137 // It's not quite perfect, but it's never wrong in the interesting edge cases, |
138 // and it's quite a bit faster than blend_perfect. | 138 // and it's quite a bit faster than blend_perfect. |
139 // | 139 // |
140 // blend_256_round_alt is our currently blessed algorithm. Please use it or an
analogous one. | 140 // blend_256_round_alt is our currently blessed algorithm. Please use it or an
analogous one. |
141 void SkBlitRow::Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMC
olor color) { | 141 void SkBlitRow::Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMC
olor color) { |
142 switch (SkGetPackedA32(color)) { | 142 switch (SkGetPackedA32(color)) { |
143 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return; | 143 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return; |
144 case 255: sk_memset32(dst, color, count); return; | 144 case 255: sk_memset32(dst, color, count); return; |
145 } | 145 } |
146 | 146 |
147 // This Sk4px impl works great on other platforms or when we have NEON. | |
148 #if defined(SK_CPU_ARM32) && !defined(SK_ARM_HAS_NEON) | |
149 if (auto proc = PlatformColor32Proc()) { return proc(dst, src, count, color)
; } | |
150 #endif | |
151 | |
152 unsigned invA = 255 - SkGetPackedA32(color); | 147 unsigned invA = 255 - SkGetPackedA32(color); |
153 invA += invA >> 7; | 148 invA += invA >> 7; |
154 SkASSERT(invA < 256); // We've already handled alpha == 0 above. | 149 SkASSERT(invA < 256); // We've already handled alpha == 0 above. |
155 | 150 |
156 Sk16h colorHighAndRound = Sk4px(color).widenHi() + Sk16h(128); | 151 Sk16h colorHighAndRound = Sk4px(color).widenHi() + Sk16h(128); |
157 Sk16b invA_16x(invA); | 152 Sk16b invA_16x(invA); |
158 | 153 |
159 Sk4px::MapSrc(count, dst, src, [&](const Sk4px& src4) -> Sk4px { | 154 Sk4px::MapSrc(count, dst, src, [&](const Sk4px& src4) -> Sk4px { |
160 return src4.mulWiden(invA_16x).addNarrowHi(colorHighAndRound); | 155 return src4.mulWiden(invA_16x).addNarrowHi(colorHighAndRound); |
161 }); | 156 }); |
162 } | 157 } |
OLD | NEW |