Make GrSurfaceContext take GrColorInfo rather than its components.

Bug: skia:11019
Change-Id: I0446e3565c892cddaaeb13d9a8379e144c0ea8ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341419
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index a52778e..7c600bd 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -551,9 +551,10 @@
     sigmaX *= scaleX;
     sigmaY *= scaleY;
 
-    auto srcCtx = GrSurfaceContext::Make(context, srcView, srcColorType, srcAlphaType, colorSpace);
+    GrColorInfo colorInfo(srcColorType, srcAlphaType, colorSpace);
+    auto srcCtx = GrSurfaceContext::Make(context, srcView, colorInfo);
     SkASSERT(srcCtx);
-    GrImageInfo rescaledII(srcColorType, srcAlphaType, colorSpace, rescaledSize);
+    GrImageInfo rescaledII(colorInfo, rescaledSize);
     srcCtx = srcCtx->rescale(rescaledII, srcCtx->origin(), srcBounds, SkSurface::RescaleGamma::kSrc,
                              kLow_SkFilterQuality);
     if (!srcCtx) {
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index a310047b..bfa24f7 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -328,8 +328,9 @@
                                              sk_sp<SkColorSpace> colorSpace,
                                              const SkSurfaceProps* surfaceProps,
                                              bool flushTimeOpsTask)
-        : GrSurfaceContext(context, std::move(readView), colorType, kPremul_SkAlphaType,
-                           std::move(colorSpace))
+        : GrSurfaceContext(context,
+                           std::move(readView),
+                           {colorType, kPremul_SkAlphaType, std::move(colorSpace)})
         , fWriteView(std::move(writeView))
         , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
         , fFlushTimeOpsTask(flushTimeOpsTask)
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 2a79b15..b633ff3 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -31,9 +31,7 @@
 
 std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* context,
                                                          GrSurfaceProxyView readView,
-                                                         GrColorType colorType,
-                                                         SkAlphaType alphaType,
-                                                         sk_sp<SkColorSpace> colorSpace) {
+                                                         const GrColorInfo& info) {
     // It is probably not necessary to check if the context is abandoned here since uses of the
     // GrSurfaceContext which need the context will mostly likely fail later on without an issue.
     // However having this hear adds some reassurance in case there is a path doesn't handle an
@@ -46,54 +44,87 @@
 
     std::unique_ptr<GrSurfaceContext> surfaceContext;
     if (proxy->asRenderTargetProxy()) {
-        SkASSERT(kPremul_SkAlphaType == alphaType || kOpaque_SkAlphaType == alphaType);
+        SkASSERT(info.alphaType() == kPremul_SkAlphaType ||
+                 info.alphaType() == kOpaque_SkAlphaType);
         // Will we ever want a swizzle that is not the default write swizzle for the format and
         // colorType here? If so we will need to manually pass that in.
         GrSwizzle writeSwizzle;
-        if (colorType != GrColorType::kUnknown) {
-            writeSwizzle =
-                    context->priv().caps()->getWriteSwizzle(proxy->backendFormat(), colorType);
+        if (info.colorType() != GrColorType::kUnknown) {
+            writeSwizzle = context->priv().caps()->getWriteSwizzle(proxy->backendFormat(),
+                                                                   info.colorType());
         }
         GrSurfaceProxyView writeView(readView.refProxy(), readView.origin(), writeSwizzle);
-        surfaceContext = std::make_unique<GrRenderTargetContext>(context, std::move(readView),
-                                                       std::move(writeView), colorType,
-                                                       std::move(colorSpace), nullptr);
+        surfaceContext = std::make_unique<GrRenderTargetContext>(context,
+                                                                 std::move(readView),
+                                                                 std::move(writeView),
+                                                                 info.colorType(),
+                                                                 info.refColorSpace(),
+                                                                 /*surface props*/ nullptr);
     } else {
-        surfaceContext = std::make_unique<GrSurfaceContext>(context, std::move(readView), colorType,
-                                                  alphaType, std::move(colorSpace));
+        surfaceContext = std::make_unique<GrSurfaceContext>(context, std::move(readView), info);
     }
     SkDEBUGCODE(surfaceContext->validate();)
     return surfaceContext;
 }
 
 std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* context,
-                                                         SkISize dimensions,
+                                                         const GrImageInfo& info,
                                                          const GrBackendFormat& format,
-                                                         GrRenderable renderable,
-                                                         int renderTargetSampleCnt,
-                                                         GrMipmapped mipMapped,
-                                                         GrProtected isProtected,
-                                                         GrSurfaceOrigin origin,
-                                                         GrColorType colorType,
-                                                         SkAlphaType alphaType,
-                                                         sk_sp<SkColorSpace> colorSpace,
                                                          SkBackingFit fit,
+                                                         GrSurfaceOrigin origin,
+                                                         GrRenderable renderable,
+                                                         int sampleCount,
+                                                         GrMipmapped mipmapped,
+                                                         GrProtected isProtected,
                                                          SkBudgeted budgeted) {
-    GrSwizzle swizzle;
-    if (colorType != GrColorType::kUnknown && !context->priv().caps()->isFormatCompressed(format)) {
-        swizzle = context->priv().caps()->getReadSwizzle(format, colorType);
+    SkASSERT(context);
+    SkASSERT(renderable == GrRenderable::kYes || sampleCount == 1);
+    if (context->abandoned()) {
+        return nullptr;
     }
-
-    sk_sp<GrTextureProxy> proxy = context->priv().proxyProvider()->createProxy(
-            format, dimensions, renderable, renderTargetSampleCnt, mipMapped, fit, budgeted,
-            isProtected);
+    sk_sp<GrTextureProxy> proxy = context->priv().proxyProvider()->createProxy(format,
+                                                                               info.dimensions(),
+                                                                               renderable,
+                                                                               sampleCount,
+                                                                               mipmapped,
+                                                                               fit,
+                                                                               budgeted,
+                                                                               isProtected);
     if (!proxy) {
         return nullptr;
     }
 
+    GrSwizzle swizzle;
+    if (info.colorType() != GrColorType::kUnknown &&
+        !context->priv().caps()->isFormatCompressed(format)) {
+        swizzle = context->priv().caps()->getReadSwizzle(format, info.colorType());
+    }
+
     GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-    return GrSurfaceContext::Make(context, std::move(view), colorType, alphaType,
-                                  std::move(colorSpace));
+    return GrSurfaceContext::Make(context, std::move(view), info.colorInfo());
+}
+
+std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* context,
+                                                         const GrImageInfo& info,
+                                                         SkBackingFit fit,
+                                                         GrSurfaceOrigin origin,
+                                                         GrRenderable renderable,
+                                                         int sampleCount,
+                                                         GrMipmapped mipmapped,
+                                                         GrProtected isProtected,
+                                                         SkBudgeted budgeted) {
+    GrBackendFormat format = context->priv().caps()->getDefaultBackendFormat(info.colorType(),
+                                                                             renderable);
+    return Make(context,
+                info,
+                format,
+                fit,
+                origin,
+                renderable,
+                sampleCount,
+                mipmapped,
+                isProtected,
+                budgeted);
 }
 
 // In MDB mode the reffing of the 'getLastOpsTask' call's result allows in-progress
