Clean up/remove unused GrFragmentProcessor-derived ctors

This is the simple (i.e., non-TextureAdjuster) portion of: https://skia-review.googlesource.com/c/8823/ (Remove GrFragmentProcessor-derived class' GrTexture-based ctors)

Change-Id: I8f673ebe922e03c69473c18c166bcf818507c662
Reviewed-on: https://skia-review.googlesource.com/8997
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index feb6691..6661b48 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -6,6 +6,8 @@
  */
 
 #include "GrDrawOpAtlas.h"
+
+#include "GrContext.h"
 #include "GrOpFlushState.h"
 #include "GrRectanizer.h"
 #include "GrTracing.h"
@@ -119,18 +121,21 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-GrDrawOpAtlas::GrDrawOpAtlas(sk_sp<GrTexture> texture, int numPlotsX, int numPlotsY)
-        : fTexture(std::move(texture)), fAtlasGeneration(kInvalidAtlasGeneration + 1) {
-    fPlotWidth = fTexture->width() / numPlotsX;
-    fPlotHeight = fTexture->height() / numPlotsY;
+GrDrawOpAtlas::GrDrawOpAtlas(GrContext* context, sk_sp<GrTextureProxy> proxy,
+                             int numPlotsX, int numPlotsY)
+        : fContext(context)
+        , fProxy(std::move(proxy))
+        , fAtlasGeneration(kInvalidAtlasGeneration + 1) {
+    fPlotWidth = fProxy->width() / numPlotsX;
+    fPlotHeight = fProxy->height() / numPlotsY;
     SkASSERT(numPlotsX * numPlotsY <= BulkUseTokenUpdater::kMaxPlots);
-    SkASSERT(fPlotWidth * numPlotsX == fTexture->width());
-    SkASSERT(fPlotHeight * numPlotsY == fTexture->height());
+    SkASSERT(fPlotWidth * numPlotsX == fProxy->width());
+    SkASSERT(fPlotHeight * numPlotsY == fProxy->height());
 
     SkDEBUGCODE(fNumPlots = numPlotsX * numPlotsY;)
 
     // We currently do not support compressed atlases...
-    SkASSERT(!GrPixelConfigIsCompressed(fTexture->desc().fConfig));
+    SkASSERT(!GrPixelConfigIsCompressed(fProxy->desc().fConfig));
 
     // set up allocated plots
     fPlotArray.reset(new sk_sp<Plot>[ numPlotsX * numPlotsY ]);
@@ -140,7 +145,7 @@
         for (int x = numPlotsX - 1, c = 0; x >= 0; --x, ++c) {
             uint32_t index = r * numPlotsX + c;
             currPlot->reset(
-                    new Plot(index, 1, x, y, fPlotWidth, fPlotHeight, fTexture->desc().fConfig));
+                    new Plot(index, 1, x, y, fPlotWidth, fPlotHeight, fProxy->desc().fConfig));
 
             // build LRU list
             fPlotList.addToHead(currPlot->get());
@@ -164,13 +169,17 @@
     if (target->hasDrawBeenFlushed(plot->lastUploadToken())) {
         // With c+14 we could move sk_sp into lamba to only ref once.
         sk_sp<Plot> plotsp(SkRef(plot));
-        GrTexture* texture = fTexture.get();
-        GrDrawOpUploadToken lastUploadToken = target->addAsapUpload(
-            [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) {
-               plotsp->uploadToTexture(writePixels, texture);
-            }
-        );
-        plot->setLastUploadToken(lastUploadToken);
+        // MDB TODO: this is currently fine since the atlas' proxy is always pre-instantiated.
+        // Once it is deferred more care must be taken upon instantiation failure.
+        GrTexture* texture = fProxy->instantiate(fContext->textureProvider());
+        if (texture) {
+            GrDrawOpUploadToken lastUploadToken = target->addAsapUpload(
+                [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) {
+                   plotsp->uploadToTexture(writePixels, texture);
+                }
+            );
+            plot->setLastUploadToken(lastUploadToken);
+        }
     }
     *id = plot->id();
 }
@@ -178,7 +187,7 @@
 bool GrDrawOpAtlas::addToAtlas(AtlasID* id, GrDrawOp::Target* target, int width, int height,
                                const void* image, SkIPoint16* loc) {
     // We should already have a texture, TODO clean this up
-    SkASSERT(fTexture);
+    SkASSERT(fProxy);
     if (width > fPlotWidth || height > fPlotHeight) {
         return false;
     }
@@ -188,7 +197,7 @@
     plotIter.init(fPlotList, PlotList::Iter::kHead_IterStart);
     Plot* plot;
     while ((plot = plotIter.get())) {
-        SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == plot->bpp());
+        SkASSERT(GrBytesPerPixel(fProxy->desc().fConfig) == plot->bpp());
         if (plot->addSubImage(width, height, image, loc)) {
             this->updatePlot(target, id, plot);
             return true;
@@ -203,7 +212,7 @@
     if (target->hasDrawBeenFlushed(plot->lastUseToken())) {
         this->processEviction(plot->id());
         plot->resetRects();
-        SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == plot->bpp());
+        SkASSERT(GrBytesPerPixel(fProxy->desc().fConfig) == plot->bpp());
         SkDEBUGCODE(bool verify = )plot->addSubImage(width, height, image, loc);
         SkASSERT(verify);
         this->updatePlot(target, id, plot);
@@ -226,7 +235,7 @@
     newPlot.reset(plot->clone());
 
     fPlotList.addToHead(newPlot.get());
-    SkASSERT(GrBytesPerPixel(fTexture->desc().fConfig) == newPlot->bpp());
+    SkASSERT(GrBytesPerPixel(fProxy->desc().fConfig) == newPlot->bpp());
     SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, loc);
     SkASSERT(verify);
 
@@ -234,13 +243,17 @@
     // one it displaced most likely was uploaded asap.
     // With c+14 we could move sk_sp into lambda to only ref once.
     sk_sp<Plot> plotsp(SkRef(newPlot.get()));
-    GrTexture* texture = fTexture.get();
-    GrDrawOpUploadToken lastUploadToken = target->addInlineUpload(
-        [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) {
-            plotsp->uploadToTexture(writePixels, texture);
-        }
-    );
-    newPlot->setLastUploadToken(lastUploadToken);
+    // MDB TODO: this is currently fine since the atlas' proxy is always pre-instantiated.
+    // Once it is deferred more care must be taken upon instantiation failure.
+    GrTexture* texture = fProxy->instantiate(fContext->textureProvider());
+    if (texture) {
+        GrDrawOpUploadToken lastUploadToken = target->addInlineUpload(
+            [plotsp, texture] (GrDrawOp::WritePixelsFn& writePixels) {
+                plotsp->uploadToTexture(writePixels, texture);
+            }
+        );
+        newPlot->setLastUploadToken(lastUploadToken);
+    }
 
     *id = newPlot->id();