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

Unified Diff: gm/scaledstrokes.cpp

Issue 1302503003: Fix transformed stroke width in GrAALinearizingConvexPathRenderer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: added an assert Created 5 years, 4 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 | src/gpu/GrAAConvexTessellator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/scaledstrokes.cpp
diff --git a/gm/scaledstrokes.cpp b/gm/scaledstrokes.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2398113a3b29f202cf5ceb8670719d221849a6dd
--- /dev/null
+++ b/gm/scaledstrokes.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkCanvas.h"
+#include "SkRRect.h"
+#include "SkPath.h"
+
+class ScaledStrokesGM : public skiagm::GM {
+public:
+ ScaledStrokesGM() {}
+
+protected:
+
+ SkString onShortName() override {
+ return SkString("scaledstrokes");
+ }
+
+ SkISize onISize() override {
+ return SkISize::Make(640, 320);
+ }
+
+ void drawPath(int size, SkCanvas* canvas, SkPaint paint) {
egdaniel 2015/08/18 16:25:28 make this draw_path
+ float c = 0.551915024494 * size;
+ SkPath path;
+ path.moveTo(0, size);
+ path.cubicTo(c, size, size, c, size, 0);
+ path.cubicTo(size, -c, c, -size, 0, -size);
+ path.cubicTo(-c, -size, -size, -c, -size, 0);
+ path.cubicTo(-size, c, -c, size, 0, size);
+ canvas->drawPath(path, paint);
+ }
+
+ void onDraw(SkCanvas* canvas) override {
+ SkPaint paint;
+ SkPath path;
+ paint.setStyle(SkPaint::Style::kStroke_Style);
+ canvas->translate(5, 5);
+ const SkScalar size = 60;
+ for (int i = 0; i < 2; i++) {
+ paint.setAntiAlias(i == 1);
+ canvas->save();
+ for (int j = 0; j < 4; j++) {
+ SkScalar scale = 4 - j;
+ paint.setStrokeWidth(4 / scale);
+ canvas->save();
+ canvas->translate(size / 2, size / 2);
+ canvas->scale(scale, scale);
+ drawPath(size / 2 / scale, canvas, paint);
+ canvas->restore();
+
+ canvas->save();
+ canvas->translate(size / 2, 80 + size / 2);
+ canvas->scale(scale, scale);
+ canvas->drawCircle(0, 0, size / 2 / scale, paint);
+ canvas->restore();
+
+ canvas->save();
+ canvas->translate(0, 160);
+ canvas->scale(scale, scale);
+ canvas->drawRect(SkRect::MakeXYWH(0, 0, size / scale, size / scale), paint);
+ canvas->restore();
+
+ canvas->save();
+ canvas->translate(0, 240);
+ canvas->scale(scale, scale);
+ canvas->drawLine(0, 0, size / scale, size / scale, paint);
+ canvas->restore();
+
+ canvas->translate(80, 0);
+ }
+ }
+
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+DEF_GM( return new ScaledStrokesGM; )
« no previous file with comments | « no previous file | src/gpu/GrAAConvexTessellator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698