@@ -102,12 +133,8 @@
 // when the renderTargetContext attempts to use it (via getOpsTask).
 GrSurfaceContext::GrSurfaceContext(GrRecordingContext* context,
                                    GrSurfaceProxyView readView,
-                                   GrColorType colorType,
-                                   SkAlphaType alphaType,
-                                   sk_sp<SkColorSpace> colorSpace)
-        : fContext(context)
-        , fReadView(std::move(readView))
-        , fColorInfo(colorType, alphaType, std::move(colorSpace)) {
+                                   const GrColorInfo& info)
+        : fContext(context), fReadView(std::move(readView)), fColorInfo(info) {
     SkASSERT(!context->abandoned());
 }
 
@@ -264,11 +291,7 @@
                 return false;
             }
             GrSurfaceProxyView view{std::move(copy), this->origin(), this->readSwizzle()};
-            tempCtx = GrSurfaceContext::Make(dContext,
-                                             std::move(view),
-                                             this->colorInfo().colorType(),
-                                             this->colorInfo().alphaType(),
-                                             this->colorInfo().refColorSpace());
+            tempCtx = GrSurfaceContext::Make(dContext, std::move(view), this->colorInfo());
             SkASSERT(tempCtx);
         }
         return tempCtx->readPixels(dContext, dstInfo, dst, rowBytes, pt);
@@ -387,22 +410,20 @@
                             dContext->priv().validPMUPMConversionExists();
 
     if (!caps->surfaceSupportsWritePixels(dstSurface) || canvas2DFastPath) {
-        GrColorType colorType;
-
+        GrColorInfo tempColorInfo;
         GrBackendFormat format;
-        SkAlphaType alphaType;
         GrSwizzle tempReadSwizzle;
         if (canvas2DFastPath) {
-            colorType = GrColorType::kRGBA_8888;
+            tempColorInfo = {GrColorType::kRGBA_8888,
+                             kUnpremul_SkAlphaType,
+                             this->colorInfo().refColorSpace()};
             format = rgbaDefaultFormat;
-            alphaType = kUnpremul_SkAlphaType;
         } else {
-            colorType = this->colorInfo().colorType();
+            tempColorInfo = this->colorInfo();
             format = dstProxy->backendFormat().makeTexture2D();
             if (!format.isValid()) {
                 return false;
             }
-            alphaType = this->colorInfo().alphaType();
             tempReadSwizzle = this->readSwizzle();
         }
 
@@ -420,8 +441,7 @@
             return false;
         }
         GrSurfaceProxyView tempView(tempProxy, tempOrigin, tempReadSwizzle);
