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/tests/ImageNewShaderTest.cpp b/tests/ImageNewShaderTest.cpp
index a92a4be..4091db0 100644
--- a/tests/ImageNewShaderTest.cpp
+++ b/tests/ImageNewShaderTest.cpp
@@ -16,7 +16,7 @@
 #include "GrContext.h"
 #endif
 
-void testBitmapEquality(skiatest::Reporter* reporter, SkBitmap& bm1, SkBitmap& bm2) {
+static void test_bitmap_equality(skiatest::Reporter* reporter, SkBitmap& bm1, SkBitmap& bm2) {
     SkAutoLockPixels lockBm1(bm1);
     SkAutoLockPixels lockBm2(bm2);
 
@@ -24,7 +24,7 @@
     REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getPixels(), bm2.getPixels(), bm1.getSize()));
 }
 
-void paintSource(SkSurface* sourceSurface) {
+static void paint_source(SkSurface* sourceSurface) {
     SkCanvas* sourceCanvas = sourceSurface->getCanvas();
     sourceCanvas->clear(0xFFDEDEDE);
 
@@ -41,8 +41,9 @@
     sourceCanvas->drawRect(rect, paintColor);
 }
 
-void runShaderTest(skiatest::Reporter* reporter, SkSurface* sourceSurface, SkSurface* destinationSurface, SkImageInfo& info) {
-    paintSource(sourceSurface);
+static void run_shader_test(skiatest::Reporter* reporter, SkSurface* sourceSurface,
+                            SkSurface* destinationSurface, SkImageInfo& info) {
+    paint_source(sourceSurface);
 
     sk_sp<SkImage> sourceImage(sourceSurface->makeImageSnapshot());
     sk_sp<SkShader> sourceShader = sourceImage->makeShader(
@@ -65,9 +66,7 @@
     SkBitmap bm;
     destinationCanvas->readPixels(rect, &bm);
 
-    testBitmapEquality(reporter, bmOrig, bm);
-
-
+    test_bitmap_equality(reporter, bmOrig, bm);
 
     // Test with a translated shader
     SkMatrix matrix;
@@ -107,47 +106,47 @@
     auto sourceSurface(SkSurface::MakeRaster(info));
     auto destinationSurface(SkSurface::MakeRaster(info));
 
-    runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
+    run_shader_test(reporter, sourceSurface.get(), destinationSurface.get(), info);
 }
 
 #if SK_SUPPORT_GPU
 
-void gpuToGpu(skiatest::Reporter* reporter, GrContext* context) {
+static void gpu_to_gpu(skiatest::Reporter* reporter, GrContext* context) {
     SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
 
     auto sourceSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
     auto destinationSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
 
-    runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
+    run_shader_test(reporter, sourceSurface.get(), destinationSurface.get(), info);
 }
 
-void gpuToRaster(skiatest::Reporter* reporter, GrContext* context) {
+static void gpu_to_raster(skiatest::Reporter* reporter, GrContext* context) {
     SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
 
     auto sourceSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
     auto destinationSurface(SkSurface::MakeRaster(info));
 
-    runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
+    run_shader_test(reporter, sourceSurface.get(), destinationSurface.get(), info);
 }
 
-void rasterToGpu(skiatest::Reporter* reporter, GrContext* context) {
+static void raster_to_gpu(skiatest::Reporter* reporter, GrContext* context) {
     SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
 
     auto sourceSurface(SkSurface::MakeRaster(info));
     auto destinationSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
 
-    runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
+    run_shader_test(reporter, sourceSurface.get(), destinationSurface.get(), info);
 }
 
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageNewShader_GPU, reporter, ctxInfo) {
     //  GPU -> GPU
-    gpuToGpu(reporter, ctxInfo.grContext());
+    gpu_to_gpu(reporter, ctxInfo.grContext());
 
     //  GPU -> RASTER
-    gpuToRaster(reporter, ctxInfo.grContext());
+    gpu_to_raster(reporter, ctxInfo.grContext());
 
     //  RASTER -> GPU
-    rasterToGpu(reporter, ctxInfo.grContext());
+    raster_to_gpu(reporter, ctxInfo.grContext());
 }
 
 #endif
diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp
index a3e17bf..3edd4cc 100644
--- a/tests/IntTextureTest.cpp
+++ b/tests/IntTextureTest.cpp
@@ -207,9 +207,8 @@
     };
 
     for (auto filter : kNamedFilters) {
-        SkMatrix m;
-        m.setIDiv(kS, kS);
-        sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nullptr, m,
+        sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nullptr,
+                                                                  SkMatrix::I(),
                                                                   filter.fMode));
         REPORTER_ASSERT(reporter, fp);
         if (!fp) {
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index a0c5409..6d075df 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -107,14 +107,12 @@
             context->makeRenderTargetContext(SkBackingFit::kExact, rectangleTexture->width(),
                                              rectangleTexture->height(), rectangleTexture->config(),
                                              nullptr));
-    SkMatrix m;
-    m.setIDiv(rectangleTexture->width(), rectangleTexture->height());
     for (auto filter : {GrSamplerParams::kNone_FilterMode,
                         GrSamplerParams::kBilerp_FilterMode,
                         GrSamplerParams::kMipMap_FilterMode}) {
         rtContext->clear(nullptr, 0xDDCCBBAA, true);
-        sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(rectangleTexture,
-                                                                  nullptr, m, filter));
+        sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(rectangleTexture, nullptr,
+                                                                  SkMatrix::I(), filter));
         GrPaint paint;
         paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
         paint.addColorFragmentProcessor(std::move(fp));
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index 79d8691..22d6890 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -132,7 +132,7 @@
     GrPaint paint;
     paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
     GrSamplerParams mipMapParams(SkShader::kRepeat_TileMode, GrSamplerParams::kMipMap_FilterMode);
-    paint.addColorTextureProcessor(texture.get(), nullptr, SkMatrix::MakeScale(0.5f), mipMapParams);
+    paint.addColorTextureProcessor(texture.get(), nullptr, SkMatrix::MakeScale(rtS), mipMapParams);
 
     // 1) Draw texture to S32 surface (should generate/use sRGB mips)
     paint.setGammaCorrect(true);