[skottie] Derive most adapters from SkNVRefCnt
Bug: skia:
Change-Id: I6355a3802090a8da2c29486bd769d6a6b12af10f
Reviewed-on: https://skia-review.googlesource.com/c/180368
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/modules/skottie/src/SkottieAdapter.cpp b/modules/skottie/src/SkottieAdapter.cpp
index 4ee8750..0dd51bb 100644
--- a/modules/skottie/src/SkottieAdapter.cpp
+++ b/modules/skottie/src/SkottieAdapter.cpp
@@ -34,6 +34,8 @@
RRectAdapter::RRectAdapter(sk_sp<sksg::RRect> wrapped_node)
: fRRectNode(std::move(wrapped_node)) {}
+RRectAdapter::~RRectAdapter() = default;
+
void RRectAdapter::apply() {
// BM "position" == "center position"
auto rr = SkRRect::MakeRectXY(SkRect::MakeXYWH(fPosition.x() - fSize.width() / 2,
@@ -47,6 +49,8 @@
TransformAdapter::TransformAdapter(sk_sp<sksg::Matrix> matrix)
: fMatrixNode(std::move(matrix)) {}
+TransformAdapter::~TransformAdapter() = default;
+
SkMatrix TransformAdapter::totalMatrix() const {
SkMatrix t = SkMatrix::MakeTrans(-fAnchorPoint.x(), -fAnchorPoint.y());
@@ -66,6 +70,8 @@
: fPathNode(std::move(wrapped_node))
, fType(t) {}
+PolyStarAdapter::~PolyStarAdapter() = default;
+
void PolyStarAdapter::apply() {
static constexpr int kMaxPointCount = 100000;
const auto count = SkToUInt(SkTPin(SkScalarRoundToInt(fPointCount), 0, kMaxPointCount));
@@ -152,6 +158,8 @@
SkASSERT(fTrimEffect);
}
+TrimEffectAdapter::~TrimEffectAdapter() = default;
+
void TrimEffectAdapter::apply() {
// BM semantics: start/end are percentages, offset is "degrees" (?!).
const auto start = fStart / 100,
@@ -207,6 +215,8 @@
fStrokeColor->setStyle(SkPaint::kStroke_Style);
}
+TextAdapter::~TextAdapter() = default;
+
sk_sp<SkTextBlob> TextAdapter::makeBlob() const {
SkFont font(fText.fTypeface, fText.fTextSize);
font.setHinting(kNo_SkFontHinting);
diff --git a/modules/skottie/src/SkottieAdapter.h b/modules/skottie/src/SkottieAdapter.h
index a162e06..13b74f2 100644
--- a/modules/skottie/src/SkottieAdapter.h
+++ b/modules/skottie/src/SkottieAdapter.h
@@ -44,9 +44,10 @@
p_type f##p_name = p_default; \
public:
-class RRectAdapter final : public SkRefCnt {
+class RRectAdapter final : public SkNVRefCnt<RRectAdapter> {
public:
explicit RRectAdapter(sk_sp<sksg::RRect>);
+ ~RRectAdapter();
ADAPTER_PROPERTY(Position, SkPoint , SkPoint::Make(0, 0))
ADAPTER_PROPERTY(Size , SkSize , SkSize::Make(0, 0))
@@ -56,17 +57,16 @@
void apply();
sk_sp<sksg::RRect> fRRectNode;
-
- using INHERITED = SkRefCnt;
};
-class PolyStarAdapter final : public SkRefCnt {
+class PolyStarAdapter final : public SkNVRefCnt<PolyStarAdapter> {
public:
enum class Type {
kStar, kPoly,
};
PolyStarAdapter(sk_sp<sksg::Path>, Type);
+ ~PolyStarAdapter();
ADAPTER_PROPERTY(Position , SkPoint , SkPoint::Make(0, 0))
ADAPTER_PROPERTY(PointCount , SkScalar, 0)
@@ -81,13 +81,12 @@
sk_sp<sksg::Path> fPathNode;
Type fType;
-
- using INHERITED = SkRefCnt;
};
-class TransformAdapter final : public SkRefCnt {
+class TransformAdapter final : public SkNVRefCnt<TransformAdapter> {
public:
explicit TransformAdapter(sk_sp<sksg::Matrix>);
+ ~TransformAdapter();
ADAPTER_PROPERTY(AnchorPoint, SkPoint , SkPoint::Make(0, 0))
ADAPTER_PROPERTY(Position , SkPoint , SkPoint::Make(0, 0))
@@ -102,8 +101,6 @@
void apply();
sk_sp<sksg::Matrix> fMatrixNode;
-
- using INHERITED = SkRefCnt;
};
class GradientAdapter : public SkRefCnt {
@@ -125,8 +122,6 @@
private:
void apply();
-
- using INHERITED = SkRefCnt;
};
class LinearGradientAdapter final : public GradientAdapter {
@@ -149,9 +144,10 @@
using INHERITED = GradientAdapter;
};
-class TrimEffectAdapter final : public SkRefCnt {
+class TrimEffectAdapter final : public SkNVRefCnt<TrimEffectAdapter> {
public:
explicit TrimEffectAdapter(sk_sp<sksg::TrimEffect>);
+ ~TrimEffectAdapter();
ADAPTER_PROPERTY(Start , SkScalar, 0)
ADAPTER_PROPERTY(End , SkScalar, 100)
@@ -161,13 +157,12 @@
void apply();
sk_sp<sksg::TrimEffect> fTrimEffect;
-
- using INHERITED = SkRefCnt;
};
-class TextAdapter final : public SkRefCnt {
+class TextAdapter final : public SkNVRefCnt<TextAdapter> {
public:
explicit TextAdapter(sk_sp<sksg::Group> root);
+ ~TextAdapter();
ADAPTER_PROPERTY(Text, TextValue, TextValue())
@@ -186,8 +181,6 @@
bool fHadFill : 1, // - state cached from the prev apply()
fHadStroke : 1; // /
-
- using INHERITED = SkRefCnt;
};
#undef ADAPTER_PROPERTY