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/src/core/SkColorShader.cpp b/src/core/SkColorShader.cpp
index d8c9f29..cfa071f 100644
--- a/src/core/SkColorShader.cpp
+++ b/src/core/SkColorShader.cpp
@@ -130,10 +130,7 @@
sk_sp<SkFlattenable> SkColor4Shader::CreateProc(SkReadBuffer& buffer) {
SkColor4f color;
- color.fR = buffer.readScalar(); // readFloat()
- color.fG = buffer.readScalar();
- color.fB = buffer.readScalar();
- color.fA = buffer.readScalar();
+ buffer.readColor4f(&color);
if (buffer.readBool()) {
// TODO how do we unflatten colorspaces
}
@@ -141,10 +138,7 @@
}
void SkColor4Shader::flatten(SkWriteBuffer& buffer) const {
- buffer.writeScalar(fColor4.fR); // writeFloat()
- buffer.writeScalar(fColor4.fG);
- buffer.writeScalar(fColor4.fB);
- buffer.writeScalar(fColor4.fA);
+ buffer.writeColor4f(fColor4);
buffer.writeBool(false); // TODO how do we flatten colorspaces?
}