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

Unified Diff: src/gpu/SkGr.cpp

Issue 1674673002: Alter SkXfermode's asFragmentProcessor & asXPFactory contracts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix unit test bug Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkXfermodeImageFilter.cpp ('k') | src/utils/debugger/SkOverdrawMode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index e4dc467e7f8b9ce2ccd27d5957f505371a515063..df65e451feacfdfac1802f197a16f6cc48d29cc8 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -489,10 +489,15 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
}
}
- SkXfermode* mode = skPaint.getXfermode();
- GrXPFactory* xpFactory = nullptr;
- SkXfermode::AsXPFactory(mode, &xpFactory);
- SkSafeUnref(grPaint->setXPFactory(xpFactory));
+ // When the xfermode is null on the SkPaint (meaning kSrcOver) we need the XPFactory field on
+ // the GrPaint to also be null (also kSrcOver).
+ SkASSERT(!grPaint->getXPFactory());
+ SkXfermode* xfermode = skPaint.getXfermode();
+ if (xfermode) {
+ // SafeUnref in case a new xfermode is added that returns null.
+ // In such cases we will fall back to kSrcOver_Mode.
+ SkSafeUnref(grPaint->setXPFactory(xfermode->asXPFactory()));
+ }
#ifndef SK_IGNORE_GPU_DITHER
if (skPaint.isDither() && grPaint->numColorFragmentProcessors() > 0) {
« no previous file with comments | « src/effects/SkXfermodeImageFilter.cpp ('k') | src/utils/debugger/SkOverdrawMode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698