Set sRGB flag for PNGs with an sRGB chunk

BUG=skia:3471
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1667823004

Review URL: https://codereview.chromium.org/1667823004
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index fa7d146..235c4e2 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -117,7 +117,12 @@
  * - otherwise match the src color type
  */
 inline bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) {
-    if (dst.profileType() != src.profileType()) {
+    // FIXME: skbug.com/4895
+    // Currently, we treat both kLinear and ksRGB encoded images as if they are kLinear.
+    // This makes sense while we do not have proper support for ksRGB.  This is also
+    // the reason why we always allow the client to request kLinear.
+    if (dst.profileType() != src.profileType() &&
+            kLinear_SkColorProfileType != dst.profileType()) {
         return false;
     }
 
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 232373c..656df7d 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -328,10 +328,13 @@
         *numberPassesPtr = numberPasses;
     }
 
-    // FIXME: Also need to check for sRGB ( https://bug.skia.org/3471 ).
+    SkColorProfileType profileType = kLinear_SkColorProfileType;
+    if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sRGB)) {
+        profileType = kSRGB_SkColorProfileType;
+    }
 
     if (imageInfo) {
-        *imageInfo = SkImageInfo::Make(origWidth, origHeight, colorType, alphaType);
+        *imageInfo = SkImageInfo::Make(origWidth, origHeight, colorType, alphaType, profileType);
     }
     autoClean.detach();
     if (png_ptrp) {