* the colorfilter.
*/
SkShader* newWithColorFilter(SkColorFilter*) const;
-
+
//////////////////////////////////////////////////////////////////////////
// Factory methods for stock shaders
*/
static SkShader* CreateColorShader(SkColor);
+ static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode::Mode);
+
+ /**
+ * Create a new compose shader, given shaders dst, src, and a combining xfermode mode.
+ * The xfermode is called with the output of the two shaders, and its output is returned.
+ * If xfer is null, SkXfermode::kSrcOver_Mode is assumed.
+ *
+ * Ownership of the shaders, and the xfermode if not null, is not transfered, so the caller
+ * is still responsible for managing its reference-count for those objects.
+ */
+ static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode* xfer);
+
/** Call this to create a new shader that will draw with the specified bitmap.
*
* If the bitmap cannot be used (e.g. has no pixels, or its dimensions
str->append(")");
}
#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+SkShader* SkShader::CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode* xfer) {
+ if (!dst || !src) {
+ return nullptr;
+ }
+ return new SkComposeShader(dst, src, xfer);
+}
+
+SkShader* SkShader::CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode::Mode mode) {
+ SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(mode));
+ return CreateComposeShader(dst, src, xfer);
+}