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

Side by Side Diff: samplecode/SamplePathEffects.cpp

Issue 953383002: fuzzer fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix up width and height in initializer 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 | « samplecode/SampleCode.h ('k') | samplecode/SamplePathFuzz.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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkView.h" 10 #include "SkView.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 }; 90 };
91 91
92 class PathEffectView : public SampleView { 92 class PathEffectView : public SampleView {
93 SkPath fPath; 93 SkPath fPath;
94 SkPoint fClickPt; 94 SkPoint fClickPt;
95 SkScalar fPhase; 95 SkScalar fPhase;
96 96
97 public: 97 public:
98 PathEffectView() : fPhase(0) { 98 PathEffectView() : fPhase(0) {
99 }
100
101 protected:
102 void onOnceBeforeDraw() SK_OVERRIDE {
99 SkRandom rand; 103 SkRandom rand;
100 int steps = 20; 104 int steps = 20;
101 SkScalar dist = SkIntToScalar(400); 105 SkScalar dist = SkIntToScalar(400);
102 SkScalar x = SkIntToScalar(20); 106 SkScalar x = SkIntToScalar(20);
103 SkScalar y = SkIntToScalar(50); 107 SkScalar y = SkIntToScalar(50);
104 108
105 fPath.moveTo(x, y); 109 fPath.moveTo(x, y);
106 for (int i = 0; i < steps; i++) { 110 for (int i = 0; i < steps; i++) {
107 x += dist/steps; 111 x += dist/steps;
108 SkScalar tmpY = y + SkIntToScalar(rand.nextS() % 25); 112 SkScalar tmpY = y + SkIntToScalar(rand.nextS() % 25);
(...skipping 10 matching lines...) Expand all
119 SkIntToScalar(100), SkIntToScalar(60)); 123 SkIntToScalar(100), SkIntToScalar(60));
120 oval.offset(x, 0); 124 oval.offset(x, 0);
121 fPath.addRoundRect(oval, SkIntToScalar(8), SkIntToScalar(8)); 125 fPath.addRoundRect(oval, SkIntToScalar(8), SkIntToScalar(8));
122 } 126 }
123 127
124 fClickPt.set(SkIntToScalar(200), SkIntToScalar(200)); 128 fClickPt.set(SkIntToScalar(200), SkIntToScalar(200));
125 129
126 this->setBGColor(0xFFDDDDDD); 130 this->setBGColor(0xFFDDDDDD);
127 } 131 }
128 132
129 protected:
130 bool onQuery(SkEvent* evt) SK_OVERRIDE { 133 bool onQuery(SkEvent* evt) SK_OVERRIDE {
131 if (SampleCode::TitleQ(*evt)) { 134 if (SampleCode::TitleQ(*evt)) {
132 SampleCode::TitleR(evt, "PathEffects"); 135 SampleCode::TitleR(evt, "PathEffects");
133 return true; 136 return true;
134 } 137 }
135 return this->INHERITED::onQuery(evt); 138 return this->INHERITED::onQuery(evt);
136 } 139 }
137 140
138 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { 141 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE {
139 SkPaint paint; 142 SkPaint paint;
(...skipping 25 matching lines...) Expand all
165 } 168 }
166 169
167 private: 170 private:
168 typedef SampleView INHERITED; 171 typedef SampleView INHERITED;
169 }; 172 };
170 173
171 ////////////////////////////////////////////////////////////////////////////// 174 //////////////////////////////////////////////////////////////////////////////
172 175
173 static SkView* MyFactory() { return new PathEffectView; } 176 static SkView* MyFactory() { return new PathEffectView; }
174 static SkViewRegister reg(MyFactory); 177 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleCode.h ('k') | samplecode/SamplePathFuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698