80 bool is_a_single_elem_;
88 int to_positive_x_stride_;
91 int to_positive_y_stride_;
109 float *buffer,
int num_channels,
int width,
int height,
bool is_a_single_elem =
false);
133 return is_a_single_elem_;
138 BLI_assert(is_a_single_elem_ ? index < num_channels_ :
140 return buffer_[index];
145 BLI_assert(is_a_single_elem_ ? index < num_channels_ :
147 return buffer_[index];
198 if (!has_coords(x, y)) {
217 if (is_a_single_elem_) {
224 const float2 texel_coordinates = (coordinates *
float2(size)) - 0.5f;
228 buffer_, result, size.x, size.y, num_channels_, texel_coordinates.x, texel_coordinates.y);
238 if (is_a_single_elem_) {
245 const float2 texel_coordinates = coordinates *
float2(size);
249 buffer_, result, size.x, size.y, num_channels_, texel_coordinates.x, texel_coordinates.y);
260 if (is_a_single_elem_) {
280 float x,
float y,
float dx[2],
float dy[2],
bool extend_boundary,
float *out)
const;
287 BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
296 BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
329 return num_channels_;
334 return num_channels_ *
sizeof(
float);
424 inline void read(
float *result,
432 if (is_a_single_elem_) {
444 x = get_relative_x(x);
445 y = get_relative_y(y);
452 mult = std::min(x + 1.0f,
w - x);
455 mult = std::min(
mult, std::min(y + 1.0f, h - y));
481 for (
int i = 0; i < num_channels_; ++i) {
486 void write_pixel(
int x,
int y,
const float color[4]);
487 void add_pixel(
int x,
int y,
const float color[4]);
503 if (is_a_single_elem_) {
504 memcpy(result, buffer_,
sizeof(
float) * num_channels_);
530 int to_channel_offset);
537 int to_channel_offset);
545 int to_channel_offset);
554 int to_channel_offset);
557 bool ensure_premultiplied =
false,
558 bool ensure_linear_space =
false);
563 int to_channel_offset,
564 bool ensure_premultiplied =
false,
565 bool ensure_linear_space =
false);
567 const rcti &src_area,
572 int to_channel_offset,
573 bool ensure_premultiplied =
false,
574 bool ensure_linear_space =
false);
576 void fill(
const rcti &area,
const float *value);
577 void fill(
const rcti &area,
int channel_offset,
const float *value,
int value_size);
621 const int64_t buffer_len()
const
626 void clear_elem(
float *out)
const
628 memset(out, 0, num_channels_ *
sizeof(
float));
631 template<
typename T> T get_relative_x(T x)
const
633 return x - rect_.
xmin;
636 template<
typename T> T get_relative_y(T y)
const
638 return y - rect_.
ymin;
641 template<
typename T>
bool has_coords(T x, T y)
const
643 return has_x(x) && has_y(y);
646 template<
typename T>
bool has_x(T x)
const
648 return x >= rect_.
xmin && x < rect_.
xmax;
651 template<
typename T>
bool has_y(T y)
const
653 return y >= rect_.
ymin && y < rect_.
ymax;
659 int floor_x(
float x)
const
661 return (
int)(x + to_positive_x_stride_) - to_positive_x_stride_;
664 int floor_y(
float y)
const
666 return (
int)(y + to_positive_y_stride_) - to_positive_y_stride_;
672 int to_channel_offset);
673 void copy_rows_from(
const MemoryBuffer *src,
const rcti &src_area,
int to_x,
int to_y);
680 int to_channel_offset);
682#ifdef WITH_CXX_GUARDEDALLOC
683 MEM_CXX_CLASS_ALLOC_FUNCS(
"COM:MemoryBuffer")
MINLINE float floored_fmod(float f, float n)
void copy_vn_fl(float *array_tar, int size, float val)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
a MemoryBuffer contains access to the data
const rcti & get_rect() const
get the rect of this MemoryBuffer
void copy_from(const struct ImBuf *src, const rcti &area, bool ensure_premultiplied=false, bool ensure_linear_space=false)
const float * get_elem_clamped(int x, int y) const
void read_elem_checked(int x, int y, float *out) const
float & get_value(int x, int y, int channel)
~MemoryBuffer()
destructor
void read(float *result, float x, float y, PixelSampler sampler=PixelSampler::Nearest, MemoryBufferExtend extend_x=MemoryBufferExtend::Clip, MemoryBufferExtend extend_y=MemoryBufferExtend::Clip) const
void copy_from(const struct ImBuf *src, const rcti &src_area, int channel_offset, int elem_size, int to_x, int to_y, int to_channel_offset, bool ensure_premultiplied=false, bool ensure_linear_space=false)
float get_max_value() const
void copy_from(const MemoryBuffer *src, const rcti &area)
BufferArea< float > get_buffer_area(const rcti &area)
BufferArea< const float > get_buffer_area(const rcti &area) const
const float & get_value(int x, int y, int channel) const
uint8_t get_num_channels() const
MemoryBuffer * inflate() const
void read_elem_checked(float x, float y, float *out) const
const int get_width() const
get the width of this MemoryBuffer
const float * get_elem(int x, int y) const
intptr_t get_coords_offset(int x, int y) const
const float & operator[](int index) const
const int get_height() const
get the height of this MemoryBuffer
BufferRange< const float > as_range() const
void write_pixel(int x, int y, const float color[4])
float * get_buffer()
get the data of this MemoryBuffer
void read_elem_bicubic_bspline(float x, float y, float *out) const
bool is_a_single_elem() const
void read_elem_bilinear(float x, float y, float *out) const
float * get_elem(int x, int y)
int get_memory_width() const
float4 texture_nearest_extend(float2 coordinates) const
void read_elem(int x, int y, float *out) const
void fill(const rcti &area, const float *value)
const float * get_row_end(int y) const
void fill_from(const MemoryBuffer &src)
add the content from other_buffer to this MemoryBuffer
void wrap_pixel(float &x, float &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y) const
void read_bilinear(float *result, float x, float y, MemoryBufferExtend extend_x=MemoryBufferExtend::Clip, MemoryBufferExtend extend_y=MemoryBufferExtend::Clip) const
MemoryBuffer(DataType data_type, int width, int height)
construct new temporarily MemoryBuffer for a width and height.
void read_elem_clamped(int x, int y, float *out) const
void read_elem_filtered(float x, float y, float dx[2], float dy[2], bool extend_boundary, float *out) const
BufferRange< float > as_range()
int get_memory_height() const
float & operator[](int index)
void copy_from(const struct ImBuf *src, const rcti &area, int channel_offset, int elem_size, int to_channel_offset, bool ensure_premultiplied=false, bool ensure_linear_space=false)
uint8_t get_elem_bytes_len() const
void apply_processor(ColormanageProcessor &processor, const rcti area)
Apply a color processor on the given area.
void add_pixel(int x, int y, const float color[4])
void read_elem_sampled(float x, float y, PixelSampler sampler, float *out) const
float4 texture_bilinear_extend(float2 coordinates) const
BuffersIterator< float > iterate_with(Span< MemoryBuffer * > inputs)
void clear()
clear the buffer. Make all pixels black transparent.
local_group_size(16, 16) .push_constant(Type local_group_size(16, 16) .push_constant(Type input_tx sampler(1, ImageType::FLOAT_2D, "matte_tx") .image(0
draw_view in_light_buf[] float
DataType
possible data types for sockets
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
T clamp(const T &a, const T &min, const T &max)
void interpolate_nearest_fl(const float *buffer, float *output, int width, int height, int components, float u, float v)
float4 interpolate_bilinear_wrap_fl(const float *buffer, int width, int height, float u, float v)
float4 interpolate_cubic_bspline_fl(const float *buffer, int width, int height, float u, float v)
float4 interpolate_bilinear_fl(const float *buffer, int width, int height, float u, float v)
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2