diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-10-14 00:01:04 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-10-14 00:41:14 +0300 |
commit | a2ee3c3a9f01f5cb2f05f1e84a1b6c1931d9d4a4 (patch) | |
tree | d409678b16280311ed228929a45c9470f67a6dcd /source/blender/compositor/intern/COM_MemoryBuffer.cc | |
parent | ea79efef70da14100b591b50dcada819808f20b6 (diff) |
Cleanup: replace members `m_` prefix by `_` suffix in Compositor
To convert old code to the current convention and
use a single code style.
Diffstat (limited to 'source/blender/compositor/intern/COM_MemoryBuffer.cc')
-rw-r--r-- | source/blender/compositor/intern/COM_MemoryBuffer.cc | 113 |
1 files changed, 56 insertions, 57 deletions
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc index 6851c3b5c5c..3aefe8a3e2f 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cc +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc @@ -46,30 +46,30 @@ static rcti create_rect(const int width, const int height) MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state) { - m_rect = rect; - m_is_a_single_elem = false; - m_memoryProxy = memoryProxy; - m_num_channels = COM_data_type_num_channels(memoryProxy->getDataType()); - m_buffer = (float *)MEM_mallocN_aligned( - sizeof(float) * buffer_len() * m_num_channels, 16, "COM_MemoryBuffer"); + rect_ = rect; + is_a_single_elem_ = false; + memoryProxy_ = memoryProxy; + num_channels_ = COM_data_type_num_channels(memoryProxy->getDataType()); + buffer_ = (float *)MEM_mallocN_aligned( + sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer"); owns_data_ = true; - m_state = state; - m_datatype = memoryProxy->getDataType(); + state_ = state; + datatype_ = memoryProxy->getDataType(); set_strides(); } MemoryBuffer::MemoryBuffer(DataType dataType, const rcti &rect, bool is_a_single_elem) { - m_rect = rect; - m_is_a_single_elem = is_a_single_elem; - m_memoryProxy = nullptr; - m_num_channels = COM_data_type_num_channels(dataType); - m_buffer = (float *)MEM_mallocN_aligned( - sizeof(float) * buffer_len() * m_num_channels, 16, "COM_MemoryBuffer"); + rect_ = rect; + is_a_single_elem_ = is_a_single_elem; + memoryProxy_ = nullptr; + num_channels_ = COM_data_type_num_channels(dataType); + buffer_ = (float *)MEM_mallocN_aligned( + sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer"); owns_data_ = true; - m_state = MemoryBufferState::Temporary; - m_datatype = dataType; + state_ = MemoryBufferState::Temporary; + datatype_ = dataType; set_strides(); } @@ -93,53 +93,52 @@ MemoryBuffer::MemoryBuffer(float *buffer, const rcti &rect, const bool is_a_single_elem) { - m_rect = rect; - m_is_a_single_elem = is_a_single_elem; - m_memoryProxy = nullptr; - m_num_channels = num_channels; - m_datatype = COM_num_channels_data_type(num_channels); - m_buffer = buffer; + rect_ = rect; + is_a_single_elem_ = is_a_single_elem; + memoryProxy_ = nullptr; + num_channels_ = num_channels; + datatype_ = COM_num_channels_data_type(num_channels); + buffer_ = buffer; owns_data_ = false; - m_state = MemoryBufferState::Temporary; + state_ = MemoryBufferState::Temporary; set_strides(); } -MemoryBuffer::MemoryBuffer(const MemoryBuffer &src) - : MemoryBuffer(src.m_datatype, src.m_rect, false) +MemoryBuffer::MemoryBuffer(const MemoryBuffer &src) : MemoryBuffer(src.datatype_, src.rect_, false) { - m_memoryProxy = src.m_memoryProxy; + memoryProxy_ = src.memoryProxy_; /* src may be single elem buffer */ fill_from(src); } void MemoryBuffer::set_strides() { - if (m_is_a_single_elem) { + if (is_a_single_elem_) { this->elem_stride = 0; this->row_stride = 0; } else { - this->elem_stride = m_num_channels; - this->row_stride = getWidth() * m_num_channels; + this->elem_stride = num_channels_; + this->row_stride = getWidth() * num_channels_; } - to_positive_x_stride_ = m_rect.xmin < 0 ? -m_rect.xmin + 1 : (m_rect.xmin == 0 ? 1 : 0); - to_positive_y_stride_ = m_rect.ymin < 0 ? -m_rect.ymin + 1 : (m_rect.ymin == 0 ? 1 : 0); + to_positive_x_stride_ = rect_.xmin < 0 ? -rect_.xmin + 1 : (rect_.xmin == 0 ? 1 : 0); + to_positive_y_stride_ = rect_.ymin < 0 ? -rect_.ymin + 1 : (rect_.ymin == 0 ? 1 : 0); } void MemoryBuffer::clear() { - memset(m_buffer, 0, buffer_len() * m_num_channels * sizeof(float)); + memset(buffer_, 0, buffer_len() * num_channels_ * sizeof(float)); } BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs) { - return iterate_with(inputs, m_rect); + return iterate_with(inputs, rect_); } BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, const rcti &area) { - BuffersIteratorBuilder<float> builder(m_buffer, m_rect, area, elem_stride); + BuffersIteratorBuilder<float> builder(buffer_, rect_, area, elem_stride); for (MemoryBuffer *input : inputs) { builder.add_input(input->getBuffer(), input->get_rect(), input->elem_stride); } @@ -153,20 +152,20 @@ BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, c MemoryBuffer *MemoryBuffer::inflate() const { BLI_assert(is_a_single_elem()); - MemoryBuffer *inflated = new MemoryBuffer(m_datatype, m_rect, false); - inflated->copy_from(this, m_rect); + MemoryBuffer *inflated = new MemoryBuffer(datatype_, rect_, false); + inflated->copy_from(this, rect_); return inflated; } float MemoryBuffer::get_max_value() const { - float result = m_buffer[0]; + float result = buffer_[0]; const unsigned int size = this->buffer_len(); unsigned int i; - const float *fp_src = m_buffer; + const float *fp_src = buffer_; - for (i = 0; i < size; i++, fp_src += m_num_channels) { + for (i = 0; i < size; i++, fp_src += num_channels_) { float value = *fp_src; if (value > result) { result = value; @@ -181,10 +180,10 @@ float MemoryBuffer::get_max_value(const rcti &rect) const rcti rect_clamp; /* first clamp the rect by the bounds or we get un-initialized values */ - BLI_rcti_isect(&rect, &m_rect, &rect_clamp); + BLI_rcti_isect(&rect, &rect_, &rect_clamp); if (!BLI_rcti_is_empty(&rect_clamp)) { - MemoryBuffer temp_buffer(m_datatype, rect_clamp); + MemoryBuffer temp_buffer(datatype_, rect_clamp); temp_buffer.fill_from(*this); return temp_buffer.get_max_value(); } @@ -195,9 +194,9 @@ float MemoryBuffer::get_max_value(const rcti &rect) const MemoryBuffer::~MemoryBuffer() { - if (m_buffer && owns_data_) { - MEM_freeN(m_buffer); - m_buffer = nullptr; + if (buffer_ && owns_data_) { + MEM_freeN(buffer_); + buffer_ = nullptr; } } @@ -398,28 +397,28 @@ void MemoryBuffer::fill(const rcti &area, void MemoryBuffer::fill_from(const MemoryBuffer &src) { rcti overlap; - overlap.xmin = MAX2(m_rect.xmin, src.m_rect.xmin); - overlap.xmax = MIN2(m_rect.xmax, src.m_rect.xmax); - overlap.ymin = MAX2(m_rect.ymin, src.m_rect.ymin); - overlap.ymax = MIN2(m_rect.ymax, src.m_rect.ymax); + overlap.xmin = MAX2(rect_.xmin, src.rect_.xmin); + overlap.xmax = MIN2(rect_.xmax, src.rect_.xmax); + overlap.ymin = MAX2(rect_.ymin, src.rect_.ymin); + overlap.ymax = MIN2(rect_.ymax, src.rect_.ymax); copy_from(&src, overlap); } void MemoryBuffer::writePixel(int x, int y, const float color[4]) { - if (x >= m_rect.xmin && x < m_rect.xmax && y >= m_rect.ymin && y < m_rect.ymax) { + if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) { const int offset = get_coords_offset(x, y); - memcpy(&m_buffer[offset], color, sizeof(float) * m_num_channels); + memcpy(&buffer_[offset], color, sizeof(float) * num_channels_); } } void MemoryBuffer::addPixel(int x, int y, const float color[4]) { - if (x >= m_rect.xmin && x < m_rect.xmax && y >= m_rect.ymin && y < m_rect.ymax) { + if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) { const int offset = get_coords_offset(x, y); - float *dst = &m_buffer[offset]; + float *dst = &buffer_[offset]; const float *src = color; - for (int i = 0; i < m_num_channels; i++, dst++, src++) { + for (int i = 0; i < num_channels_; i++, dst++, src++) { *dst += *src; } } @@ -434,7 +433,7 @@ static void read_ewa_elem(void *userdata, int x, int y, float result[4]) void MemoryBuffer::read_elem_filtered( const float x, const float y, float dx[2], float dy[2], float *out) const { - BLI_assert(m_datatype == DataType::Color); + BLI_assert(datatype_ == DataType::Color); const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}}; @@ -469,11 +468,11 @@ static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4] /* TODO(manzanilla): to be removed with tiled implementation. */ void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2]) { - if (m_is_a_single_elem) { - memcpy(result, m_buffer, sizeof(float) * m_num_channels); + if (is_a_single_elem_) { + memcpy(result, buffer_, sizeof(float) * num_channels_); } else { - BLI_assert(m_datatype == DataType::Color); + BLI_assert(datatype_ == DataType::Color); float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight(); /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives, * but compositor uses pixel space. For now let's just divide the values and |