-        GrSurfaceContext tempCtx(dContext, tempView, colorType, alphaType,
-                                 this->colorInfo().refColorSpace());
+        GrSurfaceContext tempCtx(dContext, tempView, tempColorInfo);
 
         // In the fast path we always write the srcData to the temp context as though it were RGBA.
         // When the data is really BGRA the write will cause the R and B channels to be swapped in
@@ -438,13 +458,13 @@
             std::unique_ptr<GrFragmentProcessor> fp;
             if (canvas2DFastPath) {
                 fp = dContext->priv().createUPMToPMEffect(
-                        GrTextureEffect::Make(std::move(tempView), alphaType));
+                        GrTextureEffect::Make(std::move(tempView), tempColorInfo.alphaType()));
                 // Important: check the original src color type here!
                 if (origSrcInfo.colorType() == GrColorType::kBGRA_8888) {
                     fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
                 }
             } else {
-                fp = GrTextureEffect::Make(std::move(tempView), alphaType);
+                fp = GrTextureEffect::Make(std::move(tempView), tempColorInfo.alphaType());
             }
             if (!fp) {
                 return false;
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index fc0acbd..7abfbf8 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -41,19 +41,33 @@
     // otherwise it will return a GrSurfaceContext.
     static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*,
                                                   GrSurfaceProxyView readView,
-                                                  GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
+                                                  const GrColorInfo&);
 
-    static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*, SkISize dimensions,
-                                                  const GrBackendFormat&, GrRenderable,
-                                                  int renderTargetSampleCnt, GrMipmapped,
-                                                  GrProtected, GrSurfaceOrigin, GrColorType,
-                                                  SkAlphaType, sk_sp<SkColorSpace>, SkBackingFit,
-                                                  SkBudgeted);
+    // Makes either a GrSurfaceContext or a GrRenderTargetContext, depending on GrRenderable.
+    static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*,
+                                                  const GrImageInfo&,
+                                                  const GrBackendFormat&,
+                                                  SkBackingFit = SkBackingFit::kExact,
+                                                  GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin,
+                                                  GrRenderable = GrRenderable::kNo,
+                                                  int renderTargetSampleCnt = 1,
+                                                  GrMipmapped = GrMipmapped::kNo,
+                                                  GrProtected = GrProtected::kNo,
+                                                  SkBudgeted = SkBudgeted::kYes);
+
+    static std::unique_ptr<GrSurfaceContext> Make(GrRecordingContext*,
+                                                  const GrImageInfo&,
+                                                  SkBackingFit = SkBackingFit::kExact,
+                                                  GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin,
+                                                  GrRenderable = GrRenderable::kNo,
+                                                  int renderTargetSampleCnt = 1,
+                                                  GrMipmapped = GrMipmapped::kNo,
+                                                  GrProtected = GrProtected::kNo,
+                                                  SkBudgeted = SkBudgeted::kYes);
 
     // If it is known that the GrSurfaceProxy is not renderable, you can directly call the the ctor
     // here to make a GrSurfaceContext on the stack.
-    GrSurfaceContext(GrRecordingContext*, GrSurfaceProxyView readView, GrColorType, SkAlphaType,
-                     sk_sp<SkColorSpace>);
+    GrSurfaceContext(GrRecordingContext*, GrSurfaceProxyView readView, const GrColorInfo&);
 
     virtual ~GrSurfaceContext() = default;
 
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 0d5c7a6..78e5ac8 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -275,10 +275,17 @@
     SkASSERT(format.isValid());
 
     if (src->backendFormat().textureType() != GrTextureType::kExternal) {
-        auto dstContext =
-                GrSurfaceContext::Make(context, {width, height}, format, GrRenderable::kNo, 1,
-                                       mipMapped, src->isProtected(), origin, GrColorType::kUnknown,
-                                       kUnknown_SkAlphaType, nullptr, fit, budgeted);
+        GrImageInfo info(GrColorType::kUnknown, kUnknown_SkAlphaType, nullptr, {width, height});
+        auto dstContext = GrSurfaceContext::Make(context,
+                                                 info,
+                                                 format,
+                                                 fit,
+                                                 origin,
+                                                 GrRenderable::kNo,
+                                                 1,
+                                                 mipMapped,
+                                                 src->isProtected(),
+                                                 budgeted);
         if (dstContext && dstContext->copy(src, srcRect, dstPoint)) {
             return dstContext->asSurfaceProxyRef();
         }
diff --git a/src/gpu/GrTextureProducer.h b/src/gpu/GrTextureProducer.h
index 5328e73..1399d05 100644
--- a/src/gpu/GrTextureProducer.h
+++ b/src/gpu/GrTextureProducer.h
@@ -89,6 +89,7 @@
      */
     GrSurfaceProxyView view(GrMipmapped);
 
+    const GrColorInfo& colorInfo() const { return fImageInfo.colorInfo(); }
     int width() const { return fImageInfo.width(); }
     int height() const { return fImageInfo.height(); }
     SkISize dimensions() const { return fImageInfo.dimensions(); }
diff --git a/src/gpu/text/GrAtlasManager.cpp b/src/gpu/text/GrAtlasManager.cpp
index 671f6d2..daea541 100644
--- a/src/gpu/text/GrAtlasManager.cpp
+++ b/src/gpu/text/GrAtlasManager.cpp
@@ -234,8 +234,9 @@
         return false;
     }
 
