Continue making Ganesh use absolute texture coordinates - take 2

The idea here is that the GrCoordTransform will actually hold a GrTextureProxy (rather than a GrTexture) and then, in GrGLSLPrimitiveProcessor::GetTransformMatrix, use the instantiated width & height (when uploading the transform matrix)

Relanding of: https://skia-review.googlesource.com/c/6977/


Change-Id: Ibc9b9e354f7fc23b1a6e6e4fe7c9fe3cef771c02
Reviewed-on: https://skia-review.googlesource.com/7265
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index 37272be..e68703a 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -12,7 +12,8 @@
 
 GrTexture* GrTextureMaker::refTextureForParams(const GrSamplerParams& params,
                                                SkColorSpace* dstColorSpace,
-                                               sk_sp<SkColorSpace>* texColorSpace) {
+                                               sk_sp<SkColorSpace>* texColorSpace,
+                                               SkScalar scaleAdjust[2]) {
     CopyParams copyParams;
     bool willBeMipped = params.filterMode() == GrSamplerParams::kMipMap_FilterMode;
 
@@ -25,7 +26,7 @@
     }
 
     if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->height(), params,
-                                                      &copyParams)) {
+                                                      &copyParams, scaleAdjust)) {
         return this->refOriginalTexture(willBeMipped, dstColorSpace);
     }
     GrUniqueKey copyKey;
@@ -77,22 +78,24 @@
         params.reset(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode);
     }
     sk_sp<SkColorSpace> texColorSpace;
-    sk_sp<GrTexture> texture(this->refTextureForParams(params, dstColorSpace, &texColorSpace));
+    SkScalar scaleAdjust[2] = { 1.0f, 1.0f };
+    sk_sp<GrTexture> texture(this->refTextureForParams(params, dstColorSpace, &texColorSpace,
+                                                       scaleAdjust));
     if (!texture) {
         return nullptr;
     }
+    SkMatrix adjustedMatrix = textureMatrix;
+    adjustedMatrix.postScale(scaleAdjust[0], scaleAdjust[1]);
     SkRect domain;
     DomainMode domainMode =
         DetermineDomainMode(constraintRect, filterConstraint, coordsLimitedToConstraintRect,
                             texture->width(), texture->height(),
                             nullptr, fmForDetermineDomain, &domain);
     SkASSERT(kTightCopy_DomainMode != domainMode);
-    SkMatrix normalizedTextureMatrix = textureMatrix;
-    normalizedTextureMatrix.postIDiv(texture->width(), texture->height());
     sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(texColorSpace.get(),
                                                                        dstColorSpace);
     return CreateFragmentProcessorForDomainAndFilter(texture.get(), std::move(colorSpaceXform),
-                                                     normalizedTextureMatrix, domainMode, domain,
+                                                     adjustedMatrix, domainMode, domain,
                                                      filterOrNullForBicubic);
 }