mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43: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
8107582c8b
commit
db800c8d45
3 changed files with 12 additions and 7 deletions
|
@ -980,7 +980,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(image->pooling(true));
|
layer->scene->push(image->picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,10 @@ void LottieImage::prepare()
|
||||||
{
|
{
|
||||||
LottieObject::type = LottieObject::Image;
|
LottieObject::type = LottieObject::Image;
|
||||||
|
|
||||||
auto picture = Picture::gen();
|
if (!picture) {
|
||||||
|
picture = Picture::gen();
|
||||||
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -672,9 +672,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