-    auto sContext = GrSurfaceContext::Make(dContext, std::move(view), colorType,
-                                           kUnknown_SkAlphaType, nullptr);
+    auto sContext = GrSurfaceContext::Make(dContext,
+                                           std::move(view),
+                                           {colorType, kUnknown_SkAlphaType, nullptr});
     if (!sContext || !sContext->asTextureProxy()) {
         return false;
     }
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 3ab14b5..92b47f6 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -135,9 +135,7 @@
         callback(context, nullptr);
         return;
     }
-    GrColorType ct = SkColorTypeToGrColorType(this->colorType());
-    auto ctx = GrSurfaceContext::Make(dContext, fView, ct, this->alphaType(),
-                                      this->refColorSpace());
+    auto ctx = GrSurfaceContext::Make(dContext, fView, this->imageInfo().colorInfo());
     if (!ctx) {
         callback(context, nullptr);
         return;
@@ -160,9 +158,7 @@
         callback(context, nullptr);
         return;
     }
-    GrColorType ct = SkColorTypeToGrColorType(this->colorType());
-    auto ctx = GrSurfaceContext::Make(dContext, fView, ct, this->alphaType(),
-                                      this->refColorSpace());
+    auto ctx = GrSurfaceContext::Make(dContext, fView, this->imageInfo().colorInfo());
     if (!ctx) {
         callback(context, nullptr);
         return;
@@ -609,13 +605,14 @@
         return nullptr;
     }
 
-    sk_sp<SkColorSpace> cs = pixmap.refColorSpace();
-    SkAlphaType at =  pixmap.alphaType();
-
     GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(backendFormat, grColorType);
     GrSurfaceProxyView view(std::move(proxy), surfaceOrigin, swizzle);
-    sk_sp<SkImage> image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(dContext), kNeedNewImageUniqueID, view,
-                                                   colorType, at, cs);
+    sk_sp<SkImage> image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(dContext),
+                                                   kNeedNewImageUniqueID,
+                                                   view,
+                                                   colorType,
+                                                   pixmap.alphaType(),
+                                                   pixmap.refColorSpace());
     if (!image) {
         return nullptr;
     }
@@ -625,13 +622,9 @@
         return nullptr;
     }
 
-    GrSurfaceContext surfaceContext(dContext, std::move(view),
-                                    SkColorTypeToGrColorType(pixmap.colorType()),
-                                    pixmap.alphaType(), cs);
+    GrSurfaceContext surfaceContext(dContext, std::move(view), image->imageInfo().colorInfo());
 
-    SkImageInfo srcInfo = SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType, at,
-                                            std::move(cs));
-    surfaceContext.writePixels(dContext, srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), {0, 0});
+    surfaceContext.writePixels(dContext, pixmap.info(), pixmap.addr(), pixmap.rowBytes(), {0, 0});
 
     GrSurfaceProxy* p[1] = {surfaceContext.asSurfaceProxy()};
     drawingManager->flush(p, SkSurface::BackendSurfaceAccess::kNoAccess, {}, nullptr);
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index b8c6f7b..d5d988b 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -118,8 +118,9 @@
     GrColorType grColorType = SkColorTypeAndFormatToGrColorType(
             fContext->priv().caps(), this->colorType(), view->proxy()->backendFormat());
 
-    auto sContext = GrSurfaceContext::Make(dContext, *view, grColorType, this->alphaType(),
-                                           this->refColorSpace());
+    auto sContext = GrSurfaceContext::Make(dContext,
+                                           *view,
+                                           {grColorType, this->alphaType(), this->refColorSpace()});
     if (!sContext) {
         return false;
     }
@@ -174,8 +175,8 @@
     GrColorType grColorType = SkColorTypeAndFormatToGrColorType(
             dContext->priv().caps(), this->colorType(), view->proxy()->backendFormat());
 
-    auto sContext = GrSurfaceContext::Make(dContext, *view, grColorType, this->alphaType(),
-                                           this->refColorSpace());
+    GrColorInfo colorInfo(grColorType, this->alphaType(), this->refColorSpace());
+    auto sContext = GrSurfaceContext::Make(dContext, *view, colorInfo);
     if (!sContext) {
         return false;
     }
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp
index 7cba4d7..069a083 100644
--- a/tests/CopySurfaceTest.cpp
+++ b/tests/CopySurfaceTest.cpp
@@ -105,11 +105,9 @@
                                     }
                                 }
 
-                                GrColorType grColorType = SkColorTypeToGrColorType(ii.colorType());
                                 auto dstContext = GrSurfaceContext::Make(dContext,
                                                                          std::move(dstView),
-                                                                         grColorType,
-                                                                         ii.alphaType(), nullptr);
+                                                                         ii.colorInfo());
 
                                 bool result = false;
                                 if (sOrigin == dOrigin) {
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index af06b1c..6189974 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -151,8 +151,7 @@
     // Wrap this texture ID in a GrTexture
     GrBackendTexture backendTex(kSize, kSize, GrMipmapped::kNo, externalTexture);
 
-    GrColorType colorType = GrColorType::kRGBA_8888;
-    SkAlphaType alphaType = kPremul_SkAlphaType;
+    GrColorInfo colorInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr);
     // TODO: If I make this TopLeft origin to match resolve_origin calls for kDefault, this test
     // fails on the Nexus5. Why?
     GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin;
@@ -163,11 +162,10 @@
         cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
         return;
     }
-    GrSwizzle swizzle =
-            context0->priv().caps()->getReadSwizzle(texProxy->backendFormat(), colorType);
+    GrSwizzle swizzle = context0->priv().caps()->getReadSwizzle(texProxy->backendFormat(),
+                                                                colorInfo.colorType());
     GrSurfaceProxyView view(std::move(texProxy), origin, swizzle);
-    auto surfaceContext =
-            GrSurfaceContext::Make(context0, std::move(view), colorType, alphaType, nullptr);
+    auto surfaceContext = GrSurfaceContext::Make(context0, std::move(view), colorInfo);
 
     if (!surfaceContext) {
         ERRORF(reporter, "Error wrapping external texture in GrSurfaceContext.");
@@ -186,8 +184,14 @@
 
     // Should not be able to wrap as a RT
     {
-        auto temp = GrRenderTargetContext::MakeFromBackendTexture(
-                context0, colorType, nullptr, backendTex, 1, origin, nullptr, nullptr);
+        auto temp = GrRenderTargetContext::MakeFromBackendTexture(context0,
+                                                                  colorInfo.colorType(),
+                                                                  /*color space*/ nullptr,
+                                                                  backendTex,
+                                                                  1,
+                                                                  origin,
+                                                                  /*surface props*/ nullptr,
+                                                                  /*release helper*/ nullptr);
         if (temp) {
             ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture as a RT.");
         }
@@ -200,8 +204,13 @@
 
     // Only test RT-config
     // TODO: why do we always need to draw to copy from an external texture?
-    TestCopyFromSurface(reporter, context0, surfaceContext->asSurfaceProxy(),
-                        surfaceContext->origin(), colorType, pixels.get(), "EGLImageTest-copy");
+    TestCopyFromSurface(reporter,
+                        context0,
+                        surfaceContext->asSurfaceProxy(),
+                        surfaceContext->origin(),
+                        colorInfo.colorType(),
+                        pixels.get(),
+                        "EGLImageTest-copy");
 
     cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
 }
diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp
index d7e1919..f986327 100644
--- a/tests/FloatingPointTextureTest.cpp
+++ b/tests/FloatingPointTextureTest.cpp
@@ -49,22 +49,18 @@
     }
 
     for (auto origin : {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
+        GrImageInfo info(colorType, kPremul_SkAlphaType, nullptr, {DEV_W, DEV_H});
         auto fpView = sk_gpu_test::MakeTextureProxyViewFromData(
-                dContext, GrRenderable::kYes, origin,
-                {colorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H}, controlPixelData.begin(),
-                0);
+                dContext, GrRenderable::kYes, origin, info, controlPixelData.begin(), 0);
         // Floating point textures are NOT supported everywhere
         if (!fpView) {
             continue;
         }
 
-        auto sContext = GrSurfaceContext::Make(dContext, std::move(fpView), colorType,
-                                               kPremul_SkAlphaType, nullptr);
+        auto sContext = GrSurfaceContext::Make(dContext, std::move(fpView), info.colorInfo());
         REPORTER_ASSERT(reporter, sContext);
 
-        bool result = sContext->readPixels(dContext,
-                                           {colorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H},
-                                           readBuffer.begin(), 0, {0, 0});
+        bool result = sContext->readPixels(dContext, info, readBuffer.begin(), 0, {0, 0});
         REPORTER_ASSERT(reporter, result);
         REPORTER_ASSERT(reporter,
                         !memcmp(readBuffer.begin(), controlPixelData.begin(), readBuffer.bytes()));
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index e59f643..7c849f5 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -267,9 +267,8 @@
                                                                      combo.fColorType);
                             GrSurfaceProxyView view(std::move(proxy), kTopLeft_GrSurfaceOrigin,
                                                     swizzle);
-                            auto texCtx = GrSurfaceContext::Make(dContext, std::move(view),
-                                                                 combo.fColorType,
-                                                                 kPremul_SkAlphaType, nullptr);
+                            GrColorInfo info(combo.fColorType, kPremul_SkAlphaType, nullptr);
+                            auto texCtx = GrSurfaceContext::Make(dContext, std::move(view), info);
 
                             readback.erase(kClearColor);
                             if (texCtx->readPixels(
@@ -295,11 +294,11 @@
                                     {desc.fWidth, desc.fHeight}, 1, GrMipmapped::kNo,
                                     GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
                         } else {
-                            surfCtx = GrSurfaceContext::Make(
-                                    dContext, {desc.fWidth, desc.fHeight}, combo.fFormat,
-                                    GrRenderable::kNo, 1, GrMipmapped::kNo, GrProtected::kNo,
-                                    kTopLeft_GrSurfaceOrigin, combo.fColorType,
-                                    kUnknown_SkAlphaType, nullptr, fit, SkBudgeted::kYes);
+                            GrImageInfo info(combo.fColorType,
+                                             kUnknown_SkAlphaType,
+                                             nullptr,
+                                             {desc.fHeight, desc.fHeight});
+                            surfCtx = GrSurfaceContext::Make(dContext, info, combo.fFormat, fit);
                         }
                         if (!surfCtx) {
                             continue;
@@ -371,9 +370,7 @@
         GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
                                                                     GrColorType::kRGBA_8888);
         GrSurfaceProxyView view(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
-        auto surfContext = GrSurfaceContext::Make(dContext, std::move(view), GrColorType::kRGBA_8888,
-                                                  kPremul_SkAlphaType, nullptr);
-
+        auto surfContext = GrSurfaceContext::Make(dContext, std::move(view), ii.colorInfo());
         // Read pixels should work with a read-only texture.
         {
             SkAutoPixmapStorage read;
diff --git a/tests/GrUploadPixelsTests.cpp b/tests/GrUploadPixelsTests.cpp
index be92f07..40509d9 100644
--- a/tests/GrUploadPixelsTests.cpp
+++ b/tests/GrUploadPixelsTests.cpp
@@ -31,14 +31,16 @@
 
     FillPixelData(kWidth, kHeight, srcBuffer.get());
 
-    auto grCT = SkColorTypeToGrColorType(ct);
-    auto view = sk_gpu_test::MakeTextureProxyViewFromData(
-            dContext, renderable, kTopLeft_GrSurfaceOrigin,
-            {grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0);
+    auto info = SkImageInfo::Make({kWidth, kHeight}, ct, kPremul_SkAlphaType, nullptr);
+    auto view = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
+                                                          renderable,
+                                                          kTopLeft_GrSurfaceOrigin,
+                                                          info,
+                                                          srcBuffer,
+                                                          /*row bytes*/ 0);
     REPORTER_ASSERT(reporter, view);
     if (view) {
-        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), grCT, kPremul_SkAlphaType,
-                                               nullptr);
+        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), info.colorInfo());
 
         SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
 
@@ -59,13 +61,15 @@
         REPORTER_ASSERT(reporter, DoesFullBufferContainCorrectColor(srcBuffer, dstBuffer, 10, 2));
     }
 
-    view = sk_gpu_test::MakeTextureProxyViewFromData(
-            dContext, renderable, kBottomLeft_GrSurfaceOrigin,
-            {grCT, kPremul_SkAlphaType, nullptr, kWidth, kHeight}, srcBuffer, 0);
+    view = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
+                                                     renderable,
+                                                     kBottomLeft_GrSurfaceOrigin,
+                                                     info,
+                                                     srcBuffer,
+                                                     0);
     REPORTER_ASSERT(reporter, view);
     if (view) {
-        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), grCT, kPremul_SkAlphaType,
-                                               nullptr);
+        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), info.colorInfo());
 
         SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
 
