Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(742)

Unified Diff: gm/aaclip.cpp

Issue 1096433009: new GM to test clipping cubics (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/aaclip.cpp
diff --git a/gm/aaclip.cpp b/gm/aaclip.cpp
index e613af66bdd91844c5b1401941d443fd057d3e99..8a0084c0471e792687e092866ba5562322e30ef0 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); )
+
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698