mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
lottie: code refactoring
align the internal naming for lottie "ix" properites and its variables
This commit is contained in:
parent
882cb316c4
commit
e308d3416a
4 changed files with 19 additions and 19 deletions
|
@ -1450,9 +1450,9 @@ static void _buildReference(LottieComposition* comp, LottieLayer* layer)
|
||||||
|
|
||||||
static void _buildHierarchy(LottieGroup* parent, LottieLayer* child)
|
static void _buildHierarchy(LottieGroup* parent, LottieLayer* child)
|
||||||
{
|
{
|
||||||
if (child->pidx == -1) return;
|
if (child->pix == -1) return;
|
||||||
|
|
||||||
if (child->matteTarget && child->pidx == child->matteTarget->idx) {
|
if (child->matteTarget && child->pix == child->matteTarget->ix) {
|
||||||
child->parent = child->matteTarget;
|
child->parent = child->matteTarget;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1460,11 +1460,11 @@ static void _buildHierarchy(LottieGroup* parent, LottieLayer* child)
|
||||||
ARRAY_FOREACH(p, parent->children) {
|
ARRAY_FOREACH(p, parent->children) {
|
||||||
auto parent = static_cast<LottieLayer*>(*p);
|
auto parent = static_cast<LottieLayer*>(*p);
|
||||||
if (child == parent) continue;
|
if (child == parent) continue;
|
||||||
if (child->pidx == parent->idx) {
|
if (child->pix == parent->ix) {
|
||||||
child->parent = parent;
|
child->parent = parent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (parent->matteTarget && parent->matteTarget->idx == child->pidx) {
|
if (parent->matteTarget && parent->matteTarget->ix == child->pix) {
|
||||||
child->parent = parent->matteTarget;
|
child->parent = parent->matteTarget;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1506,12 +1506,12 @@ static bool _buildComposition(LottieComposition* comp, LottieLayer* parent)
|
||||||
|
|
||||||
if (child->matteType != MaskMethod::None) {
|
if (child->matteType != MaskMethod::None) {
|
||||||
//no index of the matte layer is provided: the layer above is used as the matte source
|
//no index of the matte layer is provided: the layer above is used as the matte source
|
||||||
if (child->mid == -1) {
|
if (child->mix == -1) {
|
||||||
if (p > parent->children.begin()) {
|
if (p > parent->children.begin()) {
|
||||||
child->matteTarget = static_cast<LottieLayer*>(*(p - 1));
|
child->matteTarget = static_cast<LottieLayer*>(*(p - 1));
|
||||||
}
|
}
|
||||||
//matte layer is specified by an index.
|
//matte layer is specified by an index.
|
||||||
} else child->matteTarget = parent->layerByIdx(child->mid);
|
} else child->matteTarget = parent->layerByIdx(child->mix);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (child->matteTarget) {
|
if (child->matteTarget) {
|
||||||
|
|
|
@ -334,7 +334,7 @@ static void _buildLayer(jerry_value_t context, float frameNo, LottieLayer* layer
|
||||||
jerry_object_set_sz(context, EXP_HEIGHT, height);
|
jerry_object_set_sz(context, EXP_HEIGHT, height);
|
||||||
jerry_value_free(height);
|
jerry_value_free(height);
|
||||||
|
|
||||||
auto index = jerry_number(layer->idx);
|
auto index = jerry_number(layer->ix);
|
||||||
jerry_object_set_sz(context, EXP_INDEX, index);
|
jerry_object_set_sz(context, EXP_INDEX, index);
|
||||||
jerry_value_free(index);
|
jerry_value_free(index);
|
||||||
|
|
||||||
|
@ -1242,7 +1242,7 @@ static void _buildMath(jerry_value_t context)
|
||||||
|
|
||||||
void LottieExpressions::buildGlobal(LottieExpression* exp)
|
void LottieExpressions::buildGlobal(LottieExpression* exp)
|
||||||
{
|
{
|
||||||
auto index = jerry_number(exp->layer->idx);
|
auto index = jerry_number(exp->layer->ix);
|
||||||
jerry_object_set_sz(global, EXP_INDEX, index);
|
jerry_object_set_sz(global, EXP_INDEX, index);
|
||||||
jerry_value_free(index);
|
jerry_value_free(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ struct LottieEffect
|
||||||
|
|
||||||
virtual ~LottieEffect() {}
|
virtual ~LottieEffect() {}
|
||||||
|
|
||||||
unsigned long id;
|
unsigned long nm; //encoded by djb2
|
||||||
int16_t ix;
|
int16_t ix;
|
||||||
Type type;
|
Type type;
|
||||||
bool enable = false;
|
bool enable = false;
|
||||||
|
@ -988,9 +988,9 @@ struct LottieLayer : LottieGroup
|
||||||
float outFrame = 0.0f;
|
float outFrame = 0.0f;
|
||||||
float startFrame = 0.0f;
|
float startFrame = 0.0f;
|
||||||
unsigned long rid = 0; //pre-composition reference id.
|
unsigned long rid = 0; //pre-composition reference id.
|
||||||
int16_t mid = -1; //id of the matte layer.
|
int16_t mix = -1; //index of the matte layer.
|
||||||
int16_t pidx = -1; //index of the parent layer.
|
int16_t pix = -1; //index of the parent layer.
|
||||||
int16_t idx = -1; //index of the current layer.
|
int16_t ix = -1; //index of the current layer.
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
float frameNo = -1.0f;
|
float frameNo = -1.0f;
|
||||||
|
@ -1007,7 +1007,7 @@ struct LottieLayer : LottieGroup
|
||||||
LottieEffect* effectById(unsigned long id)
|
LottieEffect* effectById(unsigned long id)
|
||||||
{
|
{
|
||||||
ARRAY_FOREACH(p, effects) {
|
ARRAY_FOREACH(p, effects) {
|
||||||
if (id == (*p)->id) return *p;
|
if (id == (*p)->nm) return *p;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1031,12 +1031,12 @@ struct LottieLayer : LottieGroup
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LottieLayer* layerByIdx(int16_t idx)
|
LottieLayer* layerByIdx(int16_t ix)
|
||||||
{
|
{
|
||||||
ARRAY_FOREACH(p, children) {
|
ARRAY_FOREACH(p, children) {
|
||||||
if ((*p)->type != LottieObject::Type::Layer) continue;
|
if ((*p)->type != LottieObject::Type::Layer) continue;
|
||||||
auto layer = static_cast<LottieLayer*>(*p);
|
auto layer = static_cast<LottieLayer*>(*p);
|
||||||
if (layer->idx == idx) return layer;
|
if (layer->ix == ix) return layer;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1415,7 +1415,7 @@ void LottieParser::parseEffects(LottieLayer* layer)
|
||||||
if (!effect) break;
|
if (!effect) break;
|
||||||
else invalid = false;
|
else invalid = false;
|
||||||
}
|
}
|
||||||
else if (effect && KEY_AS("nm")) effect->id = djb2Encode(getString());
|
else if (effect && KEY_AS("nm")) effect->nm = djb2Encode(getString());
|
||||||
else if (effect && KEY_AS("ix")) effect->ix = getInt();
|
else if (effect && KEY_AS("ix")) effect->ix = getInt();
|
||||||
else if (effect && KEY_AS("en")) effect->enable = getInt();
|
else if (effect && KEY_AS("en")) effect->enable = getInt();
|
||||||
else if (effect && KEY_AS("ef")) parseEffect(effect);
|
else if (effect && KEY_AS("ef")) parseEffect(effect);
|
||||||
|
@ -1449,7 +1449,7 @@ LottieLayer* LottieParser::parseLayer(LottieLayer* precomp)
|
||||||
layer->id = djb2Encode(layer->name);
|
layer->id = djb2Encode(layer->name);
|
||||||
}
|
}
|
||||||
else if (KEY_AS("ddd")) ddd = getInt(); //3d layer
|
else if (KEY_AS("ddd")) ddd = getInt(); //3d layer
|
||||||
else if (KEY_AS("ind")) layer->idx = getInt();
|
else if (KEY_AS("ind")) layer->ix = getInt();
|
||||||
else if (KEY_AS("ty")) layer->type = (LottieLayer::Type) getInt();
|
else if (KEY_AS("ty")) layer->type = (LottieLayer::Type) getInt();
|
||||||
else if (KEY_AS("sr")) layer->timeStretch = getFloat();
|
else if (KEY_AS("sr")) layer->timeStretch = getFloat();
|
||||||
else if (KEY_AS("ks"))
|
else if (KEY_AS("ks"))
|
||||||
|
@ -1463,13 +1463,13 @@ LottieLayer* LottieParser::parseLayer(LottieLayer* precomp)
|
||||||
else if (KEY_AS("op")) layer->outFrame = getFloat();
|
else if (KEY_AS("op")) layer->outFrame = getFloat();
|
||||||
else if (KEY_AS("st")) layer->startFrame = getFloat();
|
else if (KEY_AS("st")) layer->startFrame = getFloat();
|
||||||
else if (KEY_AS("bm")) layer->blendMethod = (BlendMethod) getInt();
|
else if (KEY_AS("bm")) layer->blendMethod = (BlendMethod) getInt();
|
||||||
else if (KEY_AS("parent")) layer->pidx = getInt();
|
else if (KEY_AS("parent")) layer->pix = getInt();
|
||||||
else if (KEY_AS("tm")) parseTimeRemap(layer);
|
else if (KEY_AS("tm")) parseTimeRemap(layer);
|
||||||
else if (KEY_AS("w") || KEY_AS("sw")) getLayerSize(layer->w);
|
else if (KEY_AS("w") || KEY_AS("sw")) getLayerSize(layer->w);
|
||||||
else if (KEY_AS("h") || KEY_AS("sh")) getLayerSize(layer->h);
|
else if (KEY_AS("h") || KEY_AS("sh")) getLayerSize(layer->h);
|
||||||
else if (KEY_AS("sc")) color = getColor(getString());
|
else if (KEY_AS("sc")) color = getColor(getString());
|
||||||
else if (KEY_AS("tt")) layer->matteType = (MaskMethod) getInt();
|
else if (KEY_AS("tt")) layer->matteType = (MaskMethod) getInt();
|
||||||
else if (KEY_AS("tp")) layer->mid = getInt();
|
else if (KEY_AS("tp")) layer->mix = getInt();
|
||||||
else if (KEY_AS("masksProperties")) parseMasks(layer);
|
else if (KEY_AS("masksProperties")) parseMasks(layer);
|
||||||
else if (KEY_AS("hd")) layer->hidden = getBool();
|
else if (KEY_AS("hd")) layer->hidden = getBool();
|
||||||
else if (KEY_AS("refId")) layer->rid = djb2Encode(getString());
|
else if (KEY_AS("refId")) layer->rid = djb2Encode(getString());
|
||||||
|
|
Loading…
Add table
Reference in a new issue