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

Side by Side Diff: gm/cubicpaths.cpp

Issue 1299243002: subdivide path when side-clipping fails (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add init to avoid warning 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/SkEdgeClipper.cpp » ('j') | src/core/SkEdgeClipper.cpp » ('J')
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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 canvas->restore(); 47 canvas->restore();
48 canvas->translate(0, bounds.height()); 48 canvas->translate(0, bounds.height());
49 } 49 }
50 } 50 }
51 51
52 private: 52 private:
53 typedef skiagm::GM INHERITED; 53 typedef skiagm::GM INHERITED;
54 }; 54 };
55 55
56
57 class ClippedCubic2GM : public skiagm::GM {
58 public:
59 ClippedCubic2GM() {}
60
61 protected:
62
63 SkString onShortName() {
64 return SkString("clippedcubic2");
65 }
66
67 SkISize onISize() { return SkISize::Make(1240, 390); }
68
69 void onDraw(SkCanvas* canvas) override {
70 canvas->save();
71 canvas->translate(-2, 20);
72 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 80, 150));
73 canvas->translate(0, 170);
74 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 80, 100));
75 canvas->translate(0, 170);
76 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 30, 150));
77 canvas->translate(0, 170);
78 drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 10, 150));
79 canvas->restore();
80 }
81
82 void drawOne(SkCanvas* canvas, const SkPath& path, const SkRect& clip) {
83 SkPaint framePaint, fillPaint;
84 framePaint.setStyle(SkPaint::kStroke_Style);
85 canvas->drawRect(clip, framePaint);
86 canvas->drawPath(path, framePaint);
87 canvas->save();
88 canvas->clipRect(clip);
89 canvas->drawPath(path, fillPaint);
90 canvas->restore();
91 }
92
93 void onOnceBeforeDraw() override {
94 fPath.moveTo(69.7030518991886f, 0);
95 fPath.cubicTo( 69.7030518991886f, 21.831149999999997f,
96 58.08369508178456f, 43.66448333333333f, 34.8449814469765f, 65.5f );
97 fPath.cubicTo( 11.608591683531916f, 87.33115f, -0.010765133872116195f, 1 09.16448333333332f,
98 -0.013089005235602302f, 131);
99 fPath.close();
100 }
101
102 SkPath fPath;
103 private:
104 typedef skiagm::GM INHERITED;
105 };
106
107
56 class CubicPathGM : public skiagm::GM { 108 class CubicPathGM : public skiagm::GM {
57 public: 109 public:
58 CubicPathGM() {} 110 CubicPathGM() {}
59 111
60 protected: 112 protected:
61 113
62 SkString onShortName() { 114 SkString onShortName() {
63 return SkString("cubicpath"); 115 return SkString("cubicpath");
64 } 116 }
65 117
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 392
341 private: 393 private:
342 typedef skiagm::GM INHERITED; 394 typedef skiagm::GM INHERITED;
343 }; 395 };
344 396
345 ////////////////////////////////////////////////////////////////////////////// 397 //////////////////////////////////////////////////////////////////////////////
346 398
347 DEF_GM( return new CubicPathGM; ) 399 DEF_GM( return new CubicPathGM; )
348 DEF_GM( return new CubicClosePathGM; ) 400 DEF_GM( return new CubicClosePathGM; )
349 DEF_GM( return new ClippedCubicGM; ) 401 DEF_GM( return new ClippedCubicGM; )
402 DEF_GM( return new ClippedCubic2GM; )
OLDNEW
« no previous file with comments | « no previous file | src/core/SkEdgeClipper.cpp » ('j') | src/core/SkEdgeClipper.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698