Add SkColor4f serialization

Adjusted usage in color shader, and will also be using this
in gradients, soon.

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

Review-Url: https://codereview.chromium.org/2334123003
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp
index 35e9201..ba6302c 100644
--- a/tools/debugger/SkDrawCommand.cpp
+++ b/tools/debugger/SkDrawCommand.cpp
@@ -428,6 +428,15 @@
     return result;
 }
 
+Json::Value SkDrawCommand::MakeJsonColor4f(const SkColor4f& color) {
+    Json::Value result(Json::arrayValue);
+    result.append(Json::Value(color.fA));
+    result.append(Json::Value(color.fR));
+    result.append(Json::Value(color.fG));
+    result.append(Json::Value(color.fB));
+    return result;
+}
+
 Json::Value SkDrawCommand::MakeJsonPoint(const SkPoint& point) {
     Json::Value result(Json::arrayValue);
     result.append(Json::Value(point.x()));
diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h
index 27b56e2..df50be8 100644
--- a/tools/debugger/SkDrawCommand.h
+++ b/tools/debugger/SkDrawCommand.h
@@ -123,6 +123,7 @@
 
     // Helper methods for converting things to JSON
     static Json::Value MakeJsonColor(const SkColor color);
+    static Json::Value MakeJsonColor4f(const SkColor4f& color);
     static Json::Value MakeJsonPoint(const SkPoint& point);
     static Json::Value MakeJsonPoint(SkScalar x, SkScalar y);
     static Json::Value MakeJsonRect(const SkRect& rect);
diff --git a/tools/debugger/SkJsonWriteBuffer.cpp b/tools/debugger/SkJsonWriteBuffer.cpp
index 1b5a962..4b075dd 100644
--- a/tools/debugger/SkJsonWriteBuffer.cpp
+++ b/tools/debugger/SkJsonWriteBuffer.cpp
@@ -83,6 +83,18 @@
     this->append("colorArray", jsonArray);
 }
 
+void SkJsonWriteBuffer::writeColor4f(const SkColor4f& color) {
+    this->append("color", SkDrawCommand::MakeJsonColor4f(color));
+}
+
+void SkJsonWriteBuffer::writeColor4fArray(const SkColor4f* color, uint32_t count) {
+    Json::Value jsonArray(Json::arrayValue);
+    for (uint32_t i = 0; i < count; ++i) {
+        jsonArray.append(SkDrawCommand::MakeJsonColor4f(color[i]));
+    }
+    this->append("colorArray", jsonArray);
+}
+
 void SkJsonWriteBuffer::writePoint(const SkPoint& point) {
     this->append("point", SkDrawCommand::MakeJsonPoint(point));
 }
diff --git a/tools/debugger/SkJsonWriteBuffer.h b/tools/debugger/SkJsonWriteBuffer.h
index 068b650..a0cf4e7 100644
--- a/tools/debugger/SkJsonWriteBuffer.h
+++ b/tools/debugger/SkJsonWriteBuffer.h
@@ -35,6 +35,8 @@
     void writeFlattenable(const SkFlattenable* flattenable) override;
     void writeColor(SkColor color) override;
     void writeColorArray(const SkColor* color, uint32_t count) override;
+    void writeColor4f(const SkColor4f& color) override;
+    void writeColor4fArray(const SkColor4f* color, uint32_t count) override;
     void writePoint(const SkPoint& point) override;
     void writePointArray(const SkPoint* point, uint32_t count) override;
     void writeMatrix(const SkMatrix& matrix) override;