Correctly downgrade per-entry filter/mm local variables

If skia-renderer submitted a non-AA pixel-aligned rect with local coords
and identical texture domain, but with filter = bilerp, the batch
ctor would correctly identify that the netFilter could be dropped to NN,
but never updated the filter local var. Later, this value is used to
decide if the domain/subset is necessary and since it erroneously thinks
it's still bilerp, the subset is preserved.

By changing filter to match the downgraded filter quality, these quads
will automatically become non-AA, non-clamped texture draws, meaning
that the varying texture coords are passed directly to sample(), so they
remain in high precision on devices like the Mali 400.

Bug: chromium:1125298
Change-Id: I79f3d33246b6f897449c2a09015e1eb7a3e968b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439778
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index f027a0d..7e748ed 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -570,11 +570,19 @@
                 SkASSERT(mm == netMM ||
                          (netMM == GrSamplerState::MipmapMode::kNone && mm > netMM));
                 auto [mustFilter, mustMM] = filter_and_mm_have_effect(quad.fLocal, quad.fDevice);
-                if (mustFilter && filter != GrSamplerState::Filter::kNearest) {
-                    netFilter = filter;
+                if (filter != GrSamplerState::Filter::kNearest) {
+                    if (mustFilter) {
+                        netFilter = filter; // upgrade batch to higher filter level
+                    } else {
+                        filter = GrSamplerState::Filter::kNearest; // downgrade entry to lower level
+                    }
                 }
-                if (mustMM && mm != GrSamplerState::MipmapMode::kNone) {
-                    netMM = mm;
+                if (mm != GrSamplerState::MipmapMode::kNone) {
+                    if (mustMM) {
+                        netMM = mm; // promote batch
+                    } else {
+                        mm = GrSamplerState::MipmapMode::kNone; // downgrade entry
+                    }
                 }
             }
 
@@ -611,8 +619,7 @@
             normalize_src_quad(proxyParams, &quad.fLocal);
 
             // This subset may represent a no-op, otherwise it will have the origin and dimensions
-            // of the texture applied to it. Insetting for bilinear filtering is deferred until
-            // on[Pre]Prepare so that the overall filter can be lazily determined.
+            // of the texture applied to it.
             SkRect subset = normalize_and_inset_subset(filter, proxyParams, subsetForQuad);
 
             // Always append a quad (or 2 if perspective clipped), it just may refer back to a prior