Make SkCubicMap immutable
Drop setter, only keep the parameterized constructor.
Change-Id: I31517df23688b8bd7485bf70c9c055cd1c87edcf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198245
Auto-Submit: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/include/core/SkCubicMap.h b/include/core/SkCubicMap.h
index 0241f27..85ed7dd 100644
--- a/include/core/SkCubicMap.h
+++ b/include/core/SkCubicMap.h
@@ -20,13 +20,7 @@
*/
class SK_API SkCubicMap {
public:
- SkCubicMap() {} // must call setPts() before using
-
- SkCubicMap(SkPoint p1, SkPoint p2) {
- this->setPts(p1, p2);
- }
-
- void setPts(SkPoint p1, SkPoint p2);
+ SkCubicMap(SkPoint p1, SkPoint p2);
float computeYFromX(float x) const;
@@ -38,6 +32,7 @@
kCubeRoot_Type, // At^3 == x
kSolver_Type, // general monotonic cubic solver
};
+
SkPoint fCoeff[3];
Type fType;
};
diff --git a/modules/skottie/src/SkottieAnimator.cpp b/modules/skottie/src/SkottieAnimator.cpp
index eb75212..f49110c 100644
--- a/modules/skottie/src/SkottieAnimator.cpp
+++ b/modules/skottie/src/SkottieAnimator.cpp
@@ -105,9 +105,7 @@
if (c0 != kDefaultC0 || c1 != kDefaultC1) {
// TODO: is it worth de-duping these?
cm_idx = SkToInt(fCubicMaps.size());
- fCubicMaps.emplace_back();
- // TODO: why do we have to plug these inverted?
- fCubicMaps.back().setPts(c1, c0);
+ fCubicMaps.emplace_back(c1, c0);
}
fRecs.push_back({t0, t0, v0_idx, v1_idx, cm_idx });
diff --git a/src/core/SkCubicMap.cpp b/src/core/SkCubicMap.cpp
index a390d44..56aef11 100644
--- a/src/core/SkCubicMap.cpp
+++ b/src/core/SkCubicMap.cpp
@@ -189,7 +189,7 @@
return sk_float_abs(delta) <= 0.0000001f;
}
-void SkCubicMap::setPts(SkPoint p1, SkPoint p2) {
+SkCubicMap::SkCubicMap(SkPoint p1, SkPoint p2) {
Sk2s s1 = Sk2s::Load(&p1) * 3;
Sk2s s2 = Sk2s::Load(&p2) * 3;
diff --git a/tools/viewer/SlideDir.cpp b/tools/viewer/SlideDir.cpp
index a6b3b14..ccc9334 100644
--- a/tools/viewer/SlideDir.cpp
+++ b/tools/viewer/SlideDir.cpp
@@ -115,9 +115,8 @@
: fDir(dir)
, fRect(focusRect)
, fTarget(nullptr)
+ , fMap(kFocusCtrl1, kFocusCtrl0)
, fState(State::kIdle) {
- fMap.setPts(kFocusCtrl1, kFocusCtrl0);
-
fShadePaint = sksg::Color::Make(kFocusShade);
fShade = sksg::Draw::Make(sksg::Plane::Make(), fShadePaint);
}