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

Side by Side Diff: src/core/SkFloatBits.cpp

Issue 373383003: ios fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove temp directory hack Created 6 years, 5 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
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 "SkFloatBits.h" 8 #include "SkFloatBits.h"
9 #include "SkMathPriv.h" 9 #include "SkMathPriv.h"
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } else { 78 } else {
79 value <<= exp; 79 value <<= exp;
80 } 80 }
81 // apply the sign after we check for overflow 81 // apply the sign after we check for overflow
82 return SkApplySign(value, SkExtractSign(packed)); 82 return SkApplySign(value, SkExtractSign(packed));
83 } else { 83 } else {
84 // apply the sign before we right-shift 84 // apply the sign before we right-shift
85 value = SkApplySign(value, SkExtractSign(packed)); 85 value = SkApplySign(value, SkExtractSign(packed));
86 exp = -exp; 86 exp = -exp;
87 if (exp > 25) { // underflow 87 if (exp > 25) { // underflow
88 #ifdef SK_BUILD_FOR_IOS
89 if (exp > 149) return 0;
reed1 2014/07/10 18:39:39 Can we perhaps encapsulate this in a helper functi
caryclark 2014/07/10 21:07:03 I commented and gave it a platform independent #de
90 #else
88 exp = 25; 91 exp = 25;
92 #endif
89 } 93 }
90 // int add = 0; 94 // int add = 0;
91 return value >> exp; 95 return value >> exp;
92 } 96 }
93 } 97 }
94 98
95 // same as (int)floor(float + 0.5) 99 // same as (int)floor(float + 0.5)
96 int32_t SkFloatBits_toIntRound(int32_t packed) { 100 int32_t SkFloatBits_toIntRound(int32_t packed) {
97 // curse you negative 0 101 // curse you negative 0
98 if ((packed << 1) == 0) { 102 if ((packed << 1) == 0) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } else { 142 } else {
139 value <<= exp; 143 value <<= exp;
140 } 144 }
141 // apply the sign after we check for overflow 145 // apply the sign after we check for overflow
142 return SkApplySign(value, SkExtractSign(packed)); 146 return SkApplySign(value, SkExtractSign(packed));
143 } else { 147 } else {
144 // apply the sign before we right-shift 148 // apply the sign before we right-shift
145 value = SkApplySign(value, SkExtractSign(packed)); 149 value = SkApplySign(value, SkExtractSign(packed));
146 exp = -exp; 150 exp = -exp;
147 if (exp > 25) { // underflow 151 if (exp > 25) { // underflow
152 #ifdef SK_BUILD_FOR_IOS
153 if (exp > 149) return 0;
154 return 0 < value;
155 #else
148 exp = 25; 156 exp = 25;
157 #endif
149 } 158 }
150 int add = (1 << exp) - 1; 159 int add = (1 << exp) - 1;
151 return (value + add) >> exp; 160 return (value + add) >> exp;
152 } 161 }
153 } 162 }
154 163
155 float SkIntToFloatCast(int32_t value) { 164 float SkIntToFloatCast(int32_t value) {
156 if (0 == value) { 165 if (0 == value) {
157 return 0; 166 return 0;
158 } 167 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 value = SkApplySign(value, sign); 206 value = SkApplySign(value, sign);
198 207
199 int zeros = SkCLZ(value << 8); 208 int zeros = SkCLZ(value << 8);
200 value <<= zeros; 209 value <<= zeros;
201 shift -= zeros; 210 shift -= zeros;
202 211
203 SkFloatIntUnion data; 212 SkFloatIntUnion data;
204 data.fSignBitInt = (sign << 31) | (shift << 23) | (value & ~MATISSA_MAGIC_BI G); 213 data.fSignBitInt = (sign << 31) | (shift << 23) | (value & ~MATISSA_MAGIC_BI G);
205 return data.fFloat; 214 return data.fFloat;
206 } 215 }
OLDNEW
« no previous file with comments | « include/core/SkImageEncoder.h ('k') | src/core/SkPoint.cpp » ('j') | src/core/SkPoint.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698