Make blur utils take GrTextureProxies - take 2

This is a re-land of https://skia-review.googlesource.com/c/7738/ (Make blur utils take GrTextureProxies) with a fix for the Nexus7

Change-Id: I5821a26b1e986daa11d960ae826a1207512cd2a0
Reviewed-on: https://skia-review.googlesource.com/7746
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index c5f554f..66aba13 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -115,12 +115,17 @@
     }
     pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
     if (conv.useBounds()) {
-        const float* bounds = conv.bounds();
-        if (Gr1DKernelEffect::kY_Direction == conv.direction() &&
-            texture.origin() != kTopLeft_GrSurfaceOrigin) {
-            pdman.set2f(fBoundsUni, 1.0f - bounds[1], 1.0f - bounds[0]);
+        const int* bounds = conv.bounds();
+        if (Gr1DKernelEffect::kX_Direction == conv.direction()) {
+            SkScalar inv = SkScalarInvert(SkIntToScalar(texture.width()));
+            pdman.set2f(fBoundsUni, inv * bounds[0], inv * bounds[1]);
         } else {
-            pdman.set2f(fBoundsUni, bounds[0], bounds[1]);
+            SkScalar inv = SkScalarInvert(SkIntToScalar(texture.height()));
+            if (texture.origin() != kTopLeft_GrSurfaceOrigin) {
+                pdman.set2f(fBoundsUni, 1.0f - (inv * bounds[1]), 1.0f - (inv * bounds[0]));
+            } else {
+                pdman.set2f(fBoundsUni, inv * bounds[1], inv * bounds[0]);
+            }
         }
     }
     int width = Gr1DKernelEffect::WidthFromRadius(conv.radius());
@@ -144,8 +149,6 @@
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-
-
 static void fill_in_1D_guassian_kernel(float* kernel, int width, float gaussianSigma, int radius) {
     const float denom = 1.0f / (2.0f * gaussianSigma * gaussianSigma);
 
@@ -169,7 +172,7 @@
                                                                                int radius,
                                                                                float gaussianSigma,
                                                                                bool useBounds,
-                                                                               float bounds[2])
+                                                                               int bounds[2])
         : INHERITED(texture, direction, radius, ModulationFlags(texture->config()))
         , fUseBounds(useBounds) {
     this->initClassID<GrGaussianConvolutionFragmentProcessor>();
@@ -187,7 +190,7 @@
                                                                     int radius,
                                                                     float gaussianSigma,
                                                                     bool useBounds,
-                                                                    float bounds[2])
+                                                                    int bounds[2])
         : INHERITED{context,
                     ModulationFlags(proxy->config()),
                     GR_PROXY_MOVE(proxy),
@@ -230,16 +233,25 @@
         GrProcessorTestData* d) {
     int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
                                         : GrProcessorUnitTest::kAlphaTextureIdx;
-    Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction;
-    int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius);
+    sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx);
 
     bool useBounds = d->fRandom->nextBool();
-    float bounds[2];
-    for (size_t i = 0; i < SK_ARRAY_COUNT(bounds); ++i) {
-        bounds[i] = d->fRandom->nextF();
+    int bounds[2];
+
+    Direction dir;
+    if (d->fRandom->nextBool()) {
+        dir = kX_Direction;
+        bounds[0] = d->fRandom->nextRangeU(0, proxy->width()-1);
+        bounds[1] = d->fRandom->nextRangeU(bounds[0], proxy->width()-1);
+    } else {
+        dir = kY_Direction;
+        bounds[0] = d->fRandom->nextRangeU(0, proxy->height()-1);
+        bounds[1] = d->fRandom->nextRangeU(bounds[0], proxy->height()-1);
     }
 
+    int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius);
     float sigma = radius / 3.f;
+
     return GrGaussianConvolutionFragmentProcessor::Make(
             d->context(), d->textureProxy(texIdx), dir, radius, sigma, useBounds, bounds);
 }