OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkRandom.h" | 8 #include "SkRandom.h" |
9 #include "Test.h" | 9 #include "Test.h" |
10 #include "gradients/SkClampRange.h" | 10 #include "gradients/SkClampRange.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 static void slow_check(const SkClampRange& range, | 49 static void slow_check(const SkClampRange& range, |
50 SkFixed fx, SkFixed dx, int count) { | 50 SkFixed fx, SkFixed dx, int count) { |
51 SkASSERT(range.fCount0 + range.fCount1 + range.fCount2 == count); | 51 SkASSERT(range.fCount0 + range.fCount1 + range.fCount2 == count); |
52 | 52 |
53 for (int i = 0; i < range.fCount0; i++) { | 53 for (int i = 0; i < range.fCount0; i++) { |
54 int v = classify_value(fx, V0, V1); | 54 int v = classify_value(fx, V0, V1); |
55 R_ASSERT(v == range.fV0); | 55 R_ASSERT(v == range.fV0); |
56 fx += dx; | 56 fx += dx; |
57 } | 57 } |
58 if (range.fCount1 > 0 && fx != range.fFx1) { | 58 if (range.fCount1 > 0 && fx != range.fFx1) { |
59 SkDebugf("%x %x\n", fx, range.fFx1); | 59 // SkDebugf("%x %x\n", fx, range.fFx1); |
60 R_ASSERT(false); // bad fFx1 | 60 R_ASSERT(false); // bad fFx1 |
61 return; | 61 return; |
62 } | 62 } |
63 for (int i = 0; i < range.fCount1; i++) { | 63 for (int i = 0; i < range.fCount1; i++) { |
64 R_ASSERT(fx >= 0 && fx <= 0xFFFF); | 64 R_ASSERT(fx >= 0 && fx <= 0xFFFF); |
65 fx += dx; | 65 fx += dx; |
66 } | 66 } |
67 for (int i = 0; i < range.fCount2; i++) { | 67 for (int i = 0; i < range.fCount2; i++) { |
68 int v = classify_value(fx, V0, V1); | 68 int v = classify_value(fx, V0, V1); |
69 R_ASSERT(v == range.fV1); | 69 R_ASSERT(v == range.fV1); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 // test overflow cases | 112 // test overflow cases |
113 for (int i = 0; i < 100000; i++) { | 113 for (int i = 0; i < 100000; i++) { |
114 SkFixed fx = rand.nextS(); | 114 SkFixed fx = rand.nextS(); |
115 SkFixed dx = rand.nextS(); | 115 SkFixed dx = rand.nextS(); |
116 int count = rand.nextU() % 1000 + 1; | 116 int count = rand.nextU() % 1000 + 1; |
117 test_range(fx, dx, count); | 117 test_range(fx, dx, count); |
118 } | 118 } |
119 } | 119 } |
OLD | NEW |