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 #if SK_SUPPORT_GPU | 8 #if SK_SUPPORT_GPU |
9 | 9 |
10 #include "GrRectanizer_pow2.h" | 10 #include "GrRectanizer_pow2.h" |
11 #include "GrRectanizer_skyline.h" | 11 #include "GrRectanizer_skyline.h" |
12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
13 #include "SkSize.h" | 13 #include "SkSize.h" |
14 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
15 #include "Test.h" | 15 #include "Test.h" |
16 | 16 |
17 static const int kWidth = 1000; | 17 static const int kWidth = 1000; |
18 static const int kHeight = 1000; | 18 static const int kHeight = 1000; |
19 | 19 |
20 // Basic test of a GrRectanizer-derived class' functionality | 20 // Basic test of a GrRectanizer-derived class' functionality |
21 static void test_rectanizer_basic(skiatest::Reporter* reporter, GrRectanizer* re
ctanizer) { | 21 static void test_rectanizer_basic(skiatest::Reporter* reporter, GrRectanizer* re
ctanizer) { |
22 REPORTER_ASSERT(reporter, kWidth == rectanizer->width()); | 22 REPORTER_ASSERT(reporter, kWidth == rectanizer->width()); |
23 REPORTER_ASSERT(reporter, kHeight == rectanizer->height()); | 23 REPORTER_ASSERT(reporter, kHeight == rectanizer->height()); |
24 | 24 |
25 GrIPoint16 loc; | 25 SkIPoint16 loc; |
26 | 26 |
27 REPORTER_ASSERT(reporter, rectanizer->addRect(50, 50, &loc)); | 27 REPORTER_ASSERT(reporter, rectanizer->addRect(50, 50, &loc)); |
28 REPORTER_ASSERT(reporter, rectanizer->percentFull() > 0.0f); | 28 REPORTER_ASSERT(reporter, rectanizer->percentFull() > 0.0f); |
29 rectanizer->reset(); | 29 rectanizer->reset(); |
30 REPORTER_ASSERT(reporter, rectanizer->percentFull() == 0.0f); | 30 REPORTER_ASSERT(reporter, rectanizer->percentFull() == 0.0f); |
31 } | 31 } |
32 | 32 |
33 static void test_rectanizer_inserts(skiatest::Reporter*, | 33 static void test_rectanizer_inserts(skiatest::Reporter*, |
34 GrRectanizer* rectanizer, | 34 GrRectanizer* rectanizer, |
35 const SkTDArray<SkISize>& rects) { | 35 const SkTDArray<SkISize>& rects) { |
36 int i; | 36 int i; |
37 for (i = 0; i < rects.count(); ++i) { | 37 for (i = 0; i < rects.count(); ++i) { |
38 GrIPoint16 loc; | 38 SkIPoint16 loc; |
39 if (!rectanizer->addRect(rects[i].fWidth, rects[i].fHeight, &loc)) { | 39 if (!rectanizer->addRect(rects[i].fWidth, rects[i].fHeight, &loc)) { |
40 break; | 40 break; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 //SkDebugf("\n***%d %f\n", i, rectanizer->percentFull()); | 44 //SkDebugf("\n***%d %f\n", i, rectanizer->percentFull()); |
45 } | 45 } |
46 | 46 |
47 static void test_skyline(skiatest::Reporter* reporter, const SkTDArray<SkISize>&
rects) { | 47 static void test_skyline(skiatest::Reporter* reporter, const SkTDArray<SkISize>&
rects) { |
48 GrRectanizerSkyline skylineRectanizer(kWidth, kHeight); | 48 GrRectanizerSkyline skylineRectanizer(kWidth, kHeight); |
(...skipping 16 matching lines...) Expand all Loading... |
65 for (int i = 0; i < 50; i++) { | 65 for (int i = 0; i < 50; i++) { |
66 fRects.push(SkISize::Make(rand.nextRangeU(1, kWidth / 2), | 66 fRects.push(SkISize::Make(rand.nextRangeU(1, kWidth / 2), |
67 rand.nextRangeU(1, kHeight / 2))); | 67 rand.nextRangeU(1, kHeight / 2))); |
68 } | 68 } |
69 | 69 |
70 test_skyline(reporter, fRects); | 70 test_skyline(reporter, fRects); |
71 test_pow2(reporter, fRects); | 71 test_pow2(reporter, fRects); |
72 } | 72 } |
73 | 73 |
74 #endif | 74 #endif |
OLD | NEW |