aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-03-19 14:28:31 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-19 14:28:31 -0700
commitd800d878caae5d25b275d488a1b5ae8c24cea492 (patch)
treeed08ab58c0c5293ab3efc7fd19e216b596c11cec /src/core
parent12f03121bb76214b71677ac0208d74c3c56c3b1f (diff)
Try out operator overloads for Sk2x.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Sk2x.h8
-rw-r--r--src/core/SkGeometry.cpp7
2 files changed, 11 insertions, 4 deletions
diff --git a/src/core/Sk2x.h b/src/core/Sk2x.h
index 99cd45ebe8..5e78c503d5 100644
--- a/src/core/Sk2x.h
+++ b/src/core/Sk2x.h
@@ -49,6 +49,14 @@ public:
Sk2x subtract(const Sk2x&) const;
Sk2x multiply(const Sk2x&) const;
+ Sk2x operator +(const Sk2x& o) const { return this->add(o); }
+ Sk2x operator -(const Sk2x& o) const { return this->subtract(o); }
+ Sk2x operator *(const Sk2x& o) const { return this->multiply(o); }
+
+ Sk2x& operator +=(const Sk2x& o) { return (*this = *this + o); }
+ Sk2x& operator -=(const Sk2x& o) { return (*this = *this - o); }
+ Sk2x& operator *=(const Sk2x& o) { return (*this = *this * o); }
+
Sk2x rsqrt() const; // Approximate 1/this->sqrt().
Sk2x sqrt() const; // this->multiply(this->rsqrt()) may be faster, but less precise.
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index 88c4b60cdd..6d14e4bb54 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -139,12 +139,11 @@ SkPoint SkEvalQuadAt(const SkPoint src[3], SkScalar t) {
Sk2f P1 = Sk2f::Load(&src[1].fX);
Sk2f P2 = Sk2f::Load(&src[2].fX);
- Sk2f A = P2.subtract(P1.add(P1)).add(P0);
- Sk2f B = P1.subtract(P0);
- B = B.add(B);
+ Sk2f B = P1 - P0;
+ Sk2f A = P2 - P1 - B;
SkPoint result;
- A.multiply(t2).add(B).multiply(t2).add(P0).store(&result.fX);
+ ((A * t2 + B+B) * t2 + P0).store(&result.fX);
return result;
}