mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
sw_engine: ++thread safety
Synchronize the engine process precisely before updating internal data.
This commit is contained in:
parent
7556253c53
commit
1f41c9c80d
1 changed files with 10 additions and 7 deletions
|
@ -713,9 +713,6 @@ void* SwRenderer::prepareCommon(SwTask* task, const RenderTransform* transform,
|
||||||
if (!surface) return task;
|
if (!surface) return task;
|
||||||
if (flags == RenderUpdateFlag::None) return task;
|
if (flags == RenderUpdateFlag::None) return task;
|
||||||
|
|
||||||
//Finish previous task if it has duplicated request.
|
|
||||||
task->done();
|
|
||||||
|
|
||||||
//TODO: Failed threading them. It would be better if it's possible.
|
//TODO: Failed threading them. It would be better if it's possible.
|
||||||
//See: https://github.com/thorvg/thorvg/issues/1409
|
//See: https://github.com/thorvg/thorvg/issues/1409
|
||||||
//Guarantee composition targets get ready.
|
//Guarantee composition targets get ready.
|
||||||
|
@ -764,8 +761,11 @@ RenderData SwRenderer::prepare(Surface* surface, const RenderMesh* mesh, RenderD
|
||||||
//prepare task
|
//prepare task
|
||||||
auto task = static_cast<SwImageTask*>(data);
|
auto task = static_cast<SwImageTask*>(data);
|
||||||
if (!task) task = new SwImageTask;
|
if (!task) task = new SwImageTask;
|
||||||
|
else task->done();
|
||||||
|
|
||||||
task->source = surface;
|
task->source = surface;
|
||||||
task->mesh = mesh;
|
task->mesh = mesh;
|
||||||
|
|
||||||
return prepareCommon(task, transform, clips, opacity, flags);
|
return prepareCommon(task, transform, clips, opacity, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,6 +775,8 @@ RenderData SwRenderer::prepare(const Array<RenderData>& scene, RenderData data,
|
||||||
//prepare task
|
//prepare task
|
||||||
auto task = static_cast<SwSceneTask*>(data);
|
auto task = static_cast<SwSceneTask*>(data);
|
||||||
if (!task) task = new SwSceneTask;
|
if (!task) task = new SwSceneTask;
|
||||||
|
else task->done();
|
||||||
|
|
||||||
task->scene = scene;
|
task->scene = scene;
|
||||||
|
|
||||||
//TODO: Failed threading them. It would be better if it's possible.
|
//TODO: Failed threading them. It would be better if it's possible.
|
||||||
|
@ -783,6 +785,7 @@ RenderData SwRenderer::prepare(const Array<RenderData>& scene, RenderData data,
|
||||||
for (auto task = scene.begin(); task < scene.end(); ++task) {
|
for (auto task = scene.begin(); task < scene.end(); ++task) {
|
||||||
static_cast<SwTask*>(*task)->done();
|
static_cast<SwTask*>(*task)->done();
|
||||||
}
|
}
|
||||||
|
|
||||||
return prepareCommon(task, transform, clips, opacity, flags);
|
return prepareCommon(task, transform, clips, opacity, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,10 +794,10 @@ RenderData SwRenderer::prepare(const RenderShape& rshape, RenderData data, const
|
||||||
{
|
{
|
||||||
//prepare task
|
//prepare task
|
||||||
auto task = static_cast<SwShapeTask*>(data);
|
auto task = static_cast<SwShapeTask*>(data);
|
||||||
if (!task) {
|
if (!task) task = new SwShapeTask;
|
||||||
task = new SwShapeTask;
|
else task->done();
|
||||||
|
|
||||||
task->rshape = &rshape;
|
task->rshape = &rshape;
|
||||||
}
|
|
||||||
task->clipper = clipper;
|
task->clipper = clipper;
|
||||||
|
|
||||||
return prepareCommon(task, transform, clips, opacity, flags);
|
return prepareCommon(task, transform, clips, opacity, flags);
|
||||||
|
|
Loading…
Add table
Reference in a new issue