move compose-shader into base-class as factory

next steps:
1. this lands
2. update android to call the new factory
3. move SkComposeShader.h into private

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1686803003

Review URL: https://codereview.chromium.org/1686803003
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 297091d..36256f6 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -323,7 +323,7 @@
      *  the colorfilter.
      */
     SkShader* newWithColorFilter(SkColorFilter*) const;
-    
+
     //////////////////////////////////////////////////////////////////////////
     //  Factory methods for stock shaders
     
@@ -338,6 +338,18 @@
      */
     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
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index d433ff2..c49d8a4 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -252,3 +252,17 @@
     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);
+}