Blender  V2.93
COM_WrapOperation.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2011, Blender Foundation.
17  */
18 
19 #include <cmath>
20 
21 #include "COM_WrapOperation.h"
22 
23 namespace blender::compositor {
24 
26 {
27  this->m_wrappingType = CMP_NODE_WRAP_NONE;
28 }
29 
31 {
32  if (this->getWidth() == 0) {
33  return 0;
34  }
35  while (x < 0) {
36  x += this->m_width;
37  }
38  return fmodf(x, this->getWidth());
39 }
40 
42 {
43  if (this->getHeight() == 0) {
44  return 0;
45  }
46  while (y < 0) {
47  y += this->m_height;
48  }
49  return fmodf(y, this->getHeight());
50 }
51 
52 void WrapOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
53 {
54  float nx, ny;
55  nx = x;
56  ny = y;
58  switch (m_wrappingType) {
59  case CMP_NODE_WRAP_NONE:
60  // Intentionally empty, originalXPos and originalYPos have been set before
61  break;
62  case CMP_NODE_WRAP_X:
63  // wrap only on the x-axis
64  nx = this->getWrappedOriginalXPos(x);
65  extend_x = MemoryBufferExtend::Repeat;
66  break;
67  case CMP_NODE_WRAP_Y:
68  // wrap only on the y-axis
69  ny = this->getWrappedOriginalYPos(y);
70  extend_y = MemoryBufferExtend::Repeat;
71  break;
72  case CMP_NODE_WRAP_XY:
73  // wrap on both
74  nx = this->getWrappedOriginalXPos(x);
75  ny = this->getWrappedOriginalYPos(y);
76  extend_x = MemoryBufferExtend::Repeat;
77  extend_y = MemoryBufferExtend::Repeat;
78  break;
79  }
80 
81  executePixelExtend(output, nx, ny, sampler, extend_x, extend_y);
82 }
83 
85  ReadBufferOperation *readOperation,
86  rcti *output)
87 {
88  rcti newInput;
89  newInput.xmin = input->xmin;
90  newInput.xmax = input->xmax;
91  newInput.ymin = input->ymin;
92  newInput.ymax = input->ymax;
93 
94  if (ELEM(m_wrappingType, CMP_NODE_WRAP_X, CMP_NODE_WRAP_XY)) {
95  // wrap only on the x-axis if tile is wrapping
96  newInput.xmin = getWrappedOriginalXPos(input->xmin);
97  newInput.xmax = roundf(getWrappedOriginalXPos(input->xmax));
98  if (newInput.xmin >= newInput.xmax) {
99  newInput.xmin = 0;
100  newInput.xmax = this->getWidth();
101  }
102  }
103  if (ELEM(m_wrappingType, CMP_NODE_WRAP_Y, CMP_NODE_WRAP_XY)) {
104  // wrap only on the y-axis if tile is wrapping
105  newInput.ymin = getWrappedOriginalYPos(input->ymin);
106  newInput.ymax = roundf(getWrappedOriginalYPos(input->ymax));
107  if (newInput.ymin >= newInput.ymax) {
108  newInput.ymin = 0;
109  newInput.ymax = this->getHeight();
110  }
111  }
112 
113  return ReadBufferOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
114 }
115 
116 void WrapOperation::setWrapping(int wrapping_type)
117 {
118  m_wrappingType = wrapping_type;
119 }
120 
121 } // 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
#define output
void executePixelExtend(float output[4], float x, float y, PixelSampler sampler, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) override
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) override
DataType
possible data types for sockets
Definition: COM_defines.h:27
#define fmodf(x, y)
int ymin
Definition: DNA_vec_types.h:80
int ymax
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int xmax
Definition: DNA_vec_types.h:79