OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SampleCode.h" | 9 #include "SampleCode.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 fCurRects = &fRects[0]; | 46 fCurRects = &fRects[0]; |
47 | 47 |
48 fRectanizers[0] = new GrRectanizerPow2(kWidth, kHeight); | 48 fRectanizers[0] = new GrRectanizerPow2(kWidth, kHeight); |
49 fRectanizers[1] = new GrRectanizerSkyline(kWidth, kHeight); | 49 fRectanizers[1] = new GrRectanizerSkyline(kWidth, kHeight); |
50 fCurRectanizer = fRectanizers[0]; | 50 fCurRectanizer = fRectanizers[0]; |
51 } | 51 } |
52 | 52 |
53 protected: | 53 protected: |
54 virtual bool onQuery(SkEvent* evt) SK_OVERRIDE { | 54 bool onQuery(SkEvent* evt) SK_OVERRIDE { |
55 if (SampleCode::TitleQ(*evt)) { | 55 if (SampleCode::TitleQ(*evt)) { |
56 SampleCode::TitleR(evt, "Rectanizer"); | 56 SampleCode::TitleR(evt, "Rectanizer"); |
57 return true; | 57 return true; |
58 } | 58 } |
59 SkUnichar uni; | 59 SkUnichar uni; |
60 if (SampleCode::CharQ(*evt, &uni)) { | 60 if (SampleCode::CharQ(*evt, &uni)) { |
61 char utf8[kMaxBytesInUTF8Sequence]; | 61 char utf8[kMaxBytesInUTF8Sequence]; |
62 size_t size = SkUTF8_FromUnichar(uni, utf8); | 62 size_t size = SkUTF8_FromUnichar(uni, utf8); |
63 // Only consider events for single char keys | 63 // Only consider events for single char keys |
64 if (1 == size) { | 64 if (1 == size) { |
65 switch (utf8[0]) { | 65 switch (utf8[0]) { |
66 case kCycleRectanizerKey: | 66 case kCycleRectanizerKey: |
67 this->cycleRectanizer(); | 67 this->cycleRectanizer(); |
68 return true; | 68 return true; |
69 case kCycleRectsKey: | 69 case kCycleRectsKey: |
70 this->cycleRects(); | 70 this->cycleRects(); |
71 return true; | 71 return true; |
72 default: | 72 default: |
73 break; | 73 break; |
74 } | 74 } |
75 } | 75 } |
76 } | 76 } |
77 return this->INHERITED::onQuery(evt); | 77 return this->INHERITED::onQuery(evt); |
78 } | 78 } |
79 | 79 |
80 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 80 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { |
81 if (fCurRandRect < kNumRandRects) { | 81 if (fCurRandRect < kNumRandRects) { |
82 if (fCurRectanizer->addRect((*fCurRects)[fCurRandRect].fWidth, | 82 if (fCurRectanizer->addRect((*fCurRects)[fCurRandRect].fWidth, |
83 (*fCurRects)[fCurRandRect].fHeight, | 83 (*fCurRects)[fCurRandRect].fHeight, |
84 &fRectLocations[fCurRandRect])) { | 84 &fRectLocations[fCurRandRect])) { |
85 ++fCurRandRect; | 85 ++fCurRandRect; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 SkPaint blackBigFont; | 89 SkPaint blackBigFont; |
90 blackBigFont.setTextSize(20); | 90 blackBigFont.setTextSize(20); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 | 190 |
191 typedef SampleView INHERITED; | 191 typedef SampleView INHERITED; |
192 }; | 192 }; |
193 | 193 |
194 ////////////////////////////////////////////////////////////////////////////// | 194 ////////////////////////////////////////////////////////////////////////////// |
195 static SkView* MyFactory() { return new RectanizerView; } | 195 static SkView* MyFactory() { return new RectanizerView; } |
196 static SkViewRegister reg(MyFactory); | 196 static SkViewRegister reg(MyFactory); |
197 | 197 |
198 #endif | 198 #endif |
OLD | NEW |