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

Side by Side Diff: gm/scaledstrokes.cpp

Issue 1875793002: Fix scaledstrokes GM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkRRect.h" 10 #include "SkRRect.h"
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 void onDraw(SkCanvas* canvas) override { 38 void onDraw(SkCanvas* canvas) override {
39 SkPaint paint; 39 SkPaint paint;
40 SkPath path; 40 SkPath path;
41 paint.setStyle(SkPaint::Style::kStroke_Style); 41 paint.setStyle(SkPaint::Style::kStroke_Style);
42 canvas->translate(5.0f, 5.0f); 42 canvas->translate(5.0f, 5.0f);
43 const SkScalar size = 60.0f; 43 const SkScalar size = 60.0f;
44 for (int i = 0; i < 2; i++) { 44 for (int i = 0; i < 2; i++) {
45 paint.setAntiAlias(i == 1); 45 paint.setAntiAlias(i == 1);
46 canvas->save();
47 for (int j = 0; j < 4; j++) { 46 for (int j = 0; j < 4; j++) {
48 SkScalar scale = 4.0f - j; 47 SkScalar scale = 4.0f - j;
49 paint.setStrokeWidth(4.0f / scale); 48 paint.setStrokeWidth(4.0f / scale);
50 canvas->save(); 49 canvas->save();
51 canvas->translate(size / 2.0f, size / 2.0f); 50 canvas->translate(size / 2.0f, size / 2.0f);
52 canvas->scale(scale, scale); 51 canvas->scale(scale, scale);
53 draw_path(size / 2.0f / scale, canvas, paint); 52 draw_path(size / 2.0f / scale, canvas, paint);
54 canvas->restore(); 53 canvas->restore();
55 54
56 canvas->save(); 55 canvas->save();
57 canvas->translate(size / 2.0f, 80.0f + size / 2.0f); 56 canvas->translate(size / 2.0f, 80.0f + size / 2.0f);
58 canvas->scale(scale, scale); 57 canvas->scale(scale, scale);
59 canvas->drawCircle(0.0f, 0.0f, size / 2.0f / scale, paint); 58 canvas->drawCircle(0.0f, 0.0f, size / 2.0f / scale, paint);
60 canvas->restore(); 59 canvas->restore();
61 60
62 canvas->save(); 61 canvas->save();
63 canvas->translate(0.0f, 160.0f); 62 canvas->translate(0.0f, 160.0f);
64 canvas->scale(scale, scale); 63 canvas->scale(scale, scale);
65 canvas->drawRect(SkRect::MakeXYWH(0.0f, 0.0f, size / scale, size / scale), paint); 64 canvas->drawRect(SkRect::MakeXYWH(0.0f, 0.0f, size / scale, size / scale), paint);
66 canvas->restore(); 65 canvas->restore();
67 66
68 canvas->save(); 67 canvas->save();
69 canvas->translate(0.0f, 240.0f); 68 canvas->translate(0.0f, 240.0f);
70 canvas->scale(scale, scale); 69 canvas->scale(scale, scale);
71 canvas->drawLine(0.0f, 0.0f, size / scale, size / scale, paint); 70 canvas->drawLine(0.0f, 0.0f, size / scale, size / scale, paint);
72 canvas->restore(); 71 canvas->restore();
73 72
74 canvas->translate(80.0f, 0.0f); 73 canvas->translate(80.0f, 0.0f);
75 } 74 }
76 canvas->restore();
77 } 75 }
78 76
79 } 77 }
80 78
81 private: 79 private:
82 typedef GM INHERITED; 80 typedef GM INHERITED;
83 }; 81 };
84 82
85 DEF_GM( return new ScaledStrokesGM; ) 83 DEF_GM( return new ScaledStrokesGM; )
OLDNEW
« 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