Compositor: Fix memory leaks when initializing tiles multi-threaded

It was only affecting tiled fallback on full frame mode. If tiles from a
constant operation were multi-thread initialized, its buffer
was inflated multiple times.
This commit is contained in:
Manuel Castilla 2021-08-10 15:24:38 +02:00
parent 1a9b9dd64d
commit b81d88a8e2
2 changed files with 13 additions and 0 deletions

View File

@ -41,20 +41,32 @@ const float *BufferOperation::get_constant_elem()
return buffer_->getBuffer();
}
void BufferOperation::initExecution()
{
if (buffer_->is_a_single_elem()) {
initMutex();
}
}
void *BufferOperation::initializeTileData(rcti * /*rect*/)
{
if (buffer_->is_a_single_elem() == false) {
return buffer_;
}
lockMutex();
if (!inflated_buffer_) {
inflated_buffer_ = buffer_->inflate();
}
unlockMutex();
return inflated_buffer_;
}
void BufferOperation::deinitExecution()
{
if (buffer_->is_a_single_elem()) {
deinitMutex();
}
delete inflated_buffer_;
}

View File

@ -32,6 +32,7 @@ class BufferOperation : public ConstantOperation {
const float *get_constant_elem() override;
void *initializeTileData(rcti *rect) override;
void initExecution() override;
void deinitExecution() override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
void executePixelFiltered(float output[4], float x, float y, float dx[2], float dy[2]) override;