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

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

Issue 242493006: inline SkMulDiv now that 64bit mul is inlineable (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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 | « include/core/SkMath.h ('k') | no next file » | 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 "SkFloatBits.h" 9 #include "SkFloatBits.h"
10 #include "SkFloatingPoint.h" 10 #include "SkFloatingPoint.h"
(...skipping 25 matching lines...) Expand all
36 if (x & 0xC) { 36 if (x & 0xC) {
37 sub_shift(zeros, x, 2); 37 sub_shift(zeros, x, 2);
38 } 38 }
39 if (x & 0x2) { 39 if (x & 0x2) {
40 sub_shift(zeros, x, 1); 40 sub_shift(zeros, x, 1);
41 } 41 }
42 42
43 return zeros; 43 return zeros;
44 } 44 }
45 45
46 int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom) {
47 SkASSERT(denom);
48
49 int64_t tmp = sk_64_mul(numer1, numer2) / denom;
50 return sk_64_asS32(tmp);
51 }
52
53 SkFixed SkFixedMul_portable(SkFixed a, SkFixed b) { 46 SkFixed SkFixedMul_portable(SkFixed a, SkFixed b) {
54 #if defined(SkLONGLONG) 47 #if defined(SkLONGLONG)
55 return static_cast<SkFixed>((int64_t)a * b >> 16); 48 return static_cast<SkFixed>((int64_t)a * b >> 16);
56 #else 49 #else
57 int sa = SkExtractSign(a); 50 int sa = SkExtractSign(a);
58 int sb = SkExtractSign(b); 51 int sb = SkExtractSign(b);
59 // now make them positive 52 // now make them positive
60 a = SkApplySign(a, sa); 53 a = SkApplySign(a, sa);
61 b = SkApplySign(b, sb); 54 b = SkApplySign(b, sb);
62 55
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 int diff = cos2 + sin2 - SK_Fixed1; 280 int diff = cos2 + sin2 - SK_Fixed1;
288 SkASSERT(SkAbs32(diff) <= 7); 281 SkASSERT(SkAbs32(diff) <= 7);
289 } 282 }
290 #endif 283 #endif
291 284
292 if (cosValuePtr) { 285 if (cosValuePtr) {
293 *cosValuePtr = cosValue; 286 *cosValuePtr = cosValue;
294 } 287 }
295 return sinValue; 288 return sinValue;
296 } 289 }
OLDNEW
« no previous file with comments | « include/core/SkMath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698