aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/effects/gradients/SkClampRange.cpp5
-rw-r--r--src/effects/gradients/SkClampRange.h1
-rw-r--r--tests/ClampRangeTest.cpp45
3 files changed, 19 insertions, 32 deletions
diff --git a/src/effects/gradients/SkClampRange.cpp b/src/effects/gradients/SkClampRange.cpp
index 3e2ca8e932..398b02434f 100644
--- a/src/effects/gradients/SkClampRange.cpp
+++ b/src/effects/gradients/SkClampRange.cpp
@@ -50,7 +50,6 @@ void SkClampRange::init(SkFixed fx0, SkFixed dx0, int count, int v0, int v1) {
fV0 = v0;
fV1 = v1;
- fOverflowed = false;
// special case 1 == count, as it is slightly common for skia
// and avoids us ever calling divide or 64bit multiply
@@ -63,7 +62,6 @@ void SkClampRange::init(SkFixed fx0, SkFixed dx0, int count, int v0, int v1) {
int64_t dx = dx0;
// start with ex equal to the last computed value
int64_t ex = fx + (count - 1) * dx;
- fOverflowed = overflows_fixed(ex);
if ((uint64_t)(fx | ex) <= 0xFFFF) {
fCount0 = fCount2 = 0;
@@ -86,9 +84,8 @@ void SkClampRange::init(SkFixed fx0, SkFixed dx0, int count, int v0, int v1) {
// now make ex be 1 past the last computed value
ex += dx;
- fOverflowed = overflows_fixed(ex);
// now check for over/under flow
- if (fOverflowed) {
+ if (overflows_fixed(ex)) {
int originalCount = count;
int64_t ccount;
bool swap = dx < 0;
diff --git a/src/effects/gradients/SkClampRange.h b/src/effects/gradients/SkClampRange.h
index 376dc93b4b..09386d7e71 100644
--- a/src/effects/gradients/SkClampRange.h
+++ b/src/effects/gradients/SkClampRange.h
@@ -27,7 +27,6 @@ struct SkClampRange {
SkFixed fFx1; // initial fx value for the fCount1 range.
// only valid if fCount1 > 0
int fV0, fV1;
- bool fOverflowed; // true if we had to clamp due to numerical overflow
void init(SkFixed fx, SkFixed dx, int count, int v0, int v1);
diff --git a/tests/ClampRangeTest.cpp b/tests/ClampRangeTest.cpp
index b8059bc485..28fcffc5e7 100644
--- a/tests/ClampRangeTest.cpp
+++ b/tests/ClampRangeTest.cpp
@@ -50,33 +50,24 @@ static void slow_check(const SkClampRange& range,
SkFixed fx, SkFixed dx, int count) {
SkASSERT(range.fCount0 + range.fCount1 + range.fCount2 == count);
- int i;
- if (range.fOverflowed) {
- fx = range.fFx1;
- for (i = 0; i < range.fCount1; i++) {
- R_ASSERT(fx >= 0 && fx <= 0xFFFF);
- fx += dx;
- }
- } else {
- for (i = 0; i < range.fCount0; i++) {
- int v = classify_value(fx, V0, V1);
- R_ASSERT(v == range.fV0);
- fx += dx;
- }
- if (range.fCount1 > 0 && fx != range.fFx1) {
- SkDebugf("%x %x\n", fx, range.fFx1);
- R_ASSERT(false); // bad fFx1
- return;
- }
- for (i = 0; i < range.fCount1; i++) {
- R_ASSERT(fx >= 0 && fx <= 0xFFFF);
- fx += dx;
- }
- for (i = 0; i < range.fCount2; i++) {
- int v = classify_value(fx, V0, V1);
- R_ASSERT(v == range.fV1);
- fx += dx;
- }
+ for (int i = 0; i < range.fCount0; i++) {
+ int v = classify_value(fx, V0, V1);
+ R_ASSERT(v == range.fV0);
+ fx += dx;
+ }
+ if (range.fCount1 > 0 && fx != range.fFx1) {
+ SkDebugf("%x %x\n", fx, range.fFx1);
+ R_ASSERT(false); // bad fFx1
+ return;
+ }
+ for (int i = 0; i < range.fCount1; i++) {
+ R_ASSERT(fx >= 0 && fx <= 0xFFFF);
+ fx += dx;
+ }
+ for (int i = 0; i < range.fCount2; i++) {
+ int v = classify_value(fx, V0, V1);
+ R_ASSERT(v == range.fV1);
+ fx += dx;
}
}