diff --git a/tests/PackedConfigsTextureTest.cpp b/tests/PackedConfigsTextureTest.cpp
index 41fcea7..136f6b5 100644
--- a/tests/PackedConfigsTextureTest.cpp
+++ b/tests/PackedConfigsTextureTest.cpp
@@ -114,15 +114,16 @@
             SkImageInfo::Make(DEV_W, DEV_H, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
 
     for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
-        auto grColorType = SkColorTypeToGrColorType(colorType);
-        auto view = sk_gpu_test::MakeTextureProxyViewFromData(
-                dContext, GrRenderable::kNo, origin,
-                {grColorType, kPremul_SkAlphaType, nullptr, DEV_W, DEV_H}, controlPixelData.begin(),
-                0);
+        auto info = SkImageInfo::Make({DEV_W, DEV_H}, colorType, kPremul_SkAlphaType, nullptr);
+        auto view = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
+                                                              GrRenderable::kNo,
+                                                              origin,
+                                                              info,
+                                                              controlPixelData.begin(),
+                                                              0);
         SkASSERT(view);
 
-        GrSurfaceContext sContext(dContext, std::move(view), grColorType, kPremul_SkAlphaType,
-                                  nullptr);
+        GrSurfaceContext sContext(dContext, std::move(view), info.colorInfo());
 
         if (!sContext.readPixels(dContext, dstInfo, readBuffer.begin(), 0, {0, 0})) {
             // We only require this to succeed if the format is renderable.
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 07daa18..473f11c 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -410,8 +410,7 @@
     SkImageInfo ii = SkImageInfo::Make(src.proxy()->dimensions(), kRGBA_8888_SkColorType,
                                        kLogAlphaType);
 
-    auto sContext = GrSurfaceContext::Make(dContext, std::move(src), GrColorType::kRGBA_8888,
-                                           kLogAlphaType, nullptr);
+    auto sContext = GrSurfaceContext::Make(dContext, std::move(src), ii.colorInfo());
     SkBitmap bm;
     SkAssertResult(bm.tryAllocPixels(ii));
     SkAssertResult(sContext->readPixels(dContext, ii, bm.getPixels(), bm.rowBytes(), {0, 0}));
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index d6e6a75..3811722 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -433,11 +433,10 @@
         for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
             auto view = sk_gpu_test::MakeTextureProxyViewFromData(
                     dContext, renderable, origin, bmp.info(), bmp.getPixels(), bmp.rowBytes());
-            GrColorType grColorType = SkColorTypeToGrColorType(bmp.colorType());
-            auto sContext = GrSurfaceContext::Make(dContext, std::move(view),
-                    grColorType, kPremul_SkAlphaType, nullptr);
-            auto info = SkImageInfo::Make(DEV_W, DEV_H, kN32_SkColorType, kPremul_SkAlphaType);
-            test_readpixels_texture(reporter, dContext, std::move(sContext), info);
+            auto sContext = GrSurfaceContext::Make(dContext,
+                                                   std::move(view),
+                                                   bmp.info().colorInfo());
+            test_readpixels_texture(reporter, dContext, std::move(sContext), bmp.info());
         }
     }
 }
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index acb5cfd..9d70631 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -74,8 +74,7 @@
             return;
         }
 
-        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), maker.colorType(),
-                                               kPremul_SkAlphaType, nullptr);
+        auto sContext = GrSurfaceContext::Make(dContext, std::move(view), maker.colorInfo());
 
         sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, ii));
 
@@ -168,9 +167,10 @@
         }
     }
 
-    const SkImageInfo dstInfo = SkImageInfo::Make(X_SIZE, Y_SIZE,
-                                                  kAlpha_8_SkColorType,
-                                                  kPremul_SkAlphaType);
+    const GrImageInfo dstInfo(GrColorType::kAlpha_8,
+                              kPremul_SkAlphaType,
+                              nullptr,
+                              {X_SIZE, Y_SIZE});
 
     // Attempt to read back just alpha from a RGBA/BGRA texture. Once with a texture-only src and
     // once with a render target.
@@ -186,15 +186,18 @@
 
             auto origin = GrRenderable::kYes == renderable ? kBottomLeft_GrSurfaceOrigin
                                                            : kTopLeft_GrSurfaceOrigin;
-            auto view = sk_gpu_test::MakeTextureProxyViewFromData(
-                    dContext, renderable, origin,
-                    {info.fColorType, info.fAlphaType, nullptr, X_SIZE, Y_SIZE}, rgbaData, 0);
+            GrImageInfo ii = dstInfo.makeColorType(info.fColorType).makeAlphaType(info.fAlphaType);
+            auto view = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
+                                                                  renderable,
+                                                                  origin,
+                                                                  ii,
+                                                                  rgbaData,
+                                                                  /*row bytes*/ 0);
             if (!view) {
                 continue;
             }
 
