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 | |
parent | b9447ab053ffe660b7eb1ef8f60bf436a1cec600 (diff) |
Cleanup: Replace ptr with ref (COM_MemoryBuffer).
Diffstat (limited to 'source')
10 files changed, 28 insertions, 30 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); diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cc b/source/blender/compositor/operations/COM_DenoiseOperation.cc index 6a27dc4fd3d..66d0f3fd9bd 100644 --- a/source/blender/compositor/operations/COM_DenoiseOperation.cc +++ b/source/blender/compositor/operations/COM_DenoiseOperation.cc @@ -60,7 +60,7 @@ MemoryBuffer *DenoiseOperation::createMemoryBuffer(rcti *rect2) rect.ymin = 0; rect.xmax = getWidth(); rect.ymax = getHeight(); - MemoryBuffer *result = new MemoryBuffer(DataType::Color, &rect); + MemoryBuffer *result = new MemoryBuffer(DataType::Color, rect); float *data = result->getBuffer(); this->generateDenoise(data, tileColor, tileNormal, tileAlbedo, this->m_settings); return result; diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cc b/source/blender/compositor/operations/COM_GlareBaseOperation.cc index 7ad12d81ac2..cdf64ed8b5a 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.cc +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cc @@ -45,7 +45,7 @@ MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2) rect.ymin = 0; rect.xmax = getWidth(); rect.ymax = getHeight(); - MemoryBuffer *result = new MemoryBuffer(DataType::Color, &rect); + MemoryBuffer *result = new MemoryBuffer(DataType::Color, rect); float *data = result->getBuffer(); this->generateGlare(data, tile, this->m_settings); return result; diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cc b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cc index 463080988a4..8e34210ab4d 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cc +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cc @@ -268,7 +268,7 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2) float *kernelBuffer = in2->getBuffer(); float *imageBuffer = in1->getBuffer(); - MemoryBuffer *rdst = new MemoryBuffer(DataType::Color, in1->getRect()); + MemoryBuffer *rdst = new MemoryBuffer(DataType::Color, *in1->getRect()); memset(rdst->getBuffer(), 0, rdst->getWidth() * rdst->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float)); @@ -417,7 +417,7 @@ void GlareFogGlowOperation::generateGlare(float *data, // make the convolution kernel rcti kernelRect; BLI_rcti_init(&kernelRect, 0, sz, 0, sz); - ckrn = new MemoryBuffer(DataType::Color, &kernelRect); + ckrn = new MemoryBuffer(DataType::Color, kernelRect); scale = 0.25f * sqrtf((float)(sz * sz)); diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.cc b/source/blender/compositor/operations/COM_GlareStreaksOperation.cc index e2d8c7ff68e..f48692fec04 100644 --- a/source/blender/compositor/operations/COM_GlareStreaksOperation.cc +++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.cc @@ -34,7 +34,7 @@ void GlareStreaksOperation::generateGlare(float *data, bool breaked = false; MemoryBuffer *tsrc = inputTile->duplicate(); - MemoryBuffer *tdst = new MemoryBuffer(DataType::Color, inputTile->getRect()); + MemoryBuffer *tdst = new MemoryBuffer(DataType::Color, *inputTile->getRect()); tdst->clear(); memset(data, 0, size4 * sizeof(float)); |