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

Unified Diff: gm/hairlines.cpp

Issue 1491843006: add support for capped hairlines (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning Created 5 years 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 | src/core/SkDraw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/hairlines.cpp
diff --git a/gm/hairlines.cpp b/gm/hairlines.cpp
index 9d7e36631d9ef1c83b3cd7740a2b6058e2263882..c263bfc5a37e5bd03150159d6c676e79cce4117f 100644
--- a/gm/hairlines.cpp
+++ b/gm/hairlines.cpp
@@ -218,6 +218,52 @@ private:
typedef GM INHERITED;
};
+static void draw_squarehair_tests(SkCanvas* canvas, SkScalar width, SkPaint::Cap cap, bool aa) {
+ SkPaint paint;
+ paint.setStrokeCap(cap);
+ paint.setStrokeWidth(width);
+ paint.setAntiAlias(aa);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawLine(10, 10, 20, 10, paint);
+ canvas->drawLine(30, 10, 30, 20, paint);
+ canvas->drawLine(40, 10, 50, 20, paint);
+ SkPath path;
+ path.moveTo(60, 10);
+ path.quadTo(60, 20, 70, 20);
+ path.conicTo(70, 10, 80, 10, 0.707f);
+ canvas->drawPath(path, paint);
+ path.reset();
+ path.moveTo(90, 10);
+ path.cubicTo(90, 20, 100, 20, 100, 10);
+ path.lineTo(110, 10);
+ canvas->drawPath(path, paint);
+ canvas->translate(0, 30);
+}
+
+DEF_SIMPLE_GM(squarehair, canvas, 400, 400) {
+ canvas->save();
+ draw_squarehair_tests(canvas, 0, SkPaint::kButt_Cap, false);
+ draw_squarehair_tests(canvas, 0, SkPaint::kSquare_Cap, false);
reed1 2015/12/04 18:01:10 Wonder if adding 0.999 would be helpful.
caryclark 2015/12/04 20:55:15 Done.
+ draw_squarehair_tests(canvas, 0, SkPaint::kRound_Cap, false);
+ draw_squarehair_tests(canvas, 1, SkPaint::kButt_Cap, false);
+ draw_squarehair_tests(canvas, 1, SkPaint::kSquare_Cap, false);
+ draw_squarehair_tests(canvas, 1, SkPaint::kRound_Cap, false);
+ draw_squarehair_tests(canvas, 1.001f, SkPaint::kButt_Cap, false);
+ draw_squarehair_tests(canvas, 1.001f, SkPaint::kSquare_Cap, false);
+ draw_squarehair_tests(canvas, 1.001f, SkPaint::kRound_Cap, false);
+ canvas->restore();
+ canvas->translate(120, 0);
+ draw_squarehair_tests(canvas, 0, SkPaint::kButt_Cap, true);
+ draw_squarehair_tests(canvas, 0, SkPaint::kSquare_Cap, true);
+ draw_squarehair_tests(canvas, 0, SkPaint::kRound_Cap, true);
+ draw_squarehair_tests(canvas, 1, SkPaint::kButt_Cap, true);
+ draw_squarehair_tests(canvas, 1, SkPaint::kSquare_Cap, true);
+ draw_squarehair_tests(canvas, 1, SkPaint::kRound_Cap, true);
+ draw_squarehair_tests(canvas, 1.001f, SkPaint::kButt_Cap, true);
+ draw_squarehair_tests(canvas, 1.001f, SkPaint::kSquare_Cap, true);
+ draw_squarehair_tests(canvas, 1.001f, SkPaint::kRound_Cap, true);
+}
+
//////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new HairlinesGM; }
« no previous file with comments | « no previous file | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698