-            auto sContext = GrSurfaceContext::Make(dContext, std::move(view), info.fColorType,
-                                                   kPremul_SkAlphaType, nullptr);
+            auto sContext = GrSurfaceContext::Make(dContext, std::move(view), ii.colorInfo());
 
             for (auto rowBytes : kRowBytes) {
                 size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE;
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 0cf842f..a340ba1 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -134,10 +134,10 @@
 
         auto format = GrBackendFormat::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_RECTANGLE);
         GrBackendTexture rectangleTex = dContext->createBackendTexture(kWidth,
-                                                                      kHeight,
-                                                                      format,
-                                                                      GrMipmapped::kNo,
-                                                                      GrRenderable::kYes);
+                                                                       kHeight,
+                                                                       format,
+                                                                       GrMipmapped::kNo,
+                                                                       GrRenderable::kYes);
         if (!rectangleTex.isValid()) {
             continue;
         }
@@ -169,20 +169,19 @@
         SkASSERT(rectProxy->hasRestrictedSampling());
         SkASSERT(rectProxy->peekTexture()->hasRestrictedSampling());
 
+        GrImageInfo grII = ii;
         GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(rectangleTex.getBackendFormat(),
-                                                                   GrColorType::kRGBA_8888);
+                                                                    grII.colorType());
         GrSurfaceProxyView view(rectProxy, origin, swizzle);
 
-        test_basic_draw_as_src(reporter, dContext, view, GrColorType::kRGBA_8888,
-                               kPremul_SkAlphaType, refPixels);
+        test_basic_draw_as_src(reporter, dContext, view, grII.colorType(), kPremul_SkAlphaType,
+                               refPixels);
 
         // Test copy to both a texture and RT
-        TestCopyFromSurface(reporter, dContext, rectProxy.get(), origin, GrColorType::kRGBA_8888,
+        TestCopyFromSurface(reporter, dContext, rectProxy.get(), origin, grII.colorType(),
                             refPixels, "RectangleTexture-copy-from");
 
-        auto rectContext = GrSurfaceContext::Make(dContext, std::move(view),
-                                                  GrColorType::kRGBA_8888, kPremul_SkAlphaType,
-                                                  nullptr);
+        auto rectContext = GrSurfaceContext::Make(dContext, std::move(view), grII.colorInfo());
         SkASSERT(rectContext);
 
         TestReadPixels(reporter, dContext, rectContext.get(), refPixels, "RectangleTexture-read");
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 07cf7b3..10898d6 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -756,9 +756,9 @@
     auto makeImageSurfaceContext = [dContext](SkSurface* surface) {
         sk_sp<SkImage> i(surface->makeImageSnapshot());
         SkImage_Gpu* gpuImage = (SkImage_Gpu*)as_IB(i);
-        return GrSurfaceContext::Make(dContext, *gpuImage->view(dContext),
-                                      SkColorTypeToGrColorType(i->colorType()), kPremul_SkAlphaType,
-                                      gpuImage->refColorSpace());
+        return GrSurfaceContext::Make(dContext,
+                                      *gpuImage->view(dContext),
+                                      i->imageInfo().colorInfo());
     };
 
     // Test that non-wrapped RTs are created clear.
diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp
index 497d39f..5bfbdc9 100644
--- a/tests/TestUtils.cpp
+++ b/tests/TestUtils.cpp
@@ -89,8 +89,9 @@
     SkASSERT(copy && copy->asTextureProxy());
     auto swizzle = dContext->priv().caps()->getReadSwizzle(copy->backendFormat(), colorType);
     GrSurfaceProxyView view(std::move(copy), origin, swizzle);
-    auto dstContext = GrSurfaceContext::Make(dContext, std::move(view), colorType,
-                                             kPremul_SkAlphaType, nullptr);
+    auto dstContext = GrSurfaceContext::Make(dContext,
+                                             std::move(view),
+                                             {colorType, kPremul_SkAlphaType, nullptr});
     SkASSERT(dstContext);
 
     TestReadPixels(reporter, dContext, dstContext.get(), expectedPixelValues, testName);
diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp
index 182aa24..9a21cb8 100644
--- a/tools/gpu/ProxyUtils.cpp
+++ b/tools/gpu/ProxyUtils.cpp
@@ -48,8 +48,7 @@
         return {};
     }
     GrSurfaceProxyView view(proxy, origin, swizzle);
-    auto sContext = GrSurfaceContext::Make(dContext, std::move(view), imageInfo.colorType(),
-                                           imageInfo.alphaType(), imageInfo.refColorSpace());
+    auto sContext = GrSurfaceContext::Make(dContext, std::move(view), imageInfo.colorInfo());
     if (!sContext) {
         return {};
     }