mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-23 14:48:24 +00:00
lottie: prevent mem leak
Masks of pooled shapes were not unrefed, filling up the memory pool.
This commit is contained in:
parent
955c5b60b2
commit
1f0ff00651
1 changed files with 5 additions and 6 deletions
|
@ -1278,9 +1278,7 @@ void LottieBuilder::updateMasks(LottieLayer* layer, float frameNo)
|
|||
//the first mask
|
||||
if (!pShape) {
|
||||
pShape = layer->pooling();
|
||||
pShape->reset();
|
||||
pShape->fill(255, 255, 255, opacity);
|
||||
pShape->transform(layer->cache.matrix);
|
||||
P(pShape)->reset();
|
||||
auto compMethod = (method == CompositeMethod::SubtractMask || method == CompositeMethod::InvAlphaMask) ? CompositeMethod::InvAlphaMask : CompositeMethod::AlphaMask;
|
||||
//Cheaper. Replace the masking with a clipper
|
||||
if (layer->masks.count == 1 && compMethod == CompositeMethod::AlphaMask) {
|
||||
|
@ -1292,13 +1290,14 @@ void LottieBuilder::updateMasks(LottieLayer* layer, float frameNo)
|
|||
//Chain mask composition
|
||||
} else if (pMethod != method || pOpacity != opacity || (method != CompositeMethod::SubtractMask && method != CompositeMethod::DifferenceMask)) {
|
||||
auto shape = layer->pooling();
|
||||
shape->reset();
|
||||
shape->fill(255, 255, 255, opacity);
|
||||
shape->transform(layer->cache.matrix);
|
||||
P(shape)->reset();
|
||||
pShape->composite(cast(shape), method);
|
||||
pShape = shape;
|
||||
}
|
||||
|
||||
pShape->fill(255, 255, 255, opacity);
|
||||
pShape->transform(layer->cache.matrix);
|
||||
|
||||
//Default Masking
|
||||
if (expand == 0.0f) {
|
||||
mask->pathset(frameNo, P(pShape)->rs.path.cmds, P(pShape)-> rs.path.pts, nullptr, nullptr, nullptr, exps);
|
||||
|
|
Loading…
Add table
Reference in a new issue