From 8cb108979523ec55b5213a719a77358f9dad47a0 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 19 Mar 2021 16:15:08 +0100 Subject: Cleanup: Rename copyContentFrom to fill_from. --- .../blender/compositor/intern/COM_ExecutionGroup.cc | 2 +- .../blender/compositor/intern/COM_MemoryBuffer.cc | 21 ++++++++------------- source/blender/compositor/intern/COM_MemoryBuffer.h | 2 +- .../operations/COM_WriteBufferOperation.cc | 2 +- 4 files changed, 11 insertions(+), 16 deletions(-) (limited to 'source') diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index 97067c75649..cf7d6206910 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -384,7 +384,7 @@ MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy &mem { MemoryBuffer *imageBuffer = memoryProxy.getBuffer(); MemoryBuffer *result = new MemoryBuffer(&memoryProxy, rect); - result->copyContentFrom(imageBuffer); + result->fill_from(*imageBuffer); return result; } diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc index 2664612beed..b812659543b 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cc +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc @@ -132,7 +132,7 @@ float MemoryBuffer::getMaximumValue(rcti *rect) if (!BLI_rcti_is_empty(&rect_clamp)) { MemoryBuffer temp_buffer(this->m_datatype, rect_clamp); - temp_buffer.copyContentFrom(this); + temp_buffer.fill_from(*this); return temp_buffer.getMaximumValue(); } @@ -148,28 +148,23 @@ MemoryBuffer::~MemoryBuffer() } } -void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer) +void MemoryBuffer::fill_from(const MemoryBuffer &src) { - if (!otherBuffer) { - BLI_assert(0); - return; - } unsigned int otherY; - unsigned int minX = MAX2(this->m_rect.xmin, otherBuffer->m_rect.xmin); - unsigned int maxX = MIN2(this->m_rect.xmax, otherBuffer->m_rect.xmax); - unsigned int minY = MAX2(this->m_rect.ymin, otherBuffer->m_rect.ymin); - unsigned int maxY = MIN2(this->m_rect.ymax, otherBuffer->m_rect.ymax); + unsigned int minX = MAX2(this->m_rect.xmin, src.m_rect.xmin); + unsigned int maxX = MIN2(this->m_rect.xmax, src.m_rect.xmax); + unsigned int minY = MAX2(this->m_rect.ymin, src.m_rect.ymin); + unsigned int maxY = MIN2(this->m_rect.ymax, src.m_rect.ymax); int offset; int otherOffset; for (otherY = minY; otherY < maxY; otherY++) { - otherOffset = ((otherY - otherBuffer->m_rect.ymin) * otherBuffer->m_width + minX - - otherBuffer->m_rect.xmin) * + otherOffset = ((otherY - src.m_rect.ymin) * src.m_width + minX - src.m_rect.xmin) * this->m_num_channels; offset = ((otherY - this->m_rect.ymin) * this->m_width + minX - this->m_rect.xmin) * this->m_num_channels; memcpy(&this->m_buffer[offset], - &otherBuffer->m_buffer[otherOffset], + &src.m_buffer[otherOffset], (maxX - minX) * this->m_num_channels * sizeof(float)); } } diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index e19837b49c2..bc6306754e0 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -319,7 +319,7 @@ class MemoryBuffer { * \note take care when running this on a new buffer since it wont fill in * uninitialized values in areas where the buffers don't overlap. */ - void copyContentFrom(MemoryBuffer *otherBuffer); + void fill_from(const MemoryBuffer &src); /** * \brief get the rect of this MemoryBuffer diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cc b/source/blender/compositor/operations/COM_WriteBufferOperation.cc index 8d38dbfe180..23d0c7f6eac 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cc +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cc @@ -181,7 +181,7 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device, printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer); + this->getMemoryProxy()->getBuffer()->fill_from(*outputBuffer); // STEP 4 while (!clMemToCleanUp->empty()) { -- cgit v1.2.3