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

Side by Side Diff: gm/addarc.cpp

Issue 2221103002: Analytic AntiAlias for Convex Shapes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make alpha computation cleaner and faster Created 4 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 | « gm/aaa.cpp ('k') | gyp/core.gypi » ('j') | src/core/SkAntiRun.h » ('J')
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 165
166 // Fill circles and rotate them to test our Analytic Anti-Aliasing
167 class FillCircleGM : public skiagm::GM {
168 public:
169 FillCircleGM() : fRotate(0) {}
170
171 protected:
172 SkString onShortName() override { return SkString("fillcircle"); }
173
174 SkISize onISize() override { return SkISize::Make(520, 520); }
175
176 void onDraw(SkCanvas* canvas) override {
177 canvas->scale(20, 20);
178 canvas->translate(13, 13);
179
180 SkPaint paint;
181 paint.setAntiAlias(true);
182 paint.setStyle(SkPaint::kStroke_Style);
183 paint.setStrokeWidth(SK_Scalar1 / 2);
184
185 const SkScalar delta = paint.getStrokeWidth() * 3 / 2;
186 SkRect r = SkRect::MakeXYWH(-12, -12, 24, 24);
187 SkRandom rand;
188
189 SkScalar sign = 1;
190 while (r.width() > paint.getStrokeWidth() * 2) {
191 SkAutoCanvasRestore acr(canvas, true);
192 canvas->rotate(fRotate * sign);
193
194 paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 2 4)));
195 paint.setStyle(SkPaint::kFill_Style);
196 canvas->drawOval(r, paint);
197 r.inset(delta, delta);
198 sign = -sign;
199 }
200 }
201
202 bool onAnimate(const SkAnimTimer& timer) override {
203 fRotate = timer.scaled(60, 360);
204 return true;
205 }
206
207 private:
208 SkScalar fRotate;
209
210 typedef skiagm::GM INHERITED;
211 };
212 DEF_GM( return new FillCircleGM; )
213
166 ////////////////////// 214 //////////////////////
167 215
168 static void html_canvas_arc(SkPath* path, SkScalar x, SkScalar y, SkScalar r, Sk Scalar start, 216 static void html_canvas_arc(SkPath* path, SkScalar x, SkScalar y, SkScalar r, Sk Scalar start,
169 SkScalar end, bool ccw) { 217 SkScalar end, bool ccw) {
170 SkRect bounds = { x - r, y - r, x + r, y + r }; 218 SkRect bounds = { x - r, y - r, x + r, y + r };
171 SkScalar sweep = ccw ? end - start : start - end; 219 SkScalar sweep = ccw ? end - start : start - end;
172 path->arcTo(bounds, start, sweep, false); 220 path->arcTo(bounds, start, sweep, false);
173 } 221 }
174 222
175 // Lifted from canvas-arc-circumference-fill-diffs.html 223 // Lifted from canvas-arc-circumference-fill-diffs.html
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 271 }
224 canvas->restore(); 272 canvas->restore();
225 canvas->translate(0, 40); 273 canvas->translate(0, 40);
226 } 274 }
227 } 275 }
228 276
229 private: 277 private:
230 typedef skiagm::GM INHERITED; 278 typedef skiagm::GM INHERITED;
231 }; 279 };
232 DEF_GM( return new ManyArcsGM; ) 280 DEF_GM( return new ManyArcsGM; )
OLDNEW
« no previous file with comments | « gm/aaa.cpp ('k') | gyp/core.gypi » ('j') | src/core/SkAntiRun.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698