Revert of Lots of progress switching to SkColorSpace rather than SkColorProfileType (patchset #10 id:180001 of https://codereview.chromium.org/2069173002/ )

Reason for revert:
Mac crashes in GrUploadPixmapToTexture

Original issue's description:
> Lots of progress on switching to SkColorSpace rather than SkColorProfileType
>
> Fixed a bunch of code in Ganesh, as well as usage of SkColorProfileType in most of our tools (DM, SampleApp, Viewer, nanobench, skiaserve, HelloWorld).
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2069173002
>
> Committed: https://skia.googlesource.com/skia/+/6a61a875467646f8dbc37cfecf49e12d1f475170

TBR=reed@google.com,herb@google.com,msarett@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review-Url: https://codereview.chromium.org/2072813002
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 8cb8e4d..10a7e32 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -742,7 +742,7 @@
 
     if (fPixelRef->getTexture() != nullptr) {
         // Do a deep copy
-        SkPixelRef* pixelRef = fPixelRef->deepCopy(this->colorType(), this->colorSpace(), &subset);
+        SkPixelRef* pixelRef = fPixelRef->deepCopy(this->colorType(), this->profileType(), &subset);
         if (pixelRef != nullptr) {
             SkBitmap dst;
             dst.setInfo(this->info().makeWH(subset.width(), subset.height()));
@@ -911,7 +911,7 @@
 
 bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
     const SkColorType dstCT = this->colorType();
-    SkColorSpace* dstCS = this->colorSpace();
+    const SkColorProfileType dstPT = this->profileType();
 
     if (!this->canCopyTo(dstCT)) {
         return false;
@@ -920,10 +920,10 @@
     // If we have a PixelRef, and it supports deep copy, use it.
     // Currently supported only by texture-backed bitmaps.
     if (fPixelRef) {
-        SkPixelRef* pixelRef = fPixelRef->deepCopy(dstCT, dstCS, nullptr);
+        SkPixelRef* pixelRef = fPixelRef->deepCopy(dstCT, dstPT, nullptr);
         if (pixelRef) {
             uint32_t rowBytes;
-            if (this->colorType() == dstCT && this->colorSpace() == dstCS) {
+            if (this->colorType() == dstCT && this->profileType() == dstPT) {
                 // Since there is no subset to pass to deepCopy, and deepCopy
                 // succeeded, the new pixel ref must be identical.
                 SkASSERT(fPixelRef->info() == pixelRef->info());
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 2759a3e..a894f98 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -213,7 +213,7 @@
 
     SkColorType ct = origInfo.colorType();
     SkAlphaType at = origInfo.alphaType();
-    SkColorSpace* cs = origInfo.colorSpace();
+    SkColorProfileType pt = origInfo.profileType();
     if (kRGB_565_SkColorType == ct || kGray_8_SkColorType == ct) {
         at = kOpaque_SkAlphaType;  // force this setting
     }
@@ -221,13 +221,13 @@
         at = kPremul_SkAlphaType;  // force this setting
     }
 
-    GrPixelConfig origConfig = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps());
+    GrPixelConfig origConfig = SkImageInfo2GrPixelConfig(ct, at, pt, *context->caps());
     if (!context->caps()->isConfigRenderable(origConfig, sampleCount > 0)) {
         // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32
         ct = kN32_SkColorType;
     }
 
-    GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps());
+    GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, pt, *context->caps());
 
     return context->newDrawContext(SkBackingFit::kExact,               // Why exact?
                                    origInfo.width(), origInfo.height(),
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 45100f09..c2e2841 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -243,7 +243,7 @@
     GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *caps);
 
     if (caps->srgbSupport() && !GrPixelConfigIsSRGB(desc.fConfig) &&
-        pixmap.info().colorSpace() && pixmap.info().colorSpace()->gammaCloseToSRGB()) {
+        kSRGB_SkColorProfileType == pixmap.info().profileType()) {
         // We were supplied sRGB as the profile type, but we don't have a suitable pixel config.
         // Convert to 8888 sRGB so we can handle the data correctly. The raster backend doesn't
         // handle sRGB Index8 -> sRGB 8888 correctly (yet), so lie about both the source and
@@ -418,7 +418,7 @@
 
 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
 // alpha info, that will be considered.
-GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, const SkColorSpace* cs,
+GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProfileType pt,
                                         const GrCaps& caps) {
     // We intentionally ignore profile type for non-8888 formats. Anything we can't support
     // in hardware will be expanded to sRGB 8888 in GrUploadPixmapToTexture.
@@ -432,10 +432,10 @@
         case kARGB_4444_SkColorType:
             return kRGBA_4444_GrPixelConfig;
         case kRGBA_8888_SkColorType:
-            return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB())
+            return (kSRGB_SkColorProfileType == pt && caps.srgbSupport())
                    ? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig;
         case kBGRA_8888_SkColorType:
-            return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB())
+            return (kSRGB_SkColorProfileType == pt && caps.srgbSupport())
                    ? kSBGRA_8888_GrPixelConfig : kBGRA_8888_GrPixelConfig;
         case kIndex_8_SkColorType:
             return kIndex_8_GrPixelConfig;
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index df23003..df720da 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -50,7 +50,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorType dstCT,
-                                                  SkColorSpace* dstCS, const SkIRect* subset) {
+                                                  SkColorProfileType dstPT, const SkIRect* subset) {
     if (nullptr == texture || kUnknown_SkColorType == dstCT) {
         return nullptr;
     }
@@ -74,7 +74,7 @@
         srcRect = *subset;
     }
     desc.fFlags = kRenderTarget_GrSurfaceFlag;
-    desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstCS, *context->caps());
+    desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT, *context->caps());
     desc.fIsMipMapped = false;
 
     GrTexture* dst = context->textureProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0);
