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

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

Issue 113873008: remove unused SkFixed and SkFract functions (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "Sk64.h" 8 #include "Sk64.h"
9 #include "SkMathPriv.h" 9 #include "SkMathPriv.h"
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 void Sk64::abs() 127 void Sk64::abs()
128 { 128 {
129 if (fHi < 0) 129 if (fHi < 0)
130 { 130 {
131 fHi = -fHi - Sk32ToBool(fLo); 131 fHi = -fHi - Sk32ToBool(fLo);
132 fLo = 0 - fLo; 132 fLo = 0 - fLo;
133 } 133 }
134 } 134 }
135 135
136 #if 0
136 SkBool Sk64::isFixed() const 137 SkBool Sk64::isFixed() const
137 { 138 {
138 Sk64 tmp = *this; 139 Sk64 tmp = *this;
139 tmp.roundRight(16); 140 tmp.roundRight(16);
140 return tmp.is32(); 141 return tmp.is32();
141 } 142 }
142 143 #endif
143 SkFract Sk64::getFract() const
144 {
145 Sk64 tmp = *this;
146 tmp.roundRight(30);
147 return tmp.get32();
148 }
149 144
150 void Sk64::sub(const Sk64& a) 145 void Sk64::sub(const Sk64& a)
151 { 146 {
152 fHi = fHi - a.fHi - (fLo < a.fLo); 147 fHi = fHi - a.fHi - (fLo < a.fLo);
153 fLo = fLo - a.fLo; 148 fLo = fLo - a.fLo;
154 } 149 }
155 150
156 void Sk64::rsub(const Sk64& a) 151 void Sk64::rsub(const Sk64& a)
157 { 152 {
158 fHi = a.fHi - fHi - (a.fLo < fLo); 153 fHi = a.fHi - fHi - (a.fLo < fLo);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 286 }
292 287
293 #ifdef SkLONGLONG 288 #ifdef SkLONGLONG
294 SkLONGLONG Sk64::getLongLong() const 289 SkLONGLONG Sk64::getLongLong() const
295 { 290 {
296 SkLONGLONG value = fHi; 291 SkLONGLONG value = fHi;
297 value <<= 32; 292 value <<= 32;
298 return value | fLo; 293 return value | fLo;
299 } 294 }
300 #endif 295 #endif
301
302 SkFixed Sk64::getFixedDiv(const Sk64& denom) const
303 {
304 Sk64 N = *this;
305 Sk64 D = denom;
306 int32_t sign = SkExtractSign(N.fHi ^ D.fHi);
307 SkFixed result;
308
309 N.abs();
310 D.abs();
311
312 // need to knock D down to just 31 bits
313 // either by rounding it to the right, or shifting N to the left
314 // then we can just call 64/32 div
315
316 int nclz = N.fHi ? SkCLZ(N.fHi) : 32;
317 int dclz = D.fHi ? SkCLZ(D.fHi) : (33 - (D.fLo >> 31));
318
319 int shiftN = nclz - 1;
320 SkASSERT(shiftN >= 0);
321 int shiftD = 33 - dclz;
322 SkASSERT(shiftD >= 0);
323
324 if (shiftD + shiftN < 16)
325 shiftD = 16 - shiftN;
326 else
327 shiftN = 16 - shiftD;
328
329 D.roundRight(shiftD);
330 if (D.isZero())
331 result = SK_MaxS32;
332 else
333 {
334 if (shiftN >= 0)
335 N.shiftLeft(shiftN);
336 else
337 N.roundRight(-shiftN);
338 N.div(D.get32(), Sk64::kTrunc_DivOption);
339 if (N.is32())
340 result = N.get32();
341 else
342 result = SK_MaxS32;
343 }
344 return SkApplySign(result, sign);
345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698