Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: tests/ClampRangeTest.cpp

Issue 243563002: remove unused fOverflowed from SkClampRange (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/effects/gradients/SkClampRange.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 return 0; 43 return 0;
44 } 44 }
45 45
46 #define V0 -42 46 #define V0 -42
47 #define V1 1024 47 #define V1 1024
48 48
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 int i; 53 for (int i = 0; i < range.fCount0; i++) {
54 if (range.fOverflowed) { 54 int v = classify_value(fx, V0, V1);
55 fx = range.fFx1; 55 R_ASSERT(v == range.fV0);
56 for (i = 0; i < range.fCount1; i++) { 56 fx += dx;
57 R_ASSERT(fx >= 0 && fx <= 0xFFFF); 57 }
58 fx += dx; 58 if (range.fCount1 > 0 && fx != range.fFx1) {
59 } 59 SkDebugf("%x %x\n", fx, range.fFx1);
60 } else { 60 R_ASSERT(false); // bad fFx1
61 for (i = 0; i < range.fCount0; i++) { 61 return;
62 int v = classify_value(fx, V0, V1); 62 }
63 R_ASSERT(v == range.fV0); 63 for (int i = 0; i < range.fCount1; i++) {
64 fx += dx; 64 R_ASSERT(fx >= 0 && fx <= 0xFFFF);
65 } 65 fx += dx;
66 if (range.fCount1 > 0 && fx != range.fFx1) { 66 }
67 SkDebugf("%x %x\n", fx, range.fFx1); 67 for (int i = 0; i < range.fCount2; i++) {
68 R_ASSERT(false); // bad fFx1 68 int v = classify_value(fx, V0, V1);
69 return; 69 R_ASSERT(v == range.fV1);
70 } 70 fx += dx;
71 for (i = 0; i < range.fCount1; i++) {
72 R_ASSERT(fx >= 0 && fx <= 0xFFFF);
73 fx += dx;
74 }
75 for (i = 0; i < range.fCount2; i++) {
76 int v = classify_value(fx, V0, V1);
77 R_ASSERT(v == range.fV1);
78 fx += dx;
79 }
80 } 71 }
81 } 72 }
82 73
83 74
84 static void test_range(SkFixed fx, SkFixed dx, int count) { 75 static void test_range(SkFixed fx, SkFixed dx, int count) {
85 SkClampRange range; 76 SkClampRange range;
86 range.init(fx, dx, count, V0, V1); 77 range.init(fx, dx, count, V0, V1);
87 slow_check(range, fx, dx, count); 78 slow_check(range, fx, dx, count);
88 } 79 }
89 80
(...skipping 29 matching lines...) Expand all
119 } 110 }
120 111
121 // test overflow cases 112 // test overflow cases
122 for (int i = 0; i < 100000; i++) { 113 for (int i = 0; i < 100000; i++) {
123 SkFixed fx = rand.nextS(); 114 SkFixed fx = rand.nextS();
124 SkFixed dx = rand.nextS(); 115 SkFixed dx = rand.nextS();
125 int count = rand.nextU() % 1000 + 1; 116 int count = rand.nextU() % 1000 + 1;
126 test_range(fx, dx, count); 117 test_range(fx, dx, count);
127 } 118 }
128 } 119 }
OLDNEW
« no previous file with comments | « src/effects/gradients/SkClampRange.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698