Blender  V3.3
COM_WrapOperation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
4 #include <cmath>
5 
6 #include "COM_WrapOperation.h"
7 
8 namespace blender::compositor {
9 
11 {
12  wrapping_type_ = CMP_NODE_WRAP_NONE;
13 }
14 
16 {
17  if (this->get_width() == 0) {
18  return 0;
19  }
20  while (x < 0) {
21  x += this->get_width();
22  }
23  return fmodf(x, this->get_width());
24 }
25 
27 {
28  if (this->get_height() == 0) {
29  return 0;
30  }
31  while (y < 0) {
32  y += this->get_height();
33  }
34  return fmodf(y, this->get_height());
35 }
36 
38 {
39  float nx, ny;
40  nx = x;
41  ny = y;
43  switch (wrapping_type_) {
44  case CMP_NODE_WRAP_NONE:
45  /* Intentionally empty, original_xpos and original_ypos have been set before. */
46  break;
47  case CMP_NODE_WRAP_X:
48  /* Wrap only on the x-axis. */
49  nx = this->get_wrapped_original_xpos(x);
50  extend_x = MemoryBufferExtend::Repeat;
51  break;
52  case CMP_NODE_WRAP_Y:
53  /* Wrap only on the y-axis. */
54  ny = this->get_wrapped_original_ypos(y);
55  extend_y = MemoryBufferExtend::Repeat;
56  break;
57  case CMP_NODE_WRAP_XY:
58  /* Wrap on both. */
59  nx = this->get_wrapped_original_xpos(x);
60  ny = this->get_wrapped_original_ypos(y);
61  extend_x = MemoryBufferExtend::Repeat;
62  extend_y = MemoryBufferExtend::Repeat;
63  break;
64  }
65 
66  execute_pixel_extend(output, nx, ny, sampler, extend_x, extend_y);
67 }
68 
70  ReadBufferOperation *read_operation,
71  rcti *output)
72 {
73  rcti new_input;
74  new_input.xmin = input->xmin;
75  new_input.xmax = input->xmax;
76  new_input.ymin = input->ymin;
77  new_input.ymax = input->ymax;
78 
79  if (ELEM(wrapping_type_, CMP_NODE_WRAP_X, CMP_NODE_WRAP_XY)) {
80  /* Wrap only on the x-axis if tile is wrapping. */
81  new_input.xmin = get_wrapped_original_xpos(input->xmin);
82  new_input.xmax = roundf(get_wrapped_original_xpos(input->xmax));
83  if (new_input.xmin >= new_input.xmax) {
84  new_input.xmin = 0;
85  new_input.xmax = this->get_width();
86  }
87  }
88  if (ELEM(wrapping_type_, CMP_NODE_WRAP_Y, CMP_NODE_WRAP_XY)) {
89  /* Wrap only on the y-axis if tile is wrapping. */
90  new_input.ymin = get_wrapped_original_ypos(input->ymin);
91  new_input.ymax = roundf(get_wrapped_original_ypos(input->ymax));
92  if (new_input.ymin >= new_input.ymax) {
93  new_input.ymin = 0;
94  new_input.ymax = this->get_height();
95  }
96  }
97 
99  &new_input, read_operation, output);
100 }
101 
102 void WrapOperation::set_wrapping(int wrapping_type)
103 {
104  wrapping_type_ = wrapping_type;
105 }
106 
107 } // namespace blender::compositor
#define ELEM(...)
#define CMP_NODE_WRAP_X
#define CMP_NODE_WRAP_NONE
#define CMP_NODE_WRAP_XY
#define CMP_NODE_WRAP_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble ny
_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_extend(float output[4], float x, float y, PixelSampler sampler, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output) override
bool determine_depending_area_of_interest(rcti *input, ReadBufferOperation *read_operation, rcti *output) override
void set_wrapping(int wrapping_type)
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
DataType
possible data types for sockets
Definition: COM_defines.h:30
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global KernelShaderEvalInput * input
#define fmodf(x, y)
Definition: metal/compat.h:230
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
int xmax
Definition: DNA_vec_types.h:63