[skottie] Clang-tidy fixes
Mostly const-relax to allow moving. Also add an r-val overload for
Node attribute setters.
Change-Id: I15e5eeee95b7c2a460844fec5a5d312d59b612ca
Reviewed-on: https://skia-review.googlesource.com/c/163168
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/modules/skottie/src/SkottieLayer.cpp b/modules/skottie/src/SkottieLayer.cpp
index b53b7f1..98ea02c 100644
--- a/modules/skottie/src/SkottieLayer.cpp
+++ b/modules/skottie/src/SkottieLayer.cpp
@@ -142,7 +142,7 @@
std::vector<sksg::Merge::Rec> merge_recs;
merge_recs.reserve(SkToSizeT(mask_stack.count()));
- for (const auto& mask : mask_stack) {
+ for (auto& mask : mask_stack) {
const auto mode = merge_recs.empty() ? sksg::Merge::Mode::kMerge : mask.merge_mode;
merge_recs.push_back({std::move(mask.mask_path), mode});
}
@@ -160,7 +160,7 @@
} else {
std::vector<sk_sp<sksg::RenderNode>> masks;
masks.reserve(SkToSizeT(mask_stack.count()));
- for (const auto& rec : mask_stack) {
+ for (auto& rec : mask_stack) {
masks.push_back(sksg::Draw::Make(std::move(rec.mask_path),
std::move(rec.mask_paint)));
}
diff --git a/modules/skottie/src/SkottieShapeLayer.cpp b/modules/skottie/src/SkottieShapeLayer.cpp
index d0668d2..197faec 100644
--- a/modules/skottie/src/SkottieShapeLayer.cpp
+++ b/modules/skottie/src/SkottieShapeLayer.cpp
@@ -258,7 +258,7 @@
std::vector<sksg::Merge::Rec> merge_recs;
merge_recs.reserve(geos.size());
- for (const auto& geo : geos) {
+ for (auto& geo : geos) {
merge_recs.push_back(
{std::move(geo), merge_recs.empty() ? sksg::Merge::Mode::kMerge : mode});
}
@@ -308,7 +308,7 @@
std::vector<sk_sp<sksg::GeometryNode>> trimmed;
trimmed.reserve(inputs.size());
for (const auto& i : inputs) {
- const auto trimEffect = sksg::TrimEffect::Make(i);
+ auto trimEffect = sksg::TrimEffect::Make(i);
trimmed.push_back(trimEffect);
const auto adapter = sk_make_sp<TrimEffectAdapter>(std::move(trimEffect));
@@ -336,7 +336,7 @@
std::vector<sk_sp<sksg::GeometryNode>> rounded;
rounded.reserve(geos.size());
- for (const auto& g : geos) {
+ for (auto& g : geos) {
const auto roundEffect = sksg::RoundEffect::Make(std::move(g));
rounded.push_back(roundEffect);
@@ -608,7 +608,7 @@
}
// Push transformed local geometries to parent list, for subsequent paints.
- for (const auto& geo : geos) {
+ for (auto& geo : geos) {
ctx->fGeometryStack->push_back(shape_matrix
? sksg::GeometryTransform::Make(std::move(geo), shape_matrix)
: std::move(geo));
diff --git a/modules/sksg/include/SkSGNode.h b/modules/sksg/include/SkSGNode.h
index 63b8d1e..15db2e2 100644
--- a/modules/sksg/include/SkSGNode.h
+++ b/modules/sksg/include/SkSGNode.h
@@ -93,6 +93,11 @@
if (attr_container == v) return; \
attr_container = v; \
this->invalidate(); \
+ } \
+ void set##attr_name(attr_type&& v) { \
+ if (attr_container == v) return; \
+ attr_container = std::move(v); \
+ this->invalidate(); \
}
#define SG_MAPPED_ATTRIBUTE(attr_name, attr_type, attr_container) \
@@ -101,6 +106,11 @@
if (attr_container.get##attr_name() == v) return; \
attr_container.set##attr_name(v); \
this->invalidate(); \
+ } \
+ void set##attr_name(attr_type&& v) { \
+ if (attr_container.get##attr_name() == v) return; \
+ attr_container.set##attr_name(std::move(v)); \
+ this->invalidate(); \
}
} // namespace sksg