Index: tests/TextBlobTest.cpp |
diff --git a/tests/TextBlobTest.cpp b/tests/TextBlobTest.cpp |
index aa4b1ea25f677dd4740af985b8aa3d9b34e5d723..923669e8c5618e0940e729b4c6c243bab2731421 100644 |
--- a/tests/TextBlobTest.cpp |
+++ b/tests/TextBlobTest.cpp |
@@ -8,6 +8,7 @@ |
#include "SkPaint.h" |
#include "SkPoint.h" |
#include "SkTextBlobRunIterator.h" |
+#include "SkTypeface.h" |
#include "Test.h" |
@@ -172,6 +173,91 @@ public: |
} |
} |
+ // Verify that text-related properties are captured in run paints. |
+ static void TestPaintProps(skiatest::Reporter* reporter) { |
+ SkPaint font; |
+ font.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
+ |
+ SkAutoTUnref<SkTypeface> typeface(SkTypeface::RefDefault()); |
+ |
+ // Kitchen sink font. |
+ font.setTextSize(42); |
+ font.setTextScaleX(4.2f); |
+ font.setTypeface(typeface); |
+ font.setTextSkewX(0.42f); |
+ font.setTextAlign(SkPaint::kCenter_Align); |
+ font.setHinting(SkPaint::kFull_Hinting); |
+ font.setAntiAlias(true); |
+ font.setUnderlineText(true); |
+ font.setStrikeThruText(true); |
+ font.setFakeBoldText(true); |
+ font.setLinearText(true); |
+ font.setSubpixelText(true); |
+ font.setDevKernText(true); |
+ font.setLCDRenderText(true); |
+ font.setEmbeddedBitmapText(true); |
+ font.setAutohinted(true); |
+ font.setVerticalText(true); |
+ font.setFlags(font.getFlags() | SkPaint::kGenA8FromLCD_Flag); |
+ |
+ // Ensure we didn't pick default values by mistake. |
+ SkPaint defaultPaint; |
+ REPORTER_ASSERT(reporter, defaultPaint.getTextSize() != font.getTextSize()); |
+ REPORTER_ASSERT(reporter, defaultPaint.getTextScaleX() != font.getTextScaleX()); |
+ REPORTER_ASSERT(reporter, defaultPaint.getTypeface() != font.getTypeface()); |
+ REPORTER_ASSERT(reporter, defaultPaint.getTextSkewX() != font.getTextSkewX()); |
+ REPORTER_ASSERT(reporter, defaultPaint.getTextAlign() != font.getTextAlign()); |
+ REPORTER_ASSERT(reporter, defaultPaint.getHinting() != font.getHinting()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isAntiAlias() != font.isAntiAlias()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isUnderlineText() != font.isUnderlineText()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isStrikeThruText() != font.isStrikeThruText()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isFakeBoldText() != font.isFakeBoldText()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isLinearText() != font.isLinearText()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isSubpixelText() != font.isSubpixelText()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isDevKernText() != font.isDevKernText()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isLCDRenderText() != font.isLCDRenderText()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isEmbeddedBitmapText() != font.isEmbeddedBitmapText()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isAutohinted() != font.isAutohinted()); |
+ REPORTER_ASSERT(reporter, defaultPaint.isVerticalText() != font.isVerticalText()); |
+ REPORTER_ASSERT(reporter, (defaultPaint.getFlags() & SkPaint::kGenA8FromLCD_Flag) != |
+ (font.getFlags() & SkPaint::kGenA8FromLCD_Flag)); |
+ |
+ SkTextBlobBuilder builder; |
+ AddRun(font, 1, SkTextBlob::kDefault_Positioning, SkPoint::Make(0, 0), builder); |
+ AddRun(font, 1, SkTextBlob::kHorizontal_Positioning, SkPoint::Make(0, 0), builder); |
+ AddRun(font, 1, SkTextBlob::kFull_Positioning, SkPoint::Make(0, 0), builder); |
+ SkAutoTUnref<const SkTextBlob> blob(builder.build()); |
+ |
+ SkTextBlobRunIterator it(blob); |
+ while (!it.done()) { |
+ SkPaint paint; |
+ it.applyFontToPaint(&paint); |
+ |
+ REPORTER_ASSERT(reporter, paint.getTextSize() == font.getTextSize()); |
+ REPORTER_ASSERT(reporter, paint.getTextScaleX() == font.getTextScaleX()); |
+ REPORTER_ASSERT(reporter, paint.getTypeface() == font.getTypeface()); |
+ REPORTER_ASSERT(reporter, paint.getTextSkewX() == font.getTextSkewX()); |
+ REPORTER_ASSERT(reporter, paint.getTextAlign() == font.getTextAlign()); |
+ REPORTER_ASSERT(reporter, paint.getHinting() == font.getHinting()); |
+ REPORTER_ASSERT(reporter, paint.isAntiAlias() == font.isAntiAlias()); |
+ REPORTER_ASSERT(reporter, paint.isUnderlineText() == font.isUnderlineText()); |
+ REPORTER_ASSERT(reporter, paint.isStrikeThruText() == font.isStrikeThruText()); |
+ REPORTER_ASSERT(reporter, paint.isFakeBoldText() == font.isFakeBoldText()); |
+ REPORTER_ASSERT(reporter, paint.isLinearText() == font.isLinearText()); |
+ REPORTER_ASSERT(reporter, paint.isSubpixelText() == font.isSubpixelText()); |
+ REPORTER_ASSERT(reporter, paint.isDevKernText() == font.isDevKernText()); |
+ REPORTER_ASSERT(reporter, paint.isLCDRenderText() == font.isLCDRenderText()); |
+ REPORTER_ASSERT(reporter, paint.isEmbeddedBitmapText() == font.isEmbeddedBitmapText()); |
+ REPORTER_ASSERT(reporter, paint.isAutohinted() == font.isAutohinted()); |
+ REPORTER_ASSERT(reporter, paint.isVerticalText() == font.isVerticalText()); |
+ REPORTER_ASSERT(reporter, (paint.getFlags() & SkPaint::kGenA8FromLCD_Flag) == |
+ (font.getFlags() & SkPaint::kGenA8FromLCD_Flag)); |
+ |
+ it.next(); |
+ } |
+ |
+ } |
+ |
private: |
struct RunDef { |
unsigned count; |
@@ -261,3 +347,7 @@ DEF_TEST(TextBlob_builder, reporter) { |
TextBlobTester::TestBuilder(reporter); |
TextBlobTester::TestBounds(reporter); |
} |
+ |
+DEF_TEST(TextBlob_paint, reporter) { |
+ TextBlobTester::TestPaintProps(reporter); |
+} |