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

Unified Diff: include/core/SkXfermode.h

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 years, 2 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 | « include/core/SkPicture.h ('k') | include/effects/SkXfermodeImageFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkXfermode.h
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index 2d12b3c931ca6658d71acf111b9f0ea7fc872d83..253ee1b4089ae5be24ca7ef1ab37cf729310ba03 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -8,8 +8,9 @@
#ifndef SkXfermode_DEFINED
#define SkXfermode_DEFINED
-#include "SkFlattenable.h"
+#include "SkBlendMode.h"
#include "SkColor.h"
+#include "SkFlattenable.h"
class GrFragmentProcessor;
class GrTexture;
@@ -17,6 +18,8 @@ class GrXPFactory;
class SkRasterPipeline;
class SkString;
+struct SkArithmeticParams;
+
struct SkPM4f;
typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst);
@@ -112,6 +115,9 @@ public:
* Gets the name of the Mode as a string.
*/
static const char* ModeName(Mode);
+ static const char* ModeName(SkBlendMode mode) {
+ return ModeName(Mode(mode));
+ }
/**
* If the xfermode is one of the modes in the Mode enum, then asMode()
@@ -157,6 +163,31 @@ public:
}
#endif
+ /**
+ * Skia maintains global xfermode objects corresponding to each BlendMode. This returns a
+ * ptr to that global xfermode (or null if the mode is srcover). Thus the caller may use
+ * the returned ptr, but it should leave its refcnt untouched.
+ */
+ static SkXfermode* Peek(SkBlendMode mode) {
+ sk_sp<SkXfermode> xfer = Make(mode);
+ if (!xfer) {
+ SkASSERT(SkBlendMode::kSrcOver == mode);
+ return nullptr;
+ }
+ SkASSERT(!xfer->unique());
+ return xfer.get();
+ }
+
+ static sk_sp<SkXfermode> Make(SkBlendMode bm) {
+ return Make((Mode)bm);
+ }
+
+ SkBlendMode blend() const {
+ Mode mode;
+ SkAssertResult(this->asMode(&mode));
+ return (SkBlendMode)mode;
+ }
+
/** Return a function pointer to a routine that applies the specified
porter-duff transfer mode.
*/
@@ -215,6 +246,7 @@ public:
static bool IsOpaque(const sk_sp<SkXfermode>& xfer, SrcColorOpacity opacityType) {
return IsOpaque(xfer.get(), opacityType);
}
+ static bool IsOpaque(SkBlendMode, SrcColorOpacity);
#if SK_SUPPORT_GPU
/** Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentProcessor.
@@ -270,6 +302,8 @@ public:
static LCD32Proc GetLCD32Proc(uint32_t flags);
static LCDF16Proc GetLCDF16Proc(uint32_t) { return nullptr; }
+ virtual bool isArithmetic(SkArithmeticParams*) const { return false; }
+
protected:
SkXfermode() {}
/** The default implementation of xfer32/xfer16/xferA8 in turn call this
« no previous file with comments | « include/core/SkPicture.h ('k') | include/effects/SkXfermodeImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698