mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
lottie: compact code++
use constructor to remove unnecessary function call
This commit is contained in:
parent
97058badbf
commit
951ea77f5d
2 changed files with 16 additions and 60 deletions
|
@ -279,7 +279,7 @@ struct LottieText : LottieObject, LottieRenderPooler<tvg::Shape>
|
||||||
LottiePoint anchor{};
|
LottiePoint anchor{};
|
||||||
} alignOption;
|
} alignOption;
|
||||||
|
|
||||||
void prepare()
|
LottieText()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::Text;
|
LottieObject::type = LottieObject::Text;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,6 @@ struct LottieText : LottieObject, LottieRenderPooler<tvg::Shape>
|
||||||
{
|
{
|
||||||
if (byDefault) doc.release();
|
if (byDefault) doc.release();
|
||||||
doc.copy(*static_cast<LottieTextDoc*>(prop), shallow);
|
doc.copy(*static_cast<LottieTextDoc*>(prop), shallow);
|
||||||
prepare();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LottieProperty* property(uint16_t ix) override
|
LottieProperty* property(uint16_t ix) override
|
||||||
|
@ -312,7 +311,7 @@ struct LottieTrimpath : LottieObject
|
||||||
{
|
{
|
||||||
enum Type : uint8_t { Simultaneous = 1, Individual = 2 };
|
enum Type : uint8_t { Simultaneous = 1, Individual = 2 };
|
||||||
|
|
||||||
void prepare()
|
LottieTrimpath()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::Trimpath;
|
LottieObject::type = LottieObject::Trimpath;
|
||||||
}
|
}
|
||||||
|
@ -351,7 +350,7 @@ struct LottieShape : LottieObject, LottieRenderPooler<tvg::Shape>
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepare(LottieObject::Type type)
|
LottieShape(LottieObject::Type type)
|
||||||
{
|
{
|
||||||
LottieObject::type = type;
|
LottieObject::type = type;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +359,7 @@ struct LottieShape : LottieObject, LottieRenderPooler<tvg::Shape>
|
||||||
|
|
||||||
struct LottieRoundedCorner : LottieObject
|
struct LottieRoundedCorner : LottieObject
|
||||||
{
|
{
|
||||||
void prepare()
|
LottieRoundedCorner()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::RoundedCorner;
|
LottieObject::type = LottieObject::RoundedCorner;
|
||||||
}
|
}
|
||||||
|
@ -377,10 +376,7 @@ struct LottieRoundedCorner : LottieObject
|
||||||
|
|
||||||
struct LottiePath : LottieShape
|
struct LottiePath : LottieShape
|
||||||
{
|
{
|
||||||
void prepare()
|
LottiePath() : LottieShape(LottieObject::Path) {}
|
||||||
{
|
|
||||||
LottieShape::prepare(LottieObject::Path);
|
|
||||||
}
|
|
||||||
|
|
||||||
LottieProperty* property(uint16_t ix) override
|
LottieProperty* property(uint16_t ix) override
|
||||||
{
|
{
|
||||||
|
@ -394,10 +390,7 @@ struct LottiePath : LottieShape
|
||||||
|
|
||||||
struct LottieRect : LottieShape
|
struct LottieRect : LottieShape
|
||||||
{
|
{
|
||||||
void prepare()
|
LottieRect() : LottieShape(LottieObject::Rect) {}
|
||||||
{
|
|
||||||
LottieShape::prepare(LottieObject::Rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
LottieProperty* property(uint16_t ix) override
|
LottieProperty* property(uint16_t ix) override
|
||||||
{
|
{
|
||||||
|
@ -417,10 +410,7 @@ struct LottiePolyStar : LottieShape
|
||||||
{
|
{
|
||||||
enum Type : uint8_t {Star = 1, Polygon};
|
enum Type : uint8_t {Star = 1, Polygon};
|
||||||
|
|
||||||
void prepare()
|
LottiePolyStar() : LottieShape(LottieObject::Polystar) {}
|
||||||
{
|
|
||||||
LottieShape::prepare(LottieObject::Polystar);
|
|
||||||
}
|
|
||||||
|
|
||||||
LottieProperty* property(uint16_t ix) override
|
LottieProperty* property(uint16_t ix) override
|
||||||
{
|
{
|
||||||
|
@ -447,10 +437,7 @@ struct LottiePolyStar : LottieShape
|
||||||
|
|
||||||
struct LottieEllipse : LottieShape
|
struct LottieEllipse : LottieShape
|
||||||
{
|
{
|
||||||
void prepare()
|
LottieEllipse() : LottieShape(LottieObject::Ellipse) {}
|
||||||
{
|
|
||||||
LottieShape::prepare(LottieObject::Ellipse);
|
|
||||||
}
|
|
||||||
|
|
||||||
LottieProperty* property(uint16_t ix) override
|
LottieProperty* property(uint16_t ix) override
|
||||||
{
|
{
|
||||||
|
@ -484,7 +471,7 @@ struct LottieTransform : LottieObject
|
||||||
delete(rotationEx);
|
delete(rotationEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepare()
|
LottieTransform()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::Transform;
|
LottieObject::type = LottieObject::Transform;
|
||||||
}
|
}
|
||||||
|
@ -540,7 +527,7 @@ struct LottieSolid : LottieObject
|
||||||
|
|
||||||
struct LottieSolidStroke : LottieSolid, LottieStroke
|
struct LottieSolidStroke : LottieSolid, LottieStroke
|
||||||
{
|
{
|
||||||
void prepare()
|
LottieSolidStroke()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::SolidStroke;
|
LottieObject::type = LottieObject::SolidStroke;
|
||||||
}
|
}
|
||||||
|
@ -560,14 +547,13 @@ struct LottieSolidStroke : LottieSolid, LottieStroke
|
||||||
{
|
{
|
||||||
if (byDefault) color.release();
|
if (byDefault) color.release();
|
||||||
color.copy(*static_cast<LottieColor*>(prop), shallow);
|
color.copy(*static_cast<LottieColor*>(prop), shallow);
|
||||||
prepare();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct LottieSolidFill : LottieSolid
|
struct LottieSolidFill : LottieSolid
|
||||||
{
|
{
|
||||||
void prepare()
|
LottieSolidFill()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::SolidFill;
|
LottieObject::type = LottieObject::SolidFill;
|
||||||
}
|
}
|
||||||
|
@ -581,7 +567,6 @@ struct LottieSolidFill : LottieSolid
|
||||||
if (byDefault) color.release();
|
if (byDefault) color.release();
|
||||||
color.copy(*static_cast<LottieColor*>(prop), shallow);
|
color.copy(*static_cast<LottieColor*>(prop), shallow);
|
||||||
}
|
}
|
||||||
prepare();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FillRule rule = FillRule::Winding;
|
FillRule rule = FillRule::Winding;
|
||||||
|
@ -622,6 +607,7 @@ struct LottieGradient : LottieObject
|
||||||
{
|
{
|
||||||
if (byDefault) colorStops.release();
|
if (byDefault) colorStops.release();
|
||||||
colorStops.copy(*static_cast<LottieColorStop*>(prop), shallow);
|
colorStops.copy(*static_cast<LottieColorStop*>(prop), shallow);
|
||||||
|
prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t populate(ColorStop& color, size_t count);
|
uint32_t populate(ColorStop& color, size_t count);
|
||||||
|
@ -639,16 +625,9 @@ struct LottieGradient : LottieObject
|
||||||
|
|
||||||
struct LottieGradientFill : LottieGradient
|
struct LottieGradientFill : LottieGradient
|
||||||
{
|
{
|
||||||
void prepare()
|
LottieGradientFill()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::GradientFill;
|
LottieObject::type = LottieObject::GradientFill;
|
||||||
LottieGradient::prepare();
|
|
||||||
}
|
|
||||||
|
|
||||||
void override(LottieProperty* prop, bool shallow, bool byDefault) override
|
|
||||||
{
|
|
||||||
LottieGradient::override(prop, shallow, byDefault);
|
|
||||||
prepare();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FillRule rule = FillRule::Winding;
|
FillRule rule = FillRule::Winding;
|
||||||
|
@ -657,10 +636,9 @@ struct LottieGradientFill : LottieGradient
|
||||||
|
|
||||||
struct LottieGradientStroke : LottieGradient, LottieStroke
|
struct LottieGradientStroke : LottieGradient, LottieStroke
|
||||||
{
|
{
|
||||||
void prepare()
|
LottieGradientStroke()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::GradientStroke;
|
LottieObject::type = LottieObject::GradientStroke;
|
||||||
LottieGradient::prepare();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LottieProperty* property(uint16_t ix) override
|
LottieProperty* property(uint16_t ix) override
|
||||||
|
@ -673,12 +651,6 @@ struct LottieGradientStroke : LottieGradient, LottieStroke
|
||||||
}
|
}
|
||||||
return LottieGradient::property(ix);
|
return LottieGradient::property(ix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void override(LottieProperty* prop, bool shallow, bool byDefault = false) override
|
|
||||||
{
|
|
||||||
LottieGradient::override(prop, shallow, byDefault);
|
|
||||||
prepare();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -700,7 +672,7 @@ struct LottieImage : LottieObject, LottieRenderPooler<tvg::Picture>
|
||||||
|
|
||||||
struct LottieRepeater : LottieObject
|
struct LottieRepeater : LottieObject
|
||||||
{
|
{
|
||||||
void prepare()
|
LottieRepeater()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::Repeater;
|
LottieObject::type = LottieObject::Repeater;
|
||||||
}
|
}
|
||||||
|
@ -734,7 +706,7 @@ struct LottieRepeater : LottieObject
|
||||||
|
|
||||||
struct LottieOffsetPath : LottieObject
|
struct LottieOffsetPath : LottieObject
|
||||||
{
|
{
|
||||||
void prepare()
|
LottieOffsetPath()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::OffsetPath;
|
LottieObject::type = LottieObject::OffsetPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,7 +552,6 @@ LottieRect* LottieParser::parseRect()
|
||||||
else if (parseDirection(rect, key)) continue;
|
else if (parseDirection(rect, key)) continue;
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
rect->prepare();
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,7 +569,6 @@ LottieEllipse* LottieParser::parseEllipse()
|
||||||
else if (parseDirection(ellipse, key)) continue;
|
else if (parseDirection(ellipse, key)) continue;
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
ellipse->prepare();
|
|
||||||
return ellipse;
|
return ellipse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,7 +611,6 @@ LottieTransform* LottieParser::parseTransform(bool ddd)
|
||||||
else if (KEY_AS("sa")) parseProperty<LottieProperty::Type::Float>(transform->skewAxis);
|
else if (KEY_AS("sa")) parseProperty<LottieProperty::Type::Float>(transform->skewAxis);
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
transform->prepare();
|
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,7 +629,6 @@ LottieSolidFill* LottieParser::parseSolidFill()
|
||||||
else if (KEY_AS("r")) fill->rule = getFillRule();
|
else if (KEY_AS("r")) fill->rule = getFillRule();
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
fill->prepare();
|
|
||||||
return fill;
|
return fill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,7 +671,6 @@ LottieSolidStroke* LottieParser::parseSolidStroke()
|
||||||
else if (KEY_AS("d")) parseStrokeDash(stroke);
|
else if (KEY_AS("d")) parseStrokeDash(stroke);
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
stroke->prepare();
|
|
||||||
return stroke;
|
return stroke;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,7 +704,6 @@ LottiePath* LottieParser::parsePath()
|
||||||
else if (parseDirection(path, key)) continue;
|
else if (parseDirection(path, key)) continue;
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
path->prepare();
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,7 +727,6 @@ LottiePolyStar* LottieParser::parsePolyStar()
|
||||||
else if (parseDirection(star, key)) continue;
|
else if (parseDirection(star, key)) continue;
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
star->prepare();
|
|
||||||
return star;
|
return star;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,7 +742,6 @@ LottieRoundedCorner* LottieParser::parseRoundedCorner()
|
||||||
else if (KEY_AS("r")) parseProperty<LottieProperty::Type::Float>(corner->radius);
|
else if (KEY_AS("r")) parseProperty<LottieProperty::Type::Float>(corner->radius);
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
corner->prepare();
|
|
||||||
return corner;
|
return corner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -832,8 +824,6 @@ LottieTrimpath* LottieParser::parseTrimpath()
|
||||||
else if (KEY_AS("m")) trim->type = static_cast<LottieTrimpath::Type>(getInt());
|
else if (KEY_AS("m")) trim->type = static_cast<LottieTrimpath::Type>(getInt());
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
trim->prepare();
|
|
||||||
|
|
||||||
return trim;
|
return trim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,8 +854,6 @@ LottieRepeater* LottieParser::parseRepeater()
|
||||||
}
|
}
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
repeater->prepare();
|
|
||||||
|
|
||||||
return repeater;
|
return repeater;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,8 +871,6 @@ LottieOffsetPath* LottieParser::parseOffsetPath()
|
||||||
else if (KEY_AS("ml")) parseProperty<LottieProperty::Type::Float>(offsetPath->miterLimit);
|
else if (KEY_AS("ml")) parseProperty<LottieProperty::Type::Float>(offsetPath->miterLimit);
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
offsetPath->prepare();
|
|
||||||
|
|
||||||
return offsetPath;
|
return offsetPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,8 +1205,6 @@ void LottieParser::parseText(Array<LottieObject*>& parent)
|
||||||
}
|
}
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
text->prepare();
|
|
||||||
parent.push(text);
|
parent.push(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue