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

Unified Diff: include/core/SkXfermode.h

Issue 864833002: Remove the need for asCoeff in SkXfermode. (Closed) Base URL: https://skia.googlesource.com/skia.git@moreXferCleanup
Patch Set: Fix build Created 5 years, 11 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 | « no previous file | src/core/SkDraw.cpp » ('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 fc9ae21ac45445b9445285ba697c16686661b418..1dd01a2e1d7f0cf526e3c9f078f3ac7aebdd58de 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -57,29 +57,6 @@ public:
kCoeffCount
};
- /** If the xfermode can be expressed as an equation using the coefficients
- in Coeff, then asCoeff() returns true, and sets (if not null) src and
- dst accordingly.
-
- result = src_coeff * src_color + dst_coeff * dst_color;
-
- As examples, here are some of the porterduff coefficients
-
- MODE SRC_COEFF DST_COEFF
- clear zero zero
- src one zero
- dst zero one
- srcover one isa
- dstover ida one
- */
- virtual bool asCoeff(Coeff* src, Coeff* dst) const;
-
- /**
- * The same as calling xfermode->asCoeff(..), except that this also checks
- * if the xfermode is NULL, and if so, treats it as kSrcOver_Mode.
- */
- static bool AsCoeff(const SkXfermode*, Coeff* src, Coeff* dst);
-
/** List of predefined xfermodes.
The algebra for the modes uses the following symbols:
Sa, Sc - source alpha and color
@@ -190,6 +167,41 @@ public:
return AsMode(xfer, mode);
}
+ /**
+ * Returns whether or not the xfer mode can support treating coverage as alpha
+ */
+ virtual bool supportsCoverageAsAlpha() const;
+
+ /**
+ * The same as calling xfermode->supportsCoverageAsAlpha(), except that this also checks if
+ * the xfermode is NULL, and if so, treats it as kSrcOver_Mode.
+ */
+ static bool SupportsCoverageAsAlpha(const SkXfermode* xfer);
+
+ enum SrcColorOpacity {
+ // The src color is known to be opaque (alpha == 255)
+ kOpaque_SrcColorOpacity = 0,
+ // The src color is known to be fully transparent (color == 0)
+ kTransparentBlack_SrcColorOpacity = 1,
+ // The src alpha is known to be fully transparent (alpha == 0)
+ kTransparentAlpha_SrcColorOpacity = 2,
+ // The src color opacity is unknown
+ kUnknown_SrcColorOpacity = 3
+ };
+
+ /**
+ * Returns whether or not the result of the draw with the xfer mode will be opaque or not. The
+ * input to this call is an enum describing known information about the opacity of the src color
+ * that will be given to the xfer mode.
+ */
+ virtual bool isOpaque(SrcColorOpacity opacityType) const;
+
+ /**
+ * The same as calling xfermode->isOpaque(...), except that this also checks if
+ * the xfermode is NULL, and if so, treats it as kSrcOver_Mode.
+ */
+ static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType);
+
/** Implemented by a subclass to support use as an image filter in the GPU backend. When used as
an image filter the xfer mode blends the source color against a background texture rather
than the destination. It is implemented as a fragment processor. This can be called with
« no previous file with comments | « no previous file | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698