aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkXfermode.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/core/SkXfermode.h')
-rw-r--r--include/core/SkXfermode.h32
1 files changed, 31 insertions, 1 deletions
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index 2d12b3c931..8319ad6882 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;
@@ -112,6 +113,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 +161,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 +244,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.