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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrAAConvexTessellator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkCanvas.h"
10 #include "SkRRect.h"
11 #include "SkPath.h"
12
13 class ScaledStrokesGM : public skiagm::GM {
14 public:
15 ScaledStrokesGM() {}
16
17 protected:
18
19 SkString onShortName() override {
20 return SkString("scaledstrokes");
21 }
22
23 SkISize onISize() override {
24 return SkISize::Make(640, 320);
25 }
26
27 void drawPath(int size, SkCanvas* canvas, SkPaint paint) {
egdaniel 2015/08/18 16:25:28 make this draw_path
28 float c = 0.551915024494 * size;
29 SkPath path;
30 path.moveTo(0, size);
31 path.cubicTo(c, size, size, c, size, 0);
32 path.cubicTo(size, -c, c, -size, 0, -size);
33 path.cubicTo(-c, -size, -size, -c, -size, 0);
34 path.cubicTo(-size, c, -c, size, 0, size);
35 canvas->drawPath(path, paint);
36 }
37
38 void onDraw(SkCanvas* canvas) override {
39 SkPaint paint;
40 SkPath path;
41 paint.setStyle(SkPaint::Style::kStroke_Style);
42 canvas->translate(5, 5);
43 const SkScalar size = 60;
44 for (int i = 0; i < 2; i++) {
45 paint.setAntiAlias(i == 1);
46 canvas->save();
47 for (int j = 0; j < 4; j++) {
48 SkScalar scale = 4 - j;
49 paint.setStrokeWidth(4 / scale);
50 canvas->save();
51 canvas->translate(size / 2, size / 2);
52 canvas->scale(scale, scale);
53 drawPath(size / 2 / scale, canvas, paint);
54 canvas->restore();
55
56 canvas->save();
57 canvas->translate(size / 2, 80 + size / 2);
58 canvas->scale(scale, scale);
59 canvas->drawCircle(0, 0, size / 2 / scale, paint);
60 canvas->restore();
61
62 canvas->save();
63 canvas->translate(0, 160);
64 canvas->scale(scale, scale);
65 canvas->drawRect(SkRect::MakeXYWH(0, 0, size / scale, size / sca le), paint);
66 canvas->restore();
67
68 canvas->save();
69 canvas->translate(0, 240);
70 canvas->scale(scale, scale);
71 canvas->drawLine(0, 0, size / scale, size / scale, paint);
72 canvas->restore();
73
74 canvas->translate(80, 0);
75 }
76 }
77
78 }
79
80 private:
81 typedef GM INHERITED;
82 };
83
84 DEF_GM( return new ScaledStrokesGM; )
OLDNEW
« 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