diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-03-19 16:56:07 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-03-19 19:11:47 +0300 |
commit | c905dd24b694eee0aa29fc95abd50cec62930c23 (patch) | |
tree | 1f3c44fa6cf76ccaab9bc4f5cd27dad32776bf97 /source/blender/compositor/intern | |
parent | b9447ab053ffe660b7eb1ef8f60bf436a1cec600 (diff) |
Cleanup: Replace ptr with ref (COM_MemoryBuffer).
Diffstat (limited to 'source/blender/compositor/intern')
6 files changed, 23 insertions, 25 deletions
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index be54d6582fb..97067c75649 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -373,17 +373,17 @@ MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) MemoryProxy *memoryProxy = readOperation->getMemoryProxy(); this->determineDependingAreaOfInterest(&rect, readOperation, &output); MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer( - memoryProxy, &output); + *memoryProxy, output); memoryBuffers[readOperation->getOffset()] = memoryBuffer; } return memoryBuffers; } -MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, - rcti *rect) +MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy &memoryProxy, + rcti &rect) { - MemoryBuffer *imageBuffer = memoryProxy->getBuffer(); - MemoryBuffer *result = new MemoryBuffer(memoryProxy, rect); + MemoryBuffer *imageBuffer = memoryProxy.getBuffer(); + MemoryBuffer *result = new MemoryBuffer(&memoryProxy, rect); result->copyContentFrom(imageBuffer); return result; } @@ -454,7 +454,7 @@ void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int chunkNumb determineChunkRect(rect, xChunk, yChunk); } -MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int /*chunkNumber*/, rcti *rect) +MemoryBuffer *ExecutionGroup::allocateOutputBuffer(rcti &rect) { // we assume that this method is only called from complex execution groups. NodeOperation *operation = this->getOutputOperation(); diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h index 471f6ae4545..6fd93d2d93c 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.h +++ b/source/blender/compositor/intern/COM_ExecutionGroup.h @@ -339,7 +339,7 @@ class ExecutionGroup { * \brief compose multiple chunks into a single chunk * \return Memorybuffer *consolidated chunk */ - MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *rect); + MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy &memoryProxy, rcti &rect); /** * \brief initExecution is called just before the execution of the whole graph will be done. @@ -369,7 +369,7 @@ class ExecutionGroup { * \param rect: the rect of that chunk * \see determineChunkRect */ - MemoryBuffer *allocateOutputBuffer(int chunkNumber, rcti *rect); + MemoryBuffer *allocateOutputBuffer(rcti &rect); /** * \brief after a chunk is executed the needed resources can be freed or unlocked. diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc index 60f74e2ae2f..d69fe238e61 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cc +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc @@ -47,9 +47,9 @@ int MemoryBuffer::getHeight() const return this->m_height; } -MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect) +MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti &rect) { - BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + m_rect = rect; this->m_width = BLI_rcti_size_x(&this->m_rect); this->m_height = BLI_rcti_size_y(&this->m_rect); this->m_memoryProxy = memoryProxy; @@ -61,9 +61,9 @@ MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, r this->m_datatype = memoryProxy->getDataType(); } -MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect) +MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti &rect) { - BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + m_rect = rect; this->m_width = BLI_rcti_size_x(&this->m_rect); this->m_height = BLI_rcti_size_y(&this->m_rect); this->m_memoryProxy = memoryProxy; @@ -74,9 +74,9 @@ MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect) this->m_state = COM_MB_TEMPORARILY; this->m_datatype = memoryProxy->getDataType(); } -MemoryBuffer::MemoryBuffer(DataType dataType, rcti *rect) +MemoryBuffer::MemoryBuffer(DataType dataType, rcti &rect) { - BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + m_rect = rect; this->m_width = BLI_rcti_size_x(&this->m_rect); this->m_height = BLI_rcti_size_y(&this->m_rect); this->m_height = this->m_rect.ymax - this->m_rect.ymin; @@ -90,7 +90,7 @@ MemoryBuffer::MemoryBuffer(DataType dataType, rcti *rect) } MemoryBuffer *MemoryBuffer::duplicate() { - MemoryBuffer *result = new MemoryBuffer(this->m_memoryProxy, &this->m_rect); + MemoryBuffer *result = new MemoryBuffer(this->m_memoryProxy, this->m_rect); memcpy(result->m_buffer, this->m_buffer, this->determineBufferSize() * this->m_num_channels * sizeof(float)); @@ -127,11 +127,9 @@ float MemoryBuffer::getMaximumValue(rcti *rect) BLI_rcti_isect(rect, &this->m_rect, &rect_clamp); if (!BLI_rcti_is_empty(&rect_clamp)) { - MemoryBuffer *temp = new MemoryBuffer(this->m_datatype, &rect_clamp); - temp->copyContentFrom(this); - float result = temp->getMaximumValue(); - delete temp; - return result; + MemoryBuffer temp_buffer(this->m_datatype, rect_clamp); + temp_buffer.copyContentFrom(this); + return temp_buffer.getMaximumValue(); } BLI_assert(0); diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index 77661f54db5..3242f4a3d75 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -98,17 +98,17 @@ class MemoryBuffer { /** * \brief construct new MemoryBuffer for a chunk */ - MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect); + MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti &rect); /** * \brief construct new temporarily MemoryBuffer for an area */ - MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect); + MemoryBuffer(MemoryProxy *memoryProxy, rcti &rect); /** * \brief construct new temporarily MemoryBuffer for an area */ - MemoryBuffer(DataType datatype, rcti *rect); + MemoryBuffer(DataType datatype, rcti &rect); /** * \brief destructor diff --git a/source/blender/compositor/intern/COM_MemoryProxy.cc b/source/blender/compositor/intern/COM_MemoryProxy.cc index 7d590cd0ef6..3cd56e9998e 100644 --- a/source/blender/compositor/intern/COM_MemoryProxy.cc +++ b/source/blender/compositor/intern/COM_MemoryProxy.cc @@ -33,7 +33,7 @@ void MemoryProxy::allocate(unsigned int width, unsigned int height) result.ymin = 0; result.ymax = height; - this->m_buffer = new MemoryBuffer(this, 1, &result); + this->m_buffer = new MemoryBuffer(this, 1, result); } void MemoryProxy::free() diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cc b/source/blender/compositor/intern/COM_OpenCLDevice.cc index 34450366aec..838376d2e63 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cc +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cc @@ -67,7 +67,7 @@ void OpenCLDevice::execute(WorkPackage *work) executionGroup->determineChunkRect(&rect, chunkNumber); MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber); - MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect); + MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(rect); executionGroup->getOutputOperation()->executeOpenCLRegion( this, &rect, chunkNumber, inputBuffers, outputBuffer); |