Blender  V2.93
COM_SplitOperation.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 "COM_SplitOperation.h"
20 #include "BKE_image.h"
21 #include "BLI_listbase.h"
22 #include "BLI_math_color.h"
23 #include "BLI_math_vector.h"
24 #include "BLI_utildefines.h"
25 #include "MEM_guardedalloc.h"
26 
27 #include "IMB_imbuf.h"
28 #include "IMB_imbuf_types.h"
29 
30 namespace blender::compositor {
31 
33 {
37  this->m_image1Input = nullptr;
38  this->m_image2Input = nullptr;
39 }
40 
42 {
43  // When initializing the tree during initial load the width and height can be zero.
44  this->m_image1Input = getInputSocketReader(0);
45  this->m_image2Input = getInputSocketReader(1);
46 }
47 
49 {
50  this->m_image1Input = nullptr;
51  this->m_image2Input = nullptr;
52 }
53 
55  float x,
56  float y,
57  PixelSampler /*sampler*/)
58 {
59  int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f :
60  this->m_splitPercentage * this->getHeight() / 100.0f;
61  bool image1 = this->m_xSplit ? x > perc : y > perc;
62  if (image1) {
63  this->m_image1Input->readSampled(output, x, y, PixelSampler::Nearest);
64  }
65  else {
66  this->m_image2Input->readSampled(output, x, y, PixelSampler::Nearest);
67  }
68 }
69 
70 void SplitOperation::determineResolution(unsigned int resolution[2],
71  unsigned int preferredResolution[2])
72 {
73  unsigned int tempPreferredResolution[2] = {0, 0};
74  unsigned int tempResolution[2];
75 
76  this->getInputSocket(0)->determineResolution(tempResolution, tempPreferredResolution);
77  this->setResolutionInputSocketIndex((tempResolution[0] && tempResolution[1]) ? 0 : 1);
78 
79  NodeOperation::determineResolution(resolution, preferredResolution);
80 }
81 
82 } // namespace blender::compositor
_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
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
#define output
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
void readSampled(float result[4], float x, float y, PixelSampler sampler)
NodeOperationInput * getInputSocket(unsigned int index)
void addInputSocket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
void addOutputSocket(DataType datatype)
void setResolutionInputSocketIndex(unsigned int index)
set the index of the input socket that will determine the resolution of this operation
virtual void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
determine the resolution of this node
SocketReader * getInputSocketReader(unsigned int inputSocketindex)
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) override
determine the resolution of this node
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel