move parts of SkPoint to SkPointPriv
Move specialized SkPoint methods to SkPointPriv.
Use constexpr and inline initialization where possible.
R=reed@google.com,bsalomon@google.com
Bug: skia: 6898
Change-Id: I01ec5186f010f2dc80c068c70d9cc352f3221338
Reviewed-on: https://skia-review.googlesource.com/68700
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ravi Mistry <rmistry@google.com>
diff --git a/samplecode/SampleAAGeometry.cpp b/samplecode/SampleAAGeometry.cpp
index da96a0b..55aebda 100644
--- a/samplecode/SampleAAGeometry.cpp
+++ b/samplecode/SampleAAGeometry.cpp
@@ -13,6 +13,7 @@
#include "SkOpEdgeBuilder.h"
// #include "SkPathOpsSimplifyAA.h"
// #include "SkPathStroker.h"
+#include "SkPointPriv.h"
#include "SkView.h"
#if 0
@@ -1299,7 +1300,7 @@
SkScalar pt_to_line(SkPoint s, SkPoint e, int x, int y) {
SkScalar radius = fWidthControl.fValLo;
SkVector adjOpp = e - s;
- SkScalar lenSq = adjOpp.lengthSqd();
+ SkScalar lenSq = SkPointPriv::LengthSqd(adjOpp);
SkPoint rotated = {
(y - s.fY) * adjOpp.fY + (x - s.fX) * adjOpp.fX,
(y - s.fY) * adjOpp.fX - (x - s.fX) * adjOpp.fY,
diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp
index 80f656e..723dca8 100644
--- a/samplecode/SampleFatBits.cpp
+++ b/samplecode/SampleFatBits.cpp
@@ -10,6 +10,7 @@
#include "SkView.h"
#include "SkCanvas.h"
#include "SkPath.h"
+#include "SkPointPriv.h"
#include "SkRegion.h"
#include "SkShader.h"
#include "SkUtils.h"
@@ -483,7 +484,7 @@
SkScalar tol = 12;
for (int i = 0; i < count; ++i) {
- if (fPts[i].equalsWithinTolerance(pt, tol)) {
+ if (SkPointPriv::EqualsWithinTolerance(fPts[i], pt, tol)) {
index = i;
break;
}
diff --git a/samplecode/SampleHT.cpp b/samplecode/SampleHT.cpp
index 50ea287..e1483be 100644
--- a/samplecode/SampleHT.cpp
+++ b/samplecode/SampleHT.cpp
@@ -12,6 +12,7 @@
#include "SkDrawable.h"
#include "SkInterpolator.h"
#include "SkPictureRecorder.h"
+#include "SkPointPriv.h"
#include "SkRandom.h"
const SkRect gUnitSquare = { -1, -1, 1, 1 };
@@ -35,7 +36,7 @@
m.setRectToRect(r, gUnitSquare, SkMatrix::kFill_ScaleToFit);
SkPoint pt;
m.mapXY(x, y, &pt);
- return pt.lengthSqd() <= 1;
+ return SkPointPriv::LengthSqd(pt) <= 1;
}
static SkColor rand_opaque_color(uint32_t seed) {
diff --git a/samplecode/SampleQuadStroker.cpp b/samplecode/SampleQuadStroker.cpp
index ea5f97f..fa45d6e 100644
--- a/samplecode/SampleQuadStroker.cpp
+++ b/samplecode/SampleQuadStroker.cpp
@@ -11,6 +11,7 @@
#include "SkCanvas.h"
#include "SkGeometry.h"
#include "SkPathMeasure.h"
+#include "SkPointPriv.h"
#include "SkRandom.h"
#include "SkRRect.h"
#include "SkColorPriv.h"
@@ -313,7 +314,7 @@
for (SkScalar dist = 0; dist <= total; dist += delta) {
if (meas.getPosTan(dist, &pos, &tan)) {
tan.scale(radius);
- tan.rotateCCW();
+ SkPointPriv::RotateCCW(&tan);
canvas->drawLine(pos.x() + tan.x(), pos.y() + tan.y(),
pos.x() - tan.x(), pos.y() - tan.y(), paint);
if (0 == index % 10) {
@@ -375,7 +376,7 @@
return;
}
tan.setLength(radius);
- tan.rotateCCW();
+ SkPointPriv::RotateCCW(&tan);
canvas->drawLine(pos.x() + tan.x(), pos.y() + tan.y(),
pos.x() - tan.x(), pos.y() - tan.y(), paint);
if (0 == index % 10) {
@@ -556,8 +557,8 @@
before.setLength(fRadius);
after.setLength(fRadius);
SkVector beforeCCW, afterCCW;
- before.rotateCCW(&beforeCCW);
- after.rotateCCW(&afterCCW);
+ SkPointPriv::RotateCCW(before, &beforeCCW);
+ SkPointPriv::RotateCCW(after, &afterCCW);
beforeCCW += pts[0];
afterCCW += pts[2];
*center = beforeCCW;
@@ -566,8 +567,8 @@
return true;
}
SkVector beforeCW, afterCW;
- before.rotateCW(&beforeCW);
- after.rotateCW(&afterCW);
+ SkPointPriv::RotateCW(before, &beforeCW);
+ SkPointPriv::RotateCW(after, &afterCW);
beforeCW += pts[0];
afterCW += pts[2];
*center = beforeCW;