lottie: Added gradient population preventing logic

`LottieGradient.populate` function checks whether the value has already been calculated and populated via the flag `populated`.
This commit is contained in:
Jinny You 2024-03-20 11:01:22 +09:00 committed by Hermet Park
parent 23386625fc
commit dcdec440df
2 changed files with 10 additions and 5 deletions

View file

@ -455,17 +455,20 @@ struct LottieGradient : LottieObject
color.input->reset();
delete(color.input);
colorStops.populated = true;
return output.count;
}
bool prepare()
{
if (colorStops.frames) {
for (auto v = colorStops.frames->begin(); v < colorStops.frames->end(); ++v) {
colorStops.count = populate(v->value);
if (!colorStops.populated) {
if (colorStops.frames) {
for (auto v = colorStops.frames->begin(); v < colorStops.frames->end(); ++v) {
colorStops.count = populate(v->value);
}
} else {
colorStops.count = populate(colorStops.value);
}
} else {
colorStops.count = populate(colorStops.value);
}
if (start.frames || end.frames || height.frames || angle.frames || opacity.frames || colorStops.frames) return true;
return false;

View file

@ -361,6 +361,7 @@ struct LottieColorStop : LottieProperty
Array<LottieScalarFrame<ColorStop>>* frames = nullptr;
ColorStop value;
uint16_t count = 0; //colorstop count
bool populated = false;
~LottieColorStop()
{
@ -462,6 +463,7 @@ struct LottieColorStop : LottieProperty
value = other.value;
const_cast<LottieColorStop&>(other).value.data = nullptr;
}
populated = other.populated;
count = other.count;
return *this;
}