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

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

Issue 21122005: fold SK_CPU_HAS_CONDITION_INSTR through as always defined (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: typo Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBitmapProcState_matrixProcs.cpp ('k') | src/core/SkMathPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 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 "SkMathPriv.h" 8 #include "SkMathPriv.h"
9 #include "SkCordic.h" 9 #include "SkCordic.h"
10 #include "SkFloatBits.h" 10 #include "SkFloatBits.h"
11 #include "SkFloatingPoint.h" 11 #include "SkFloatingPoint.h"
12 #include "Sk64.h" 12 #include "Sk64.h"
13 #include "SkScalar.h" 13 #include "SkScalar.h"
14 14
15 #ifdef SK_SCALAR_IS_FLOAT 15 #ifdef SK_SCALAR_IS_FLOAT
16 const uint32_t gIEEENotANumber = 0x7FFFFFFF; 16 const uint32_t gIEEENotANumber = 0x7FFFFFFF;
17 const uint32_t gIEEEInfinity = 0x7F800000; 17 const uint32_t gIEEEInfinity = 0x7F800000;
18 const uint32_t gIEEENegativeInfinity = 0xFF800000; 18 const uint32_t gIEEENegativeInfinity = 0xFF800000;
19 #endif 19 #endif
20 20
21 #define sub_shift(zeros, x, n) \ 21 #define sub_shift(zeros, x, n) \
22 zeros -= n; \ 22 zeros -= n; \
23 x >>= n 23 x >>= n
24 24
25 int SkCLZ_portable(uint32_t x) { 25 int SkCLZ_portable(uint32_t x) {
26 if (x == 0) { 26 if (x == 0) {
27 return 32; 27 return 32;
28 } 28 }
29 29
30 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
31 int zeros = 31; 30 int zeros = 31;
32 if (x & 0xFFFF0000) { 31 if (x & 0xFFFF0000) {
33 sub_shift(zeros, x, 16); 32 sub_shift(zeros, x, 16);
34 } 33 }
35 if (x & 0xFF00) { 34 if (x & 0xFF00) {
36 sub_shift(zeros, x, 8); 35 sub_shift(zeros, x, 8);
37 } 36 }
38 if (x & 0xF0) { 37 if (x & 0xF0) {
39 sub_shift(zeros, x, 4); 38 sub_shift(zeros, x, 4);
40 } 39 }
41 if (x & 0xC) { 40 if (x & 0xC) {
42 sub_shift(zeros, x, 2); 41 sub_shift(zeros, x, 2);
43 } 42 }
44 if (x & 0x2) { 43 if (x & 0x2) {
45 sub_shift(zeros, x, 1); 44 sub_shift(zeros, x, 1);
46 } 45 }
47 #else
48 int zeros = ((x >> 16) - 1) >> 31 << 4;
49 x <<= zeros;
50
51 int nonzero = ((x >> 24) - 1) >> 31 << 3;
52 zeros += nonzero;
53 x <<= nonzero;
54
55 nonzero = ((x >> 28) - 1) >> 31 << 2;
56 zeros += nonzero;
57 x <<= nonzero;
58
59 nonzero = ((x >> 30) - 1) >> 31 << 1;
60 zeros += nonzero;
61 x <<= nonzero;
62
63 zeros += (~x) >> 31;
64 #endif
65 46
66 return zeros; 47 return zeros;
67 } 48 }
68 49
69 int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom) { 50 int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom) {
70 SkASSERT(denom); 51 SkASSERT(denom);
71 52
72 Sk64 tmp; 53 Sk64 tmp;
73 tmp.setMul(numer1, numer2); 54 tmp.setMul(numer1, numer2);
74 tmp.div(denom, Sk64::kTrunc_DivOption); 55 tmp.div(denom, Sk64::kTrunc_DivOption);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 } 508 }
528 509
529 /////////////////////////////////////////////////////////////////////////////// 510 ///////////////////////////////////////////////////////////////////////////////
530 511
531 SkFixed SkFixedTan(SkFixed radians) { return SkCordicTan(radians); } 512 SkFixed SkFixedTan(SkFixed radians) { return SkCordicTan(radians); }
532 SkFixed SkFixedASin(SkFixed x) { return SkCordicASin(x); } 513 SkFixed SkFixedASin(SkFixed x) { return SkCordicASin(x); }
533 SkFixed SkFixedACos(SkFixed x) { return SkCordicACos(x); } 514 SkFixed SkFixedACos(SkFixed x) { return SkCordicACos(x); }
534 SkFixed SkFixedATan2(SkFixed y, SkFixed x) { return SkCordicATan2(y, x); } 515 SkFixed SkFixedATan2(SkFixed y, SkFixed x) { return SkCordicATan2(y, x); }
535 SkFixed SkFixedExp(SkFixed x) { return SkCordicExp(x); } 516 SkFixed SkFixedExp(SkFixed x) { return SkCordicExp(x); }
536 SkFixed SkFixedLog(SkFixed x) { return SkCordicLog(x); } 517 SkFixed SkFixedLog(SkFixed x) { return SkCordicLog(x); }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState_matrixProcs.cpp ('k') | src/core/SkMathPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698