From bc7b448c01f35a027bf2ba0b207ab3f55ec3d945 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sat, 29 Apr 2023 22:25:16 +0900 Subject: [PATCH] sw_engine: ++thread-safety One more regression bug by afea40a947c7c902b5242e82c13ec5625bedfe59 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 --- src/lib/sw_engine/tvgSwRenderer.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRenderer.cpp b/src/lib/sw_engine/tvgSwRenderer.cpp index 74e5965e..bc35ebb8 100644 --- a/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/src/lib/sw_engine/tvgSwRenderer.cpp @@ -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(*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(*clip); //Guarantee composition targets get ready. clipper->done(tid); if (!clipper->clip(image.rle)) goto err; } + return; } } } goto end; - err: rleReset(image.rle); end: