OLD | NEW |
(Empty) | |
| 1 #ifdef SK_BUILD_FOR_ANDROID |
| 2 |
| 3 #include "SkPaintOptionsAndroid.h" |
| 4 #include "SkOrderedReadBuffer.h" |
| 5 #include "SkOrderedWriteBuffer.h" |
| 6 #include "SkPaint.h" |
| 7 #include "Test.h" |
| 8 #include "TestClassDef.h" |
| 9 |
| 10 static bool Equal(const SkPaintOptionsAndroid& a, const SkPaintOptionsAndroid& b
) { |
| 11 return !(a != b); |
| 12 } |
| 13 |
| 14 static void android_cjk_serialization(skiatest::Reporter* r) { |
| 15 // We want to make sure that Android's paint options survive a flatten/unfla
tten round trip. |
| 16 // These are all non-default options. |
| 17 SkPaintOptionsAndroid options; |
| 18 options.setLanguage("ja-JP"); |
| 19 options.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant); |
| 20 options.setUseFontFallbacks(true); |
| 21 |
| 22 SkPaint paint; |
| 23 paint.setPaintOptionsAndroid(options); |
| 24 |
| 25 // Flatten the paint. |
| 26 SkOrderedWriteBuffer writer(64 /*arbitrary*/); |
| 27 paint.flatten(writer); |
| 28 const size_t size = writer.bytesWritten(); |
| 29 SkAutoMalloc bytes(size); |
| 30 writer.writeToMemory(bytes.get()); |
| 31 |
| 32 // Unflatten the bytes into a new paint. |
| 33 SkPaint reconstructed; |
| 34 SkOrderedReadBuffer reader(bytes.get(), size); |
| 35 reconstructed.unflatten(reader); |
| 36 |
| 37 REPORTER_ASSERT(r, Equal(options, reconstructed.getPaintOptionsAndroid())); |
| 38 } |
| 39 DEFINE_TESTCLASS_SHORT(android_cjk_serialization); |
| 40 |
| 41 #endif // SK_BUILD_FOR_ANDROID |
OLD | NEW |