diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/third_party/skia/gm/patheffects.cpp | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/skia/gm/patheffects.cpp')
-rw-r--r-- | chromium/third_party/skia/gm/patheffects.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/chromium/third_party/skia/gm/patheffects.cpp b/chromium/third_party/skia/gm/patheffects.cpp index 37715f1b361..695d5e24f04 100644 --- a/chromium/third_party/skia/gm/patheffects.cpp +++ b/chromium/third_party/skia/gm/patheffects.cpp @@ -237,3 +237,58 @@ private: }; DEF_GM(return new ComboPathEfectsGM;) +#include "include/effects/SkStrokeAndFillPathEffect.h" + +// Test that we can replicate SkPaint::kStrokeAndFill_Style +// with a patheffect. We expect the 2nd and 3rd columns to draw the same. +DEF_SIMPLE_GM(stroke_and_fill_patheffect, canvas, 900, 450) { + const float kStrokeWidth = 20; + + typedef void (*Maker)(SkPath*); + const Maker makers[] = { + [](SkPath* path) { + path->addOval({0, 0, 100, 100}, SkPathDirection::kCW); + }, + [](SkPath* path) { + path->addOval({0, 0, 100, 100}, SkPathDirection::kCCW); + }, + [](SkPath* path) { + path->moveTo(0, 0).lineTo(100, 100).lineTo(0, 100).lineTo(100, 0).close(); + }, + }; + + const struct { + SkPaint::Style fStyle; + float fWidth; + bool fUsePE; + bool fExpectStrokeAndFill; + } rec[] = { + { SkPaint::kStroke_Style, 0, false, false }, + { SkPaint::kFill_Style, 0, true, false }, + { SkPaint::kStroke_Style, 0, true, false }, + { SkPaint::kStrokeAndFill_Style, kStrokeWidth, false, true }, + { SkPaint::kStroke_Style, kStrokeWidth, true, true }, + { SkPaint::kStrokeAndFill_Style, kStrokeWidth, true, true }, + }; + + SkPaint paint; + canvas->translate(20, 20); + for (auto maker : makers) { + SkPath path; + maker(&path); + + canvas->save(); + for (const auto& r : rec) { + paint.setStyle(r.fStyle); + paint.setStrokeWidth(r.fWidth); + paint.setPathEffect(r.fUsePE ? SkStrokeAndFillPathEffect::Make() : nullptr); + paint.setColor(r.fExpectStrokeAndFill ? SK_ColorGRAY : SK_ColorBLACK); + + canvas->drawPath(path, paint); + canvas->translate(150, 0); + } + canvas->restore(); + + canvas->translate(0, 150); + } +} |