Tag images as sRGB by default in SkCodec

Unmarked images should be treated as sRGB.

BUG=skia:4895

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4151

Change-Id: I5f8c308d22fd2d069cbfa89c5a5bb19ae6fde8bd
Reviewed-on: https://skia-review.googlesource.com/4151
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index 368d5e3..c2519cb 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -626,7 +626,7 @@
             int height,
             const SkEncodedInfo&,
             SkStream*,
-            sk_sp<SkColorSpace> = nullptr,
+            sk_sp<SkColorSpace>,
             Origin = kTopLeft_Origin);
 
     /**
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp
index 2f796ad..18e2be4 100644
--- a/src/codec/SkBmpCodec.cpp
+++ b/src/codec/SkBmpCodec.cpp
@@ -583,7 +583,7 @@
 
 SkBmpCodec::SkBmpCodec(int width, int height, const SkEncodedInfo& info, SkStream* stream,
         uint16_t bitsPerPixel, SkCodec::SkScanlineOrder rowOrder)
-    : INHERITED(width, height, info, stream)
+    : INHERITED(width, height, info, stream, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named))
     , fBitsPerPixel(bitsPerPixel)
     , fRowOrder(rowOrder)
     , fSrcRowBytes(SkAlign4(compute_row_bytes(width, fBitsPerPixel)))
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index 3c57f2d..fe0a2b6 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -98,9 +98,10 @@
     // zeroes, which is arguably premultiplied.
     const auto alphaType = reader->firstFrameHasAlpha() ? kUnpremul_SkAlphaType
                                                         : kOpaque_SkAlphaType;
-    // FIXME: GIF should default to SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).
+
     const auto imageInfo = SkImageInfo::Make(reader->screenWidth(), reader->screenHeight(),
-                                             colorType, alphaType);
+                                             colorType, alphaType,
+                                             SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named));
     return new SkGifCodec(encodedInfo, imageInfo, reader.release());
 }
 
diff --git a/src/codec/SkIcoCodec.cpp b/src/codec/SkIcoCodec.cpp
index d01904d..bfbe913 100644
--- a/src/codec/SkIcoCodec.cpp
+++ b/src/codec/SkIcoCodec.cpp
@@ -171,10 +171,11 @@
     int width = codecs->operator[](maxIndex)->getInfo().width();
     int height = codecs->operator[](maxIndex)->getInfo().height();
     SkEncodedInfo info = codecs->operator[](maxIndex)->getEncodedInfo();
+    SkColorSpace* colorSpace = codecs->operator[](maxIndex)->getInfo().colorSpace();
 
     // Note that stream is owned by the embedded codec, the ico does not need
     // direct access to the stream.
-    return new SkIcoCodec(width, height, info, codecs.release());
+    return new SkIcoCodec(width, height, info, codecs.release(), sk_ref_sp(colorSpace));
 }
 
 /*
@@ -182,8 +183,9 @@
  * Called only by NewFromStream
  */
 SkIcoCodec::SkIcoCodec(int width, int height, const SkEncodedInfo& info,
-                       SkTArray<SkAutoTDelete<SkCodec>, true>* codecs)
-    : INHERITED(width, height, info, nullptr)
+                       SkTArray<SkAutoTDelete<SkCodec>, true>* codecs,
+                       sk_sp<SkColorSpace> colorSpace)
+    : INHERITED(width, height, info, nullptr, std::move(colorSpace))
     , fEmbeddedCodecs(codecs)
     , fCurrScanlineCodec(nullptr)
     , fCurrIncrementalCodec(nullptr)
diff --git a/src/codec/SkIcoCodec.h b/src/codec/SkIcoCodec.h
index a227d8c..b9ed823 100644
--- a/src/codec/SkIcoCodec.h
+++ b/src/codec/SkIcoCodec.h
@@ -77,7 +77,7 @@
      * @param embeddedCodecs codecs for the embedded images, takes ownership
      */
     SkIcoCodec(int width, int height, const SkEncodedInfo& info,
-            SkTArray<SkAutoTDelete<SkCodec>, true>* embeddedCodecs);
+            SkTArray<SkAutoTDelete<SkCodec>, true>* embeddedCodecs, sk_sp<SkColorSpace> colorSpace);
 
     SkAutoTDelete<SkTArray<SkAutoTDelete<SkCodec>, true>> fEmbeddedCodecs; // owned
 
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp
index 2a6a48f..5ae44d1 100644
--- a/src/codec/SkRawCodec.cpp
+++ b/src/codec/SkRawCodec.cpp
@@ -778,5 +778,6 @@
 SkRawCodec::~SkRawCodec() {}
 
 SkRawCodec::SkRawCodec(SkDngImage* dngImage)
-    : INHERITED(dngImage->width(), dngImage->height(), dngImage->getEncodedInfo(), nullptr)
+    : INHERITED(dngImage->width(), dngImage->height(), dngImage->getEncodedInfo(), nullptr,
+                SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named))
     , fDngImage(dngImage) {}
diff --git a/src/codec/SkWbmpCodec.cpp b/src/codec/SkWbmpCodec.cpp
index 099b6e4..45296d8 100644
--- a/src/codec/SkWbmpCodec.cpp
+++ b/src/codec/SkWbmpCodec.cpp
@@ -105,7 +105,7 @@
 }
 
 SkWbmpCodec::SkWbmpCodec(int width, int height, const SkEncodedInfo& info, SkStream* stream)
-    : INHERITED(width, height, info, stream)
+    : INHERITED(width, height, info, stream, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named))
     , fSrcRowBytes(get_src_row_bytes(this->getInfo().width()))
     , fSwizzler(nullptr)
     , fColorTable(nullptr)