Infer NodeType in attachDiscardableAdapter.
This makes the call sites a bit simpler, doesn't materially change anything in an optimized build, allows NRVO, and generally fixes a number of warnings in gcc 9 about pessimizing-move. Change-Id: I0ea5f57db163425da728630bfa6c1add7c416bd7 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278178 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
664cb9ebe5
commit
9339266839
@ -42,7 +42,7 @@ private:
|
||||
} // namespace
|
||||
|
||||
sk_sp<sksg::Path> AnimationBuilder::attachPath(const skjson::Value& jpath) const {
|
||||
return this->attachDiscardableAdapter<PathAdapter, sk_sp<sksg::Path>>(jpath, *this);
|
||||
return this->attachDiscardableAdapter<PathAdapter>(jpath, *this);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -118,16 +118,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename NodeType = sk_sp<sksg::RenderNode>, typename... Args>
|
||||
NodeType attachDiscardableAdapter(Args&&... args) const {
|
||||
template <typename T, typename... Args>
|
||||
auto attachDiscardableAdapter(Args&&... args) const ->
|
||||
typename std::decay<decltype(T::Make(std::forward<Args>(args)...)->node())>::type
|
||||
{
|
||||
using NodeType =
|
||||
typename std::decay<decltype(T::Make(std::forward<Args>(args)...)->node())>::type;
|
||||
|
||||
NodeType node;
|
||||
if (auto adapter = T::Make(std::forward<Args>(args)...)) {
|
||||
auto node = adapter->node();
|
||||
node = adapter->node();
|
||||
this->attachDiscardableAdapter(std::move(adapter));
|
||||
|
||||
return std::move(node);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return node;
|
||||
}
|
||||
|
||||
class AutoPropertyTracker {
|
||||
|
@ -48,8 +48,7 @@ private:
|
||||
|
||||
sk_sp<sksg::GeometryNode> ShapeBuilder::AttachEllipseGeometry(const skjson::ObjectValue& jellipse,
|
||||
const AnimationBuilder* abuilder) {
|
||||
return abuilder->attachDiscardableAdapter<EllipseGeometryAdapter, sk_sp<sksg::GeometryNode>>
|
||||
(jellipse, abuilder);
|
||||
return abuilder->attachDiscardableAdapter<EllipseGeometryAdapter>(jellipse, abuilder);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -129,7 +129,7 @@ sk_sp<sksg::PaintNode> ShapeBuilder::AttachFill(const skjson::ObjectValue& jpain
|
||||
const AnimationBuilder* abuilder,
|
||||
sk_sp<sksg::PaintNode> paint_node,
|
||||
sk_sp<AnimatablePropertyContainer> gradient) {
|
||||
return abuilder->attachDiscardableAdapter<FillStrokeAdapter, sk_sp<sksg::PaintNode>>
|
||||
return abuilder->attachDiscardableAdapter<FillStrokeAdapter>
|
||||
(jpaint,
|
||||
*abuilder,
|
||||
std::move(paint_node),
|
||||
@ -141,7 +141,7 @@ sk_sp<sksg::PaintNode> ShapeBuilder::AttachStroke(const skjson::ObjectValue& jpa
|
||||
const AnimationBuilder* abuilder,
|
||||
sk_sp<sksg::PaintNode> paint_node,
|
||||
sk_sp<AnimatablePropertyContainer> gradient) {
|
||||
return abuilder->attachDiscardableAdapter<FillStrokeAdapter, sk_sp<sksg::PaintNode>>
|
||||
return abuilder->attachDiscardableAdapter<FillStrokeAdapter>
|
||||
(jpaint,
|
||||
*abuilder,
|
||||
std::move(paint_node),
|
||||
@ -173,7 +173,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AdjustStrokeGeometry(
|
||||
const skjson::ArrayValue* jdash = jstroke["d"];
|
||||
if (jdash && jdash->size() > 1) {
|
||||
for (size_t i = 0; i < geos.size(); ++i) {
|
||||
geos[i] = abuilder->attachDiscardableAdapter<DashAdapter, sk_sp<sksg::GeometryNode>>(
|
||||
geos[i] = abuilder->attachDiscardableAdapter<DashAdapter>(
|
||||
*jdash, *abuilder, std::move(geos[i]));
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ sk_sp<sksg::GeometryNode> ShapeBuilder::AttachPolystarGeometry(const skjson::Obj
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return abuilder->attachDiscardableAdapter<PolystarGeometryAdapter, sk_sp<sksg::GeometryNode>>
|
||||
return abuilder->attachDiscardableAdapter<PolystarGeometryAdapter>
|
||||
(jstar, abuilder, gTypes[type]);
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,7 @@ private:
|
||||
|
||||
sk_sp<sksg::GeometryNode> ShapeBuilder::AttachRRectGeometry(const skjson::ObjectValue& jrect,
|
||||
const AnimationBuilder* abuilder) {
|
||||
return abuilder->attachDiscardableAdapter<RectangleGeometryAdapter, sk_sp<sksg::GeometryNode>>
|
||||
(jrect, abuilder);
|
||||
return abuilder->attachDiscardableAdapter<RectangleGeometryAdapter>(jrect, abuilder);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -47,7 +47,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachRoundGeometryEffect(
|
||||
|
||||
for (auto& g : geos) {
|
||||
rounded.push_back(
|
||||
abuilder->attachDiscardableAdapter<RoundCornersAdapter, sk_sp<sksg::RoundEffect>>
|
||||
abuilder->attachDiscardableAdapter<RoundCornersAdapter>
|
||||
(jround, *abuilder, std::move(g)));
|
||||
}
|
||||
|
||||
|
@ -95,8 +95,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachTrimGeometryEffect(
|
||||
|
||||
for (const auto& i : inputs) {
|
||||
trimmed.push_back(
|
||||
abuilder->attachDiscardableAdapter<TrimEffectAdapter, sk_sp<sksg::TrimEffect>>
|
||||
(jtrim, *abuilder, i));
|
||||
abuilder->attachDiscardableAdapter<TrimEffectAdapter>(jtrim, *abuilder, i));
|
||||
}
|
||||
|
||||
return trimmed;
|
||||
|
Loading…
Reference in New Issue
Block a user