Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Unified Diff: tests/SerializationTest.cpp

Issue 2334123003: Add SkColor4f serialization (Closed)
Patch Set: Switched to memcpy, rebased Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkWriteBuffer.cpp ('k') | tools/debugger/SkDrawCommand.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SerializationTest.cpp
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index bc2770ebda0d0a9e0143a408bf115e2ceb2f7bc8..f0412ba48c9b71e7c03c3a4aee4fdd2bdc83e031 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 };
« no previous file with comments | « src/core/SkWriteBuffer.cpp ('k') | tools/debugger/SkDrawCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698