remove prepForSampling from GrSurfaceContext::writePixels.

We believe with advent of  GrBackendSurfaceMutableState that this is
only needed for inline atlas uploads. Those call GrGpu directly.

Bug: 1191058
Change-Id: Iad851ebc9f5b7df21d16064a84caa9575da98634
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393082
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index cbd9d3b..69f60c5 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -527,7 +527,7 @@
     for (int i = 0; i < numLevels; ++i) {
         tmpSrc[i] = src[i];
     }
-    if (!surfaceContext.writePixels(context, tmpSrc.get(), numLevels, /*prep for sampling*/ true)) {
+    if (!surfaceContext.writePixels(context, tmpSrc.get(), numLevels)) {
         return false;
     }
 
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 8aec8f3..6d822cd 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -820,8 +820,7 @@
                                           GrColorType srcColorType,
                                           GrColorType dstColorType,
                                           const GrMipLevel levels[],
-                                          int levelCount,
-                                          bool prepForSampling) {
+                                          int levelCount) {
     SkDEBUGCODE(this->validate());
     SkASSERT(fContext);
 
@@ -843,8 +842,7 @@
                                                                   srcColorType,
                                                                   dstColorType,
                                                                   levels,
-                                                                  levelCount,
-                                                                  prepForSampling));
+                                                                  levelCount));
     if (!task) {
         return false;
     }
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 1d91b24..a289422 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -94,8 +94,7 @@
                             GrColorType srcColorType,
                             GrColorType dstColorType,
                             const GrMipLevel[],
-                            int levelCount,
-                            bool prepForSampling);
+                            int levelCount);
 
     GrRecordingContext* getContext() { return fContext; }
 
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index f98b377..bea7206 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -357,8 +357,7 @@
 
 bool GrSurfaceContext::writePixels(GrDirectContext* dContext,
                                    GrCPixmap src,
-                                   SkIPoint dstPt,
-                                   bool prepForSampling) {
+                                   SkIPoint dstPt) {
     ASSERT_SINGLE_OWNER
     RETURN_FALSE_IF_ABANDONED
     SkDEBUGCODE(this->validate();)
@@ -370,13 +369,12 @@
     if (!src.info().bpp() || src.rowBytes() % src.info().bpp()) {
         return false;
     }
-    return this->internalWritePixels(dContext, &src, 1, dstPt, prepForSampling);
+    return this->internalWritePixels(dContext, &src, 1, dstPt);
 }
 
 bool GrSurfaceContext::writePixels(GrDirectContext* dContext,
                                    const GrCPixmap src[],
-                                   int numLevels,
-                                   bool prepForSampling) {
+                                   int numLevels) {
     ASSERT_SINGLE_OWNER
     RETURN_FALSE_IF_ABANDONED
     SkDEBUGCODE(this->validate();)
@@ -389,7 +387,7 @@
         if (src->dimensions() != this->dimensions()) {
             return false;
         }
-        return this->writePixels(dContext, src[0], {0, 0}, prepForSampling);
+        return this->writePixels(dContext, src[0], {0, 0});
     }
     if (!this->asTextureProxy() || this->asTextureProxy()->proxyMipmapped() == GrMipmapped::kNo) {
         return false;
@@ -411,14 +409,13 @@
         }
         dims = {std::max(1, dims.width()/2), std::max(1, dims.height()/2)};
     }
