diff options
author | Mike Reed <reed@google.com> | 2018-07-18 13:28:42 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-18 18:56:07 +0000 |
commit | 0ef539af4cfbcccf1ef23e9ef3d1fcdafd2a6b99 (patch) | |
tree | 0cfd6fba733002ac1c030eb24d1266df2be53695 /gm | |
parent | 0afc75e7548bcb623132afa7cf7c8df179359151 (diff) |
add new patheffects
Bug: skia:
Change-Id: Icc94eafbb26a097d5032cdb4f6e2e0f52a4e1025
Reviewed-on: https://skia-review.googlesource.com/141961
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'gm')
-rw-r--r-- | gm/patheffects.cpp | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/gm/patheffects.cpp b/gm/patheffects.cpp index 744817a489..0f600c4fb5 100644 --- a/gm/patheffects.cpp +++ b/gm/patheffects.cpp @@ -161,9 +161,66 @@ private: typedef GM INHERITED; }; -////////////////////////////////////////////////////////////////////////////// - static GM* PathEffectFactory(void*) { return new PathEffectGM; } static GMRegistry regPathEffect(PathEffectFactory); } + +////////////////////////////////////////////////////////////////////////////// +#include "SkOpPathEffect.h" + +class ComboPathEfectsGM : public skiagm::GM { +public: + ComboPathEfectsGM() {} + +protected: + + SkString onShortName() override { + return SkString("combo-patheffects"); + } + + SkISize onISize() override { return SkISize::Make(360, 630); } + + void onDraw(SkCanvas* canvas) override { + SkPath path0, path1, path2; + path0.addCircle(100, 100, 60); + path1.moveTo(20, 20); path1.cubicTo(20, 180, 140, 0, 140, 140); + + sk_sp<SkPathEffect> effects[] = { + nullptr, + SkStrokePathEffect::Make(20, SkPaint::kRound_Join, SkPaint::kRound_Cap, 0), + SkOpPathEffect::Make(nullptr, + SkStrokePathEffect::Make(20, SkPaint::kRound_Join, SkPaint::kRound_Cap, 0), + kDifference_SkPathOp), + SkOpPathEffect::Make(SkMatrixPathEffect::MakeTranslate(50, 30), + SkStrokePathEffect::Make(20, SkPaint::kRound_Join, SkPaint::kRound_Cap, 0), + kReverseDifference_SkPathOp), + }; + + SkPaint wireframe; + wireframe.setStyle(SkPaint::kStroke_Style); + wireframe.setAntiAlias(true); + + SkPaint paint; + paint.setColor(0xFF8888FF); + paint.setAntiAlias(true); + + for (auto& path : { path0, path1 }) { + canvas->save(); + for (auto pe : effects) { + paint.setPathEffect(pe); + canvas->drawPath(path, paint); + canvas->drawPath(path, wireframe); + + canvas->translate(0, 150); + } + canvas->restore(); + canvas->translate(180, 0); + } + } + +private: + typedef GM INHERITED; +}; +DEF_GM(return new ComboPathEfectsGM;) + |