diff options
Diffstat (limited to 'gm/cubicpaths.cpp')
-rw-r--r-- | gm/cubicpaths.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/gm/cubicpaths.cpp b/gm/cubicpaths.cpp index 9ab710a7ae..00a741234d 100644 --- a/gm/cubicpaths.cpp +++ b/gm/cubicpaths.cpp @@ -9,6 +9,47 @@ #include "SkPaint.h" #include "SkRandom.h" +// skbug.com/1316 shows that this cubic, when slightly clipped, creates big +// (incorrect) changes to its control points. +class ClippedCubicGM : public skiagm::GM { +public: + ClippedCubicGM() {} + +protected: + SkString onShortName() { + return SkString("cubicpath"); + } + + SkISize onISize() { return SkISize::Make(1240, 390); } + + virtual void onDraw(SkCanvas* canvas) { + SkPath path; + path.moveTo(0, 0); + path.cubicTo(140, 150, 40, 10, 170, 150); + + SkPaint paint; + SkRect bounds = path.getBounds(); + + for (int dy = -1; dy <= 1; ++dy) { + canvas->save(); + for (int dx = -1; dx <= 1; ++dx) { + canvas->save(); + canvas->clipRect(bounds); + canvas->translate(dx, dy); + canvas->drawPath(path, paint); + canvas->restore(); + + canvas->translate(bounds.width(), 0); + } + canvas->restore(); + canvas->translate(0, bounds.height()); + } + } + +private: + typedef skiagm::GM INHERITED; +}; + class CubicPathGM : public skiagm::GM { public: CubicPathGM() {} @@ -300,3 +341,4 @@ private: DEF_GM( return new CubicPathGM; ) DEF_GM( return new CubicClosePathGM; ) +DEF_GM( return new ClippedCubicGM; ) |