mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13: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,11 +455,13 @@ struct LottieGradient : LottieObject
|
||||||
color.input->reset();
|
color.input->reset();
|
||||||
delete(color.input);
|
delete(color.input);
|
||||||
|
|
||||||
|
colorStops.populated = true;
|
||||||
return output.count;
|
return output.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool prepare()
|
bool prepare()
|
||||||
{
|
{
|
||||||
|
if (!colorStops.populated) {
|
||||||
if (colorStops.frames) {
|
if (colorStops.frames) {
|
||||||
for (auto v = colorStops.frames->begin(); v < colorStops.frames->end(); ++v) {
|
for (auto v = colorStops.frames->begin(); v < colorStops.frames->end(); ++v) {
|
||||||
colorStops.count = populate(v->value);
|
colorStops.count = populate(v->value);
|
||||||
|
@ -467,6 +469,7 @@ struct LottieGradient : LottieObject
|
||||||
} else {
|
} else {
|
||||||
colorStops.count = populate(colorStops.value);
|
colorStops.count = populate(colorStops.value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (start.frames || end.frames || height.frames || angle.frames || opacity.frames || colorStops.frames) return true;
|
if (start.frames || end.frames || height.frames || angle.frames || opacity.frames || colorStops.frames) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,6 +361,7 @@ struct LottieColorStop : LottieProperty
|
||||||
Array<LottieScalarFrame<ColorStop>>* frames = nullptr;
|
Array<LottieScalarFrame<ColorStop>>* frames = nullptr;
|
||||||
ColorStop value;
|
ColorStop value;
|
||||||
uint16_t count = 0; //colorstop count
|
uint16_t count = 0; //colorstop count
|
||||||
|
bool populated = false;
|
||||||
|
|
||||||
~LottieColorStop()
|
~LottieColorStop()
|
||||||
{
|
{
|
||||||
|
@ -462,6 +463,7 @@ struct LottieColorStop : LottieProperty
|
||||||
value = other.value;
|
value = other.value;
|
||||||
const_cast<LottieColorStop&>(other).value.data = nullptr;
|
const_cast<LottieColorStop&>(other).value.data = nullptr;
|
||||||
}
|
}
|
||||||
|
populated = other.populated;
|
||||||
count = other.count;
|
count = other.count;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue