Add ability to default incoming image data as sRGB by default.
authorherb <herb@google.com>
Fri, 15 Apr 2016 19:57:42 +0000 (12:57 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 15 Apr 2016 19:57:42 +0000 (12:57 -0700)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1893663002

Review URL: https://codereview.chromium.org/1893663002

src/codec/SkCodecImageGenerator.cpp

index db13aae..2548a00 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "SkCodecImageGenerator.h"
+#include "SkPM4fPriv.h"
 
 SkImageGenerator* SkCodecImageGenerator::NewFromEncodedCodec(SkData* data) {
     SkCodec* codec = SkCodec::NewFromData(data);
@@ -25,9 +26,12 @@ static SkImageInfo fix_info(const SkCodec& codec) {
     SkAlphaType alphaType = (kUnpremul_SkAlphaType == info.alphaType()) ? kPremul_SkAlphaType :
             info.alphaType();
 
-    // Crudely guess that the presence of a color space means sRGB.
-    SkColorProfileType profileType = (codec.getColorSpace()) ? kSRGB_SkColorProfileType :
-            kLinear_SkColorProfileType;
+    SkColorProfileType profileType = kLinear_SkColorProfileType;
+    // Crudely guess that the presence of a color space means sRGB, or obey the global sRGB
+    // selector.
+    if (gTreatSkColorAsSRGB || codec.getColorSpace()) {
+        profileType = kSRGB_SkColorProfileType;
+    }
 
     return SkImageInfo::Make(info.width(), info.height(), info.colorType(), alphaType, profileType);
 }