| 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 22 matching lines...) Expand all Loading... |
| 33 fRectLocations.setReserve(kNumRandRects); | 33 fRectLocations.setReserve(kNumRandRects); |
| 34 | 34 |
| 35 SkRandom random; | 35 SkRandom random; |
| 36 for (int i = 0; i < kNumRandRects; ++i) { | 36 for (int i = 0; i < kNumRandRects; ++i) { |
| 37 *fRects[0].append() = SkISize::Make(random.nextRangeU(kMinRectSize,
kMaxRectSize), | 37 *fRects[0].append() = SkISize::Make(random.nextRangeU(kMinRectSize,
kMaxRectSize), |
| 38 random.nextRangeU(kMinRectSize,
kMaxRectSize)); | 38 random.nextRangeU(kMinRectSize,
kMaxRectSize)); |
| 39 *fRects[1].append() = SkISize::Make( | 39 *fRects[1].append() = SkISize::Make( |
| 40 GrNextPow2(random.nextRangeU(kMinRectSize, kMaxRectSize)
), | 40 GrNextPow2(random.nextRangeU(kMinRectSize, kMaxRectSize)
), |
| 41 GrNextPow2(random.nextRangeU(kMinRectSize, kMaxRectSize)
)); | 41 GrNextPow2(random.nextRangeU(kMinRectSize, kMaxRectSize)
)); |
| 42 *fRects[2].append() = SkISize::Make(128, 128); | 42 *fRects[2].append() = SkISize::Make(128, 128); |
| 43 *fRectLocations.append() = GrIPoint16::Make(0, 0); | 43 *fRectLocations.append() = SkIPoint16::Make(0, 0); |
| 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: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 static const int kHeight = 1024; | 135 static const int kHeight = 1024; |
| 136 static const int kNumRandRects = 200; | 136 static const int kNumRandRects = 200; |
| 137 static const char kCycleRectanizerKey = 'j'; | 137 static const char kCycleRectanizerKey = 'j'; |
| 138 static const char kCycleRectsKey = 'h'; | 138 static const char kCycleRectsKey = 'h'; |
| 139 static const int kMinRectSize = 2; | 139 static const int kMinRectSize = 2; |
| 140 static const int kMaxRectSize = 256; | 140 static const int kMaxRectSize = 256; |
| 141 | 141 |
| 142 int fCurRandRect; | 142 int fCurRandRect; |
| 143 SkTDArray<SkISize> fRects[3]; | 143 SkTDArray<SkISize> fRects[3]; |
| 144 SkTDArray<SkISize>* fCurRects; | 144 SkTDArray<SkISize>* fCurRects; |
| 145 SkTDArray<GrIPoint16> fRectLocations; | 145 SkTDArray<SkIPoint16> fRectLocations; |
| 146 GrRectanizer* fRectanizers[2]; | 146 GrRectanizer* fRectanizers[2]; |
| 147 GrRectanizer* fCurRectanizer; | 147 GrRectanizer* fCurRectanizer; |
| 148 | 148 |
| 149 const char* getRectanizerName() const { | 149 const char* getRectanizerName() const { |
| 150 if (fCurRectanizer == fRectanizers[0]) { | 150 if (fCurRectanizer == fRectanizers[0]) { |
| 151 return "Pow2"; | 151 return "Pow2"; |
| 152 } else { | 152 } else { |
| 153 return "Skyline"; | 153 return "Skyline"; |
| 154 } | 154 } |
| 155 } | 155 } |
| (...skipping 33 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 |