Blender  V3.3
Public Member Functions | Public Attributes | List of all members
blender::compositor::MemoryBuffer Class Reference

a MemoryBuffer contains access to the data of a chunk More...

#include <COM_MemoryBuffer.h>

Public Member Functions

 MemoryBuffer (MemoryProxy *memory_proxy, const rcti &rect, MemoryBufferState state)
 construct new temporarily MemoryBuffer for an area More...
 
 MemoryBuffer (DataType data_type, const rcti &rect, bool is_a_single_elem=false)
 construct new temporarily MemoryBuffer for an area More...
 
 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 More...
 
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
 
void read_elem (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
 
void read_elem_bilinear (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], 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 More...
 
floatrelease_ownership_buffer ()
 
MemoryBufferinflate () const
 
void wrap_pixel (int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
 
void wrap_pixel (float &x, float &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y) const
 
void read (float *result, int x, int y, MemoryBufferExtend extend_x=MemoryBufferExtend::Clip, MemoryBufferExtend extend_y=MemoryBufferExtend::Clip)
 
void read_no_check (float *result, int x, int y, MemoryBufferExtend extend_x=MemoryBufferExtend::Clip, MemoryBufferExtend extend_y=MemoryBufferExtend::Clip)
 
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 readEWA (float *result, const float uv[2], const float derivatives[2][2])
 
bool is_temporarily () const
 is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk) More...
 
void apply_processor (ColormanageProcessor &processor, const rcti area)
 Apply a color processor on the given area. More...
 
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_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_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_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 More...
 
const rctiget_rect () const
 get the rect of this MemoryBuffer More...
 
const int get_width () const
 get the width of this MemoryBuffer More...
 
const int get_height () const
 get the height of this MemoryBuffer More...
 
void clear ()
 clear the buffer. Make all pixels black transparent. More...
 
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 of a chunk

Definition at line 43 of file COM_MemoryBuffer.h.

Constructor & Destructor Documentation

◆ MemoryBuffer() [1/5]

blender::compositor::MemoryBuffer::MemoryBuffer ( MemoryProxy memory_proxy,
const rcti rect,
MemoryBufferState  state 
)

◆ MemoryBuffer() [2/5]

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

◆ 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 62 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 68 of file COM_MemoryBuffer.cc.

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

◆ MemoryBuffer() [5/5]

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

Copy constructor

Definition at line 85 of file COM_MemoryBuffer.cc.

References fill_from(), and src.

◆ ~MemoryBuffer()

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

destructor

Definition at line 168 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 
)

◆ 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 336 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 341 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 106 of file COM_MemoryBuffer.cc.

Referenced by blender::compositor::GlareStreaksOperation::generate_glare().

◆ copy_from() [1/10]

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

◆ 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 190 of file COM_MemoryBuffer.cc.

References blender::compositor::area(), copy_from(), and src.

◆ 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 199 of file COM_MemoryBuffer.cc.

References blender::compositor::area(), BLI_assert, is_a_single_elem(), and src.

◆ copy_from() [4/10]

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

◆ copy_from() [5/10]

void blender::compositor::MemoryBuffer::copy_from ( const struct ImBuf src,
const rcti area,
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_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_linear_space = false 
)

◆ copy_from() [8/10]

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

◆ 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 228 of file COM_MemoryBuffer.cc.

References blender::compositor::area(), copy_from(), elem_stride, row_stride, and src.

◆ 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 373 of file COM_MemoryBuffer.cc.

References blender::compositor::area(), and get_num_channels().

◆ fill() [2/2]

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

Definition at line 378 of file COM_MemoryBuffer.cc.

References blender::compositor::area(), 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 387 of file COM_MemoryBuffer.cc.

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

Referenced by blender::compositor::WriteBufferOperation::execute_opencl_region(), get_max_value(), and MemoryBuffer().

◆ get_buffer()

float* blender::compositor::MemoryBuffer::get_buffer ( )
inline

get the data of this MemoryBuffer

Note
buffer should already be available in memory

Definition at line 363 of file COM_MemoryBuffer.h.

