| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "SkFloatBits.h" | 9 #include "SkFloatBits.h" |
| 10 #include "SkFloatingPoint.h" | 10 #include "SkFloatingPoint.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 for (int src = 0; src <= 255; src++) { | 137 for (int src = 0; src <= 255; src++) { |
| 138 for (int dst = 0; dst <= 255; dst++) { | 138 for (int dst = 0; dst <= 255; dst++) { |
| 139 for (int a = 0; a <= 31; a++) { | 139 for (int a = 0; a <= 31; a++) { |
| 140 // int r0 = blend31(src, dst, a); | 140 // int r0 = blend31(src, dst, a); |
| 141 // int r0 = blend31_round(src, dst, a); | 141 // int r0 = blend31_round(src, dst, a); |
| 142 // int r0 = blend31_old(src, dst, a); | 142 // int r0 = blend31_old(src, dst, a); |
| 143 int r0 = blend31_slow(src, dst, a); | 143 int r0 = blend31_slow(src, dst, a); |
| 144 | 144 |
| 145 float f = float_blend(src, dst, a / 31.f); | 145 float f = float_blend(src, dst, a / 31.f); |
| 146 int r1 = (int)f; | 146 int r1 = (int)f; |
| 147 int r2 = SkScalarRoundToInt(SkFloatToScalar(f)); | 147 int r2 = SkScalarRoundToInt(f); |
| 148 | 148 |
| 149 if (r0 != r1 && r0 != r2) { | 149 if (r0 != r1 && r0 != r2) { |
| 150 SkDebugf("src:%d dst:%d a:%d result:%d float:%g\n", | 150 SkDebugf("src:%d dst:%d a:%d result:%d float:%g\n", |
| 151 src, dst, a, r0, f); | 151 src, dst, a, r0, f); |
| 152 failed += 1; | 152 failed += 1; |
| 153 } | 153 } |
| 154 if (r0 > 255) { | 154 if (r0 > 255) { |
| 155 death += 1; | 155 death += 1; |
| 156 SkDebugf("death src:%d dst:%d a:%d result:%d float:%g\n", | 156 SkDebugf("death src:%d dst:%d a:%d result:%d float:%g\n", |
| 157 src, dst, a, r0, f); | 157 src, dst, a, r0, f); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 SkDebugf("---- failed %d death %d\n", failed, death); | 162 SkDebugf("---- failed %d death %d\n", failed, death); |
| 163 } | 163 } |
| 164 | 164 |
| 165 static void test_blend(skiatest::Reporter* reporter) { | 165 static void test_blend(skiatest::Reporter* reporter) { |
| 166 for (int src = 0; src <= 255; src++) { | 166 for (int src = 0; src <= 255; src++) { |
| 167 for (int dst = 0; dst <= 255; dst++) { | 167 for (int dst = 0; dst <= 255; dst++) { |
| 168 for (int a = 0; a <= 255; a++) { | 168 for (int a = 0; a <= 255; a++) { |
| 169 int r0 = SkAlphaBlend255(src, dst, a); | 169 int r0 = SkAlphaBlend255(src, dst, a); |
| 170 float f1 = float_blend(src, dst, a / 255.f); | 170 float f1 = float_blend(src, dst, a / 255.f); |
| 171 int r1 = SkScalarRoundToInt(SkFloatToScalar(f1)); | 171 int r1 = SkScalarRoundToInt(f1); |
| 172 | 172 |
| 173 if (r0 != r1) { | 173 if (r0 != r1) { |
| 174 float diff = sk_float_abs(f1 - r1); | 174 float diff = sk_float_abs(f1 - r1); |
| 175 diff = sk_float_abs(diff - 0.5f); | 175 diff = sk_float_abs(diff - 0.5f); |
| 176 if (diff > (1 / 255.f)) { | 176 if (diff > (1 / 255.f)) { |
| 177 #ifdef SK_DEBUG | 177 #ifdef SK_DEBUG |
| 178 SkDebugf("src:%d dst:%d a:%d result:%d float:%g\n", | 178 SkDebugf("src:%d dst:%d a:%d result:%d float:%g\n", |
| 179 src, dst, a, r0, f1); | 179 src, dst, a, r0, f1); |
| 180 #endif | 180 #endif |
| 181 REPORTER_ASSERT(reporter, false); | 181 REPORTER_ASSERT(reporter, false); |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 test_divmod<int16_t>(r); | 755 test_divmod<int16_t>(r); |
| 756 } | 756 } |
| 757 | 757 |
| 758 DEF_TEST(divmod_s32, r) { | 758 DEF_TEST(divmod_s32, r) { |
| 759 test_divmod<int32_t>(r); | 759 test_divmod<int32_t>(r); |
| 760 } | 760 } |
| 761 | 761 |
| 762 DEF_TEST(divmod_s64, r) { | 762 DEF_TEST(divmod_s64, r) { |
| 763 test_divmod<int64_t>(r); | 763 test_divmod<int64_t>(r); |
| 764 } | 764 } |
| OLD | NEW |