Support domain clamping and transform matrices in YUVToRGB effects

This helps avoid flattening of YUV/A images when drawn with a strict src
rect constraint. SkiaRenderer almost always provides a strict constraint
for their YUV videos.

This adds a GM that replicates the issue in skbug:8959, and adds a GM to
the wacky_yuv set that checks domain clamping across all of the different
formats.

Bug: 8959
Change-Id: I53f531a94f3b63f81d8c3cbe22d868e3356aeabd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207020
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp
index 5e5327f..0ce1f7b 100644
--- a/src/gpu/GrImageTextureMaker.cpp
+++ b/src/gpu/GrImageTextureMaker.cpp
@@ -92,13 +92,7 @@
     const GrSamplerState::Filter* filterOrNullForBicubic) {
 
     // Check simple cases to see if we need to fall back to flattening the image
-    // TODO: See if we can relax this -- for example, if filterConstraint
-    //       is kYes_FilterConstraint we still may not need a TextureDomain
-    //       in some cases. Or allow YUVtoRGBEffect to take a wrap mode to
-    //       handle ClampToBorder when a decal is needed.
-    if (!textureMatrix.isIdentity() || kNo_FilterConstraint != filterConstraint ||
-        !coordsLimitedToConstraintRect || !filterOrNullForBicubic ||
-        this->domainNeedsDecal()) {
+    if (!filterOrNullForBicubic || this->domainNeedsDecal()) {
         return this->INHERITED::createFragmentProcessor(textureMatrix, constraintRect,
                                                         filterConstraint,
                                                         coordsLimitedToConstraintRect,
@@ -106,15 +100,24 @@
     }
 
     // Check to see if the client has given us pre-mipped textures or we can generate them
-    // If not, fall back to bilerp
+    // If not, fall back to bilerp. Also fall back to bilerp when a domain is requested
     GrSamplerState::Filter filter = *filterOrNullForBicubic;
     if (GrSamplerState::Filter::kMipMap == filter &&
-        !fImage->setupMipmapsForPlanes(this->context())) {
+        (filterConstraint == GrTextureProducer::kYes_FilterConstraint ||
+         !fImage->setupMipmapsForPlanes(this->context()))) {
         filter = GrSamplerState::Filter::kBilerp;
     }
 
+    // Cannot rely on GrTextureProducer's domain infrastructure since we need to calculate domain's
+    // per plane, which may be different, so respect the filterConstraint without any additional
+    // analysis.
+    const SkRect* domain = nullptr;
+    if (filterConstraint == GrTextureProducer::kYes_FilterConstraint) {
+        domain = &constraintRect;
+    }
+
     auto fp = GrYUVtoRGBEffect::Make(fImage->fProxies, fImage->fYUVAIndices,
-                                     fImage->fYUVColorSpace, filter);
+                                     fImage->fYUVColorSpace, filter, textureMatrix, domain);
     if (fImage->fFromColorSpace) {
         fp = GrColorSpaceXformEffect::Make(std::move(fp), fImage->fFromColorSpace.get(),
                                            fImage->alphaType(), fImage->colorSpace());