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

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

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/core/SkOpts.cpp ('k') | src/opts/SkOpts_neon.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkXfermode.h" 9 #include "SkXfermode.h"
10 #include "SkXfermode_proccoeff.h" 10 #include "SkXfermode_proccoeff.h"
11 #include "Sk4pxXfermode.h"
12 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
13 #include "SkLazyPtr.h" 12 #include "SkLazyPtr.h"
14 #include "SkMathPriv.h" 13 #include "SkMathPriv.h"
14 #include "SkOpts.h"
15 #include "SkPMFloat.h" 15 #include "SkPMFloat.h"
16 #include "SkReadBuffer.h" 16 #include "SkReadBuffer.h"
17 #include "SkString.h" 17 #include "SkString.h"
18 #include "SkWriteBuffer.h" 18 #include "SkWriteBuffer.h"
19 19
20 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b) 20 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b)
21 21
22 static inline unsigned saturated_add(unsigned a, unsigned b) { 22 static inline unsigned saturated_add(unsigned a, unsigned b) {
23 SkASSERT(a <= 255); 23 SkASSERT(a <= 255);
24 SkASSERT(b <= 255); 24 SkASSERT(b <= 255);
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 str->append(" dst: "); 990 str->append(" dst: ");
991 if (CANNOT_USE_COEFF == fDstCoeff) { 991 if (CANNOT_USE_COEFF == fDstCoeff) {
992 str->append("can't use"); 992 str->append("can't use");
993 } else { 993 } else {
994 str->append(gCoeffStrings[fDstCoeff]); 994 str->append(gCoeffStrings[fDstCoeff]);
995 } 995 }
996 } 996 }
997 #endif 997 #endif
998 998
999 999
1000 extern SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec, SkXf ermode::Mode mode);
1001 extern SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode);
1002
1003 // Technically, can't be static and passed as a template parameter. So we use a nonymous namespace. 1000 // Technically, can't be static and passed as a template parameter. So we use a nonymous namespace.
1004 namespace { 1001 namespace {
1005 SkXfermode* create_mode(int iMode) { 1002 SkXfermode* create_mode(int iMode) {
1006 SkXfermode::Mode mode = (SkXfermode::Mode)iMode; 1003 SkXfermode::Mode mode = (SkXfermode::Mode)iMode;
1007 1004
1008 ProcCoeff rec = gProcCoeffs[mode]; 1005 ProcCoeff rec = gProcCoeffs[mode];
1009 if (auto proc = SkPlatformXfermodeProcFactory(mode)) { 1006 if (auto xfermode = SkOpts::create_xfermode(rec, mode)) {
1010 rec.fProc = proc;
1011 }
1012
1013 // Check for compile-time SIMD xfermode.
1014 if (auto xfermode = SkCreate4pxXfermode(rec, mode)) {
1015 return xfermode; 1007 return xfermode;
1016 } 1008 }
1017
1018 // Check for runtime-detected SIMD xfermode.
1019 if (auto xfermode = SkPlatformXfermodeFactory(rec, mode)) {
1020 return xfermode;
1021 }
1022
1023 // Serial fallback.
1024 return SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode)); 1009 return SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode));
1025 } 1010 }
1026 } // namespace 1011 } // namespace
1027 1012
1028 SK_DECLARE_STATIC_LAZY_PTR_ARRAY(SkXfermode, cached, SkXfermode::kLastMode + 1, create_mode); 1013 SK_DECLARE_STATIC_LAZY_PTR_ARRAY(SkXfermode, cached, SkXfermode::kLastMode + 1, create_mode);
1029 1014
1030 SkXfermode* SkXfermode::Create(Mode mode) { 1015 SkXfermode* SkXfermode::Create(Mode mode) {
1031 SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount); 1016 SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount);
1032 1017
1033 if ((unsigned)mode >= kModeCount) { 1018 if ((unsigned)mode >= kModeCount) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 if (!xfer) { 1094 if (!xfer) {
1110 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; 1095 return SkXfermode::kOpaque_SrcColorOpacity == opacityType;
1111 } 1096 }
1112 1097
1113 return xfer->isOpaque(opacityType); 1098 return xfer->isOpaque(opacityType);
1114 } 1099 }
1115 1100
1116 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1101 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1117 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1102 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1118 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1103 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/core/SkOpts.cpp ('k') | src/opts/SkOpts_neon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698