Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: src/core/SkBlitRow_D32.cpp

Issue 1314863006: Port SkBlitRow::Color32 to SkOpts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkBlitRow.h ('k') | src/core/SkOpts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "SkOpts.h"
11 #include "SkUtils.h" 12 #include "SkUtils.h"
12 13
13 #define UNROLL 14 #define UNROLL
14 15
15 static void S32_Opaque_BlitRow32(SkPMColor* SK_RESTRICT dst, 16 static void S32_Opaque_BlitRow32(SkPMColor* SK_RESTRICT dst,
16 const SkPMColor* SK_RESTRICT src, 17 const SkPMColor* SK_RESTRICT src,
17 int count, U8CPU alpha) { 18 int count, U8CPU alpha) {
18 SkASSERT(255 == alpha); 19 SkASSERT(255 == alpha);
19 memcpy(dst, src, count * 4); 20 memcpy(dst, src, count * 4);
20 } 21 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 flags &= kFlags32_Mask; 125 flags &= kFlags32_Mask;
125 126
126 SkBlitRow::Proc32 proc = PlatformProcs32(flags); 127 SkBlitRow::Proc32 proc = PlatformProcs32(flags);
127 if (nullptr == proc) { 128 if (nullptr == proc) {
128 proc = gDefault_Procs32[flags]; 129 proc = gDefault_Procs32[flags];
129 } 130 }
130 SkASSERT(proc); 131 SkASSERT(proc);
131 return proc; 132 return proc;
132 } 133 }
133 134
134 #include "Sk4px.h"
135
136 // Color32 uses the blend_256_round_alt algorithm from tests/BlendTest.cpp.
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.
139 //
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) { 135 void SkBlitRow::Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMC olor color) {
142 switch (SkGetPackedA32(color)) { 136 switch (SkGetPackedA32(color)) {
143 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return; 137 case 0: memmove(dst, src, count * sizeof(SkPMColor)); return;
144 case 255: sk_memset32(dst, color, count); return; 138 case 255: sk_memset32(dst, color, count); return;
145 } 139 }
146 140 return SkOpts::blit_row_color32(dst, src, count, color);
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);
153 invA += invA >> 7;
154 SkASSERT(invA < 256); // We've already handled alpha == 0 above.
155
156 Sk16h colorHighAndRound = Sk4px::DupPMColor(color).widenHi() + Sk16h(128);
157 Sk16b invA_16x(invA);
158
159 Sk4px::MapSrc(count, dst, src, [&](const Sk4px& src4) -> Sk4px {
160 return (src4 * invA_16x).addNarrowHi(colorHighAndRound);
161 });
162 } 141 }
OLDNEW
« no previous file with comments | « include/core/SkBlitRow.h ('k') | src/core/SkOpts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698