-    return this->internalWritePixels(dContext, src, numLevels, {0, 0}, prepForSampling);
+    return this->internalWritePixels(dContext, src, numLevels, {0, 0});
 }
 
 bool GrSurfaceContext::internalWritePixels(GrDirectContext* dContext,
                                            const GrCPixmap src[],
                                            int numLevels,
-                                           SkIPoint pt,
-                                           bool prepForSampling) {
+                                           SkIPoint pt) {
     GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrSurfaceContext::internalWritePixels");
 
     SkASSERT(numLevels >= 1);
@@ -484,9 +481,7 @@
                             dContext->priv().validPMUPMConversionExists();
     // Drawing code path doesn't support writing to levels and doesn't support inserting layout
     // transitions.
-    if ((!caps->surfaceSupportsWritePixels(dstSurface) || canvas2DFastPath) &&
-        numLevels == 1 &&
-        !prepForSampling) {
+    if ((!caps->surfaceSupportsWritePixels(dstSurface) || canvas2DFastPath) && numLevels == 1) {
         GrColorInfo tempColorInfo;
         GrBackendFormat format;
         GrSwizzle tempReadSwizzle;
@@ -620,8 +615,7 @@
                 allowedColorType,
                 this->colorInfo().colorType(),
                 srcLevels.begin(),
-                numLevels,
-                prepForSampling)) {
+                numLevels)) {
         return false;
     }
     if (numLevels > 1) {
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index deb2242..a9b6574 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -132,14 +132,10 @@
      * @param dContext         The direct context to use
      * @param src              source for the write
      * @param dstPt            offset w/in the surface context at which to write
-     * @param prepForSampling  Should the surface be configured for sampling after the write
-     *                         completes. Used to avoid a separate submission to change texture
-     *                         layout
      */
     bool writePixels(GrDirectContext* dContext,
                      GrCPixmap src,
-                     SkIPoint dstPt,
-                     bool prepForSampling = false);
+                     SkIPoint dstPt);
 
     /**
      * Fully populates either the base level or all MIP levels of the GrSurface with pixel data.
@@ -147,14 +143,10 @@
      * @param src              Array of pixmaps
      * @param numLevels        Number of pixmaps in src. To succeed this must be 1 or the total
      *                         number of MIP levels.
-     * @param prepForSampling  Should the surface be configured for sampling after the write
-     *                         completes. Used to avoid a separate submission to change texture
-     *                         layout
      */
     bool writePixels(GrDirectContext* dContext,
                      const GrCPixmap src[],
-                     int numLevels,
-                     bool prepForSampling = false);
+                     int numLevels);
 
     GrSurfaceProxy* asSurfaceProxy() { return fReadView.proxy(); }
     const GrSurfaceProxy* asSurfaceProxy() const { return fReadView.proxy(); }
@@ -269,8 +261,7 @@
     bool internalWritePixels(GrDirectContext* dContext,
                              const GrCPixmap src[],
                              int numLevels,
-                             SkIPoint,
-                             bool prepForSampling);
+                             SkIPoint);
 
     class AsyncReadResult;
 
diff --git a/src/gpu/GrWritePixelsRenderTask.cpp b/src/gpu/GrWritePixelsRenderTask.cpp
index 51901a0..e8caeb2 100644
--- a/src/gpu/GrWritePixelsRenderTask.cpp
+++ b/src/gpu/GrWritePixelsRenderTask.cpp
@@ -17,16 +17,14 @@
                                             GrColorType srcColorType,
                                             GrColorType dstColorType,
                                             const GrMipLevel texels[],
-                                            int levelCount,
-                                            bool prepForSampling) {
+                                            int levelCount) {
     return sk_sp<GrRenderTask>(new GrWritePixelsTask(dm,
                                                      std::move(dst),
                                                      rect,
                                                      srcColorType,
                                                      dstColorType,
                                                      texels,
-                                                     levelCount,
-                                                     prepForSampling));
+                                                     levelCount));
 }
 
 GrWritePixelsTask::GrWritePixelsTask(GrDrawingManager* dm,
@@ -35,12 +33,10 @@
                                      GrColorType srcColorType,
                                      GrColorType dstColorType,
                                      const GrMipLevel texels[],
-                                     int levelCount,
-                                     bool prepForSampling)
+                                     int levelCount)
         : fRect(rect)
         , fSrcColorType(srcColorType)
-        , fDstColorType(dstColorType)
-        , fPrepForSampling(prepForSampling) {
+        , fDstColorType(dstColorType) {
     this->addTarget(dm, std::move(dst));
     fLevels.reset(levelCount);
     std::copy_n(texels, levelCount, fLevels.get());
@@ -72,6 +68,5 @@
                                           fDstColorType,
                                           fSrcColorType,
                                           fLevels.get(),
-                                          fLevels.count(),
-                                          fPrepForSampling);
+                                          fLevels.count());
 }
