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

Unified Diff: include/core/SkPoint.h

Issue 60083014: Add sk_float_rsqrt with SSE + NEON fast paths. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: test Created 7 years, 1 month 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 | « include/core/SkFloatingPoint.h ('k') | src/core/SkPoint.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPoint.h
diff --git a/include/core/SkPoint.h b/include/core/SkPoint.h
index b94f730ec2846056540bd657859826c8b3bb8f6d..caf26507ffa3c5e632ceb078a6a3301d0c08c5eb 100644
--- a/include/core/SkPoint.h
+++ b/include/core/SkPoint.h
@@ -216,13 +216,10 @@ struct SK_API SkPoint {
* Return true if the computed length of the vector is >= the internal
* tolerance (used to avoid dividing by tiny values).
*/
- static bool CanNormalize(SkScalar dx, SkScalar dy)
-#ifdef SK_SCALAR_IS_FLOAT
- // Simple enough (and performance critical sometimes) so we inline it.
- { return (dx*dx + dy*dy) > (SK_ScalarNearlyZero * SK_ScalarNearlyZero); }
-#else
- ;
-#endif
+ static bool CanNormalize(SkScalar dx, SkScalar dy) {
+ // Simple enough (and performance critical sometimes) so we inline it.
+ return (dx*dx + dy*dy) > (SK_ScalarNearlyZero * SK_ScalarNearlyZero);
+ }
bool canNormalize() const {
return CanNormalize(fX, fY);
@@ -252,6 +249,14 @@ struct SK_API SkPoint {
*/
bool setLength(SkScalar x, SkScalar y, SkScalar length);
+ /** Same as setLength, but favoring speed over accuracy.
+ */
+ bool setLengthFast(SkScalar length);
+
+ /** Same as setLength, but favoring speed over accuracy.
+ */
+ bool setLengthFast(SkScalar x, SkScalar y, SkScalar length);
+
/** Scale the point's coordinates by scale, writing the answer into dst.
It is legal for dst == this.
*/
@@ -316,7 +321,6 @@ struct SK_API SkPoint {
* Returns true if both X and Y are finite (not infinity or NaN)
*/
bool isFinite() const {
-#ifdef SK_SCALAR_IS_FLOAT
SkScalar accum = 0;
accum *= fX;
accum *= fY;
@@ -327,12 +331,6 @@ struct SK_API SkPoint {
// value==value will be true iff value is not NaN
// TODO: is it faster to say !accum or accum==accum?
return accum == accum;
-#else
- // use bit-or for speed, since we don't care about short-circuting the
- // tests, and we expect the common case will be that we need to check all.
- int isNaN = (SK_FixedNaN == fX) | (SK_FixedNaN == fX));
- return !isNaN;
-#endif
}
/**
« no previous file with comments | « include/core/SkFloatingPoint.h ('k') | src/core/SkPoint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698