11 #define ASSERT_BUFFER_CONTAINS_AREA(buf, area) \
12 BLI_assert(BLI_rcti_inside_rcti(&(buf)->get_rect(), &(area)))
14 #define ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(buf, area, x, y) \
15 BLI_assert((buf)->get_rect().xmin <= (x)); \
16 BLI_assert((buf)->get_rect().ymin <= (y)); \
17 BLI_assert((buf)->get_rect().xmax >= (x) + BLI_rcti_size_x(&(area))); \
18 BLI_assert((buf)->get_rect().ymax >= (y) + BLI_rcti_size_y(&(area)))
20 #define ASSERT_VALID_ELEM_SIZE(buf, channel_offset, elem_size) \
21 BLI_assert((buf)->get_num_channels() >= (channel_offset) + (elem_size))
35 is_a_single_elem_ =
false;
36 memory_proxy_ = memory_proxy;
39 sizeof(
float) * buffer_len() * num_channels_, 16,
"COM_MemoryBuffer");
51 memory_proxy_ =
nullptr;
54 sizeof(
float) * buffer_len() * num_channels_, 16,
"COM_MemoryBuffer");
57 datatype_ = data_type;
69 const int num_channels,
71 const bool is_a_single_elem)
75 memory_proxy_ =
nullptr;
76 num_channels_ = num_channels;
87 memory_proxy_ =
src.memory_proxy_;
92 void MemoryBuffer::set_strides()
94 if (is_a_single_elem_) {
102 to_positive_x_stride_ = rect_.
xmin < 0 ? -rect_.
xmin + 1 : (rect_.
xmin == 0 ? 1 : 0);
103 to_positive_y_stride_ = rect_.
ymin < 0 ? -rect_.
ymin + 1 : (rect_.
ymin == 0 ? 1 : 0);
108 memset(buffer_, 0, buffer_len() * num_channels_ *
sizeof(
float));
122 return builder.
build();
135 float result = buffer_[0];
136 const unsigned int size = this->buffer_len();
139 const float *fp_src = buffer_;
141 for (i = 0; i <
size; i++, fp_src += num_channels_) {
142 float value = *fp_src;
170 if (buffer_ && owns_data_) {
192 const int channel_offset,
194 const int to_channel_offset)
201 const int channel_offset,
205 const int to_channel_offset)
208 copy_single_elem_from(
src, channel_offset, elem_size, to_channel_offset);
210 else if (!
src->is_a_single_elem() && elem_size ==
src->get_num_channels() &&
211 elem_size == this->get_num_channels()) {
214 copy_rows_from(
src,
area, to_x, to_y);
217 copy_elems_from(
src,
area, channel_offset, elem_size, to_x, to_y, to_channel_offset);
230 const int channel_offset,
232 const int elem_stride,
233 const int row_stride,
234 const int to_channel_offset)
249 const int channel_offset,
251 const int elem_stride,
252 const int row_stride,
255 const int to_channel_offset)
265 float *to_elem = &this->
get_value(to_x, to_y +
y, to_channel_offset);
267 while (to_elem < row_end) {
268 for (
int i = 0; i < elem_size; i++) {
269 to_elem[i] = ((
float)from_elem[i]) * (1.0f / 255.0f);
320 const int channel_offset,
322 const int to_channel_offset,
323 const bool ensure_linear_space)
332 ensure_linear_space);
337 const int channel_offset,
341 const int to_channel_offset,
342 const bool ensure_linear_space)
344 if (
src->rect_float) {
346 copy_from(&mem_buf,
area, channel_offset, elem_size, to_x, to_y, to_channel_offset);
348 else if (
src->rect) {
361 if (ensure_linear_space) {
367 const float *zero_elem =
new float[elem_size]{0};
368 fill(
area, to_channel_offset, zero_elem, elem_size);
379 const int channel_offset,
381 const int value_size)
399 if (
x >= rect_.
xmin && x < rect_.xmax && y >= rect_.
ymin &&
y < rect_.
ymax) {
401 memcpy(&buffer_[
offset],
color,
sizeof(
float) * num_channels_);
407 if (
x >= rect_.
xmin && x < rect_.xmax && y >= rect_.
ymin &&
y < rect_.
ymax) {
409 float *dst = &buffer_[
offset];
411 for (
int i = 0; i < num_channels_; i++, dst++,
src++) {
424 const float x,
const float y,
float dx[2],
float dy[2],
float *
out)
const
428 const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}};
435 float uv_normal[2] = {get_relative_x(
x) * inv_width, get_relative_y(
y) * inv_height};
436 float du_normal[2] = {deriv[0][0] * inv_width, deriv[0][1] * inv_height};
437 float dv_normal[2] = {deriv[1][0] * inv_width, deriv[1][1] * inv_height};
461 if (is_a_single_elem_) {
462 memcpy(
result, buffer_,
sizeof(
float) * num_channels_);
472 float uv_normal[2] = {uv[0] * inv_width, uv[1] * inv_height};
473 float du_normal[2] = {derivatives[0][0] * inv_width, derivatives[0][1] * inv_height};
474 float dv_normal[2] = {derivatives[1][0] * inv_width, derivatives[1][1] * inv_height};
490 const int channel_offset,
492 const int to_channel_offset)
500 const float *from_elem = &
src->get_value(
501 src->get_rect().xmin,
src->get_rect().ymin, channel_offset);
502 const int elem_bytes = elem_size *
sizeof(
float);
503 memcpy(to_elem, from_elem, elem_bytes);
506 void MemoryBuffer::copy_rows_from(
const MemoryBuffer *
src,
521 float *to_row = this->
get_elem(to_x, to_y +
y);
522 const float *from_row =
src->get_elem(
area.xmin,
area.ymin +
y);
523 memcpy(to_row, from_row, row_bytes);
527 void MemoryBuffer::copy_elems_from(
const MemoryBuffer *
src,
529 const int channel_offset,
533 const int to_channel_offset)
542 const int elem_bytes = elem_size *
sizeof(
float);
544 float *to_elem = &this->
get_value(to_x, to_y +
y, to_channel_offset);
545 const float *from_elem = &
src->get_value(
area.xmin,
area.ymin +
y, channel_offset);
547 while (to_elem < row_end) {
548 memcpy(to_elem, from_elem, elem_bytes);
550 from_elem +=
src->elem_stride;
typedef float(TangentPoint)[2]
void BLI_ewa_filter(int width, int height, bool intpol, bool use_alpha, const float uv[2], const float du[2], const float dv[2], ewa_filter_read_pixel_cb read_pixel_cb, void *userdata, float result[4])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
bool BLI_rcti_is_empty(const struct rcti *rect)
#define ASSERT_VALID_ELEM_SIZE(buf, channel_offset, elem_size)
#define ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(buf, area, x, y)
#define ASSERT_BUFFER_CONTAINS_AREA(buf, area)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void IMB_colormanagement_processor_apply(struct ColormanageProcessor *cm_processor, float *buffer, int width, int height, int channels, bool predivide)
void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, bool predivide)
Contains defines and structs used throughout the imbuf module.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void add_input(const T *input, const rcti &buffer_area, int elem_stride=1)
BuffersIteratorBuilder::Iterator build()
a MemoryBuffer contains access to the data of a chunk
MemoryBuffer(MemoryProxy *memory_proxy, const rcti &rect, MemoryBufferState state)
construct new temporarily MemoryBuffer for an area
~MemoryBuffer()
destructor
float get_max_value() const
void copy_from(const MemoryBuffer *src, const rcti &area)
const rcti & get_rect() const
get the rect of this MemoryBuffer
uint8_t get_num_channels() const
float * get_elem(int x, int y)
MemoryBuffer * inflate() const
const int get_width() const
get the width of this MemoryBuffer
intptr_t get_coords_offset(int x, int y) const
const int get_height() const
get the height of this MemoryBuffer
void write_pixel(int x, int y, const float color[4])
bool is_a_single_elem() const
void fill(const rcti &area, const float *value)
void fill_from(const MemoryBuffer &src)
add the content from other_buffer to this MemoryBuffer
void readEWA(float *result, const float uv[2], const float derivatives[2][2])
float & get_value(int x, int y, int channel)
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])
BuffersIterator< float > iterate_with(Span< MemoryBuffer * > inputs)
void clear()
clear the buffer. Make all pixels black transparent.
void read_elem_filtered(float x, float y, float dx[2], float dy[2], float *out) const
A MemoryProxy is a unique identifier for a memory buffer. A single MemoryProxy is used among all chun...
SyclQueue void void * src
MemoryBufferState
state of a memory buffer
@ Temporary
chunk is consolidated from other chunks. special state.
DataType
possible data types for sockets
ccl_global float * buffer
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_global KernelShaderEvalInput * input
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN_aligned)(size_t len, size_t alignment, const char *str)
static void read_ewa_elem(void *userdata, int x, int y, float result[4])
static void area(int d1, int d2, int e1, int e2, float weights[2])
static rcti create_rect(const int width, const int height)
constexpr DataType COM_num_channels_data_type(const int num_channels)
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4])
constexpr int COM_data_type_num_channels(const DataType datatype)
static void colorspace_to_scene_linear(MemoryBuffer *buf, const rcti &area, ColorSpace *colorspace)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static bNodeSocketTemplate inputs[]