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

Side by Side Diff: src/opts/SkXfermode_opts.h

Issue 1526523003: Unify some SkNx code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typo Created 5 years 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 | « src/opts/SkNx_sse.h ('k') | tests/SkNxTest.cpp » ('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 Sk4pxXfermode_DEFINED 8 #ifndef Sk4pxXfermode_DEFINED
9 #define Sk4pxXfermode_DEFINED 9 #define Sk4pxXfermode_DEFINED
10 10
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 for (int i = 0; i < n; i++) { 258 for (int i = 0; i < n; i++) {
259 SkPMColor dst32 = SkPixel16ToPixel32(dst[i]); 259 SkPMColor dst32 = SkPixel16ToPixel32(dst[i]);
260 dst32 = aa ? this->xfer32(dst32, src[i], aa[i]) 260 dst32 = aa ? this->xfer32(dst32, src[i], aa[i])
261 : this->xfer32(dst32, src[i]); 261 : this->xfer32(dst32, src[i]);
262 dst[i] = SkPixel32ToPixel16(dst32); 262 dst[i] = SkPixel32ToPixel16(dst32);
263 } 263 }
264 } 264 }
265 265
266 private: 266 private:
267 static Sk4f Load(SkPMColor c) { 267 static Sk4f Load(SkPMColor c) {
268 return Sk4f::FromBytes((uint8_t*)&c) * Sk4f(1.0f/255); 268 return SkNx_cast<float>(Sk4b::Load((uint8_t*)&c)) * Sk4f(1.0f/255);
269 } 269 }
270 static SkPMColor Round(const Sk4f& f) { 270 static SkPMColor Round(const Sk4f& f) {
271 SkPMColor c; 271 SkPMColor c;
272 (f * Sk4f(255) + Sk4f(0.5f)).toBytes((uint8_t*)&c); 272 SkNx_cast<uint8_t>(f * Sk4f(255) + Sk4f(0.5f)).store((uint8_t*)&c);
273 return c; 273 return c;
274 } 274 }
275 inline SkPMColor xfer32(SkPMColor dst, SkPMColor src) const { 275 inline SkPMColor xfer32(SkPMColor dst, SkPMColor src) const {
276 return Round(fProcF(Load(dst), Load(src))); 276 return Round(fProcF(Load(dst), Load(src)));
277 } 277 }
278 278
279 inline SkPMColor xfer32(SkPMColor dst, SkPMColor src, SkAlpha aa) const { 279 inline SkPMColor xfer32(SkPMColor dst, SkPMColor src, SkAlpha aa) const {
280 Sk4f s(Load(src)), 280 Sk4f s(Load(src)),
281 d(Load(dst)), 281 d(Load(dst)),
282 b(fProcF(d,s)); 282 b(fProcF(d,s));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 #undef CASE 330 #undef CASE
331 331
332 default: break; 332 default: break;
333 } 333 }
334 return nullptr; 334 return nullptr;
335 } 335 }
336 336
337 } // namespace SK_OPTS_NS 337 } // namespace SK_OPTS_NS
338 338
339 #endif//Sk4pxXfermode_DEFINED 339 #endif//Sk4pxXfermode_DEFINED
OLDNEW
« no previous file with comments | « src/opts/SkNx_sse.h ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698