Flutter Engine
The Flutter Engine
Classes | Macros | Typedefs | Functions | Variables
MathBench.cpp File Reference
#include "bench/Benchmark.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkString.h"
#include "include/private/SkColorData.h"
#include "include/private/base/SkFixed.h"
#include "src/base/SkMathPriv.h"
#include "src/base/SkRandom.h"
#include "src/base/SkFloatBits.h"

Go to the source code of this file.

Classes

class  MathBench
 
class  MathBenchU32
 
class  NoOpMathBench
 
class  SkRSqrtMathBench
 
class  SlowISqrtMathBench
 
class  FastISqrtMathBench
 
class  QMul64Bench
 
class  QMul32Bench
 
class  IsFiniteBench
 
class  FloorBench
 
class  CLZBench
 
class  CTZBench
 
class  NormalizeBench
 
class  FixedMathBench
 
class  Floor2IntBench
 

Macros

#define mulzeroadd(data)   (data[0]*0 + data[1]*0 + data[2]*0 + data[3]*0)
 
#define MAKEREC(name)   { name, #name }
 

Typedefs

typedef bool(* IsFiniteProc) (const float[])
 

Functions

static float sk_fsel (float pred, float result_ge, float result_lt)
 
static float fast_floor (float x)
 
static uint32_t QMul64 (uint32_t value, U8CPU alpha)
 
static bool isFinite_int (float x)
 
static bool isFinite_mulzero (float x)
 
static bool isfinite_and_int (const float data[4])
 
static bool isfinite_and_mulzero (const float data[4])
 
static bool isfinite_plus_int (const float data[4])
 
static bool isfinite_plus_mulzero (const float data[4])
 
static bool isFinite (const SkRect &r)
 

Variables

struct {
   IsFiniteProc   fProc
 
   const char *   fName
 
gRec []
 

Macro Definition Documentation

◆ MAKEREC

#define MAKEREC (   name)    { name, #name }

Definition at line 216 of file MathBench.cpp.

◆ mulzeroadd

#define mulzeroadd (   data)    (data[0]*0 + data[1]*0 + data[2]*0 + data[3]*0)

Definition at line 203 of file MathBench.cpp.

Typedef Documentation

◆ IsFiniteProc

typedef bool(* IsFiniteProc) (const float[])

Definition at line 214 of file MathBench.cpp.

Function Documentation

◆ fast_floor()

static float fast_floor ( float  x)
static

Definition at line 21 of file MathBench.cpp.

21 {
22// float big = sk_fsel(x, 0x1.0p+23, -0x1.0p+23);
23 float big = sk_fsel(x, (float)(1 << 23), -(float)(1 << 23));
24 return (x + big) - big;
25}
static float sk_fsel(float pred, float result_ge, float result_lt)
Definition: MathBench.cpp:17
double x

◆ isFinite()

static bool isFinite ( const SkRect r)
static

Definition at line 230 of file MathBench.cpp.

230 {
231 // x * 0 will be NaN iff x is infinity or NaN.
232 // a + b will be NaN iff either a or b is NaN.
233 float value = r.fLeft * 0 + r.fTop * 0 + r.fRight * 0 + r.fBottom * 0;
234
235 // value is either NaN or it is finite (zero).
236 // value==value will be true iff value is not NaN
237 return value == value;
238}
uint8_t value
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

◆ isfinite_and_int()

static bool isfinite_and_int ( const float  data[4])
static

Definition at line 195 of file MathBench.cpp.

195 {
196 return isFinite_int(data[0]) && isFinite_int(data[1]) && isFinite_int(data[2]) && isFinite_int(data[3]);
197}
static bool isFinite_int(float x)
Definition: MathBench.cpp:184
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ isfinite_and_mulzero()

static bool isfinite_and_mulzero ( const float  data[4])
static

Definition at line 199 of file MathBench.cpp.

199 {
201}
static bool isFinite_mulzero(float x)
Definition: MathBench.cpp:190

◆ isFinite_int()

static bool isFinite_int ( float  x)
static

Definition at line 184 of file MathBench.cpp.

184 {
185 uint32_t bits = SkFloat2Bits(x); // need unsigned for our shifts
186 int exponent = bits << 1 >> 24;
187 return exponent != 0xFF;
188}
static uint32_t SkFloat2Bits(float value)
Definition: SkFloatBits.h:41

◆ isFinite_mulzero()

static bool isFinite_mulzero ( float  x)
static

Definition at line 190 of file MathBench.cpp.

190 {
191 float y = x * 0;
192 return y == y;
193}
double y

◆ isfinite_plus_int()

static bool isfinite_plus_int ( const float  data[4])
static

Definition at line 205 of file MathBench.cpp.

205 {
207}
#define mulzeroadd(data)
Definition: MathBench.cpp:203

◆ isfinite_plus_mulzero()

static bool isfinite_plus_mulzero ( const float  data[4])
static

Definition at line 209 of file MathBench.cpp.

209 {
210 float x = mulzeroadd(data);
211 return x == x;
212}

◆ QMul64()

static uint32_t QMul64 ( uint32_t  value,
U8CPU  alpha 
)
inlinestatic

Definition at line 142 of file MathBench.cpp.

142 {
143 SkASSERT((uint8_t)alpha == alpha);
144 const uint32_t mask = 0xFF00FF;
145
146 uint64_t tmp = value;
147 tmp = (tmp & mask) | ((tmp & ~mask) << 24);
148 tmp *= alpha;
149 return (uint32_t) (((tmp >> 8) & mask) | ((tmp >> 32) & ~mask));
150}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ sk_fsel()

static float sk_fsel ( float  pred,
float  result_ge,
float  result_lt 
)
static

Definition at line 17 of file MathBench.cpp.

17 {
18 return pred >= 0 ? result_ge : result_lt;
19}

Variable Documentation

◆ fName

const char* fName

Definition at line 220 of file MathBench.cpp.

◆ fProc

IsFiniteProc fProc

Definition at line 219 of file MathBench.cpp.

◆ 

const struct { ... } gRec[]
Initial value:
= {
}
static bool isfinite_plus_int(const float data[4])
Definition: MathBench.cpp:205
static bool isfinite_and_int(const float data[4])
Definition: MathBench.cpp:195
static bool isfinite_and_mulzero(const float data[4])
Definition: MathBench.cpp:199
#define MAKEREC(name)
Definition: MathBench.cpp:216
static bool isfinite_plus_mulzero(const float data[4])
Definition: MathBench.cpp:209