Rework GrSamplerParams to be more compact and use its own wrap mode enum.

The main change is to make GrSamplerParams smaller by making its enums have byte-sized underlying types. The rest is cosmetic.

Change-Id: Ib71ea50612d24619a85e463826c6b8dfb9b445e3
Reviewed-on: https://skia-review.googlesource.com/43200
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/tests/DetermineDomainModeTest.cpp b/tests/DetermineDomainModeTest.cpp
index ee9a694..111194f 100644
--- a/tests/DetermineDomainModeTest.cpp
+++ b/tests/DetermineDomainModeTest.cpp
@@ -23,14 +23,13 @@
 public:
     using DomainMode = GrTextureProducer::DomainMode;
 
-    static DomainMode DetermineDomainMode(
-                                const SkRect& constraintRect,
-                                GrTextureProducer::FilterConstraint filterConstraint,
-                                bool coordsLimitedToConstraintRect,
-                                GrTextureProxy* proxy,
-                                const SkIRect* textureContentArea,
-                                const GrSamplerParams::FilterMode* filterModeOrNullForBicubic,
-                                SkRect* domainRect) {
+    static DomainMode DetermineDomainMode(const SkRect& constraintRect,
+                                          GrTextureProducer::FilterConstraint filterConstraint,
+                                          bool coordsLimitedToConstraintRect,
+                                          GrTextureProxy* proxy,
+                                          const SkIRect* textureContentArea,
+                                          const GrSamplerState::Filter* filterModeOrNullForBicubic,
+                                          SkRect* domainRect) {
         return GrTextureProducer::DetermineDomainMode(constraintRect,
                                                       filterConstraint,
                                                       coordsLimitedToConstraintRect,
@@ -346,15 +345,14 @@
     GrTextureProducer_TestAccess::DomainMode actualMode, expectedMode;
     SkRect actualDomainRect;
 
-    static const GrSamplerParams::FilterMode gModes[] = {
-        GrSamplerParams::kNone_FilterMode,
-        GrSamplerParams::kBilerp_FilterMode,
-        GrSamplerParams::kMipMap_FilterMode,
+    static const GrSamplerState::Filter gModes[] = {
+            GrSamplerState::Filter::kNearest,
+            GrSamplerState::Filter::kBilerp,
+            GrSamplerState::Filter::kMipMap,
     };
 
-    static const GrSamplerParams::FilterMode* gModePtrs[] = {
-        &gModes[0], &gModes[1], nullptr, &gModes[2]
-    };
+    static const GrSamplerState::Filter* gModePtrs[] = {&gModes[0], &gModes[1], nullptr,
+                                                        &gModes[2]};
 
     static const float gHalfFilterWidth[] = { 0.0f, 0.5f, 1.5f, 10000.0f };
 
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 4ee2803..96b5b29 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -927,19 +927,19 @@
             // Any context should be able to borrow the texture at this point
             sk_sp<SkColorSpace> texColorSpace;
             sk_sp<GrTextureProxy> proxy = as_IB(refImg)->asTextureProxyRef(
-                ctx, GrSamplerParams::ClampNoFilter(), nullptr, &texColorSpace, nullptr);
+                    ctx, GrSamplerState::ClampNearest(), nullptr, &texColorSpace, nullptr);
             REPORTER_ASSERT(reporter, proxy);
 
             // But once it's borrowed, no other context should be able to borrow
             otherTestContext->makeCurrent();
             sk_sp<GrTextureProxy> otherProxy = as_IB(refImg)->asTextureProxyRef(
-                otherCtx, GrSamplerParams::ClampNoFilter(), nullptr, &texColorSpace, nullptr);
+                    otherCtx, GrSamplerState::ClampNearest(), nullptr, &texColorSpace, nullptr);
             REPORTER_ASSERT(reporter, !otherProxy);
 
             // Original context (that's already borrowing) should be okay
             testContext->makeCurrent();
             sk_sp<GrTextureProxy> proxySecondRef = as_IB(refImg)->asTextureProxyRef(
-                ctx, GrSamplerParams::ClampNoFilter(), nullptr, &texColorSpace, nullptr);
+                    ctx, GrSamplerState::ClampNearest(), nullptr, &texColorSpace, nullptr);
             REPORTER_ASSERT(reporter, proxySecondRef);
 
             // Releae all refs from the original context
@@ -948,8 +948,8 @@
 
             // Now we should be able to borrow the texture from the other context
             otherTestContext->makeCurrent();
-            otherProxy = as_IB(refImg)->asTextureProxyRef(
-                otherCtx, GrSamplerParams::ClampNoFilter(), nullptr, &texColorSpace, nullptr);
+            otherProxy = as_IB(refImg)->asTextureProxyRef(otherCtx, GrSamplerState::ClampNearest(),
+                                                          nullptr, &texColorSpace, nullptr);
             REPORTER_ASSERT(reporter, otherProxy);
 
             // Release everything
diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp
index 35019b8..3baded9 100644
--- a/tests/IntTextureTest.cpp
+++ b/tests/IntTextureTest.cpp
@@ -249,13 +249,11 @@
             SkBackingFit::kExact, kS, kS, kRGBA_8888_GrPixelConfig, nullptr);
 
     struct {
-        GrSamplerParams::FilterMode fMode;
+        GrSamplerState::Filter fMode;
         const char* fName;
-    } kNamedFilters[] ={
-        { GrSamplerParams::kNone_FilterMode, "filter-none" },
-        { GrSamplerParams::kBilerp_FilterMode, "filter-bilerp" },
-        { GrSamplerParams::kMipMap_FilterMode, "filter-mipmap" }
-    };
+    } kNamedFilters[] = {{GrSamplerState::Filter::kNearest, "filter-none"},
+                         {GrSamplerState::Filter::kBilerp, "filter-bilerp"},
+                         {GrSamplerState::Filter::kMipMap, "filter-mipmap"}};
 
     for (auto filter : kNamedFilters) {
         auto fp = GrSimpleTextureEffect::Make(sContext->asTextureProxyRef(), nullptr, SkMatrix::I(),
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 08569a7..25a8b93 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -25,9 +25,9 @@
             context->makeDeferredRenderTargetContext(SkBackingFit::kExact, rectProxy->width(),
                                                      rectProxy->height(), rectProxy->config(),
                                                      nullptr));
-    for (auto filter : {GrSamplerParams::kNone_FilterMode,
-                        GrSamplerParams::kBilerp_FilterMode,
-                        GrSamplerParams::kMipMap_FilterMode}) {
+    for (auto filter : {GrSamplerState::Filter::kNearest,
+                        GrSamplerState::Filter::kBilerp,
+                        GrSamplerState::Filter::kMipMap}) {
         rtContext->clear(nullptr, 0xDDCCBBAA, true);
         auto fp = GrSimpleTextureEffect::Make(rectProxy, nullptr, SkMatrix::I(), filter);
         GrPaint paint;
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index a661d50..e10c248 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -145,9 +145,10 @@
     GrNoClip noClip;
     GrPaint paint;
     paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
-    GrSamplerParams mipMapParams(SkShader::kRepeat_TileMode, GrSamplerParams::kMipMap_FilterMode);
-    paint.addColorTextureProcessor(std::move(proxy),
-                                   nullptr, SkMatrix::MakeScale(rtS), mipMapParams);
+    GrSamplerState mipMapSamplerState(GrSamplerState::WrapMode::kRepeat,
+                                      GrSamplerState::Filter::kMipMap);
+    paint.addColorTextureProcessor(std::move(proxy), nullptr, SkMatrix::MakeScale(rtS),
+                                   mipMapSamplerState);
 
     // 1) Draw texture to S32 surface (should generate/use sRGB mips)
     paint.setGammaCorrect(true);