mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13:43 +00:00
lottie: fixed a memory leak
A regression bug by efe7440fa0
To address this, removed the non-essential image pooling mechanism.
issue: https://github.com/thorvg/thorvg/issues/2959
This commit is contained in:
parent
88098f547f
commit
a989dc9a7d
3 changed files with 12 additions and 7 deletions
|
@ -978,7 +978,7 @@ void LottieBuilder::updateSolid(LottieLayer* layer)
|
||||||
void LottieBuilder::updateImage(LottieGroup* layer)
|
void LottieBuilder::updateImage(LottieGroup* layer)
|
||||||
{
|
{
|
||||||
auto image = static_cast<LottieImage*>(layer->children.first());
|
auto image = static_cast<LottieImage*>(layer->children.first());
|
||||||
layer->scene->push(tvg::cast(image->pooling(true)));
|
layer->scene->push(tvg::cast(image->picture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,10 @@ void LottieImage::prepare()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::Image;
|
LottieObject::type = LottieObject::Image;
|
||||||
|
|
||||||
auto picture = Picture::gen().release();
|
if (!picture) {
|
||||||
|
picture = Picture::gen().release();
|
||||||
|
PP(picture)->ref();
|
||||||
|
}
|
||||||
|
|
||||||
//force to load a picture on the same thread
|
//force to load a picture on the same thread
|
||||||
TaskScheduler::async(false);
|
TaskScheduler::async(false);
|
||||||
|
@ -170,10 +173,6 @@ void LottieImage::prepare()
|
||||||
TaskScheduler::async(true);
|
TaskScheduler::async(true);
|
||||||
|
|
||||||
picture->size(data.width, data.height);
|
picture->size(data.width, data.height);
|
||||||
PP(picture)->ref();
|
|
||||||
|
|
||||||
pooler.reset();
|
|
||||||
pooler.push(picture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -656,9 +656,15 @@ struct LottieGradientStroke : LottieGradient, LottieStroke
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct LottieImage : LottieObject, LottieRenderPooler<tvg::Picture>
|
struct LottieImage : LottieObject
|
||||||
{
|
{
|
||||||
LottieBitmap data;
|
LottieBitmap data;
|
||||||
|
Picture* picture = nullptr;
|
||||||
|
|
||||||
|
~LottieImage()
|
||||||
|
{
|
||||||
|
if (PP(picture)->unref() == 0) delete(picture);
|
||||||
|
}
|
||||||
|
|
||||||
void override(LottieProperty* prop, bool byDefault = false) override
|
void override(LottieProperty* prop, bool byDefault = false) override
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue