mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
commmon: ++neat code
introduced ARRAY_REVERSE_FOREACH() macro.
This commit is contained in:
parent
580019b64b
commit
8833cc8521
3 changed files with 8 additions and 5 deletions
|
@ -30,6 +30,9 @@
|
||||||
#define ARRAY_FOREACH(A, B) \
|
#define ARRAY_FOREACH(A, B) \
|
||||||
for (auto A = (B).begin(); A < (B).end(); ++A)
|
for (auto A = (B).begin(); A < (B).end(); ++A)
|
||||||
|
|
||||||
|
#define ARRAY_REVERSE_FOREACH(A, B) \
|
||||||
|
for (auto A = (B).end() - 1; A >= (B).begin(); --A)
|
||||||
|
|
||||||
namespace tvg
|
namespace tvg
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,7 @@ static void _repeat(LottieGroup* parent, Shape* path, RenderContext* ctx)
|
||||||
propagators.push(ctx->propagator);
|
propagators.push(ctx->propagator);
|
||||||
Array<Shape*> shapes;
|
Array<Shape*> shapes;
|
||||||
|
|
||||||
for (auto repeater = ctx->repeaters.end() - 1; repeater >= ctx->repeaters.begin(); --repeater) {
|
ARRAY_REVERSE_FOREACH(repeater, ctx->repeaters) {
|
||||||
shapes.reserve(repeater->cnt);
|
shapes.reserve(repeater->cnt);
|
||||||
|
|
||||||
for (int i = 0; i < repeater->cnt; ++i) {
|
for (int i = 0; i < repeater->cnt; ++i) {
|
||||||
|
@ -363,7 +363,7 @@ static void _repeat(LottieGroup* parent, Shape* path, RenderContext* ctx)
|
||||||
propagators.push(*p);
|
propagators.push(*p);
|
||||||
}
|
}
|
||||||
} else if (!shapes.empty()) {
|
} else if (!shapes.empty()) {
|
||||||
for (auto shape = shapes.end() - 1; shape >= shapes.begin(); --shape) {
|
ARRAY_REVERSE_FOREACH(shape, shapes) {
|
||||||
parent->scene->push(*shape);
|
parent->scene->push(*shape);
|
||||||
propagators.push(*shape);
|
propagators.push(*shape);
|
||||||
}
|
}
|
||||||
|
@ -949,7 +949,7 @@ void LottieBuilder::updatePrecomp(LottieComposition* comp, LottieLayer* precomp,
|
||||||
|
|
||||||
frameNo = precomp->remap(comp, frameNo, exps);
|
frameNo = precomp->remap(comp, frameNo, exps);
|
||||||
|
|
||||||
for (auto c = precomp->children.end() - 1; c >= precomp->children.begin(); --c) {
|
ARRAY_REVERSE_FOREACH(c, precomp->children) {
|
||||||
auto child = static_cast<LottieLayer*>(*c);
|
auto child = static_cast<LottieLayer*>(*c);
|
||||||
if (!child->matteSrc) updateLayer(comp, precomp->scene, child, frameNo);
|
if (!child->matteSrc) updateLayer(comp, precomp->scene, child, frameNo);
|
||||||
}
|
}
|
||||||
|
@ -1589,7 +1589,7 @@ bool LottieBuilder::update(LottieComposition* comp, float frameNo)
|
||||||
|
|
||||||
if (exps && comp->expressions) exps->update(comp->timeAtFrame(frameNo));
|
if (exps && comp->expressions) exps->update(comp->timeAtFrame(frameNo));
|
||||||
|
|
||||||
for (auto child = root->children.end() - 1; child >= root->children.begin(); --child) {
|
ARRAY_REVERSE_FOREACH(child, root->children) {
|
||||||
auto layer = static_cast<LottieLayer*>(*child);
|
auto layer = static_cast<LottieLayer*>(*child);
|
||||||
if (!layer->matteSrc) updateLayer(comp, root->scene, layer, frameNo);
|
if (!layer->matteSrc) updateLayer(comp, root->scene, layer, frameNo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,7 +409,7 @@ void LottieGroup::prepare(LottieObject::Type type)
|
||||||
size_t strokeCnt = 0;
|
size_t strokeCnt = 0;
|
||||||
size_t fillCnt = 0;
|
size_t fillCnt = 0;
|
||||||
|
|
||||||
for (auto c = children.end() - 1; c >= children.begin(); --c) {
|
ARRAY_REVERSE_FOREACH(c, children) {
|
||||||
auto child = static_cast<LottieObject*>(*c);
|
auto child = static_cast<LottieObject*>(*c);
|
||||||
|
|
||||||
if (child->type == LottieObject::Type::Trimpath) trimpath = true;
|
if (child->type == LottieObject::Type::Trimpath) trimpath = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue