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

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

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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/SkShader.cpp ('k') | src/core/SkXfermode_proccoeff.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkXfermode.h" 8 #include "SkXfermode.h"
9 #include "SkXfermode_proccoeff.h" 9 #include "SkXfermode_proccoeff.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkMathPriv.h" 11 #include "SkMathPriv.h"
12 #include "SkOnce.h" 12 #include "SkOnce.h"
13 #include "SkOpts.h" 13 #include "SkOpts.h"
14 #include "SkReadBuffer.h" 14 #include "SkReadBuffer.h"
15 #include "SkString.h" 15 #include "SkString.h"
16 #include "SkWriteBuffer.h" 16 #include "SkWriteBuffer.h"
17 #include "SkPM4f.h" 17 #include "SkPM4f.h"
18 18
19 #if SK_SUPPORT_GPU
20 #include "GrFragmentProcessor.h"
21 #include "effects/GrCustomXfermode.h"
22 #include "effects/GrPorterDuffXferProcessor.h"
23 #include "effects/GrXfermodeFragmentProcessor.h"
24 #endif
25
19 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b) 26 #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b)
20 27
21 static inline unsigned saturated_add(unsigned a, unsigned b) { 28 static inline unsigned saturated_add(unsigned a, unsigned b) {
22 SkASSERT(a <= 255); 29 SkASSERT(a <= 255);
23 SkASSERT(b <= 255); 30 SkASSERT(b <= 255);
24 unsigned sum = a + b; 31 unsigned sum = a + b;
25 if (sum > 255) { 32 if (sum > 255) {
26 sum = 255; 33 sum = 255;
27 } 34 }
28 return sum; 35 return sum;
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 { luminosity_modeproc, proc_4f<luminosity_4f>, CANNOT_USE_COEFF, CANN OT_USE_COEFF }, 985 { luminosity_modeproc, proc_4f<luminosity_4f>, CANNOT_USE_COEFF, CANN OT_USE_COEFF },
979 }; 986 };
980 987
981 /////////////////////////////////////////////////////////////////////////////// 988 ///////////////////////////////////////////////////////////////////////////////
982 989
983 bool SkXfermode::asMode(Mode* mode) const { 990 bool SkXfermode::asMode(Mode* mode) const {
984 return false; 991 return false;
985 } 992 }
986 993
987 #if SK_SUPPORT_GPU 994 #if SK_SUPPORT_GPU
988 const GrFragmentProcessor* SkXfermode::getFragmentProcessorForImageFilter( 995 sk_sp<GrFragmentProcessor> SkXfermode::makeFragmentProcessorForImageFilter(
989 const GrFragment Processor*) const { 996 sk_sp<GrFragment Processor>) const {
990 // This should never be called. 997 // This should never be called.
991 // TODO: make pure virtual in SkXfermode once Android update lands 998 // TODO: make pure virtual in SkXfermode once Android update lands
992 SkASSERT(0); 999 SkASSERT(0);
993 return nullptr; 1000 return nullptr;
994 } 1001 }
995 1002
996 GrXPFactory* SkXfermode::asXPFactory() const { 1003 sk_sp<GrXPFactory> SkXfermode::asXPFactory() const {
997 // This should never be called. 1004 // This should never be called.
998 // TODO: make pure virtual in SkXfermode once Android update lands 1005 // TODO: make pure virtual in SkXfermode once Android update lands
999 SkASSERT(0); 1006 SkASSERT(0);
1000 return nullptr; 1007 return nullptr;
1001 } 1008 }
1002 #endif 1009 #endif
1003 1010
1004 SkPMColor SkXfermode::xferColor(SkPMColor src, SkPMColor dst) const{ 1011 SkPMColor SkXfermode::xferColor(SkPMColor src, SkPMColor dst) const{
1005 // no-op. subclasses should override this 1012 // no-op. subclasses should override this
1006 return dst; 1013 return dst;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 A = SkAlphaBlend(A, dstA, SkAlpha255To256(a)); 1240 A = SkAlphaBlend(A, dstA, SkAlpha255To256(a));
1234 } 1241 }
1235 dst[i] = SkToU8(A); 1242 dst[i] = SkToU8(A);
1236 } 1243 }
1237 } 1244 }
1238 } 1245 }
1239 } 1246 }
1240 } 1247 }
1241 1248
1242 #if SK_SUPPORT_GPU 1249 #if SK_SUPPORT_GPU
1243 #include "effects/GrCustomXfermode.h" 1250 sk_sp<GrFragmentProcessor> SkProcCoeffXfermode::makeFragmentProcessorForImageFil ter(
1244 #include "effects/GrPorterDuffXferProcessor.h" 1251 sk_sp<GrFragmentProc essor> dst) const {
1245 #include "effects/GrXfermodeFragmentProcessor.h"
1246
1247 const GrFragmentProcessor* SkProcCoeffXfermode::getFragmentProcessorForImageFilt er(
1248 const GrFragmentProc essor* dst) const {
1249 SkASSERT(dst); 1252 SkASSERT(dst);
1250 return GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode); 1253 return GrXfermodeFragmentProcessor::MakeFromDstProcessor(std::move(dst), fMo de);
1251 } 1254 }
1252 1255
1253 GrXPFactory* SkProcCoeffXfermode::asXPFactory() const { 1256 sk_sp<GrXPFactory> SkProcCoeffXfermode::asXPFactory() const {
1254 if (CANNOT_USE_COEFF != fSrcCoeff) { 1257 if (CANNOT_USE_COEFF != fSrcCoeff) {
1255 GrXPFactory* result = GrPorterDuffXPFactory::Create(fMode); 1258 sk_sp<GrXPFactory> result(GrPorterDuffXPFactory::Make(fMode));
1256 SkASSERT(result); 1259 SkASSERT(result);
1257 return result; 1260 return result;
1258 } 1261 }
1259 1262
1260 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); 1263 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode));
1261 return GrCustomXfermode::CreateXPFactory(fMode); 1264 return GrCustomXfermode::MakeXPFactory(fMode);
1262 } 1265 }
1263 #endif 1266 #endif
1264 1267
1265 const char* SkXfermode::ModeName(Mode mode) { 1268 const char* SkXfermode::ModeName(Mode mode) {
1266 SkASSERT((unsigned) mode <= (unsigned)kLastMode); 1269 SkASSERT((unsigned) mode <= (unsigned)kLastMode);
1267 const char* gModeStrings[] = { 1270 const char* gModeStrings[] = {
1268 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn", 1271 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn",
1269 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus", 1272 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus",
1270 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", 1273 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge",
1271 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", 1274 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion",
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 if (!xfer) { 1416 if (!xfer) {
1414 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; 1417 return SkXfermode::kOpaque_SrcColorOpacity == opacityType;
1415 } 1418 }
1416 1419
1417 return xfer->isOpaque(opacityType); 1420 return xfer->isOpaque(opacityType);
1418 } 1421 }
1419 1422
1420 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1423 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1421 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1424 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1422 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1425 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/core/SkShader.cpp ('k') | src/core/SkXfermode_proccoeff.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698