OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "DataTypes.h" | 7 #include "DataTypes.h" |
8 | 8 |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 20 matching lines...) Expand all Loading... |
31 { | 31 { |
32 Float_t(float num = 0.0f) : f(num) {} | 32 Float_t(float num = 0.0f) : f(num) {} |
33 // Portable extraction of components. | 33 // Portable extraction of components. |
34 bool negative() const { return (i >> 31) != 0; } | 34 bool negative() const { return (i >> 31) != 0; } |
35 #if 0 // unused | 35 #if 0 // unused |
36 int32_t RawMantissa() const { return i & ((1 << 23) - 1); } | 36 int32_t RawMantissa() const { return i & ((1 << 23) - 1); } |
37 int32_t RawExponent() const { return (i >> 23) & 0xFF; } | 37 int32_t RawExponent() const { return (i >> 23) & 0xFF; } |
38 #endif | 38 #endif |
39 int32_t i; | 39 int32_t i; |
40 float f; | 40 float f; |
41 #if SK_DEBUG | 41 #ifdef SK_DEBUG |
42 struct | 42 struct |
43 { // Bitfields for exploration. Do not use in production code. | 43 { // Bitfields for exploration. Do not use in production code. |
44 uint32_t mantissa : 23; | 44 uint32_t mantissa : 23; |
45 uint32_t exponent : 8; | 45 uint32_t exponent : 8; |
46 uint32_t sign : 1; | 46 uint32_t sign : 1; |
47 } parts; | 47 } parts; |
48 #endif | 48 #endif |
49 }; | 49 }; |
50 | 50 |
51 bool AlmostEqualUlps(float A, float B) | 51 bool AlmostEqualUlps(float A, float B) |
(...skipping 17 matching lines...) Expand all Loading... |
69 #if 1 | 69 #if 1 |
70 int UlpsDiff(float A, float B) | 70 int UlpsDiff(float A, float B) |
71 { | 71 { |
72 Float_t uA(A); | 72 Float_t uA(A); |
73 Float_t uB(B); | 73 Float_t uB(B); |
74 | 74 |
75 return abs(uA.i - uB.i); | 75 return abs(uA.i - uB.i); |
76 } | 76 } |
77 #endif | 77 #endif |
78 | 78 |
79 #if SK_DEBUG | 79 #ifdef SK_DEBUG |
80 void mathematica_ize(char* str, size_t bufferLen) { | 80 void mathematica_ize(char* str, size_t bufferLen) { |
81 size_t len = strlen(str); | 81 size_t len = strlen(str); |
82 bool num = false; | 82 bool num = false; |
83 for (size_t idx = 0; idx < len; ++idx) { | 83 for (size_t idx = 0; idx < len; ++idx) { |
84 if (num && str[idx] == 'e') { | 84 if (num && str[idx] == 'e') { |
85 if (len + 2 >= bufferLen) { | 85 if (len + 2 >= bufferLen) { |
86 return; | 86 return; |
87 } | 87 } |
88 memmove(&str[idx + 2], &str[idx + 1], len - idx); | 88 memmove(&str[idx + 2], &str[idx + 1], len - idx); |
89 str[idx] = '*'; | 89 str[idx] = '*'; |
90 str[idx + 1] = '^'; | 90 str[idx + 1] = '^'; |
91 ++len; | 91 ++len; |
92 } | 92 } |
93 num = str[idx] >= '0' && str[idx] <= '9'; | 93 num = str[idx] >= '0' && str[idx] <= '9'; |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 bool valid_wind(int wind) { | 97 bool valid_wind(int wind) { |
98 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF; | 98 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF; |
99 } | 99 } |
100 | 100 |
101 void winding_printf(int wind) { | 101 void winding_printf(int wind) { |
102 if (wind == SK_MinS32) { | 102 if (wind == SK_MinS32) { |
103 SkDebugf("?"); | 103 SkDebugf("?"); |
104 } else { | 104 } else { |
105 SkDebugf("%d", wind); | 105 SkDebugf("%d", wind); |
106 } | 106 } |
107 } | 107 } |
108 #endif | 108 #endif |
OLD | NEW |