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 "Test.h" | 8 #include "Test.h" |
9 #include "TestClassDef.h" | 9 #include "TestClassDef.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 SkLONGLONG w = wide.getLongLong(); | 167 SkLONGLONG w = wide.getLongLong(); |
168 | 168 |
169 REPORTER_ASSERT(reporter, check == w); | 169 REPORTER_ASSERT(reporter, check == w); |
170 | 170 |
171 wide.setMul(rand.nextS(), rand.nextS()); | 171 wide.setMul(rand.nextS(), rand.nextS()); |
172 wide.abs(); | 172 wide.abs(); |
173 denom = wide.getSqrt(); | 173 denom = wide.getSqrt(); |
174 int32_t ck = (int32_t)sqrt((double)wide.getLongLong()); | 174 int32_t ck = (int32_t)sqrt((double)wide.getLongLong()); |
175 int diff = denom - ck; | 175 int diff = denom - ck; |
176 REPORTER_ASSERT(reporter, SkAbs32(diff) <= 1); | 176 REPORTER_ASSERT(reporter, SkAbs32(diff) <= 1); |
177 | |
178 wide.setMul(rand.nextS(), rand.nextS()); | |
179 Sk64 dwide; | |
180 dwide.setMul(rand.nextS(), rand.nextS()); | |
181 SkFixed fixdiv = wide.getFixedDiv(dwide); | |
182 double dnumer = (double)wide.getLongLong(); | |
183 double ddenom = (double)dwide.getLongLong(); | |
184 double ddiv = dnumer / ddenom; | |
185 SkFixed dfixdiv; | |
186 if (ddiv >= (double)SK_MaxS32 / (double)SK_Fixed1) | |
187 dfixdiv = SK_MaxS32; | |
188 else if (ddiv <= -(double)SK_MaxS32 / (double)SK_Fixed1) | |
189 dfixdiv = SK_MinS32; | |
190 else | |
191 dfixdiv = SkFloatToFixed(dnumer / ddenom); | |
192 diff = fixdiv - dfixdiv; | |
193 | |
194 if (SkAbs32(diff) > 1) { | |
195 SkDebugf(" %d === numer %g denom %g div %g xdiv %x fxdiv %x\n", | |
196 i, dnumer, ddenom, ddiv, dfixdiv, fixdiv); | |
197 } | |
198 REPORTER_ASSERT(reporter, SkAbs32(diff) <= 1); | |
199 } | 177 } |
200 #endif | 178 #endif |
201 } | 179 } |
OLD | NEW |