mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +00:00
lottie: fix matte layer finding
Layer identifiers do not have to be unique within
the entire file - they are unique within a given
group. Searching the entire composition to find
the referenced matte was an incorrect approach.
Error introduced by 1ee79a6c2a
@Issue: https://github.com/thorvg/thorvg/issues/2349
This commit is contained in:
parent
7c687816c2
commit
ca92d4a53b
2 changed files with 12 additions and 7 deletions
|
@ -98,7 +98,7 @@ struct RenderContext
|
|||
|
||||
static void _updateChildren(LottieGroup* parent, float frameNo, Inlist<RenderContext>& contexts, LottieExpressions* exps);
|
||||
static void _updateLayer(LottieLayer* root, LottieLayer* layer, float frameNo, LottieExpressions* exps);
|
||||
static bool _buildComposition(LottieComposition* comp, LottieGroup* parent);
|
||||
static bool _buildComposition(LottieComposition* comp, LottieLayer* parent);
|
||||
static Shape* _draw(LottieGroup* parent, RenderContext* ctx);
|
||||
|
||||
static void _rotateX(Matrix* m, float degree)
|
||||
|
@ -1315,7 +1315,7 @@ static void _attachFont(LottieComposition* comp, LottieLayer* parent)
|
|||
}
|
||||
|
||||
|
||||
static bool _buildComposition(LottieComposition* comp, LottieGroup* parent)
|
||||
static bool _buildComposition(LottieComposition* comp, LottieLayer* parent)
|
||||
{
|
||||
if (parent->children.count == 0) return false;
|
||||
if (parent->buildDone) return true;
|
||||
|
@ -1334,11 +1334,7 @@ static bool _buildComposition(LottieComposition* comp, LottieGroup* parent)
|
|||
child->matteTarget = static_cast<LottieLayer*>(*(c - 1));
|
||||
}
|
||||
//matte layer is specified by an index.
|
||||
} else {
|
||||
if (auto matte = comp->layerByIdx(child->mid)) {
|
||||
child->matteTarget = matte;
|
||||
}
|
||||
}
|
||||
} else child->matteTarget = parent->layerByIdx(child->mid);
|
||||
}
|
||||
|
||||
if (child->matteTarget) {
|
||||
|
|
|
@ -571,6 +571,15 @@ struct LottieLayer : LottieGroup
|
|||
Type type = Null;
|
||||
bool autoOrient = false;
|
||||
bool matteSrc = false;
|
||||
|
||||
LottieLayer* layerByIdx(int16_t idx)
|
||||
{
|
||||
for (auto child = children.begin(); child < children.end(); ++child) {
|
||||
auto layer = static_cast<LottieLayer*>(*child);
|
||||
if (layer->idx == idx) return layer;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue