Blender V4.3
blender::compositor::MemoryBuffer Class Reference

a MemoryBuffer contains access to the data More...

#include <COM_MemoryBuffer.h>

Public Member Functions

 MemoryBuffer (DataType data_type, int width, int height)
 construct new temporarily MemoryBuffer for a width and height.
 
 MemoryBuffer (DataType data_type, const rcti &rect, bool is_a_single_elem=false)
 construct new temporarily MemoryBuffer for an area
 
 MemoryBuffer (float *buffer, int num_channels, int width, int height, bool is_a_single_elem=false)
 
 MemoryBuffer (float *buffer, int num_channels, const rcti &rect, bool is_a_single_elem=false)
 
 MemoryBuffer (const MemoryBuffer &src)
 
 ~MemoryBuffer ()
 destructor
 
bool is_a_single_elem () const
 
floatoperator[] (int index)
 
const floatoperator[] (int index) const
 
intptr_t get_coords_offset (int x, int y) const
 
floatget_elem (int x, int y)
 
const floatget_elem (int x, int y) const
 
const floatget_elem_clamped (int x, int y) const
 
void read_elem (int x, int y, float *out) const
 
void read_elem_clamped (int x, int y, float *out) const
 
void read_elem_checked (int x, int y, float *out) const
 
void read_elem_checked (float x, float y, float *out) const
 
float4 texture_bilinear_extend (float2 coordinates) const
 
float4 texture_nearest_extend (float2 coordinates) const
 
void read_elem_bilinear (float x, float y, float *out) const
 
void read_elem_bicubic_bspline (float x, float y, float *out) const
 
void read_elem_sampled (float x, float y, PixelSampler sampler, float *out) const
 
void read_elem_filtered (float x, float y, float dx[2], float dy[2], bool extend_boundary, float *out) const
 
floatget_value (int x, int y, int channel)
 
const floatget_value (int x, int y, int channel) const
 
const floatget_row_end (int y) const
 
int get_memory_width () const
 
int get_memory_height () const
 
uint8_t get_num_channels () const
 
uint8_t get_elem_bytes_len () const
 
BufferRange< floatas_range ()
 
BufferRange< const floatas_range () const
 
BufferArea< floatget_buffer_area (const rcti &area)
 
BufferArea< const floatget_buffer_area (const rcti &area) const
 
BuffersIterator< floatiterate_with (Span< MemoryBuffer * > inputs)
 
BuffersIterator< floatiterate_with (Span< MemoryBuffer * > inputs, const rcti &area)
 
floatget_buffer ()
 get the data of this MemoryBuffer
 
MemoryBufferinflate () const
 
void wrap_pixel (float &x, float &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y) const
 
void read (float *result, float x, float y, PixelSampler sampler=PixelSampler::Nearest, MemoryBufferExtend extend_x=MemoryBufferExtend::Clip, MemoryBufferExtend extend_y=MemoryBufferExtend::Clip) const
 
void write_pixel (int x, int y, const float color[4])
 
void add_pixel (int x, int y, const float color[4])
 
void read_bilinear (float *result, float x, float y, MemoryBufferExtend extend_x=MemoryBufferExtend::Clip, MemoryBufferExtend extend_y=MemoryBufferExtend::Clip) const
 
void apply_processor (ColormanageProcessor &processor, const rcti area)
 Apply a color processor on the given area.
 
void copy_from (const MemoryBuffer *src, const rcti &area)
 
void copy_from (const MemoryBuffer *src, const rcti &area, int to_x, int to_y)
 
void copy_from (const MemoryBuffer *src, const rcti &area, int channel_offset, int elem_size, int to_channel_offset)
 
void copy_from (const MemoryBuffer *src, const rcti &area, int channel_offset, int elem_size, int to_x, int to_y, int to_channel_offset)
 
void copy_from (const uchar *src, const rcti &area)
 
void copy_from (const uchar *src, const rcti &area, int channel_offset, int elem_size, int elem_stride, int row_stride, int to_channel_offset)
 
void copy_from (const uchar *src, const rcti &area, int channel_offset, int elem_size, int elem_stride, int row_stride, int to_x, int to_y, int to_channel_offset)
 
void copy_from (const struct ImBuf *src, const rcti &area, bool ensure_premultiplied=false, bool ensure_linear_space=false)
 
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)
 
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)
 
void fill (const rcti &area, const float *value)
 
void fill (const rcti &area, int channel_offset, const float *value, int value_size)
 
void fill_from (const MemoryBuffer &src)
 add the content from other_buffer to this MemoryBuffer
 
const rctiget_rect () const
 get the rect of this MemoryBuffer
 
const int get_width () const
 get the width of this MemoryBuffer
 
const int get_height () const
 get the height of this MemoryBuffer
 
void clear ()
 clear the buffer. Make all pixels black transparent.
 
float get_max_value () const
 
float get_max_value (const rcti &rect) const
 

Public Attributes

int elem_stride
 
int row_stride
 

Detailed Description

a MemoryBuffer contains access to the data

Definition at line 35 of file COM_MemoryBuffer.h.

Constructor & Destructor Documentation

◆ MemoryBuffer() [1/5]

blender::compositor::MemoryBuffer::MemoryBuffer ( DataType data_type,
int width,
int height )

construct new temporarily MemoryBuffer for a width and height.

Definition at line 31 of file COM_MemoryBuffer.cc.

References BLI_rcti_init(), blender::compositor::COM_data_type_num_channels(), and MEM_mallocN_aligned().

Referenced by inflate().

◆ MemoryBuffer() [2/5]

blender::compositor::MemoryBuffer::MemoryBuffer ( DataType data_type,
const rcti & rect,
bool is_a_single_elem = false )

construct new temporarily MemoryBuffer for an area

Definition at line 44 of file COM_MemoryBuffer.cc.

References blender::compositor::COM_data_type_num_channels(), is_a_single_elem(), and MEM_mallocN_aligned().

◆ MemoryBuffer() [3/5]

blender::compositor::MemoryBuffer::MemoryBuffer ( float * buffer,
int num_channels,
int width,
int height,
bool is_a_single_elem = false )

Construct MemoryBuffer from a float buffer. MemoryBuffer is not responsible for freeing it.

Definition at line 57 of file COM_MemoryBuffer.cc.

◆ MemoryBuffer() [4/5]

blender::compositor::MemoryBuffer::MemoryBuffer ( float * buffer,
int num_channels,
const rcti & rect,
bool is_a_single_elem = false )

Construct MemoryBuffer from a float buffer area. MemoryBuffer is not responsible for freeing given buffer.

Definition at line 63 of file COM_MemoryBuffer.cc.

References blender::compositor::COM_num_channels_data_type(), and is_a_single_elem().

◆ MemoryBuffer() [5/5]

blender::compositor::MemoryBuffer::MemoryBuffer ( const MemoryBuffer & src)

Copy constructor

Definition at line 78 of file COM_MemoryBuffer.cc.

References fill_from().

◆ ~MemoryBuffer()

blender::compositor::MemoryBuffer::~MemoryBuffer ( )

destructor

Definition at line 160 of file COM_MemoryBuffer.cc.

References MEM_freeN().

Member Function Documentation

◆ add_pixel()

void blender::compositor::MemoryBuffer::add_pixel ( int x,
int y,
const float color[4] )

◆ apply_processor()

void blender::compositor::MemoryBuffer::apply_processor ( ColormanageProcessor & processor,
const rcti area )

Apply a color processor on the given area.

Definition at line 270 of file COM_MemoryBuffer.cc.

References BLI_rcti_size_x(), BLI_rcti_size_y(), get_elem(), get_num_channels(), get_width(), IMB_colormanagement_processor_apply(), and row_stride.

◆ as_range() [1/2]

BufferRange< float > blender::compositor::MemoryBuffer::as_range ( )
inline

Get all buffer elements as a range with no offsets.

Definition at line 340 of file COM_MemoryBuffer.h.

References elem_stride.

◆ as_range() [2/2]

BufferRange< const float > blender::compositor::MemoryBuffer::as_range ( ) const
inline

Definition at line 345 of file COM_MemoryBuffer.h.

References elem_stride.

◆ clear()

void blender::compositor::MemoryBuffer::clear ( )

clear the buffer. Make all pixels black transparent.

Definition at line 98 of file COM_MemoryBuffer.cc.

Referenced by blender::compositor::GlareStreaksOperation::generate_glare(), and blender::compositor::DoubleEdgeMaskOperation::update_memory_buffer().

◆ copy_from() [1/10]

◆ copy_from() [2/10]

void blender::compositor::MemoryBuffer::copy_from ( const MemoryBuffer * src,
const rcti & area,
int channel_offset,
int elem_size,
int to_channel_offset )

Definition at line 182 of file COM_MemoryBuffer.cc.

References copy_from().

◆ copy_from() [3/10]

void blender::compositor::MemoryBuffer::copy_from ( const MemoryBuffer * src,
const rcti & area,
int channel_offset,
int elem_size,
int to_x,
int to_y,
int to_channel_offset )

Definition at line 191 of file COM_MemoryBuffer.cc.

References BLI_assert, get_num_channels(), and is_a_single_elem().

◆ copy_from() [4/10]

void blender::compositor::MemoryBuffer::copy_from ( const MemoryBuffer * src,
const rcti & area,
int to_x,
int to_y )

Definition at line 173 of file COM_MemoryBuffer.cc.

References BLI_assert, copy_from(), and get_num_channels().

◆ copy_from() [5/10]

void blender::compositor::MemoryBuffer::copy_from ( const struct ImBuf * src,
const rcti & area,
bool ensure_premultiplied = false,
bool ensure_linear_space = false )

◆ copy_from() [6/10]

void blender::compositor::MemoryBuffer::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 )

◆ copy_from() [7/10]

void blender::compositor::MemoryBuffer::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 )

◆ copy_from() [8/10]

void blender::compositor::MemoryBuffer::copy_from ( const uchar * src,
const rcti & area )

Definition at line 214 of file COM_MemoryBuffer.cc.

References copy_from(), elem_stride, get_num_channels(), get_width(), and row_stride.

◆ copy_from() [9/10]

void blender::compositor::MemoryBuffer::copy_from ( const uchar * src,
const rcti & area,
int channel_offset,
int elem_size,
int elem_stride,
int row_stride,
int to_channel_offset )

Definition at line 221 of file COM_MemoryBuffer.cc.

References copy_from(), elem_stride, and row_stride.

◆ copy_from() [10/10]

void blender::compositor::MemoryBuffer::copy_from ( const uchar * src,
const rcti & area,
int channel_offset,
int elem_size,
int elem_stride,
int row_stride,
int to_x,
int to_y,
int to_channel_offset )

◆ fill() [1/2]

void blender::compositor::MemoryBuffer::fill ( const rcti & area,
const float * value )

Definition at line 384 of file COM_MemoryBuffer.cc.

References fill(), and get_num_channels().

Referenced by fill().

◆ fill() [2/2]

void blender::compositor::MemoryBuffer::fill ( const rcti & area,
int channel_offset,
const float * value,
int value_size )

Definition at line 389 of file COM_MemoryBuffer.cc.

References copy_from(), and get_rect().

◆ fill_from()

void blender::compositor::MemoryBuffer::fill_from ( const MemoryBuffer & src)

add the content from other_buffer to this MemoryBuffer

Parameters
other_buffersource buffer
Note
take care when running this on a new buffer since it won't fill in uninitialized values in areas where the buffers don't overlap.

Definition at line 398 of file COM_MemoryBuffer.cc.

References copy_from(), rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.

Referenced by get_max_value(), and MemoryBuffer().

◆ get_buffer()

◆ get_buffer_area() [1/2]

BufferArea< float > blender::compositor::MemoryBuffer::get_buffer_area ( const rcti & area)
inline

Definition at line 350 of file COM_MemoryBuffer.h.

References elem_stride, and get_width().

◆ get_buffer_area() [2/2]

BufferArea< const float > blender::compositor::MemoryBuffer::get_buffer_area ( const rcti & area) const
inline

Definition at line 355 of file COM_MemoryBuffer.h.

References elem_stride, and get_width().

◆ get_coords_offset()

intptr_t blender::compositor::MemoryBuffer::get_coords_offset ( int x,
int y ) const
inline

Get offset needed to jump from buffer start to given coordinates.

Definition at line 153 of file COM_MemoryBuffer.h.

References elem_stride, row_stride, rcti::xmin, and rcti::ymin.

Referenced by add_pixel(), get_elem(), get_elem(), get_elem_clamped(), get_row_end(), get_value(), get_value(), operator[](), operator[](), and write_pixel().

◆ get_elem() [1/2]

◆ get_elem() [2/2]

const float * blender::compositor::MemoryBuffer::get_elem ( int x,
int y ) const
inline

Get buffer element at given coordinates.

Definition at line 170 of file COM_MemoryBuffer.h.

References BLI_assert, and get_coords_offset().

◆ get_elem_bytes_len()

uint8_t blender::compositor::MemoryBuffer::get_elem_bytes_len ( ) const
inline

◆ get_elem_clamped()

◆ get_height()

◆ get_max_value() [1/2]

float blender::compositor::MemoryBuffer::get_max_value ( ) const

◆ get_max_value() [2/2]

float blender::compositor::MemoryBuffer::get_max_value ( const rcti & rect) const

◆ get_memory_height()

int blender::compositor::MemoryBuffer::get_memory_height ( ) const
inline

Get number of elements in memory for a column. For single element buffers it will always be 1.

Definition at line 322 of file COM_MemoryBuffer.h.

References get_height(), and is_a_single_elem().

◆ get_memory_width()

int blender::compositor::MemoryBuffer::get_memory_width ( ) const
inline

Get the number of elements in memory for a row. For single element buffers it will always be 1.

Definition at line 313 of file COM_MemoryBuffer.h.

References get_width(), and is_a_single_elem().

◆ get_num_channels()

uint8_t blender::compositor::MemoryBuffer::get_num_channels ( ) const
inline

◆ get_rect()

◆ get_row_end()

const float * blender::compositor::MemoryBuffer::get_row_end ( int y) const
inline

Get the buffer row end.

Definition at line 303 of file COM_MemoryBuffer.h.

References BLI_assert, get_coords_offset(), get_width(), and is_a_single_elem().

◆ get_value() [1/2]

float & blender::compositor::MemoryBuffer::get_value ( int x,
int y,
int channel )
inline

Get channel value at given coordinates.

Definition at line 285 of file COM_MemoryBuffer.h.

References BLI_assert, and get_coords_offset().

Referenced by copy_from().

◆ get_value() [2/2]

const float & blender::compositor::MemoryBuffer::get_value ( int x,
int y,
int channel ) const
inline

Get channel value at given coordinates.

Definition at line 294 of file COM_MemoryBuffer.h.

References BLI_assert, and get_coords_offset().

◆ get_width()

◆ inflate()

MemoryBuffer * blender::compositor::MemoryBuffer::inflate ( ) const

Converts a single elem buffer to a full size buffer (allocates memory for all elements in resolution).

Definition at line 117 of file COM_MemoryBuffer.cc.

References BLI_assert, copy_from(), is_a_single_elem(), and MemoryBuffer().

Referenced by blender::compositor::DoubleEdgeMaskOperation::update_memory_buffer(), and blender::compositor::VectorBlurOperation::update_memory_buffer().

◆ is_a_single_elem()

◆ iterate_with() [1/2]

◆ iterate_with() [2/2]

BuffersIterator< float > blender::compositor::MemoryBuffer::iterate_with ( Span< MemoryBuffer * > inputs,
const rcti & area )

◆ operator[]() [1/2]

float & blender::compositor::MemoryBuffer::operator[] ( int index)
inline

Definition at line 136 of file COM_MemoryBuffer.h.

References BLI_assert, get_coords_offset(), get_height(), and get_width().

◆ operator[]() [2/2]

const float & blender::compositor::MemoryBuffer::operator[] ( int index) const
inline

Definition at line 143 of file COM_MemoryBuffer.h.

References BLI_assert, get_coords_offset(), get_height(), and get_width().

◆ read()

◆ read_bilinear()

◆ read_elem()

◆ read_elem_bicubic_bspline()

void blender::compositor::MemoryBuffer::read_elem_bicubic_bspline ( float x,
float y,
float * out ) const
inline

◆ read_elem_bilinear()

◆ read_elem_checked() [1/2]

void blender::compositor::MemoryBuffer::read_elem_checked ( float x,
float y,
float * out ) const
inline

Definition at line 206 of file COM_MemoryBuffer.h.

References read_elem_checked().

◆ read_elem_checked() [2/2]

void blender::compositor::MemoryBuffer::read_elem_checked ( int x,
int y,
float * out ) const
inline

◆ read_elem_clamped()

void blender::compositor::MemoryBuffer::read_elem_clamped ( int x,
int y,
float * out ) const
inline

◆ read_elem_filtered()

◆ read_elem_sampled()

◆ texture_bilinear_extend()

float4 blender::compositor::MemoryBuffer::texture_bilinear_extend ( float2 coordinates) const
inline

◆ texture_nearest_extend()

float4 blender::compositor::MemoryBuffer::texture_nearest_extend ( float2 coordinates) const
inline

◆ wrap_pixel()

void blender::compositor::MemoryBuffer::wrap_pixel ( float & x,
float & y,
MemoryBufferExtend extend_x,
MemoryBufferExtend extend_y ) const
inline

◆ write_pixel()

void blender::compositor::MemoryBuffer::write_pixel ( int x,
int y,
const float color[4] )

Member Data Documentation

◆ elem_stride

int blender::compositor::MemoryBuffer::elem_stride

Offset between elements.

Should always be used for the x dimension when calculating buffer offsets. It will be 0 when is_a_single_elem=true. e.g: buffer_index = y * buffer.row_stride + x * buffer.elem_stride

Definition at line 44 of file COM_MemoryBuffer.h.

Referenced by as_range(), as_range(), copy_from(), copy_from(), copy_from(), get_buffer_area(), get_buffer_area(), get_coords_offset(), iterate_with(), and blender::compositor::MixBaseOperation::update_memory_buffer_partial().

◆ row_stride

int blender::compositor::MemoryBuffer::row_stride

Offset between rows.

Should always be used for the y dimension when calculating buffer offsets. It will be 0 when is_a_single_elem=true. e.g: buffer_index = y * buffer.row_stride + x * buffer.elem_stride

Definition at line 53 of file COM_MemoryBuffer.h.

Referenced by apply_processor(), blender::compositor::colorspace_to_scene_linear(), copy_from(), copy_from(), copy_from(), and get_coords_offset().


The documentation for this class was generated from the following files: