Switch over to using new direct allocation API in our tests (as much as possible at least)

To fully switch over we need the entry point that uploads data but most of the old call
sites can be switched over now.

Change-Id: I362b1dfde7d88bf8d3f8f90155f53d9ac442a329
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214300
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index 3a1aae9..d6d1249 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -34,14 +34,13 @@
     if (!context->priv().caps()->mipMapSupport()) {
         return;
     }
-    GrGpu* gpu = context->priv().getGpu();
 
     for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
         for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
-            // CreateTestingOnlyBackendTexture currently doesn't support uploading data to mip maps
+            // createBackendTexture currently doesn't support uploading data to mip maps
             // so we don't send any. However, we pretend there is data for the checks below which is
             // fine since we are never actually using these textures for any work on the gpu.
-            GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
+            GrBackendTexture backendTex = context->priv().createBackendTexture(
                     kSize, kSize, kRGBA_8888_SkColorType, mipMapped, renderable);
 
             sk_sp<GrTextureProxy> proxy;
@@ -68,7 +67,7 @@
             }
             REPORTER_ASSERT(reporter, proxy);
             if (!proxy) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
                 return;
             }
 
@@ -77,7 +76,7 @@
             GrTexture* texture = proxy->peekTexture();
             REPORTER_ASSERT(reporter, texture);
             if (!texture) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
                 return;
             }
 
@@ -91,7 +90,7 @@
             } else {
                 REPORTER_ASSERT(reporter, GrMipMapped::kNo == texture->texturePriv().mipMapped());
             }
-            gpu->deleteTestingOnlyBackendTexture(backendTex);
+            context->priv().deleteBackendTexture(backendTex);
         }
     }
 }
@@ -103,11 +102,10 @@
     if (!context->priv().caps()->mipMapSupport()) {
         return;
     }
-    GrGpu* gpu = context->priv().getGpu();
 
     for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
         for (auto willUseMips : {false, true}) {
-            GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
+            GrBackendTexture backendTex = context->priv().createBackendTexture(
                     kSize, kSize, kRGBA_8888_SkColorType, mipMapped, GrRenderable::kNo);
 
             sk_sp<SkImage> image = SkImage::MakeFromTexture(context, backendTex,
@@ -119,7 +117,7 @@
             GrTextureProxy* proxy = as_IB(image)->peekProxy();
             REPORTER_ASSERT(reporter, proxy);
             if (!proxy) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
                 return;
             }
 
@@ -128,7 +126,7 @@
             sk_sp<GrTexture> texture = sk_ref_sp(proxy->peekTexture());
             REPORTER_ASSERT(reporter, texture);
             if (!texture) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
                 return;
             }
 
@@ -137,7 +135,7 @@
                     kPremul_SkAlphaType, nullptr);
             REPORTER_ASSERT(reporter, imageGen);
             if (!imageGen) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
                 return;
             }
 
@@ -149,7 +147,7 @@
 
             REPORTER_ASSERT(reporter, genProxy);
             if (!genProxy) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
                 return;
             }
 
@@ -161,14 +159,14 @@
 
             REPORTER_ASSERT(reporter, genProxy->isInstantiated());
             if (!genProxy->isInstantiated()) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
                 return;
             }
 
             GrTexture* genTexture = genProxy->peekTexture();
             REPORTER_ASSERT(reporter, genTexture);
             if (!genTexture) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
                 return;
             }
 
@@ -227,9 +225,10 @@
             // Must make sure the uses of the backend texture have finished (we possibly have a
             // queued up copy) before we delete the backend texture.
             context->flush();
-            gpu->testingOnly_flushGpuAndSync();
 
-            gpu->deleteTestingOnlyBackendTexture(backendTex);
+            context->priv().getGpu()->testingOnly_flushGpuAndSync();
+
+            context->priv().deleteBackendTexture(backendTex);
         }
     }
 }
@@ -243,13 +242,12 @@
     }
 
     auto resourceProvider = context->priv().resourceProvider();
-    GrGpu* gpu = context->priv().getGpu();
 
     for (auto willUseMips : {false, true}) {
         for (auto isWrapped : {false, true}) {
             GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo;
             sk_sp<SkSurface> surface;
-            GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
+            GrBackendTexture backendTex = context->priv().createBackendTexture(
                     kSize, kSize, kRGBA_8888_SkColorType, mipMapped, GrRenderable::kYes);
             if (isWrapped) {
                 surface = SkSurface::MakeFromBackendTexture(context,
@@ -268,7 +266,7 @@
             }
             REPORTER_ASSERT(reporter, surface);
             if (!surface) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
             }
             SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice();
             GrTextureProxy* texProxy = device->accessRenderTargetContext()->asTextureProxy();
@@ -281,7 +279,7 @@
             sk_sp<SkImage> image = surface->makeImageSnapshot();
             REPORTER_ASSERT(reporter, image);
             if (!image) {
-                gpu->deleteTestingOnlyBackendTexture(backendTex);
+                context->priv().deleteBackendTexture(backendTex);
             }
             texProxy = as_IB(image)->peekProxy();
             REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped());
@@ -293,8 +291,8 @@
             // Must flush the context to make sure all the cmds (copies, etc.) from above are sent
             // to the gpu before we delete the backendHandle.
             context->flush();
-            gpu->testingOnly_flushGpuAndSync();
-            gpu->deleteTestingOnlyBackendTexture(backendTex);
+            context->priv().getGpu()->testingOnly_flushGpuAndSync();
+            context->priv().deleteBackendTexture(backendTex);
         }
     }
 }