Finish color space support for SkCodec

Implements color space xforms and F16 for SkRawCodec and SkWbmpCodec.

BUG=skia:4895

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

Change-Id: I8c72918e46387350b49a9811ce654d26b1ab352a
Reviewed-on: https://skia-review.googlesource.com/4459
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
diff --git a/src/codec/SkWbmpCodec.cpp b/src/codec/SkWbmpCodec.cpp
index 4102bf2..19c8c7d 100644
--- a/src/codec/SkWbmpCodec.cpp
+++ b/src/codec/SkWbmpCodec.cpp
@@ -30,14 +30,16 @@
     }
 }
 
-static inline bool valid_color_type(SkColorType colorType) {
-    switch (colorType) {
+static inline bool valid_color_type(const SkImageInfo& dstInfo) {
+    switch (dstInfo.colorType()) {
         case kRGBA_8888_SkColorType:
         case kBGRA_8888_SkColorType:
         case kIndex_8_SkColorType:
         case kGray_8_SkColorType:
         case kRGB_565_SkColorType:
             return true;
+        case kRGBA_F16_SkColorType:
+            return dstInfo.colorSpace() && dstInfo.colorSpace()->gammaIsLinear();
         default:
             return false;
     }
@@ -127,8 +129,7 @@
         return kUnimplemented;
     }
 
-    if (!valid_color_type(info.colorType()) ||
-            !valid_alpha(info.alphaType(), this->getInfo().alphaType())) {
+    if (!valid_color_type(info) || !valid_alpha(info.alphaType(), this->getInfo().alphaType())) {
         return kInvalidConversion;
     }
 
@@ -194,8 +195,9 @@
         return kUnimplemented;
     }
 
-    if (!valid_color_type(dstInfo.colorType()) ||
-            !valid_alpha(dstInfo.alphaType(), this->getInfo().alphaType())) {
+    if (!valid_color_type(dstInfo) ||
+        !valid_alpha(dstInfo.alphaType(), this->getInfo().alphaType()))
+    {
         return kInvalidConversion;
     }