Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/compositor/intern/COM_MemoryBuffer.h')
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h140
1 files changed, 69 insertions, 71 deletions
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index c0d086e5727..984db4acc2a 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -77,38 +77,38 @@ class MemoryBuffer {
/**
* \brief proxy of the memory (same for all chunks in the same buffer)
*/
- MemoryProxy *m_memoryProxy;
+ MemoryProxy *memoryProxy_;
/**
* \brief the type of buffer DataType::Value, DataType::Vector, DataType::Color
*/
- DataType m_datatype;
+ DataType datatype_;
/**
* \brief region of this buffer inside relative to the MemoryProxy
*/
- rcti m_rect;
+ rcti rect_;
/**
* \brief state of the buffer
*/
- MemoryBufferState m_state;
+ MemoryBufferState state_;
/**
* \brief the actual float buffer/data
*/
- float *m_buffer;
+ float *buffer_;
/**
* \brief the number of channels of a single value in the buffer.
* For value buffers this is 1, vector 3 and color 4
*/
- uint8_t m_num_channels;
+ uint8_t num_channels_;
/**
* Whether buffer is a single element in memory.
*/
- bool m_is_a_single_elem;
+ bool is_a_single_elem_;
/**
* Whether MemoryBuffer owns buffer data.
@@ -153,21 +153,21 @@ class MemoryBuffer {
*/
bool is_a_single_elem() const
{
- return m_is_a_single_elem;
+ return is_a_single_elem_;
}
float &operator[](int index)
{
- BLI_assert(m_is_a_single_elem ? index < m_num_channels :
- index < get_coords_offset(getWidth(), getHeight()));
- return m_buffer[index];
+ BLI_assert(is_a_single_elem_ ? index < num_channels_ :
+ index < get_coords_offset(getWidth(), getHeight()));
+ return buffer_[index];
}
const float &operator[](int index) const
{
- BLI_assert(m_is_a_single_elem ? index < m_num_channels :
- index < get_coords_offset(getWidth(), getHeight()));
- return m_buffer[index];
+ BLI_assert(is_a_single_elem_ ? index < num_channels_ :
+ index < get_coords_offset(getWidth(), getHeight()));
+ return buffer_[index];
}
/**
@@ -175,7 +175,7 @@ class MemoryBuffer {
*/
intptr_t get_coords_offset(int x, int y) const
{
- return ((intptr_t)y - m_rect.ymin) * row_stride + ((intptr_t)x - m_rect.xmin) * elem_stride;
+ return ((intptr_t)y - rect_.ymin) * row_stride + ((intptr_t)x - rect_.xmin) * elem_stride;
}
/**
@@ -184,7 +184,7 @@ class MemoryBuffer {
float *get_elem(int x, int y)
{
BLI_assert(has_coords(x, y));
- return m_buffer + get_coords_offset(x, y);
+ return buffer_ + get_coords_offset(x, y);
}
/**
@@ -193,7 +193,7 @@ class MemoryBuffer {
const float *get_elem(int x, int y) const
{
BLI_assert(has_coords(x, y));
- return m_buffer + get_coords_offset(x, y);
+ return buffer_ + get_coords_offset(x, y);
}
void read_elem(int x, int y, float *out) const
@@ -219,16 +219,14 @@ class MemoryBuffer {
void read_elem_bilinear(float x, float y, float *out) const
{
/* Only clear past +/-1 borders to be able to smooth edges. */
- if (x <= m_rect.xmin - 1.0f || x >= m_rect.xmax || y <= m_rect.ymin - 1.0f ||
- y >= m_rect.ymax) {
+ if (x <= rect_.xmin - 1.0f || x >= rect_.xmax || y <= rect_.ymin - 1.0f || y >= rect_.ymax) {
clear_elem(out);
return;
}
- if (m_is_a_single_elem) {
- if (x >= m_rect.xmin && x < m_rect.xmax - 1.0f && y >= m_rect.ymin &&
- y < m_rect.ymax - 1.0f) {
- memcpy(out, m_buffer, get_elem_bytes_len());
+ if (is_a_single_elem_) {
+ if (x >= rect_.xmin && x < rect_.xmax - 1.0f && y >= rect_.ymin && y < rect_.ymax - 1.0f) {
+ memcpy(out, buffer_, get_elem_bytes_len());
return;
}
@@ -253,15 +251,15 @@ class MemoryBuffer {
single_y = rel_y - last_y;
}
- BLI_bilinear_interpolation_fl(m_buffer, out, 1, 1, m_num_channels, single_x, single_y);
+ BLI_bilinear_interpolation_fl(buffer_, out, 1, 1, num_channels_, single_x, single_y);
return;
}
- BLI_bilinear_interpolation_fl(m_buffer,
+ BLI_bilinear_interpolation_fl(buffer_,
out,
getWidth(),
getHeight(),
- m_num_channels,
+ num_channels_,
get_relative_x(x),
get_relative_y(y));
}
@@ -288,8 +286,8 @@ class MemoryBuffer {
*/
float &get_value(int x, int y, int channel)
{
- BLI_assert(has_coords(x, y) && channel >= 0 && channel < m_num_channels);
- return m_buffer[get_coords_offset(x, y) + channel];
+ BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
+ return buffer_[get_coords_offset(x, y) + channel];
}
/**
@@ -297,8 +295,8 @@ class MemoryBuffer {
*/
const float &get_value(int x, int y, int channel) const
{
- BLI_assert(has_coords(x, y) && channel >= 0 && channel < m_num_channels);
- return m_buffer[get_coords_offset(x, y) + channel];
+ BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
+ return buffer_[get_coords_offset(x, y) + channel];
}
/**
@@ -307,7 +305,7 @@ class MemoryBuffer {
const float *get_row_end(int y) const
{
BLI_assert(has_y(y));
- return m_buffer + (is_a_single_elem() ? m_num_channels : get_coords_offset(getWidth(), y));
+ return buffer_ + (is_a_single_elem() ? num_channels_ : get_coords_offset(getWidth(), y));
}
/**
@@ -330,12 +328,12 @@ class MemoryBuffer {
uint8_t get_num_channels() const
{
- return m_num_channels;
+ return num_channels_;
}
uint8_t get_elem_bytes_len() const
{
- return m_num_channels * sizeof(float);
+ return num_channels_ * sizeof(float);
}
/**
@@ -343,22 +341,22 @@ class MemoryBuffer {
*/
BufferRange<float> as_range()
{
- return BufferRange<float>(m_buffer, 0, buffer_len(), elem_stride);
+ return BufferRange<float>(buffer_, 0, buffer_len(), elem_stride);
}
BufferRange<const float> as_range() const
{
- return BufferRange<const float>(m_buffer, 0, buffer_len(), elem_stride);
+ return BufferRange<const float>(buffer_, 0, buffer_len(), elem_stride);
}
BufferArea<float> get_buffer_area(const rcti &area)
{
- return BufferArea<float>(m_buffer, getWidth(), area, elem_stride);
+ return BufferArea<float>(buffer_, getWidth(), area, elem_stride);
}
BufferArea<const float> get_buffer_area(const rcti &area) const
{
- return BufferArea<const float>(m_buffer, getWidth(), area, elem_stride);
+ return BufferArea<const float>(buffer_, getWidth(), area, elem_stride);
}
BuffersIterator<float> iterate_with(Span<MemoryBuffer *> inputs);
@@ -370,13 +368,13 @@ class MemoryBuffer {
*/
float *getBuffer()
{
- return m_buffer;
+ return buffer_;
}
float *release_ownership_buffer()
{
owns_data_ = false;
- return m_buffer;
+ return buffer_;
}
MemoryBuffer *inflate() const;
@@ -385,8 +383,8 @@ class MemoryBuffer {
{
const int w = getWidth();
const int h = getHeight();
- x = x - m_rect.xmin;
- y = y - m_rect.ymin;
+ x = x - rect_.xmin;
+ y = y - rect_.ymin;
switch (extend_x) {
case MemoryBufferExtend::Clip:
@@ -426,8 +424,8 @@ class MemoryBuffer {
break;
}
- x = x + m_rect.xmin;
- y = y + m_rect.ymin;
+ x = x + rect_.xmin;
+ y = y + rect_.ymin;
}
inline void wrap_pixel(float &x,
@@ -437,8 +435,8 @@ class MemoryBuffer {
{
const float w = (float)getWidth();
const float h = (float)getHeight();
- x = x - m_rect.xmin;
- y = y - m_rect.ymin;
+ x = x - rect_.xmin;
+ y = y - rect_.ymin;
switch (extend_x) {
case MemoryBufferExtend::Clip:
@@ -478,8 +476,8 @@ class MemoryBuffer {
break;
}
- x = x + m_rect.xmin;
- y = y + m_rect.ymin;
+ x = x + rect_.xmin;
+ y = y + rect_.ymin;
}
/* TODO(manzanilla): to be removed with tiled implementation. For applying #MemoryBufferExtend
@@ -490,19 +488,19 @@ class MemoryBuffer {
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip)
{
- bool clip_x = (extend_x == MemoryBufferExtend::Clip && (x < m_rect.xmin || x >= m_rect.xmax));
- bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < m_rect.ymin || y >= m_rect.ymax));
+ bool clip_x = (extend_x == MemoryBufferExtend::Clip && (x < rect_.xmin || x >= rect_.xmax));
+ bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < rect_.ymin || y >= rect_.ymax));
if (clip_x || clip_y) {
/* clip result outside rect is zero */
- memset(result, 0, m_num_channels * sizeof(float));
+ memset(result, 0, num_channels_ * sizeof(float));
}
else {
int u = x;
int v = y;
this->wrap_pixel(u, v, extend_x, extend_y);
const int offset = get_coords_offset(u, v);
- float *buffer = &m_buffer[offset];
- memcpy(result, buffer, sizeof(float) * m_num_channels);
+ float *buffer = &buffer_[offset];
+ memcpy(result, buffer, sizeof(float) * num_channels_);
}
}
@@ -520,11 +518,11 @@ class MemoryBuffer {
const int offset = get_coords_offset(u, v);
BLI_assert(offset >= 0);
- BLI_assert(offset < this->buffer_len() * m_num_channels);
- BLI_assert(!(extend_x == MemoryBufferExtend::Clip && (u < m_rect.xmin || u >= m_rect.xmax)) &&
- !(extend_y == MemoryBufferExtend::Clip && (v < m_rect.ymin || v >= m_rect.ymax)));
- float *buffer = &m_buffer[offset];
- memcpy(result, buffer, sizeof(float) * m_num_channels);
+ BLI_assert(offset < this->buffer_len() * num_channels_);
+ BLI_assert(!(extend_x == MemoryBufferExtend::Clip && (u < rect_.xmin || u >= rect_.xmax)) &&
+ !(extend_y == MemoryBufferExtend::Clip && (v < rect_.ymin || v >= rect_.ymax)));
+ float *buffer = &buffer_[offset];
+ memcpy(result, buffer, sizeof(float) * num_channels_);
}
void writePixel(int x, int y, const float color[4]);
@@ -540,18 +538,18 @@ class MemoryBuffer {
this->wrap_pixel(u, v, extend_x, extend_y);
if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= getWidth())) ||
(extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= getHeight()))) {
- copy_vn_fl(result, m_num_channels, 0.0f);
+ copy_vn_fl(result, num_channels_, 0.0f);
return;
}
- 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_bilinear_interpolation_wrap_fl(m_buffer,
+ BLI_bilinear_interpolation_wrap_fl(buffer_,
result,
getWidth(),
getHeight(),
- m_num_channels,
+ num_channels_,
u,
v,
extend_x == MemoryBufferExtend::Repeat,
@@ -566,7 +564,7 @@ class MemoryBuffer {
*/
inline bool isTemporarily() const
{
- return m_state == MemoryBufferState::Temporary;
+ return state_ == MemoryBufferState::Temporary;
}
void copy_from(const MemoryBuffer *src, const rcti &area);
@@ -632,7 +630,7 @@ class MemoryBuffer {
*/
const rcti &get_rect() const
{
- return m_rect;
+ return rect_;
}
/**
@@ -640,7 +638,7 @@ class MemoryBuffer {
*/
const int getWidth() const
{
- return BLI_rcti_size_x(&m_rect);
+ return BLI_rcti_size_x(&rect_);
}
/**
@@ -648,7 +646,7 @@ class MemoryBuffer {
*/
const int getHeight() const
{
- return BLI_rcti_size_y(&m_rect);
+ return BLI_rcti_size_y(&rect_);
}
/**
@@ -668,17 +666,17 @@ class MemoryBuffer {
void clear_elem(float *out) const
{
- memset(out, 0, m_num_channels * sizeof(float));
+ memset(out, 0, num_channels_ * sizeof(float));
}
template<typename T> T get_relative_x(T x) const
{
- return x - m_rect.xmin;
+ return x - rect_.xmin;
}
template<typename T> T get_relative_y(T y) const
{
- return y - m_rect.ymin;
+ return y - rect_.ymin;
}
template<typename T> bool has_coords(T x, T y) const
@@ -688,12 +686,12 @@ class MemoryBuffer {
template<typename T> bool has_x(T x) const
{
- return x >= m_rect.xmin && x < m_rect.xmax;
+ return x >= rect_.xmin && x < rect_.xmax;
}
template<typename T> bool has_y(T y) const
{
- return y >= m_rect.ymin && y < m_rect.ymax;
+ return y >= rect_.ymin && y < rect_.ymax;
}
/* Fast `floor(..)` functions. The caller should check result is within buffer bounds.