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

Unified Diff: gm/hairlines.cpp

Issue 1502613002: add hairline with caps gm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | no next file » | 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..89c5cd3d4fbe4f6596e30c9f8c9a62d9007a0a64 100644
--- a/gm/hairlines.cpp
+++ b/gm/hairlines.cpp
@@ -218,6 +218,44 @@ 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, 240, 360) {
+ const bool aliases[] = { false, true };
+ const SkScalar widths[] = { 0, 0.999f, 1, 1.001f };
+ const SkPaint::Cap caps[] = { SkPaint::kButt_Cap, SkPaint::kSquare_Cap, SkPaint::kRound_Cap };
+ for (auto alias : aliases) {
+ canvas->save();
+ for (auto width : widths) {
+ for (auto cap : caps) {
+ draw_squarehair_tests(canvas, width, cap, alias);
+ }
+ }
+ canvas->restore();
+ canvas->translate(120, 0);
+ }
+}
+
//////////////////////////////////////////////////////////////////////////////
static GM* MyFactory(void*) { return new HairlinesGM; }
« 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