blob: e58807c0900aa551bc56b404f4ed6bac7505696f [file] [log] [blame]
robertphillips05a4cf52016-09-08 09:02:43 -07001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "gm.h"
Mike Klein33d20552017-03-22 13:47:51 -04009#include "sk_tool_utils.h"
robertphillips05a4cf52016-09-08 09:02:43 -070010#include "SkAnimTimer.h"
11#include "SkBlurMaskFilter.h"
Robert Phillipsa29a9562016-10-20 09:40:55 -040012#include "SkRRectsGaussianEdgeMaskFilter.h"
robertphillips05a4cf52016-09-08 09:02:43 -070013#include "SkPath.h"
14#include "SkPathOps.h"
Mike Reed242135a2018-02-22 13:41:39 -050015#include "SkRRectPriv.h"
robertphillips05a4cf52016-09-08 09:02:43 -070016#include "SkStroke.h"
17
18constexpr int kNumCols = 2;
19constexpr int kNumRows = 5;
20constexpr int kCellSize = 128;
21constexpr SkScalar kPad = 8.0f;
Robert Phillips40085e62016-10-18 12:58:29 -040022constexpr SkScalar kInitialBlurRadius = 8.0f;
robertphillips05a4cf52016-09-08 09:02:43 -070023constexpr SkScalar kPeriod = 8.0f;
24constexpr int kClipOffset = 32;
25
26///////////////////////////////////////////////////////////////////////////////////////////////////
robertphillips05a4cf52016-09-08 09:02:43 -070027
robertphillips2af83ac2016-09-12 12:02:16 -070028class Object {
29public:
30 virtual ~Object() {}
Ben Wagner63fd7602017-10-09 15:45:33 -040031 // When it returns true, this call will have placed a device-space _circle, rect or
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -040032 // simple circular_ RRect in "rr"
33 virtual bool asDevSpaceRRect(const SkMatrix& ctm, SkRRect* rr) const = 0;
robertphillipsf619a7a2016-09-12 17:25:50 -070034 virtual SkPath asPath(SkScalar inset) const = 0;
robertphillips2af83ac2016-09-12 12:02:16 -070035 virtual void draw(SkCanvas* canvas, const SkPaint& paint) const = 0;
36 virtual void clip(SkCanvas* canvas) const = 0;
37 virtual bool contains(const SkRect& r) const = 0;
38 virtual const SkRect& bounds() const = 0;
39};
robertphillips05a4cf52016-09-08 09:02:43 -070040
robertphillips2af83ac2016-09-12 12:02:16 -070041typedef Object* (*PFMakeMthd)(const SkRect& r);
42
43class RRect : public Object {
44public:
45 RRect(const SkRect& r) {
46 fRRect = SkRRect::MakeRectXY(r, 4*kPad, 4*kPad);
robertphillips05a4cf52016-09-08 09:02:43 -070047 }
robertphillips05a4cf52016-09-08 09:02:43 -070048
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -040049 bool asDevSpaceRRect(const SkMatrix& ctm, SkRRect* rr) const override {
50 if (!ctm.isSimilarity()) { // the corners have to remain circular
51 return false;
52 }
53
54 SkScalar scales[2];
55 if (!ctm.getMinMaxScales(scales)) {
56 return false;
57 }
58
59 SkASSERT(SkScalarNearlyEqual(scales[0], scales[1]));
60
61 SkRect devRect;
62 ctm.mapRect(&devRect, fRRect.rect());
63
Mike Reed242135a2018-02-22 13:41:39 -050064 SkScalar scaledRad = scales[0] * SkRRectPriv::GetSimpleRadii(fRRect).fX;
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -040065
66 *rr = SkRRect::MakeRectXY(devRect, scaledRad, scaledRad);
robertphillips2af83ac2016-09-12 12:02:16 -070067 return true;
68 }
robertphillips05a4cf52016-09-08 09:02:43 -070069
robertphillipsf619a7a2016-09-12 17:25:50 -070070 SkPath asPath(SkScalar inset) const override {
71 SkRRect tmp = fRRect;
72 tmp.inset(inset, inset);
robertphillips2af83ac2016-09-12 12:02:16 -070073 SkPath p;
robertphillipsf619a7a2016-09-12 17:25:50 -070074 p.addRRect(tmp);
robertphillips2af83ac2016-09-12 12:02:16 -070075 return p;
76 }
robertphillips05a4cf52016-09-08 09:02:43 -070077
robertphillips2af83ac2016-09-12 12:02:16 -070078 void draw(SkCanvas* canvas, const SkPaint& paint) const override {
79 canvas->drawRRect(fRRect, paint);
80 }
robertphillips05a4cf52016-09-08 09:02:43 -070081
robertphillips2af83ac2016-09-12 12:02:16 -070082 void clip(SkCanvas* canvas) const override {
83 canvas->clipRRect(fRRect);
84 }
85
86 bool contains(const SkRect& r) const override {
87 return fRRect.contains(r);
88 }
89
90 const SkRect& bounds() const override {
91 return fRRect.getBounds();
92 }
93
94 static Object* Make(const SkRect& r) {
95 return new RRect(r);
96 }
97
98private:
99 SkRRect fRRect;
100};
101
102class StrokedRRect : public Object {
103public:
104 StrokedRRect(const SkRect& r) {
105 fRRect = SkRRect::MakeRectXY(r, 2*kPad, 2*kPad);
106 fStrokedBounds = r.makeOutset(kPad, kPad);
107 }
108
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -0400109 bool asDevSpaceRRect(const SkMatrix& ctm, SkRRect* rr) const override {
robertphillips2af83ac2016-09-12 12:02:16 -0700110 return false;
111 }
112
robertphillipsf619a7a2016-09-12 17:25:50 -0700113 SkPath asPath(SkScalar inset) const override {
114 SkRRect tmp = fRRect;
115 tmp.inset(inset, inset);
116
robertphillips2af83ac2016-09-12 12:02:16 -0700117 // In this case we want the outline of the stroked rrect
118 SkPaint paint;
119 paint.setAntiAlias(true);
120 paint.setStyle(SkPaint::kStroke_Style);
121 paint.setStrokeWidth(kPad);
122
robertphillips05a4cf52016-09-08 09:02:43 -0700123 SkPath p, stroked;
robertphillipsf619a7a2016-09-12 17:25:50 -0700124 p.addRRect(tmp);
robertphillips05a4cf52016-09-08 09:02:43 -0700125 SkStroke stroke(paint);
126 stroke.strokePath(p, &stroked);
robertphillips2af83ac2016-09-12 12:02:16 -0700127 return stroked;
robertphillips05a4cf52016-09-08 09:02:43 -0700128 }
129
robertphillips2af83ac2016-09-12 12:02:16 -0700130 void draw(SkCanvas* canvas, const SkPaint& paint) const override {
131 SkPaint stroke(paint);
132 stroke.setStyle(SkPaint::kStroke_Style);
133 stroke.setStrokeWidth(kPad);
robertphillips05a4cf52016-09-08 09:02:43 -0700134
robertphillips2af83ac2016-09-12 12:02:16 -0700135 canvas->drawRRect(fRRect, stroke);
robertphillips05a4cf52016-09-08 09:02:43 -0700136 }
137
robertphillips2af83ac2016-09-12 12:02:16 -0700138 void clip(SkCanvas* canvas) const override {
robertphillipsf619a7a2016-09-12 17:25:50 -0700139 canvas->clipPath(this->asPath(0.0f));
robertphillips05a4cf52016-09-08 09:02:43 -0700140 }
141
robertphillips2af83ac2016-09-12 12:02:16 -0700142 bool contains(const SkRect& r) const override {
143 return false;
robertphillips05a4cf52016-09-08 09:02:43 -0700144 }
145
robertphillips2af83ac2016-09-12 12:02:16 -0700146 const SkRect& bounds() const override {
147 return fStrokedBounds;
148 }
robertphillips05a4cf52016-09-08 09:02:43 -0700149
robertphillips2af83ac2016-09-12 12:02:16 -0700150 static Object* Make(const SkRect& r) {
151 return new StrokedRRect(r);
152 }
robertphillips05a4cf52016-09-08 09:02:43 -0700153
robertphillips2af83ac2016-09-12 12:02:16 -0700154private:
155 SkRRect fRRect;
156 SkRect fStrokedBounds;
157};
robertphillips05a4cf52016-09-08 09:02:43 -0700158
robertphillips2af83ac2016-09-12 12:02:16 -0700159class Oval : public Object {
160public:
161 Oval(const SkRect& r) {
162 fRRect = SkRRect::MakeOval(r);
163 }
164
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -0400165 bool asDevSpaceRRect(const SkMatrix& ctm, SkRRect* rr) const override {
166 if (!ctm.isSimilarity()) { // circles have to remain circles
167 return false;
168 }
169
170 SkRect devRect;
171 ctm.mapRect(&devRect, fRRect.rect());
172 *rr = SkRRect::MakeOval(devRect);
robertphillips2af83ac2016-09-12 12:02:16 -0700173 return true;
174 }
175
Ben Wagner63fd7602017-10-09 15:45:33 -0400176 SkPath asPath(SkScalar inset) const override {
robertphillipsf619a7a2016-09-12 17:25:50 -0700177 SkRRect tmp = fRRect;
178 tmp.inset(inset, inset);
179
robertphillips2af83ac2016-09-12 12:02:16 -0700180 SkPath p;
robertphillipsf619a7a2016-09-12 17:25:50 -0700181 p.addRRect(tmp);
robertphillips2af83ac2016-09-12 12:02:16 -0700182 return p;
183 }
184
185 void draw(SkCanvas* canvas, const SkPaint& paint) const override {
186 canvas->drawRRect(fRRect, paint);
187 }
188
189 void clip(SkCanvas* canvas) const override {
190 canvas->clipRRect(fRRect);
191 }
192
193 bool contains(const SkRect& r) const override {
194 return fRRect.contains(r);
195 }
196
197 const SkRect& bounds() const override {
198 return fRRect.getBounds();
199 }
200
201 static Object* Make(const SkRect& r) {
202 return new Oval(r);
203 }
204
205private:
206 SkRRect fRRect;
207};
208
209class Rect : public Object {
210public:
211 Rect(const SkRect& r) : fRect(r) { }
212
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -0400213 bool asDevSpaceRRect(const SkMatrix& ctm, SkRRect* rr) const override {
214 if (!ctm.rectStaysRect()) {
215 return false;
216 }
217
218 SkRect devRect;
219 ctm.mapRect(&devRect, fRect);
220 *rr = SkRRect::MakeRect(devRect);
robertphillips2af83ac2016-09-12 12:02:16 -0700221 return true;
222 }
223
Ben Wagner63fd7602017-10-09 15:45:33 -0400224 SkPath asPath(SkScalar inset) const override {
robertphillipsf619a7a2016-09-12 17:25:50 -0700225 SkRect tmp = fRect;
226 tmp.inset(inset, inset);
227
robertphillips2af83ac2016-09-12 12:02:16 -0700228 SkPath p;
robertphillipsf619a7a2016-09-12 17:25:50 -0700229 p.addRect(tmp);
robertphillips2af83ac2016-09-12 12:02:16 -0700230 return p;
231 }
232
233 void draw(SkCanvas* canvas, const SkPaint& paint) const override {
234 canvas->drawRect(fRect, paint);
235 }
236
237 void clip(SkCanvas* canvas) const override {
238 canvas->clipRect(fRect);
239 }
240
241 bool contains(const SkRect& r) const override {
242 return fRect.contains(r);
243 }
244
245 const SkRect& bounds() const override {
246 return fRect;
247 }
248
249 static Object* Make(const SkRect& r) {
250 return new Rect(r);
251 }
252
253private:
254 SkRect fRect;
255};
256
257class Pentagon : public Object {
258public:
259 Pentagon(const SkRect& r) {
260 SkPoint points[5] = {
261 { 0.000000f, -1.000000f },
262 { -0.951056f, -0.309017f },
263 { -0.587785f, 0.809017f },
264 { 0.587785f, 0.809017f },
265 { 0.951057f, -0.309017f },
266 };
267
268 SkScalar height = r.height()/2.0f;
269 SkScalar width = r.width()/2.0f;
270
271 fPath.moveTo(r.centerX() + points[0].fX * width, r.centerY() + points[0].fY * height);
272 fPath.lineTo(r.centerX() + points[1].fX * width, r.centerY() + points[1].fY * height);
273 fPath.lineTo(r.centerX() + points[2].fX * width, r.centerY() + points[2].fY * height);
274 fPath.lineTo(r.centerX() + points[3].fX * width, r.centerY() + points[3].fY * height);
275 fPath.lineTo(r.centerX() + points[4].fX * width, r.centerY() + points[4].fY * height);
276 fPath.close();
277 }
278
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -0400279 bool asDevSpaceRRect(const SkMatrix& ctm, SkRRect* rr) const override {
robertphillips2af83ac2016-09-12 12:02:16 -0700280 return false;
281 }
282
robertphillipsf619a7a2016-09-12 17:25:50 -0700283 SkPath asPath(SkScalar inset) const override { return fPath; }
robertphillips2af83ac2016-09-12 12:02:16 -0700284
285 void draw(SkCanvas* canvas, const SkPaint& paint) const override {
286 canvas->drawPath(fPath, paint);
287 }
288
289 void clip(SkCanvas* canvas) const override {
robertphillipsf619a7a2016-09-12 17:25:50 -0700290 canvas->clipPath(this->asPath(0.0f));
robertphillips2af83ac2016-09-12 12:02:16 -0700291 }
292
293 bool contains(const SkRect& r) const override {
294 return false;
295 }
296
297 const SkRect& bounds() const override {
298 return fPath.getBounds();
299 }
300
301 static Object* Make(const SkRect& r) {
302 return new Pentagon(r);
303 }
304
305private:
306 SkPath fPath;
307};
robertphillips05a4cf52016-09-08 09:02:43 -0700308
309///////////////////////////////////////////////////////////////////////////////////////////////////
310namespace skiagm {
311
312// This GM attempts to mimic Android's reveal animation
313class RevealGM : public GM {
314public:
robertphillips2af83ac2016-09-12 12:02:16 -0700315 enum Mode {
robertphillips2af83ac2016-09-12 12:02:16 -0700316 kBlurMask_Mode,
317 kRRectsGaussianEdge_Mode,
318
319 kLast_Mode = kRRectsGaussianEdge_Mode
320 };
robertphillips2af83ac2016-09-12 12:02:16 -0700321 static const int kModeCount = kLast_Mode + 1;
322
Robert Phillipsa29a9562016-10-20 09:40:55 -0400323 enum CoverageGeom {
324 kRect_CoverageGeom,
325 kRRect_CoverageGeom,
326 kDRRect_CoverageGeom,
327 kPath_CoverageGeom,
328
329 kLast_CoverageGeom = kPath_CoverageGeom
330 };
331 static const int kCoverageGeomCount = kLast_CoverageGeom + 1;
332
Robert Phillips40085e62016-10-18 12:58:29 -0400333 RevealGM()
334 : fFraction(0.5f)
335 , fMode(kRRectsGaussianEdge_Mode)
336 , fPause(false)
Robert Phillipsa29a9562016-10-20 09:40:55 -0400337 , fBlurRadius(kInitialBlurRadius)
338 , fCoverageGeom(kRect_CoverageGeom) {
robertphillips05a4cf52016-09-08 09:02:43 -0700339 this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC));
340 }
341
342protected:
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -0400343 bool runAsBench() const override { return true; }
robertphillips05a4cf52016-09-08 09:02:43 -0700344
345 SkString onShortName() override {
346 return SkString("reveal");
347 }
348
349 SkISize onISize() override {
350 return SkISize::Make(kNumCols * kCellSize, kNumRows * kCellSize);
351 }
352
353 void onDraw(SkCanvas* canvas) override {
robertphillips2af83ac2016-09-12 12:02:16 -0700354 PFMakeMthd clipMakes[kNumCols] = { Oval::Make, Rect::Make };
355 PFMakeMthd drawMakes[kNumRows] = {
356 RRect::Make, StrokedRRect::Make, Oval::Make, Rect::Make, Pentagon::Make
robertphillips05a4cf52016-09-08 09:02:43 -0700357 };
358
359 SkPaint strokePaint;
robertphillips05a4cf52016-09-08 09:02:43 -0700360 strokePaint.setStyle(SkPaint::kStroke_Style);
361 strokePaint.setStrokeWidth(0.0f);
362
363 for (int y = 0; y < kNumRows; ++y) {
364 for (int x = 0; x < kNumCols; ++x) {
365 SkRect cell = SkRect::MakeXYWH(SkIntToScalar(x*kCellSize),
366 SkIntToScalar(y*kCellSize),
367 SkIntToScalar(kCellSize),
368 SkIntToScalar(kCellSize));
369
robertphillips2af83ac2016-09-12 12:02:16 -0700370 canvas->save();
371 canvas->clipRect(cell);
372
robertphillips05a4cf52016-09-08 09:02:43 -0700373 cell.inset(kPad, kPad);
374 SkPoint clipCenter = SkPoint::Make(cell.centerX() - kClipOffset,
375 cell.centerY() + kClipOffset);
robertphillips05a4cf52016-09-08 09:02:43 -0700376 SkScalar curSize = kCellSize * fFraction;
robertphillips2af83ac2016-09-12 12:02:16 -0700377 const SkRect clipRect = SkRect::MakeLTRB(clipCenter.fX - curSize,
378 clipCenter.fY - curSize,
379 clipCenter.fX + curSize,
380 clipCenter.fY + curSize);
381
Ben Wagner145dbcd2016-11-03 14:40:50 -0400382 std::unique_ptr<Object> clipObj((*clipMakes[x])(clipRect));
383 std::unique_ptr<Object> drawObj((*drawMakes[y])(cell));
robertphillips05a4cf52016-09-08 09:02:43 -0700384
Ben Wagner63fd7602017-10-09 15:45:33 -0400385 // The goal is to replace this clipped draw (which clips the
robertphillips05a4cf52016-09-08 09:02:43 -0700386 // shadow) with a draw using the geometric clip
Florin Malitabb3f5622017-05-31 14:20:12 +0000387 if (kBlurMask_Mode == fMode) {
robertphillips2af83ac2016-09-12 12:02:16 -0700388 SkPath clippedPath;
robertphillips05a4cf52016-09-08 09:02:43 -0700389
Robert Phillips40085e62016-10-18 12:58:29 -0400390 SkScalar sigma = fBlurRadius / 4.0f;
robertphillipsf619a7a2016-09-12 17:25:50 -0700391
robertphillips2af83ac2016-09-12 12:02:16 -0700392 if (clipObj->contains(drawObj->bounds())) {
robertphillipsf619a7a2016-09-12 17:25:50 -0700393 clippedPath = drawObj->asPath(2.0f*sigma);
robertphillips2af83ac2016-09-12 12:02:16 -0700394 } else {
robertphillipsf619a7a2016-09-12 17:25:50 -0700395 SkPath drawnPath = drawObj->asPath(2.0f*sigma);
396 SkPath clipPath = clipObj->asPath(2.0f*sigma);
robertphillips05a4cf52016-09-08 09:02:43 -0700397
robertphillips2af83ac2016-09-12 12:02:16 -0700398 SkAssertResult(Op(clipPath, drawnPath, kIntersect_SkPathOp, &clippedPath));
399 }
robertphillips05a4cf52016-09-08 09:02:43 -0700400
401 SkPaint blurPaint;
402 blurPaint.setAntiAlias(true);
robertphillipsf619a7a2016-09-12 17:25:50 -0700403 blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma));
robertphillips05a4cf52016-09-08 09:02:43 -0700404 canvas->drawPath(clippedPath, blurPaint);
robertphillips2af83ac2016-09-12 12:02:16 -0700405 } else {
406 SkASSERT(kRRectsGaussianEdge_Mode == fMode);
407
408 SkRect cover = drawObj->bounds();
409 SkAssertResult(cover.intersect(clipObj->bounds()));
410
411 SkPaint paint;
412
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -0400413 SkRRect devSpaceClipRR, devSpaceDrawnRR;
robertphillips2af83ac2016-09-12 12:02:16 -0700414
Robert Phillipsd2fe3bc2016-10-20 11:58:40 -0400415 if (clipObj->asDevSpaceRRect(canvas->getTotalMatrix(), &devSpaceClipRR) &&
416 drawObj->asDevSpaceRRect(canvas->getTotalMatrix(), &devSpaceDrawnRR)) {
417 paint.setMaskFilter(SkRRectsGaussianEdgeMaskFilter::Make(devSpaceClipRR,
418 devSpaceDrawnRR,
Robert Phillipsa29a9562016-10-20 09:40:55 -0400419 fBlurRadius));
robertphillips2af83ac2016-09-12 12:02:16 -0700420 }
421
Robert Phillipsa29a9562016-10-20 09:40:55 -0400422 strokePaint.setColor(SK_ColorBLUE);
423
424 switch (fCoverageGeom) {
425 case kRect_CoverageGeom:
426 canvas->drawRect(cover, paint);
427 canvas->drawRect(cover, strokePaint);
428 break;
429 case kRRect_CoverageGeom: {
430 const SkRRect rrect = SkRRect::MakeRectXY(
431 cover.makeOutset(10.0f, 10.0f),
432 10.0f, 10.0f);
433 canvas->drawRRect(rrect, paint);
434 canvas->drawRRect(rrect, strokePaint);
435 break;
436 }
437 case kDRRect_CoverageGeom: {
438 const SkRRect inner = SkRRect::MakeRectXY(cover.makeInset(10.0f, 10.0f),
439 10.0f, 10.0f);
440 const SkRRect outer = SkRRect::MakeRectXY(
441 cover.makeOutset(10.0f, 10.0f),
442 10.0f, 10.0f);
443 canvas->drawDRRect(outer, inner, paint);
444 canvas->drawDRRect(outer, inner, strokePaint);
445 break;
446 }
447 case kPath_CoverageGeom: {
448 SkPath path;
449 path.moveTo(cover.fLeft, cover.fTop);
450 path.lineTo(cover.centerX(), cover.centerY());
451 path.lineTo(cover.fRight, cover.fTop);
452 path.lineTo(cover.fRight, cover.fBottom);
453 path.lineTo(cover.centerX(), cover.centerY());
454 path.lineTo(cover.fLeft, cover.fBottom);
455 path.close();
456 canvas->drawPath(path, paint);
457 canvas->drawPath(path, strokePaint);
458 break;
459 }
460 }
robertphillips05a4cf52016-09-08 09:02:43 -0700461 }
robertphillips2af83ac2016-09-12 12:02:16 -0700462
463 // Draw the clip and draw objects for reference
robertphillips2af83ac2016-09-12 12:02:16 -0700464 strokePaint.setColor(SK_ColorRED);
robertphillipsf619a7a2016-09-12 17:25:50 -0700465 canvas->drawPath(drawObj->asPath(0.0f), strokePaint);
robertphillips2af83ac2016-09-12 12:02:16 -0700466 strokePaint.setColor(SK_ColorGREEN);
robertphillipsf619a7a2016-09-12 17:25:50 -0700467 canvas->drawPath(clipObj->asPath(0.0f), strokePaint);
robertphillips2af83ac2016-09-12 12:02:16 -0700468
469 canvas->restore();
robertphillips05a4cf52016-09-08 09:02:43 -0700470 }
471 }
472 }
473
474 bool onHandleKey(SkUnichar uni) override {
475 switch (uni) {
476 case 'C':
robertphillips2af83ac2016-09-12 12:02:16 -0700477 fMode = (Mode)((fMode + 1) % kModeCount);
robertphillips05a4cf52016-09-08 09:02:43 -0700478 return true;
Robert Phillips40085e62016-10-18 12:58:29 -0400479 case '+':
480 fBlurRadius += 1.0f;
481 return true;
482 case '-':
483 fBlurRadius = SkTMax(1.0f, fBlurRadius - 1.0f);
484 return true;
robertphillipsf619a7a2016-09-12 17:25:50 -0700485 case 'p':
486 fPause = !fPause;
487 return true;
Robert Phillipsa29a9562016-10-20 09:40:55 -0400488 case 'G':
489 fCoverageGeom = (CoverageGeom) ((fCoverageGeom+1) % kCoverageGeomCount);
490 return true;
Ben Wagner63fd7602017-10-09 15:45:33 -0400491 }
492
robertphillips05a4cf52016-09-08 09:02:43 -0700493 return false;
494 }
495
496 bool onAnimate(const SkAnimTimer& timer) override {
robertphillipsf619a7a2016-09-12 17:25:50 -0700497 if (!fPause) {
498 fFraction = timer.pingPong(kPeriod, 0.0f, 0.0f, 1.0f);
499 }
robertphillips05a4cf52016-09-08 09:02:43 -0700500 return true;
501 }
502
503private:
Robert Phillipsa29a9562016-10-20 09:40:55 -0400504 SkScalar fFraction;
505 Mode fMode;
506 bool fPause;
507 float fBlurRadius;
508 CoverageGeom fCoverageGeom;
robertphillips05a4cf52016-09-08 09:02:43 -0700509
510 typedef GM INHERITED;
511};
512
513//////////////////////////////////////////////////////////////////////////////
514
515DEF_GM(return new RevealGM;)
516}