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
|
} // namespace
|
||||||
|
|
||||||
sk_sp<sksg::Path> AnimationBuilder::attachPath(const skjson::Value& jpath) const {
|
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
|
} // namespace internal
|
||||||
|
@ -118,16 +118,19 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename NodeType = sk_sp<sksg::RenderNode>, typename... Args>
|
template <typename T, typename... Args>
|
||||||
NodeType attachDiscardableAdapter(Args&&... args) const {
|
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)...)) {
|
if (auto adapter = T::Make(std::forward<Args>(args)...)) {
|
||||||
auto node = adapter->node();
|
node = adapter->node();
|
||||||
this->attachDiscardableAdapter(std::move(adapter));
|
this->attachDiscardableAdapter(std::move(adapter));
|
||||||
|
|
||||||
return std::move(node);
|
|
||||||
}
|
}
|
||||||
|
return node;
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AutoPropertyTracker {
|
class AutoPropertyTracker {
|
||||||
|
@ -48,8 +48,7 @@ private:
|
|||||||
|
|
||||||
sk_sp<sksg::GeometryNode> ShapeBuilder::AttachEllipseGeometry(const skjson::ObjectValue& jellipse,
|
sk_sp<sksg::GeometryNode> ShapeBuilder::AttachEllipseGeometry(const skjson::ObjectValue& jellipse,
|
||||||
const AnimationBuilder* abuilder) {
|
const AnimationBuilder* abuilder) {
|
||||||
return abuilder->attachDiscardableAdapter<EllipseGeometryAdapter, sk_sp<sksg::GeometryNode>>
|
return abuilder->attachDiscardableAdapter<EllipseGeometryAdapter>(jellipse, abuilder);
|
||||||
(jellipse, abuilder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@ -129,7 +129,7 @@ sk_sp<sksg::PaintNode> ShapeBuilder::AttachFill(const skjson::ObjectValue& jpain
|
|||||||
const AnimationBuilder* abuilder,
|
const AnimationBuilder* abuilder,
|
||||||
sk_sp<sksg::PaintNode> paint_node,
|
sk_sp<sksg::PaintNode> paint_node,
|
||||||
sk_sp<AnimatablePropertyContainer> gradient) {
|
sk_sp<AnimatablePropertyContainer> gradient) {
|
||||||
return abuilder->attachDiscardableAdapter<FillStrokeAdapter, sk_sp<sksg::PaintNode>>
|
return abuilder->attachDiscardableAdapter<FillStrokeAdapter>
|
||||||
(jpaint,
|
(jpaint,
|
||||||
*abuilder,
|
*abuilder,
|
||||||
std::move(paint_node),
|
std::move(paint_node),
|
||||||
@ -141,7 +141,7 @@ sk_sp<sksg::PaintNode> ShapeBuilder::AttachStroke(const skjson::ObjectValue& jpa
|
|||||||
const AnimationBuilder* abuilder,
|
const AnimationBuilder* abuilder,
|
||||||
sk_sp<sksg::PaintNode> paint_node,
|
sk_sp<sksg::PaintNode> paint_node,
|
||||||
sk_sp<AnimatablePropertyContainer> gradient) {
|
sk_sp<AnimatablePropertyContainer> gradient) {
|
||||||
return abuilder->attachDiscardableAdapter<FillStrokeAdapter, sk_sp<sksg::PaintNode>>
|
return abuilder->attachDiscardableAdapter<FillStrokeAdapter>
|
||||||
(jpaint,
|
(jpaint,
|
||||||
*abuilder,
|
*abuilder,
|
||||||
std::move(paint_node),
|
std::move(paint_node),
|
||||||
@ -173,7 +173,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AdjustStrokeGeometry(
|
|||||||
const skjson::ArrayValue* jdash = jstroke["d"];
|
const skjson::ArrayValue* jdash = jstroke["d"];
|
||||||
if (jdash && jdash->size() > 1) {
|
if (jdash && jdash->size() > 1) {
|
||||||
for (size_t i = 0; i < geos.size(); ++i) {
|
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]));
|
*jdash, *abuilder, std::move(geos[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ sk_sp<sksg::GeometryNode> ShapeBuilder::AttachPolystarGeometry(const skjson::Obj
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return abuilder->attachDiscardableAdapter<PolystarGeometryAdapter, sk_sp<sksg::GeometryNode>>
|
return abuilder->attachDiscardableAdapter<PolystarGeometryAdapter>
|
||||||
(jstar, abuilder, gTypes[type]);
|
(jstar, abuilder, gTypes[type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,7 @@ private:
|
|||||||
|
|
||||||
sk_sp<sksg::GeometryNode> ShapeBuilder::AttachRRectGeometry(const skjson::ObjectValue& jrect,
|
sk_sp<sksg::GeometryNode> ShapeBuilder::AttachRRectGeometry(const skjson::ObjectValue& jrect,
|
||||||
const AnimationBuilder* abuilder) {
|
const AnimationBuilder* abuilder) {
|
||||||
return abuilder->attachDiscardableAdapter<RectangleGeometryAdapter, sk_sp<sksg::GeometryNode>>
|
return abuilder->attachDiscardableAdapter<RectangleGeometryAdapter>(jrect, abuilder);
|
||||||
(jrect, abuilder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@ -47,7 +47,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachRoundGeometryEffect(
|
|||||||
|
|
||||||
for (auto& g : geos) {
|
for (auto& g : geos) {
|
||||||
rounded.push_back(
|
rounded.push_back(
|
||||||
abuilder->attachDiscardableAdapter<RoundCornersAdapter, sk_sp<sksg::RoundEffect>>
|
abuilder->attachDiscardableAdapter<RoundCornersAdapter>
|
||||||
(jround, *abuilder, std::move(g)));
|
(jround, *abuilder, std::move(g)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +95,7 @@ std::vector<sk_sp<sksg::GeometryNode>> ShapeBuilder::AttachTrimGeometryEffect(
|
|||||||
|
|
||||||
for (const auto& i : inputs) {
|
for (const auto& i : inputs) {
|
||||||
trimmed.push_back(
|
trimmed.push_back(
|
||||||
abuilder->attachDiscardableAdapter<TrimEffectAdapter, sk_sp<sksg::TrimEffect>>
|
abuilder->attachDiscardableAdapter<TrimEffectAdapter>(jtrim, *abuilder, i));
|
||||||
(jtrim, *abuilder, i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return trimmed;
|
return trimmed;
|
||||||
|
Loading…
Reference in New Issue
Block a user