Index: tests/PaintTest.cpp |
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp |
index c41e23ac54630e5844710f6427a7a8c1671bb208..57c6be85a78584af640e68e4a1eb162ef8bdf7da 100644 |
--- a/tests/PaintTest.cpp |
+++ b/tests/PaintTest.cpp |
@@ -228,6 +228,76 @@ DEF_TEST(Paint_regression_cubic, reporter) { |
REPORTER_ASSERT(reporter, maxR.contains(strokeR)); |
} |
+DEF_TEST(Paint_flattening, reporter) { |
+ const SkPaint::FilterLevel levels[] = { |
+ SkPaint::kNone_FilterLevel, |
+ SkPaint::kLow_FilterLevel, |
+ SkPaint::kMedium_FilterLevel, |
+ SkPaint::kHigh_FilterLevel, |
+ }; |
+ const SkPaint::Hinting hinting[] = { |
+ SkPaint::kNo_Hinting, |
+ SkPaint::kSlight_Hinting, |
+ SkPaint::kNormal_Hinting, |
+ SkPaint::kFull_Hinting, |
+ }; |
+ const SkPaint::Align align[] = { |
+ SkPaint::kLeft_Align, |
+ SkPaint::kCenter_Align, |
+ SkPaint::kRight_Align |
+ }; |
+ const SkPaint::Cap caps[] = { |
+ SkPaint::kButt_Cap, |
+ SkPaint::kRound_Cap, |
+ SkPaint::kSquare_Cap, |
+ }; |
+ const SkPaint::Join joins[] = { |
+ SkPaint::kMiter_Join, |
+ SkPaint::kRound_Join, |
+ SkPaint::kBevel_Join, |
+ }; |
+ const SkPaint::TextEncoding encodings[] = { |
+ SkPaint::kUTF8_TextEncoding, |
+ SkPaint::kUTF16_TextEncoding, |
+ SkPaint::kUTF32_TextEncoding, |
+ SkPaint::kGlyphID_TextEncoding, |
+ }; |
+ const SkPaint::Style styles[] = { |
+ SkPaint::kFill_Style, |
+ SkPaint::kStroke_Style, |
+ SkPaint::kStrokeAndFill_Style, |
+ }; |
+ |
+#define FOR_SETUP(index, array, setter) \ |
+ for (size_t index = 0; index < SK_ARRAY_COUNT(array); ++index) { \ |
+ paint.setter(array[index]); \ |
+ |
+ SkPaint paint; |
+ paint.setFlags(0x1234); |
+ |
+ FOR_SETUP(i, levels, setFilterLevel) |
+ FOR_SETUP(j, hinting, setHinting) |
+ FOR_SETUP(k, align, setTextAlign) |
+ FOR_SETUP(l, caps, setStrokeCap) |
+ FOR_SETUP(m, joins, setStrokeJoin) |
+ FOR_SETUP(n, encodings, setTextEncoding) |
+ FOR_SETUP(p, styles, setStyle) |
+ |
+ SkWriteBuffer writer; |
+ paint.flatten(writer); |
+ |
+ const uint32_t* written = writer.getWriter32()->contiguousArray(); |
+ SkReadBuffer reader(written, writer.bytesWritten()); |
+ |
+ SkPaint paint2; |
+ paint2.unflatten(reader); |
+ REPORTER_ASSERT(reporter, paint2 == paint); |
+ |
+ }}}}}}} |
+#undef FOR_SETUP |
+ |
+} |
+ |
// found and fixed for android: not initializing rect for string's of length 0 |
DEF_TEST(Paint_regression_measureText, reporter) { |