mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
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:
parent
23386625fc
commit
dcdec440df
2 changed files with 10 additions and 5 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue