inline SkMulDiv now that 64bit mul is inlineable

TBR=caryclark@google.com

Author: reed@google.com

Review URL: https://codereview.chromium.org/242493006

git-svn-id: http://skia.googlecode.com/svn/trunk@14268 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-04-19 22:12:35 +00:00
parent 2cfa3200fd
commit 0f1fef834c
2 changed files with 28 additions and 30 deletions

View File

@ -12,29 +12,6 @@
#include "SkTypes.h" #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 // 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) //! Returns the number of leading zero bits (0...32)
int SkCLZ_portable(uint32_t); int SkCLZ_portable(uint32_t);

View File

@ -43,13 +43,6 @@ int SkCLZ_portable(uint32_t x) {
return zeros; return zeros;
} }
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);
}
SkFixed SkFixedMul_portable(SkFixed a, SkFixed b) { SkFixed SkFixedMul_portable(SkFixed a, SkFixed b) {
#if defined(SkLONGLONG) #if defined(SkLONGLONG)
return static_cast<SkFixed>((int64_t)a * b >> 16); return static_cast<SkFixed>((int64_t)a * b >> 16);