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

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

Issue 1264543006: Port SkXfermode opts to SkOpts.h (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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 | « src/opts/SkOpts_sse2.cpp ('k') | src/opts/SkXfermode_opts_arm.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
11 #include "Sk4px.h" 11 #include "Sk4px.h"
12 #include "SkPMFloat.h" 12 #include "SkPMFloat.h"
13 #include "SkXfermode_proccoeff.h" 13 #include "SkXfermode_proccoeff.h"
14 14
15 // This file is possibly included into multiple .cpp files. 15 // This file is possibly included into multiple .cpp files.
16 // Each gets its own independent instantiation by wrapping in an anonymous names pace. 16 // Each gets its own independent instantiation by wrapping in an anonymous names pace.
17 namespace { 17 namespace {
18 18
19 #if defined(SK_CPU_ARM32) && !defined(SK_ARM_HAS_NEON)
20 // Signals SkXfermode.cpp to look for runtime-detected NEON.
21 static SkProcCoeffXfermode* SkCreate4pxXfermode(const ProcCoeff& rec, SkXfer mode::Mode mode) {
22 return nullptr;
23 }
24 #else
25
26 // Most xfermodes can be done most efficiently 4 pixels at a time in 8 or 16-bit fixed point. 19 // Most xfermodes can be done most efficiently 4 pixels at a time in 8 or 16-bit fixed point.
27 #define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px s, Sk4px d) 20 #define XFERMODE(Name) static Sk4px SK_VECTORCALL Name(Sk4px s, Sk4px d)
28 21
29 XFERMODE(Clear) { return Sk4px::DupPMColor(0); } 22 XFERMODE(Clear) { return Sk4px::DupPMColor(0); }
30 XFERMODE(Src) { return s; } 23 XFERMODE(Src) { return s; }
31 XFERMODE(Dst) { return d; } 24 XFERMODE(Dst) { return d; }
32 XFERMODE(SrcIn) { return s.approxMulDiv255(d.alphas() ); } 25 XFERMODE(SrcIn) { return s.approxMulDiv255(d.alphas() ); }
33 XFERMODE(SrcOut) { return s.approxMulDiv255(d.alphas().inv()); } 26 XFERMODE(SrcOut) { return s.approxMulDiv255(d.alphas().inv()); }
34 XFERMODE(SrcOver) { return s + d.approxMulDiv255(s.alphas().inv()); } 27 XFERMODE(SrcOver) { return s + d.approxMulDiv255(s.alphas().inv()); }
35 XFERMODE(DstIn) { return SrcIn (d,s); } 28 XFERMODE(DstIn) { return SrcIn (d,s); }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // We do aa in full float precision before going back down to bytes, bec ause we can! 269 // We do aa in full float precision before going back down to bytes, bec ause we can!
277 SkPMFloat a = Sk4f(aa) * Sk4f(1.0f/255); 270 SkPMFloat a = Sk4f(aa) * Sk4f(1.0f/255);
278 b = b*a + d*(Sk4f(1)-a); 271 b = b*a + d*(Sk4f(1)-a);
279 return b.round(); 272 return b.round();
280 } 273 }
281 274
282 ProcF fProcF; 275 ProcF fProcF;
283 typedef SkProcCoeffXfermode INHERITED; 276 typedef SkProcCoeffXfermode INHERITED;
284 }; 277 };
285 278
286 static SkProcCoeffXfermode* SkCreate4pxXfermode(const ProcCoeff& rec, SkXfermode ::Mode mode) { 279 static SkXfermode* SkCreate4pxXfermode(const ProcCoeff& rec, SkXfermode::Mode mo de) {
287 switch (mode) { 280 switch (mode) {
288 #define CASE(Mode) case SkXfermode::k##Mode##_Mode: \ 281 #define CASE(Mode) case SkXfermode::k##Mode##_Mode: \
289 return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>)) 282 return SkNEW_ARGS(Sk4pxXfermode, (rec, mode, &Mode, &xfer_aa<Mode>))
290 CASE(Clear); 283 CASE(Clear);
291 CASE(Src); 284 CASE(Src);
292 CASE(Dst); 285 CASE(Dst);
293 CASE(SrcOver); 286 CASE(SrcOver);
294 CASE(DstOver); 287 CASE(DstOver);
295 CASE(SrcIn); 288 CASE(SrcIn);
296 CASE(DstIn); 289 CASE(DstIn);
(...skipping 19 matching lines...) Expand all
316 CASE(ColorDodge); 309 CASE(ColorDodge);
317 CASE(ColorBurn); 310 CASE(ColorBurn);
318 CASE(SoftLight); 311 CASE(SoftLight);
319 #undef CASE 312 #undef CASE
320 313
321 default: break; 314 default: break;
322 } 315 }
323 return nullptr; 316 return nullptr;
324 } 317 }
325 318
326 #endif
327
328 } // namespace 319 } // namespace
329 320
330 #endif//Sk4pxXfermode_DEFINED 321 #endif//Sk4pxXfermode_DEFINED
OLDNEW
« no previous file with comments | « src/opts/SkOpts_sse2.cpp ('k') | src/opts/SkXfermode_opts_arm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698