aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SerializationTest.cpp
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-09-25 13:15:58 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-25 13:15:58 -0700
commit97bbf8211fa35bbb0811d5835cb0eaaf37cc679e (patch)
treeb5f342be6cd99cd090f793b297496783bee87d70 /tests/SerializationTest.cpp
parentb82ac17757edfbe27c1bdf5487e6541b30044b3a (diff)
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
Diffstat (limited to 'tests/SerializationTest.cpp')
-rw-r--r--tests/SerializationTest.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index bc2770ebda..f0412ba48c 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -104,6 +104,15 @@ template<> struct SerializationUtils<SkColor> {
}
};
+template<> struct SerializationUtils<SkColor4f> {
+ static void Write(SkWriteBuffer& writer, SkColor4f* data, uint32_t arraySize) {
+ writer.writeColor4fArray(data, arraySize);
+ }
+ static bool Read(SkValidatingReadBuffer& reader, SkColor4f* data, uint32_t arraySize) {
+ return reader.readColor4fArray(data, arraySize);
+ }
+};
+
template<> struct SerializationUtils<int32_t> {
static void Write(SkWriteBuffer& writer, int32_t* data, uint32_t arraySize) {
writer.writeIntArray(data, arraySize);
@@ -225,7 +234,7 @@ static void TestArraySerialization(T* data, skiatest::Reporter* reporter) {
// This should write the length (in 4 bytes) and the array
REPORTER_ASSERT(reporter, (4 + kArraySize * sizeof(T)) == bytesWritten);
- unsigned char dataWritten[1024];
+ unsigned char dataWritten[2048];
writer.writeToMemory(dataWritten);
// Make sure this fails when it should
@@ -494,6 +503,17 @@ DEF_TEST(Serialization, reporter) {
TestArraySerialization(data, reporter);
}
+ // Test readColor4fArray
+ {
+ SkColor4f data[kArraySize] = {
+ SkColor4f::FromColor(SK_ColorBLACK),
+ SkColor4f::FromColor(SK_ColorWHITE),
+ SkColor4f::FromColor(SK_ColorRED),
+ { 1.f, 2.f, 4.f, 8.f }
+ };
+ TestArraySerialization(data, reporter);
+ }
+
// Test readIntArray
{
int32_t data[kArraySize] = { 1, 2, 4, 8 };