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

Side by Side Diff: src/core/Sk4px.h

Issue 1278253003: Sk4px blit mask. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: note overflow Created 5 years, 4 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 | « no previous file | src/core/SkBlitMask.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 2015 Google Inc. 2 * Copyright 2015 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 Sk4px_DEFINED 8 #ifndef Sk4px_DEFINED
9 #define Sk4px_DEFINED 9 #define Sk4px_DEFINED
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 fn(Load2(dst), Load2(src)).store2(dst); 158 fn(Load2(dst), Load2(src)).store2(dst);
159 dst += 2; src += 2; n -= 2; 159 dst += 2; src += 2; n -= 2;
160 } 160 }
161 if (n >= 1) { 161 if (n >= 1) {
162 fn(Load1(dst), Load1(src)).store1(dst); 162 fn(Load1(dst), Load1(src)).store1(dst);
163 } 163 }
164 break; 164 break;
165 } 165 }
166 } 166 }
167 167
168 // As above, but with dst4' = fn(dst4, alpha4).
169 template <typename Fn, typename Dst>
170 static void MapDstAlpha(int n, Dst* dst, const SkAlpha* a, const Fn& fn) {
171 while (n > 0) {
172 if (n >= 8) {
173 Sk4px dst0 = fn(Load4(dst+0), Load4Alphas(a+0)),
174 dst4 = fn(Load4(dst+4), Load4Alphas(a+4));
175 dst0.store4(dst+0);
176 dst4.store4(dst+4);
177 dst += 8; a += 8; n -= 8;
178 continue; // Keep our stride at 8 pixels as long as possible.
179 }
180 SkASSERT(n <= 7);
181 if (n >= 4) {
182 fn(Load4(dst), Load4Alphas(a)).store4(dst);
183 dst += 4; a += 4; n -= 4;
184 }
185 if (n >= 2) {
186 fn(Load2(dst), Load2Alphas(a)).store2(dst);
187 dst += 2; a += 2; n -= 2;
188 }
189 if (n >= 1) {
190 fn(Load1(dst), DupAlpha(*a)).store1(dst);
191 }
192 break;
193 }
194 }
195
168 // As above, but with dst4' = fn(dst4, src4, alpha4). 196 // As above, but with dst4' = fn(dst4, src4, alpha4).
169 template <typename Fn, typename Dst> 197 template <typename Fn, typename Dst>
170 static void MapDstSrcAlpha(int n, Dst* dst, const SkPMColor* src, const SkAl pha* a, 198 static void MapDstSrcAlpha(int n, Dst* dst, const SkPMColor* src, const SkAl pha* a,
171 const Fn& fn) { 199 const Fn& fn) {
172 while (n > 0) { 200 while (n > 0) {
173 if (n >= 8) { 201 if (n >= 8) {
174 Sk4px dst0 = fn(Load4(dst+0), Load4(src+0), Load4Alphas(a+0)), 202 Sk4px dst0 = fn(Load4(dst+0), Load4(src+0), Load4Alphas(a+0)),
175 dst4 = fn(Load4(dst+4), Load4(src+4), Load4Alphas(a+4)); 203 dst4 = fn(Load4(dst+4), Load4(src+4), Load4Alphas(a+4));
176 dst0.store4(dst+0); 204 dst0.store4(dst+0);
177 dst4.store4(dst+4); 205 dst4.store4(dst+4);
(...skipping 28 matching lines...) Expand all
206 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 234 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
207 #include "../opts/Sk4px_SSE2.h" 235 #include "../opts/Sk4px_SSE2.h"
208 #elif defined(SK_ARM_HAS_NEON) 236 #elif defined(SK_ARM_HAS_NEON)
209 #include "../opts/Sk4px_NEON.h" 237 #include "../opts/Sk4px_NEON.h"
210 #else 238 #else
211 #include "../opts/Sk4px_none.h" 239 #include "../opts/Sk4px_none.h"
212 #endif 240 #endif
213 #endif 241 #endif
214 242
215 #endif//Sk4px_DEFINED 243 #endif//Sk4px_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBlitMask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698