diff options
author | reed <reed@google.com> | 2015-04-22 17:38:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-22 17:38:23 -0700 |
commit | 8f76cb905a7c62dd0ffec4ba7e5ad82caa4b9446 (patch) | |
tree | 98ae6241845744fa2e9a05adc50ae79ea5567155 /gm/aaclip.cpp | |
parent | 632e92fc3fa99e6a78fcbc67d6da68d5bd8334c3 (diff) |
new GM to test clipping cubics
BUG=skia:3716
TBR=caryclark@google.com
Review URL: https://codereview.chromium.org/1096433009
Diffstat (limited to 'gm/aaclip.cpp')
-rw-r--r-- | gm/aaclip.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/gm/aaclip.cpp b/gm/aaclip.cpp index e613af66bd..8a0084c047 100644 --- a/gm/aaclip.cpp +++ b/gm/aaclip.cpp @@ -193,3 +193,72 @@ private: DEF_GM( return SkNEW(CGImageGM); ) #endif #endif + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +// skbug.com/3716 +class ClipCubicGM : public skiagm::GM { + const SkScalar W = 100; + const SkScalar H = 240; + + SkPath fVPath, fHPath; +public: + ClipCubicGM() { + fVPath.moveTo(W, 0); + fVPath.cubicTo(W, H-10, 0, 10, 0, H); + + SkMatrix pivot; + pivot.setRotate(90, W/2, H/2); + fVPath.transform(pivot, &fHPath); + } + +protected: + SkString onShortName() override { + return SkString("clipcubic"); + } + + SkISize onISize() override { + return SkISize::Make(400, 410); + } + + void doDraw(SkCanvas* canvas, const SkPath& path) { + SkPaint paint; + paint.setAntiAlias(true); + + paint.setColor(0xFFCCCCCC); + canvas->drawPath(path, paint); + + paint.setColor(SK_ColorRED); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPath(path, paint); + } + + void drawAndClip(SkCanvas* canvas, const SkPath& path, SkScalar dx, SkScalar dy) { + SkAutoCanvasRestore acr(canvas, true); + + SkRect r = SkRect::MakeXYWH(0, H/4, W, H/2); + SkPaint paint; + paint.setColor(0xFF8888FF); + + canvas->drawRect(r, paint); + this->doDraw(canvas, path); + + canvas->translate(dx, dy); + + canvas->drawRect(r, paint); + canvas->clipRect(r); + this->doDraw(canvas, path); + } + + void onDraw(SkCanvas* canvas) override { + canvas->translate(80, 10); + this->drawAndClip(canvas, fVPath, 200, 0); + canvas->translate(0, 200); + this->drawAndClip(canvas, fHPath, 200, 0); + } + +private: + typedef skiagm::GM INHERITED; +}; +DEF_GM( return SkNEW(ClipCubicGM); ) + |