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

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: 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 static void draw_path(SkScalar size, SkCanvas* canvas, SkPaint paint) {
28 SkScalar c = 0.551915024494f * size;
29 SkPath path;
30 path.moveTo(0.0f, size);
31 path.cubicTo(c, size, size, c, size, 0.0f);
32 path.cubicTo(size, -c, c, -size, 0.0f, -size);
33 path.cubicTo(-c, -size, -size, -c, -size, 0.0f);
34 path.cubicTo(-size, c, -c, size, 0.0f, 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.0f, 5.0f);
43 const SkScalar size = 60.0f;
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.0f - j;
49 paint.setStrokeWidth(4.0f / scale);
50 canvas->save();
51 canvas->translate(size / 2.0f, size / 2.0f);
52 canvas->scale(scale, scale);
53 draw_path(size / 2.0f / scale, canvas, paint);
54 canvas->restore();
55
56 canvas->save();
57 canvas->translate(size / 2.0f, 80.0f + size / 2.0f);
58 canvas->scale(scale, scale);
59 canvas->drawCircle(0.0f, 0.0f, size / 2.0f / scale, paint);
60 canvas->restore();
61
62 canvas->save();
63 canvas->translate(0.0f, 160.0f);
64 canvas->scale(scale, scale);
65 canvas->drawRect(SkRect::MakeXYWH(0.0f, 0.0f, size / scale, size / scale), paint);
66 canvas->restore();
67
68 canvas->save();
69 canvas->translate(0.0f, 240.0f);
70 canvas->scale(scale, scale);
71 canvas->drawLine(0.0f, 0.0f, size / scale, size / scale, paint);
72 canvas->restore();
73
74 canvas->translate(80.0f, 0.0f);
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