@@ -89,7 +89,7 @@
     context->flushSurfaceWrites(dst);
 
     SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPremul_SkAlphaType,
-                                         sk_ref_sp(dstCS));
+                                         dstPT);
     SkGrPixelRef* pixelRef = new SkGrPixelRef(info, dst);
     SkSafeUnref(dst);
     return pixelRef;
@@ -130,7 +130,8 @@
     }
 }
 
-SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, SkColorSpace* dstCS, const SkIRect* subset) {
+SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, SkColorProfileType dstPT,
+                                   const SkIRect* subset) {
     if (nullptr == fSurface) {
         return nullptr;
     }
@@ -141,7 +142,7 @@
     // a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live
     // independently of that texture.  Texture-backed pixel refs, on the other
     // hand, own their GrTextures, and are thus self-contained.
-    return copy_to_new_texture_pixelref(fSurface->asTexture(), dstCT, dstCS, subset);
+    return copy_to_new_texture_pixelref(fSurface->asTexture(), dstCT, dstPT, subset);
 }
 
 static bool tryAllocBitmapPixels(SkBitmap* bitmap) {
@@ -182,7 +183,7 @@
         SkBitmap cachedBitmap;
         cachedBitmap.setInfo(SkImageInfo::Make(bounds.width(), bounds.height(), colorType,
                                                this->info().alphaType(),
-                                               sk_ref_sp(this->info().colorSpace())));
+                                               this->info().profileType()));
 
         // If we can't alloc the pixels, then fail
         if (!tryAllocBitmapPixels(&cachedBitmap)) {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 7ce6450..7f45937 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -111,7 +111,9 @@
 
 bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
                                int srcX, int srcY, CachingHint) const {
-    GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fTexture->getContext()->caps());
+    GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(),
+                                                     info.profileType(),
+                                                     *fTexture->getContext()->caps());
     uint32_t flags = 0;
     if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlphaType) {
         // let the GPU perform this transformation for us
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index 9165c08..d06d6bb 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -67,16 +67,15 @@
     this->resize(fBitmap.info().makeWH(width, height));
 }
 
-void SkWindow::setColorType(SkColorType ct, sk_sp<SkColorSpace> cs) {
+void SkWindow::setColorType(SkColorType ct, SkColorProfileType pt) {
     const SkImageInfo& info = fBitmap.info();
-    this->resize(SkImageInfo::Make(info.width(), info.height(), ct, kPremul_SkAlphaType, cs));
+    this->resize(SkImageInfo::Make(info.width(), info.height(), ct, kPremul_SkAlphaType, pt));
 
     // Set the global flag that enables or disables "legacy" mode, depending on our format.
     // With sRGB 32-bit or linear FP 16, we turn on gamma-correct handling of inputs:
     SkSurfaceProps props = this->getSurfaceProps();
     uint32_t flags = (props.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) |
-        (SkColorAndColorSpaceAreGammaCorrect(ct, cs.get())
-         ? SkSurfaceProps::kGammaCorrect_Flag : 0);
+        (SkColorAndProfileAreGammaCorrect(ct, pt) ? SkSurfaceProps::kGammaCorrect_Flag : 0);
     this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry()));
 }