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

Side by Side Diff: gm/addarc.cpp

Issue 931183002: add gm for path-arcs, and catch degenerate arc in conic-case (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | include/core/SkPath.h » ('j') | 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 "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 fRotate = timer.scaled(60, 360); 155 fRotate = timer.scaled(60, 360);
156 return true; 156 return true;
157 } 157 }
158 158
159 private: 159 private:
160 SkScalar fRotate; 160 SkScalar fRotate;
161 161
162 typedef skiagm::GM INHERITED; 162 typedef skiagm::GM INHERITED;
163 }; 163 };
164 DEF_GM( return new StrokeCircleGM; ) 164 DEF_GM( return new StrokeCircleGM; )
165
166 //////////////////////
167
168 static void arc(SkPath* path, SkScalar x, SkScalar y, SkScalar r, SkScalar start , SkScalar end,
169 bool ccw) {
170 SkRect bounds = { x - r, y - r, x + r, y + r };
171 SkScalar sweep = ccw ? end - start : start - end;
172 path->arcTo(bounds, start, sweep, false);
173 }
174
robertphillips 2015/02/17 17:33:45 Which one?
reed2 2015/02/17 18:35:36 Done.
175 // Lifted from layouttest
176 class ManyArcsGM : public skiagm::GM {
177 public:
178 ManyArcsGM() {}
179
180 protected:
181 SkString onShortName() SK_OVERRIDE { return SkString("manyarcs"); }
182
183 SkISize onISize() SK_OVERRIDE { return SkISize::Make(620, 330); }
184
185 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
186 SkPaint paint;
187 paint.setAntiAlias(true);
188 paint.setStyle(SkPaint::kStroke_Style);
189
190 canvas->translate(10, 10);
191
192 // 20 angles.
193 SkScalar sweepAngles[] = {
194 -123.7, -2.3, -2, -1, -0.3, -0.000001, 0, 0.000001, 0 .3, 0.7,
195 1, 1.3, 1.5, 1.7, 1.99999, 2, 2.00001, 2.3, 4.3, 3934 723942837.3
196 };
197 for (size_t i = 0; i < SK_ARRAY_COUNT(sweepAngles); ++i) {
198 sweepAngles[i] *= 180;
199 }
200
201 SkScalar startAngles[] = { -1, -0.5, 0, 0.5 };
202 for (size_t i = 0; i < SK_ARRAY_COUNT(startAngles); ++i) {
203 startAngles[i] *= 180;
204 }
205
206 bool anticlockwise = false;
207 SkScalar sign = 1;
208 for (size_t i = 0; i < SK_ARRAY_COUNT(startAngles) * 2; ++i) {
209 if (i == SK_ARRAY_COUNT(startAngles)) {
210 anticlockwise = true;
211 sign = -1;
212 }
213 SkScalar startAngle = startAngles[i % SK_ARRAY_COUNT(startAngles)] * sign;
214 canvas->save();
215 for (size_t j = 0; j < SK_ARRAY_COUNT(sweepAngles); ++j) {
216 SkPath path;
217 path.moveTo(0, 2);
robertphillips 2015/02/17 17:33:45 overlength ?
reed2 2015/02/17 18:35:36 Not sure what you mean.
reed2 2015/02/17 18:55:20 Done.
218 arc(&path, 18, 15, 10, startAngle, startAngle + (sweepAngles[j] * sign), anticlockwise);
219 path.lineTo(0, 28);
220 canvas->drawPath(path, paint);
221 canvas->translate(30, 0);
222 }
223 canvas->restore();
224 canvas->translate(0, 40);
225 }
226 }
227
228 private:
229 typedef skiagm::GM INHERITED;
230 };
231 DEF_GM( return new ManyArcsGM; )
232
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698