rewrote GrAlphaThresholdFragmentProcessor in sksl

Bug: skia:
Change-Id: I641b206fc3bc19ac190ad94ee755ab9e1caab9b3
Reviewed-on: https://skia-review.googlesource.com/21341
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.h b/src/effects/GrAlphaThresholdFragmentProcessor.h
index de58bbf..4540857 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.h
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.h
@@ -1,75 +1,79 @@
 /*
- * Copyright 2016 Google Inc.
+ * Copyright 2017 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
 
+/*
+ * This file was autogenerated from GrAlphaThresholdFragmentProcessor.fp; do not modify.
+ */
 #ifndef GrAlphaThresholdFragmentProcessor_DEFINED
 #define GrAlphaThresholdFragmentProcessor_DEFINED
 
-#include "SkTypes.h"
-
-#if SK_SUPPORT_GPU
-
-#include "GrColorSpaceXform.h"
-#include "GrCoordTransform.h"
+    #include "SkTypes.h"
+    #if SK_SUPPORT_GPU
 #include "GrFragmentProcessor.h"
-#include "GrProcessorUnitTest.h"
-
+#include "GrCoordTransform.h"
+#include "effects/GrProxyMove.h"
 class GrAlphaThresholdFragmentProcessor : public GrFragmentProcessor {
-
 public:
-    static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
-                                           sk_sp<GrColorSpaceXform> colorSpaceXform,
-                                           sk_sp<GrTextureProxy> maskProxy,
-                                           float innerThreshold,
-                                           float outerThreshold,
-                                           const SkIRect& bounds) {
-        return sk_sp<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(
-                                                                    std::move(proxy),
-                                                                    std::move(colorSpaceXform),
-                                                                    std::move(maskProxy),
-                                                                    innerThreshold, outerThreshold,
-                                                                    bounds));
-    }
 
-    const char* name() const override { return "Alpha Threshold"; }
-
+    inline OptimizationFlags optFlags(float outerThreshold);
+    sk_sp<GrColorSpaceXform> colorXform() const { return fColorXform; }
     float innerThreshold() const { return fInnerThreshold; }
     float outerThreshold() const { return fOuterThreshold; }
 
-    GrColorSpaceXform* colorSpaceXform() const { return fColorSpaceXform.get(); }
-
+    static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> image,
+                                           sk_sp<GrColorSpaceXform> colorXform,
+                                           sk_sp<GrTextureProxy> mask,
+                                           float innerThreshold,
+                                           float outerThreshold,
+                                           const SkIRect& bounds) {
+        return sk_sp<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(image,
+                                                                                colorXform,
+                                                                                mask,
+                                                                                innerThreshold,
+                                                                                outerThreshold,
+                                                                                bounds));
+    }
+    const char* name() const override { return "AlphaThresholdFragmentProcessor"; }
 private:
-    static OptimizationFlags OptFlags(float outerThreshold);
+    GrAlphaThresholdFragmentProcessor(sk_sp<GrTextureProxy> image, sk_sp<GrColorSpaceXform> colorXform, sk_sp<GrTextureProxy> mask, float innerThreshold, float outerThreshold, 
+    const SkIRect& bounds
+)
+    : INHERITED(kNone_OptimizationFlags)
+    , 
+    fImageCoordTransform(SkMatrix::I(), image.get()),
+    fMaskCoordTransform(SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())),
+                        mask.get())
 
-    GrAlphaThresholdFragmentProcessor(sk_sp<GrTextureProxy> proxy,
-                                      sk_sp<GrColorSpaceXform> colorSpaceXform,
-                                      sk_sp<GrTextureProxy> maskProxy,
-                                      float innerThreshold,
-                                      float outerThreshold,
-                                      const SkIRect& bounds);
+    , fImage(std::move(image))
+    , fColorXform(colorXform)
+    , fMask(std::move(mask))
+    , fInnerThreshold(innerThreshold)
+    , fOuterThreshold(outerThreshold) {
 
+    this->addCoordTransform(&fImageCoordTransform);
+    this->addCoordTransform(&fMaskCoordTransform);
+        this->addTextureSampler(&fImage);
+        this->addTextureSampler(&fMask);
+        this->initClassID<GrAlphaThresholdFragmentProcessor>();
+    }
     GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
-
-    void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
-
+    void onGetGLSLProcessorKey(const GrShaderCaps&,GrProcessorKeyBuilder*) const override;
     bool onIsEqual(const GrFragmentProcessor&) const override;
-
     GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
 
+    GrCoordTransform fImageCoordTransform;
+    GrCoordTransform fMaskCoordTransform;
+    TextureSampler fImage;
+    sk_sp<GrColorSpaceXform> fColorXform;
+    TextureSampler fMask;
     float fInnerThreshold;
     float fOuterThreshold;
-    GrCoordTransform fImageCoordTransform;
-    TextureSampler   fImageTextureSampler;
-    // Color space transform is for the image (not the mask)
-    sk_sp<GrColorSpaceXform> fColorSpaceXform;
-    GrCoordTransform fMaskCoordTransform;
-    TextureSampler   fMaskTextureSampler;
-
     typedef GrFragmentProcessor INHERITED;
 };
 
-#endif
+    #endif
 #endif