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

Unified Diff: include/core/SkMath.h

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkMath.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkMath.h
diff --git a/include/core/SkMath.h b/include/core/SkMath.h
index ba6223ed06e732101140de41c8675886a2470340..9d4c9eae357cd30ca3c4c10c5f24bcd5cd862a1a 100644
--- a/include/core/SkMath.h
+++ b/include/core/SkMath.h
@@ -12,29 +12,6 @@
#include "SkTypes.h"
-/**
- * Computes numer1 * numer2 / denom in full 64 intermediate precision.
- * It is an error for denom to be 0. There is no special handling if
- * the result overflows 32bits.
- */
-int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom);
-
-/**
- * Computes (numer1 << shift) / denom in full 64 intermediate precision.
- * It is an error for denom to be 0. There is no special handling if
- * the result overflows 32bits.
- */
-int32_t SkDivBits(int32_t numer, int32_t denom, int shift);
-
-/**
- * Return the integer square root of value, with a bias of bitBias
- */
-int32_t SkSqrtBits(int32_t value, int bitBias);
-
-/** Return the integer square root of n, treated as a SkFixed (16.16)
- */
-#define SkSqrt32(n) SkSqrtBits(n, 15)
-
// 64bit -> 32bit utilities
/**
@@ -63,6 +40,34 @@ static inline int64_t sk_64_mul(int64_t a, int64_t b) {
///////////////////////////////////////////////////////////////////////////////
+/**
+ * Computes numer1 * numer2 / denom in full 64 intermediate precision.
+ * It is an error for denom to be 0. There is no special handling if
+ * the result overflows 32bits.
+ */
+static inline int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom) {
+ SkASSERT(denom);
+
+ int64_t tmp = sk_64_mul(numer1, numer2) / denom;
+ return sk_64_asS32(tmp);
+}
+
+/**
+ * Computes (numer1 << shift) / denom in full 64 intermediate precision.
+ * It is an error for denom to be 0. There is no special handling if
+ * the result overflows 32bits.
+ */
+int32_t SkDivBits(int32_t numer, int32_t denom, int shift);
+
+/**
+ * Return the integer square root of value, with a bias of bitBias
+ */
+int32_t SkSqrtBits(int32_t value, int bitBias);
+
+/** Return the integer square root of n, treated as a SkFixed (16.16)
+ */
+#define SkSqrt32(n) SkSqrtBits(n, 15)
+
//! Returns the number of leading zero bits (0...32)
int SkCLZ_portable(uint32_t);
« no previous file with comments | « no previous file | src/core/SkMath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698