OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkPath.h" | 10 #include "SkPath.h" |
11 | 11 |
12 class CircularClipsGM : public skiagm::GM { | 12 class CircularClipsGM : public skiagm::GM { |
13 SkScalar fX1, fX2, fY, fR; | 13 SkScalar fX1, fX2, fY, fR; |
14 SkPath fCircle1, fCircle2; | 14 SkPath fCircle1, fCircle2; |
15 | 15 |
16 public: | 16 public: |
17 CircularClipsGM() { | 17 CircularClipsGM() { |
18 fX1 = 80; | 18 fX1 = 80; |
19 fX2 = 120; | 19 fX2 = 120; |
20 fY = 50; | 20 fY = 50; |
21 fR = 40; | 21 fR = 40; |
22 | 22 |
23 fCircle1.addCircle(fX1, fY, fR, SkPath::kCW_Direction); | 23 fCircle1.addCircle(fX1, fY, fR, SkPath::kCW_Direction); |
24 fCircle2.addCircle(fX2, fY, fR, SkPath::kCW_Direction); | 24 fCircle2.addCircle(fX2, fY, fR, SkPath::kCW_Direction); |
25 } | 25 } |
26 | 26 |
27 protected: | 27 protected: |
28 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 28 uint32_t onGetFlags() const SK_OVERRIDE { |
29 return kSkipTiled_Flag | kAsBench_Flag; | 29 return kSkipTiled_Flag | kAsBench_Flag; |
30 } | 30 } |
31 | 31 |
32 virtual SkString onShortName() SK_OVERRIDE { | 32 SkString onShortName() SK_OVERRIDE { |
33 return SkString("circular-clips"); | 33 return SkString("circular-clips"); |
34 } | 34 } |
35 | 35 |
36 virtual SkISize onISize() SK_OVERRIDE { | 36 SkISize onISize() SK_OVERRIDE { |
37 return SkISize::Make(800, 600); | 37 return SkISize::Make(800, 600); |
38 } | 38 } |
39 | 39 |
40 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 40 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
41 SkRegion::Op ops[] = { | 41 SkRegion::Op ops[] = { |
42 SkRegion::kDifference_Op, | 42 SkRegion::kDifference_Op, |
43 SkRegion::kIntersect_Op, | 43 SkRegion::kIntersect_Op, |
44 SkRegion::kUnion_Op, | 44 SkRegion::kUnion_Op, |
45 SkRegion::kXOR_Op, | 45 SkRegion::kXOR_Op, |
46 SkRegion::kReverseDifference_Op, | 46 SkRegion::kReverseDifference_Op, |
47 SkRegion::kReplace_Op, | 47 SkRegion::kReplace_Op, |
48 }; | 48 }; |
49 | 49 |
50 SkRect rect = SkRect::MakeLTRB(fX1 - fR, fY - fR, fX2 + fR, fY + fR); | 50 SkRect rect = SkRect::MakeLTRB(fX1 - fR, fY - fR, fX2 + fR, fY + fR); |
(...skipping 23 matching lines...) Expand all Loading... |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 private: | 77 private: |
78 typedef skiagm::GM INHERITED; | 78 typedef skiagm::GM INHERITED; |
79 }; | 79 }; |
80 | 80 |
81 ////////////////////////////////////////////////////////////////////////////// | 81 ////////////////////////////////////////////////////////////////////////////// |
82 | 82 |
83 DEF_GM( return new CircularClipsGM; ) | 83 DEF_GM( return new CircularClipsGM; ) |
OLD | NEW |