Referenced by blender::compositor::convolve(), blender::compositor::WriteBufferOperation::execute_opencl_region(), blender::compositor::AntiAliasOperation::execute_pixel(), blender::compositor::BokehBlurOperation::execute_pixel(), blender::compositor::DilateErodeThresholdOperation::execute_pixel(), blender::compositor::DilateDistanceOperation::execute_pixel(), blender::compositor::ErodeDistanceOperation::execute_pixel(), blender::compositor::GaussianAlphaXBlurOperation::execute_pixel(), blender::compositor::GaussianAlphaYBlurOperation::execute_pixel(), blender::compositor::GaussianBokehBlurOperation::execute_pixel(), blender::compositor::GaussianBlurReferenceOperation::execute_pixel(), blender::compositor::GaussianXBlurOperation::execute_pixel(), blender::compositor::GaussianYBlurOperation::execute_pixel(), blender::compositor::IDMaskOperation::execute_pixel(), blender::compositor::KeyingBlurOperation::execute_pixel(), blender::compositor::KeyingClipOperation::execute_pixel(), blender::compositor::VariableSizeBokehBlurOperation::execute_pixel(), blender::compositor::WriteBufferOperation::execute_region(), blender::compositor::DenoiseOperation::generate_denoise(), blender::compositor::GlareGhostOperation::generate_glare(), blender::compositor::GlareSimpleStarOperation::generate_glare(), blender::compositor::GlareStreaksOperation::generate_glare(), blender::compositor::VectorBlurOperation::generate_vector_blur(), blender::compositor::BufferOperation::get_constant_elem(), blender::compositor::DoubleEdgeMaskOperation::initialize_tile_data(), blender::compositor::FastGaussianBlurValueOperation::initialize_tile_data(), blender::compositor::InpaintSimpleOperation::initialize_tile_data(), blender::compositor::GlareBaseOperation::update_memory_buffer(), and blender::compositor::DoubleEdgeMaskOperation::update_memory_buffer().

◆ get_buffer_area() [1/2]

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

Definition at line 346 of file COM_MemoryBuffer.h.

References blender::compositor::area(), 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 351 of file COM_MemoryBuffer.h.

References blender::compositor::area(), 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 171 of file COM_MemoryBuffer.h.

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

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

◆ get_elem() [1/2]

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

◆ 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 188 of file COM_MemoryBuffer.h.

References BLI_assert, get_coords_offset(), x, and y.

◆ get_elem_bytes_len()

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

Definition at line 328 of file COM_MemoryBuffer.h.

References float().

Referenced by read_elem(), and read_elem_bilinear().

◆ get_height()

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

◆ 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 318 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 309 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()

const rcti& blender::compositor::MemoryBuffer::get_rect ( ) const
inline

◆ get_row_end()

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

Get the buffer row end.

Definition at line 299 of file COM_MemoryBuffer.h.

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

◆ 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 281 of file COM_MemoryBuffer.h.

References BLI_assert, get_coords_offset(), x, and y.

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 290 of file COM_MemoryBuffer.h.

References BLI_assert, get_coords_offset(), x, and y.

◆ get_width()

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

get the width of this MemoryBuffer

Definition at line 642 of file COM_MemoryBuffer.h.

References BLI_rcti_size_x().

