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

Side by Side Diff: gm/strokes.cpp

Issue 1311273002: fix zero-length tangent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove duplicate code; add unit tests 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/core/SkGeometry.cpp » ('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 2011 Google Inc. 2 * Copyright 2011 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 "SkPath.h" 9 #include "SkPath.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 paint.setStrokeWidth(0.055f); 259 paint.setStrokeWidth(0.055f);
260 260
261 canvas->scale(1000, 1000); 261 canvas->scale(1000, 1000);
262 canvas->drawCircle(0, 2, 1.97f, paint); 262 canvas->drawCircle(0, 2, 1.97f, paint);
263 } 263 }
264 264
265 private: 265 private:
266 typedef skiagm::GM INHERITED; 266 typedef skiagm::GM INHERITED;
267 }; 267 };
268 268
269 // Test stroking for curves that produce degenerate tangents when t is 0 or 1 (s ee bug 4191)
270 class Strokes5GM : public skiagm::GM {
271 public:
272 Strokes5GM() {}
273
274 protected:
275
276 SkString onShortName() override {
277 return SkString("zero_control_stroke");
278 }
279
280 SkISize onISize() override {
281 return SkISize::Make(W, H*2);
282 }
283
284 void onDraw(SkCanvas* canvas) override {
285 SkPaint p;
286 p.setColor(SK_ColorRED);
287 p.setAntiAlias(true);
288 p.setStyle(SkPaint::kStroke_Style);
289 p.setStrokeWidth(40);
290 p.setStrokeCap(SkPaint::kButt_Cap);
291
292 SkPath path;
293 path.moveTo(157.474f,111.753f);
294 path.cubicTo(128.5f,111.5f,35.5f,29.5f,35.5f,29.5f);
295 canvas->drawPath(path, p);
296 path.reset();
297 path.moveTo(250, 50);
298 path.quadTo(280, 80, 280, 80);
299 canvas->drawPath(path, p);
300 path.reset();
301 path.moveTo(150, 50);
302 path.conicTo(180, 80, 180, 80, 0.707f);
303 canvas->drawPath(path, p);
304
305 path.reset();
306 path.moveTo(157.474f,311.753f);
307 path.cubicTo(157.474f,311.753f,85.5f,229.5f,35.5f,229.5f);
308 canvas->drawPath(path, p);
309 path.reset();
310 path.moveTo(280, 250);
311 path.quadTo(280, 250, 310, 280);
312 canvas->drawPath(path, p);
313 path.reset();
314 path.moveTo(180, 250);
315 path.conicTo(180, 250, 210, 280, 0.707f);
316 canvas->drawPath(path, p);
317 }
318
319 private:
320 typedef skiagm::GM INHERITED;
321 };
322
269 323
270 ////////////////////////////////////////////////////////////////////////////// 324 //////////////////////////////////////////////////////////////////////////////
271 325
272 static skiagm::GM* F0(void*) { return new StrokesGM; } 326 static skiagm::GM* F0(void*) { return new StrokesGM; }
273 static skiagm::GM* F1(void*) { return new Strokes2GM; } 327 static skiagm::GM* F1(void*) { return new Strokes2GM; }
274 static skiagm::GM* F2(void*) { return new Strokes3GM; } 328 static skiagm::GM* F2(void*) { return new Strokes3GM; }
275 static skiagm::GM* F3(void*) { return new Strokes4GM; } 329 static skiagm::GM* F3(void*) { return new Strokes4GM; }
330 static skiagm::GM* F4(void*) { return new Strokes5GM; }
276 331
277 static skiagm::GMRegistry R0(F0); 332 static skiagm::GMRegistry R0(F0);
278 static skiagm::GMRegistry R1(F1); 333 static skiagm::GMRegistry R1(F1);
279 static skiagm::GMRegistry R2(F2); 334 static skiagm::GMRegistry R2(F2);
280 static skiagm::GMRegistry R3(F3); 335 static skiagm::GMRegistry R3(F3);
336 static skiagm::GMRegistry R4(F4);
OLDNEW
« no previous file with comments | « no previous file | src/core/SkGeometry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698