diff --git a/src/gpu/GrWritePixelsRenderTask.h b/src/gpu/GrWritePixelsRenderTask.h
index 3fac21b..79a4c7e 100644
--- a/src/gpu/GrWritePixelsRenderTask.h
+++ b/src/gpu/GrWritePixelsRenderTask.h
@@ -18,8 +18,7 @@
                                     GrColorType srcColorType,
                                     GrColorType dstColorType,
                                     const GrMipLevel[],
-                                    int levelCount,
-                                    bool prepForSampling);
+                                    int levelCount);
 
 private:
     GrWritePixelsTask(GrDrawingManager*,
@@ -28,8 +27,7 @@
                       GrColorType srcColorType,
                       GrColorType dstColorType,
                       const GrMipLevel[],
-                      int levelCount,
-                      bool prepForSampling);
+                      int levelCount);
 
     bool onIsUsed(GrSurfaceProxy* proxy) const override { return false; }
     void gatherProxyIntervals(GrResourceAllocator*) const override;
@@ -47,7 +45,6 @@
     SkIRect fRect;
     GrColorType fSrcColorType;
     GrColorType fDstColorType;
-    bool fPrepForSampling;
 };
 
 #endif
diff --git a/tests/BackendAllocationTest.cpp b/tests/BackendAllocationTest.cpp
index c2b60fb..e504f9d 100644
--- a/tests/BackendAllocationTest.cpp
+++ b/tests/BackendAllocationTest.cpp
@@ -555,25 +555,10 @@
     kReadOnlyOptimal,
 };
 
-void check_vk_layout(const GrBackendTexture& backendTex, VkLayout layout) {
+void check_vk_tiling(const GrBackendTexture& backendTex) {
 #if defined(SK_VULKAN) && defined(SK_DEBUG)
-    VkImageLayout expected;
-
-    switch (layout) {
-        case VkLayout::kUndefined:
-            expected = VK_IMAGE_LAYOUT_UNDEFINED;
-            break;
-        case VkLayout::kReadOnlyOptimal:
-            expected = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
-            break;
-        default:
-            SkUNREACHABLE;
-    }
-
     GrVkImageInfo vkII;
-
     if (backendTex.getVkImageInfo(&vkII)) {
-        SkASSERT(expected == vkII.fImageLayout);
         SkASSERT(VK_IMAGE_TILING_OPTIMAL == vkII.fImageTiling);
     }
 #endif
@@ -657,7 +642,7 @@
                                                                            mipmapped,
                                                                            renderable,
                                                                            GrProtected::kNo);
-                        check_vk_layout(mbet->texture(), VkLayout::kUndefined);
+                        check_vk_tiling(mbet->texture());
 #ifdef SK_DEBUG
                         {
                             GrBackendFormat format = dContext->defaultBackendFormat(colorType,
@@ -685,7 +670,7 @@
                                                                         mipmapped,
                                                                         renderable,
                                                                         GrProtected::kNo);
-                        check_vk_layout(mbet->texture(), VkLayout::kReadOnlyOptimal);
+                        check_vk_tiling(mbet->texture());
 
 #ifdef SK_DEBUG
                         {
@@ -715,7 +700,7 @@
                                                                         origin,
                                                                         renderable,
                                                                         GrProtected::kNo);
-                        check_vk_layout(mbet->texture(), VkLayout::kReadOnlyOptimal);
+                        check_vk_tiling(mbet->texture());
 #ifdef SK_DEBUG
                         {
                             auto format = dContext->defaultBackendFormat(srcData[0].colorType(),
@@ -1004,7 +989,7 @@
                                                                            mipMapped,
                                                                            renderable,
                                                                            GrProtected::kNo);
-                        check_vk_layout(mbet->texture(), VkLayout::kUndefined);
+                        check_vk_tiling(mbet->texture());
                         return mbet;
                     };
 
@@ -1057,7 +1042,7 @@
                                                                         mipMapped,
                                                                         renderable,
                                                                         GrProtected::kNo);
-                        check_vk_layout(mbet->texture(), VkLayout::kReadOnlyOptimal);
+                        check_vk_tiling(mbet->texture());
                         return mbet;
                     };
                     test_color_init(context, reporter, createWithColorMtd, combo.fColorType,