Referenced by apply_processor(), blender::compositor::blur_pixel(), blender::compositor::colorspace_to_scene_linear(), blender::compositor::OpenCLDevice::COM_cl_enqueue_range(), blender::compositor::convolve(), copy_from(), blender::compositor::WriteBufferOperation::execute_opencl_region(), blender::compositor::AntiAliasOperation::execute_pixel(), blender::compositor::BokehBlurOperation::execute_pixel(), blender::compositor::DilateErodeThresholdOperation::execute_pixel(), blender::compositor::DilateDistanceOperation::execute_pixel(), blender::compositor::ErodeDistanceOperation::execute_pixel(), blender::compositor::GaussianAlphaXBlurOperation::execute_pixel(), blender::compositor::GaussianAlphaYBlurOperation::execute_pixel(), blender::compositor::GaussianBokehBlurOperation::execute_pixel(), blender::compositor::GaussianXBlurOperation::execute_pixel(), blender::compositor::GaussianYBlurOperation::execute_pixel(), blender::compositor::IDMaskOperation::execute_pixel(), blender::compositor::KeyingBlurOperation::execute_pixel(), blender::compositor::KeyingClipOperation::execute_pixel(), blender::compositor::VariableSizeBokehBlurOperation::execute_pixel(), blender::compositor::WriteBufferOperation::execute_region(), blender::compositor::DebugInfo::export_operation(), blender::compositor::GlareGhostOperation::generate_glare(), blender::compositor::GlareStreaksOperation::generate_glare(), get_buffer_area(), get_memory_width(), get_row_end(), operator[](), read_bilinear(), read_elem_bilinear(), read_elem_filtered(), readEWA(), and wrap_pixel().

◆ inflate()

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

◆ is_a_single_elem()

bool blender::compositor::MemoryBuffer::is_a_single_elem ( ) const
inline

◆ is_temporarily()

bool blender::compositor::MemoryBuffer::is_temporarily ( ) const
inline

is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)

Definition at line 563 of file COM_MemoryBuffer.h.

References blender::compositor::Temporary.

◆ iterate_with() [1/2]

BuffersIterator< float > blender::compositor::MemoryBuffer::iterate_with ( Span< MemoryBuffer * >  inputs)

Definition at line 111 of file COM_MemoryBuffer.cc.

References inputs.

◆ 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 154 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 161 of file COM_MemoryBuffer.h.

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

◆ read()

void blender::compositor::MemoryBuffer::read ( float result,
int  x,
int  y,
MemoryBufferExtend  extend_x = MemoryBufferExtend::Clip,
MemoryBufferExtend  extend_y = MemoryBufferExtend::Clip 
)
inline

◆ read_bilinear()

void blender::compositor::MemoryBuffer::read_bilinear ( float result,
float  x,
float  y,
MemoryBufferExtend  extend_x = MemoryBufferExtend::Clip,
MemoryBufferExtend  extend_y = MemoryBufferExtend::Clip 
) const
inline

◆ read_elem()

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

◆ read_elem_bilinear()

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

◆ read_elem_checked() [1/2]

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

Definition at line 209 of file COM_MemoryBuffer.h.

References usdtokens::out(), read_elem_checked(), x, and y.

◆ read_elem_checked() [2/2]

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

◆ read_elem_filtered()

void blender::compositor::MemoryBuffer::read_elem_filtered ( float  x,
float  y,
float  dx[2],
float  dy[2],
float out 
) const

◆ read_elem_sampled()

void blender::compositor::MemoryBuffer::read_elem_sampled ( float  x,
float  y,
PixelSampler  sampler,
float out 
) const
inline

◆ read_no_check()

void blender::compositor::MemoryBuffer::read_no_check ( float result,
int  x,
int  y,
MemoryBufferExtend  extend_x = MemoryBufferExtend::Clip,
MemoryBufferExtend  extend_y = MemoryBufferExtend::Clip 
)
inline

◆ readEWA()

void blender::compositor::MemoryBuffer::readEWA ( float result,
const float  uv[2],
const float  derivatives[2][2] 
)

◆ release_ownership_buffer()

float* blender::compositor::MemoryBuffer::release_ownership_buffer ( )
inline

◆ wrap_pixel() [1/2]

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

◆ wrap_pixel() [2/2]

void blender::compositor::MemoryBuffer::wrap_pixel ( int &  x,
int &  y,
MemoryBufferExtend  extend_x,
MemoryBufferExtend  extend_y 
)
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

◆ 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 61 of file COM_MemoryBuffer.h.

Referenced by apply_processor(), blender::compositor::blur_pixel(), blender::compositor::colorspace_to_scene_linear(), copy_from(), get_coords_offset(), blender::compositor::BokehBlurOperation::update_memory_buffer_partial(), and blender::compositor::GaussianBlurReferenceOperation::update_memory_buffer_partial().


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