Remove option to make GrCoordTransforms apply to device positions.

Adds a device space texture decal effect to use for clipping.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2870

Change-Id: Ifcc7617ea87f5a86e301995cba9dfc30a4b0e2c5
Reviewed-on: https://skia-review.googlesource.com/2870
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 9edecac..82ff73c 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -85,7 +85,7 @@
         );
     }
 
-    bool operator== (const GrTextureDomain& that) const {
+    bool operator==(const GrTextureDomain& that) const {
         return fMode == that.fMode && (kIgnore_Mode == fMode || fDomain == that.fDomain);
     }
 
@@ -140,7 +140,7 @@
          * computed key. The returned will be limited to the lower kDomainKeyBits bits.
          */
         static uint32_t DomainKey(const GrTextureDomain& domain) {
-            GR_STATIC_ASSERT(kModeCount <= 4);
+            GR_STATIC_ASSERT(kModeCount <= (1 << kDomainKeyBits));
             return domain.mode();
         }
 
@@ -171,35 +171,28 @@
                                            const SkMatrix&,
                                            const SkRect& domain,
                                            GrTextureDomain::Mode,
-                                           GrTextureParams::FilterMode filterMode,
-                                           GrCoordSet = kLocal_GrCoordSet);
-
-    virtual ~GrTextureDomainEffect();
+                                           GrTextureParams::FilterMode filterMode);
 
     const char* name() const override { return "TextureDomain"; }
 
     SkString dumpInfo() const override {
         SkString str;
-        str.appendf("Domain: [L: %.2f, T: %.2f, R: %.2f, B: %.2f] ",
+        str.appendf("Domain: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]",
                     fTextureDomain.domain().fLeft, fTextureDomain.domain().fTop,
                     fTextureDomain.domain().fRight, fTextureDomain.domain().fBottom);
         str.append(INHERITED::dumpInfo());
         return str;
     }
 
-    const GrTextureDomain& textureDomain() const { return fTextureDomain; }
-
-protected:
+private:
     GrTextureDomain fTextureDomain;
 
-private:
     GrTextureDomainEffect(GrTexture*,
                           sk_sp<GrColorSpaceXform>,
                           const SkMatrix&,
                           const SkRect& domain,
                           GrTextureDomain::Mode,
-                          GrTextureParams::FilterMode,
-                          GrCoordSet);
+                          GrTextureParams::FilterMode);
 
     GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
 
@@ -214,4 +207,40 @@
     typedef GrSingleTextureEffect INHERITED;
 };
 
+class GrDeviceSpaceTextureDecalFragmentProcessor : public GrFragmentProcessor {
+public:
+    static sk_sp<GrFragmentProcessor> Make(GrTexture*, const SkIRect& subset,
+                                           const SkIPoint& deviceSpaceOffset);
+
+    const char* name() const override { return "GrDeviceSpaceTextureDecalFragmentProcessor"; }
+
+    SkString dumpInfo() const override {
+        SkString str;
+        str.appendf("Domain: [L: %.2f, T: %.2f, R: %.2f, B: %.2f] Offset: [%d %d]",
+                    fTextureDomain.domain().fLeft, fTextureDomain.domain().fTop,
+                    fTextureDomain.domain().fRight, fTextureDomain.domain().fBottom,
+                    fDeviceSpaceOffset.fX, fDeviceSpaceOffset.fY);
+        str.append(INHERITED::dumpInfo());
+        return str;
+    }
+
+private:
+    GrTextureAccess fTextureAccess;
+    GrTextureDomain fTextureDomain;
+    SkIPoint fDeviceSpaceOffset;
+
+    GrDeviceSpaceTextureDecalFragmentProcessor(GrTexture*, const SkIRect&, const SkIPoint&);
+
+    GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
+
+    // Since we always use decal mode, there is no need for key data.
+    void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override {}
+
+    bool onIsEqual(const GrFragmentProcessor& fp) const override;
+    void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
+
+    GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
+
+    typedef GrFragmentProcessor INHERITED;
+};
 #endif