start on 2pt conical gradients

Couple ways to do this masking, but since we basically
need the same for decal, seems easiest to send it up to
the common code and handle it all together.

Change-Id: Idf806d7feab12a9caf339febd30dd3a2432ec038
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267244
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.cpp b/src/shaders/gradients/SkTwoPointConicalGradient.cpp
index f158bdd..b01291d 100644
--- a/src/shaders/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/shaders/gradients/SkTwoPointConicalGradient.cpp
@@ -234,6 +234,34 @@
     }
 }
 
+SkGradientShaderBase::MaskNeeded
+SkTwoPointConicalGradient::transformT(skvm::Builder* p, skvm::Uniforms* uniforms,
+                                      skvm::F32 x, skvm::F32 y, skvm::F32* t) const {
+    // See https://skia.org/dev/design/conical, and onAppendStages() above.
+
+    if (fType == Type::kRadial) {
+        // As if ordinary radial for [0,r2].
+        skvm::F32 r = p->sqrt(p->mad(x,x, p->mul(y,y)));
+
+        // Rescale to [r1,r2]
+        float denom = 1.0f / (fRadius2 - fRadius1),
+              scale = SkTMax(fRadius1, fRadius2) * denom,
+               bias =                  -fRadius1 * denom;
+        *t = p->mad(r, p->uniformF(uniforms->pushF(scale))
+                     , p->uniformF(uniforms->pushF(bias )));
+        return MaskNeeded::None;
+    }
+
+    if (fType == Type::kStrip) {
+        float r = fRadius1 / this->getCenterX1();
+        *t = p->add(x, p->sqrt(p->sub(p->splat(r*r),
+                                      p->mul(y,y))));
+        return MaskNeeded::NaNs;
+    }
+
+    return MaskNeeded::NotYetImplemented;
+}
+
 /////////////////////////////////////////////////////////////////////
 
 #if SK_SUPPORT_GPU