Blender  V3.3
COM_BufferOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2021 Blender Foundation. */
3 
4 #include "COM_BufferOperation.h"
5 
6 namespace blender::compositor {
7 
9 {
10  buffer_ = buffer;
11  inflated_buffer_ = nullptr;
12  set_canvas(buffer->get_rect());
13  add_output_socket(data_type);
16 }
17 
19 {
20  BLI_assert(buffer_->is_a_single_elem());
21  return buffer_->get_buffer();
22 }
23 
25 {
26  if (buffer_->is_a_single_elem()) {
27  init_mutex();
28  }
29 }
30 
32 {
33  if (buffer_->is_a_single_elem() == false) {
34  return buffer_;
35  }
36 
37  lock_mutex();
38  if (!inflated_buffer_) {
39  inflated_buffer_ = buffer_->inflate();
40  }
41  unlock_mutex();
42  return inflated_buffer_;
43 }
44 
46 {
47  if (buffer_->is_a_single_elem()) {
48  deinit_mutex();
49  }
50  delete inflated_buffer_;
51 }
52 
54  float x,
55  float y,
57 {
58  switch (sampler) {
60  buffer_->read(output, x, y);
61  break;
63  default:
64  buffer_->read_bilinear(output, x, y);
65  break;
67  /* No bicubic. Same implementation as ReadBufferOperation. */
68  buffer_->read_bilinear(output, x, y);
69  break;
70  }
71 }
72 
74  float output[4], float x, float y, float dx[2], float dy[2])
75 {
76  const float uv[2] = {x, y};
77  const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}};
78  buffer_->readEWA(output, uv, deriv);
79 }
80 
81 } // namespace blender::compositor
#define BLI_assert(a)
Definition: BLI_assert.h:46
_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
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
BufferOperation(MemoryBuffer *buffer, DataType data_type)
void execute_pixel_filtered(float output[4], float x, float y, float dx[2], float dy[2]) override
calculate a single pixel using an EWA filter
const float * get_constant_elem() override
void * initialize_tile_data(rcti *rect) override
a MemoryBuffer contains access to the data of a chunk
void read(float *result, int x, int y, MemoryBufferExtend extend_x=MemoryBufferExtend::Clip, MemoryBufferExtend extend_y=MemoryBufferExtend::Clip)
float * get_buffer()
get the data of this MemoryBuffer
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])
void set_canvas(const rcti &canvas_area)
void add_output_socket(DataType datatype)
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
DataType
possible data types for sockets
Definition: COM_defines.h:30
ccl_global float * buffer
ccl_global KernelShaderEvalInput ccl_global float * output