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

Unified Diff: src/core/Sk4x_portable.h

Issue 964603002: Add sqrt() and rsqrt() to Sk4f. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 10 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 | « src/core/Sk4x.h ('k') | src/core/Sk4x_sse.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/Sk4x_portable.h
diff --git a/src/core/Sk4x_portable.h b/src/core/Sk4x_portable.h
index bd056c777eef682dc8b01df1fec6c9f16fcf7976..440e91faaa581b87a0d5441256bc62c0fe88538f 100644
--- a/src/core/Sk4x_portable.h
+++ b/src/core/Sk4x_portable.h
@@ -2,6 +2,8 @@
// This file will be intentionally included three times.
#if defined(SK4X_PREAMBLE)
+ #include "SkFloatingPoint.h"
+ #include <math.h>
#elif defined(SK4X_PRIVATE)
typedef T Type;
@@ -60,6 +62,20 @@ M(Sk4x<T>) multiply(const Sk4x<T>& other) const { return Sk4x(BINOP(*)); }
M(Sk4x<T>) divide(const Sk4x<T>& other) const { return Sk4x(BINOP(/)); }
#undef BINOP
+template<> inline Sk4f Sk4f::rsqrt() const {
+ return Sk4f(sk_float_rsqrt(fVec[0]),
+ sk_float_rsqrt(fVec[1]),
+ sk_float_rsqrt(fVec[2]),
+ sk_float_rsqrt(fVec[3]));
+}
+
+template<> inline Sk4f Sk4f::sqrt() const {
+ return Sk4f(sqrtf(fVec[0]),
+ sqrtf(fVec[1]),
+ sqrtf(fVec[2]),
+ sqrtf(fVec[3]));
+}
+
#define BOOL_BINOP(op) fVec[0] op other.fVec[0] ? -1 : 0, \
fVec[1] op other.fVec[1] ? -1 : 0, \
fVec[2] op other.fVec[2] ? -1 : 0, \
« no previous file with comments | « src/core/Sk4x.h ('k') | src/core/Sk4x_sse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698