Add GrPixmap. Like SkPixmap but uses GrColorType.

Will be used to simplify current and forthcoming code that needs
GrImageInfo, void* pixels, size_t rowbytes. The motivation here is
to make GrSurfaceContext::writePixels support mip levels via an array
of GrPixmap. The goal of that is to remove special purpose
updateBackendTexture code. That code path doesn't support the three
GrColorType paradigm used by GrSuraceContext::writePixele: src color
type, dst color type, intermediate color type used for upload.


Bug: skia:8862
Change-Id: I1f09e1ee017c8a2637ac9f630a13a1ed8040d891
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345175
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index 988f567..1324a46 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -491,24 +491,26 @@
                                         GrSurfaceOrigin textureOrigin,
                                         sk_sp<GrRefCntedCallback> finishedCallback) {
     std::unique_ptr<char[]> tempStorage;
-    SkAutoSTArray<15, SkPixmap> tempPixmaps;
+    SkAutoSTArray<15, GrPixmap> tempPixmaps(numLevels);
     if (textureOrigin == kBottomLeft_GrSurfaceOrigin) {
         size_t size = 0;
         for (int i = 0; i < numLevels; ++i) {
             size += srcData[i].info().minRowBytes()*srcData[i].height();
         }
         tempStorage.reset(new char[size]);
-        tempPixmaps.reset(numLevels);
         size = 0;
         for (int i = 0; i < numLevels; ++i) {
             size_t tempRB = srcData[i].info().minRowBytes();
-            tempPixmaps[i].reset(srcData[i].info(), tempStorage.get() + size, tempRB);
+            tempPixmaps[i] = {srcData[i].info(), tempStorage.get() + size, tempRB};
             SkAssertResult(GrConvertPixels(tempPixmaps[i], srcData[i], /*flip*/ true));
             size += tempRB*srcData[i].height();
         }
-        srcData = tempPixmaps.get();
+    } else {
+        for (int i = 0; i < numLevels; ++i) {
+            tempPixmaps[i] = srcData[i];
+        }
     }
-    GrGpu::BackendTextureData data(srcData);
+    GrGpu::BackendTextureData data(tempPixmaps.get());
     return gpu->updateBackendTexture(backendTexture, std::move(finishedCallback), &data);
 }