sw_engine: ++thread-safety

One more regression bug by afea40a947

As tasks will now be triggered by other tasks on the worker threads,
the designated memory pool data (outline) for each thread should be
reset before moving on to other tasks.

@Issue: https://github.com/thorvg/thorvg/issues/1409
This commit is contained in:
Hermet Park 2023-04-29 22:25:16 +09:00
parent e9b12aa9f7
commit bc7b448c01

View file

@ -167,6 +167,9 @@ struct SwShapeTask : SwTask
}
}
//Clear current task memorypool here if the clippers would use the same memory pool
shapeDelOutline(&shape, mpool, tid);
//Clip Path
for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) {
auto clipper = static_cast<SwTask*>(*clip);
@ -177,11 +180,10 @@ struct SwShapeTask : SwTask
//Clip stroke rle
if (shape.strokeRle && !clipper->clip(shape.strokeRle)) goto err;
}
goto end;
return;
err:
shapeReset(&shape);
end:
shapeDelOutline(&shape, mpool, tid);
}
@ -299,17 +301,19 @@ struct SwImageTask : SwTask
if (mesh->triangleCnt == 0 && clips.count > 0) {
if (!imageGenRle(&image, bbox, false)) goto end;
if (image.rle) {
//Clear current task memorypool here if the clippers would use the same memory pool
imageDelOutline(&image, mpool, tid);
for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) {
auto clipper = static_cast<SwTask*>(*clip);
//Guarantee composition targets get ready.
clipper->done(tid);
if (!clipper->clip(image.rle)) goto err;
}
return;
}
}
}
goto end;
err:
rleReset(image.rle);
end: