OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkGraphics.h" | 10 #include "SkGraphics.h" |
11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
12 #include "SkLayerDrawLooper.h" | 12 #include "SkLayerDrawLooper.h" |
13 #include "SkBlurMaskFilter.h" | 13 #include "SkBlurMaskFilter.h" |
14 | 14 |
15 static SkRect inset(const SkRect& r) { | 15 static SkRect inset(const SkRect& r) { |
16 SkRect rect = r; | 16 SkRect rect = r; |
17 rect.inset(r.width() / 8, r.height() / 8); | 17 rect.inset(r.width() / 8, r.height() / 8); |
18 return rect; | 18 return rect; |
19 } | 19 } |
20 | 20 |
21 class PathInteriorGM : public skiagm::GM { | 21 class PathInteriorGM : public skiagm::GM { |
22 public: | 22 public: |
23 PathInteriorGM() { | 23 PathInteriorGM() { |
24 this->setBGColor(0xFFDDDDDD); | 24 this->setBGColor(0xFFDDDDDD); |
25 } | 25 } |
26 | 26 |
27 protected: | 27 protected: |
28 SkISize onISize() SK_OVERRIDE { | 28 SkISize onISize() override { |
29 return SkISize::Make(770, 770); | 29 return SkISize::Make(770, 770); |
30 } | 30 } |
31 | 31 |
32 SkString onShortName() SK_OVERRIDE { | 32 SkString onShortName() override { |
33 return SkString("pathinterior"); | 33 return SkString("pathinterior"); |
34 } | 34 } |
35 | 35 |
36 void show(SkCanvas* canvas, const SkPath& path) { | 36 void show(SkCanvas* canvas, const SkPath& path) { |
37 SkPaint paint; | 37 SkPaint paint; |
38 paint.setAntiAlias(true); | 38 paint.setAntiAlias(true); |
39 | 39 |
40 SkRect rect; | 40 SkRect rect; |
41 #if 0 | 41 #if 0 |
42 bool hasInterior = path.hasRectangularInterior(&rect); | 42 bool hasInterior = path.hasRectangularInterior(&rect); |
43 #else | 43 #else |
44 bool hasInterior = false; | 44 bool hasInterior = false; |
45 #endif | 45 #endif |
46 | 46 |
47 paint.setColor(hasInterior ? 0xFF8888FF : SK_ColorGRAY); | 47 paint.setColor(hasInterior ? 0xFF8888FF : SK_ColorGRAY); |
48 canvas->drawPath(path, paint); | 48 canvas->drawPath(path, paint); |
49 paint.setStyle(SkPaint::kStroke_Style); | 49 paint.setStyle(SkPaint::kStroke_Style); |
50 paint.setColor(SK_ColorRED); | 50 paint.setColor(SK_ColorRED); |
51 canvas->drawPath(path, paint); | 51 canvas->drawPath(path, paint); |
52 | 52 |
53 if (hasInterior) { | 53 if (hasInterior) { |
54 paint.setStyle(SkPaint::kFill_Style); | 54 paint.setStyle(SkPaint::kFill_Style); |
55 paint.setColor(0x8800FF00); | 55 paint.setColor(0x8800FF00); |
56 canvas->drawRect(rect, paint); | 56 canvas->drawRect(rect, paint); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 60 void onDraw(SkCanvas* canvas) override { |
61 canvas->translate(8.5f, 8.5f); | 61 canvas->translate(8.5f, 8.5f); |
62 | 62 |
63 const SkRect rect = { 0, 0, 80, 80 }; | 63 const SkRect rect = { 0, 0, 80, 80 }; |
64 const SkScalar RAD = rect.width()/8; | 64 const SkScalar RAD = rect.width()/8; |
65 | 65 |
66 int i = 0; | 66 int i = 0; |
67 for (int insetFirst = 0; insetFirst <= 1; ++insetFirst) { | 67 for (int insetFirst = 0; insetFirst <= 1; ++insetFirst) { |
68 for (int doEvenOdd = 0; doEvenOdd <= 1; ++doEvenOdd) { | 68 for (int doEvenOdd = 0; doEvenOdd <= 1; ++doEvenOdd) { |
69 for (int outerRR = 0; outerRR <= 1; ++outerRR) { | 69 for (int outerRR = 0; outerRR <= 1; ++outerRR) { |
70 for (int innerRR = 0; innerRR <= 1; ++innerRR) { | 70 for (int innerRR = 0; innerRR <= 1; ++innerRR) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 private: | 105 private: |
106 | 106 |
107 typedef GM INHERITED; | 107 typedef GM INHERITED; |
108 }; | 108 }; |
109 | 109 |
110 ////////////////////////////////////////////////////////////////////////////// | 110 ////////////////////////////////////////////////////////////////////////////// |
111 | 111 |
112 static skiagm::GM* MyFactory(void*) { return new PathInteriorGM; } | 112 static skiagm::GM* MyFactory(void*) { return new PathInteriorGM; } |
113 static skiagm::GMRegistry reg(MyFactory); | 113 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |