Blender  V3.3
COM_SplitOperation.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 "COM_SplitOperation.h"
5 
6 namespace blender::compositor {
7 
9 {
13  image1Input_ = nullptr;
14  image2Input_ = nullptr;
15 }
16 
18 {
19  /* When initializing the tree during initial load the width and height can be zero. */
20  image1Input_ = get_input_socket_reader(0);
21  image2Input_ = get_input_socket_reader(1);
22 }
23 
25 {
26  image1Input_ = nullptr;
27  image2Input_ = nullptr;
28 }
29 
31  float x,
32  float y,
33  PixelSampler /*sampler*/)
34 {
35  int perc = x_split_ ? split_percentage_ * this->get_width() / 100.0f :
36  split_percentage_ * this->get_height() / 100.0f;
37  bool image1 = x_split_ ? x > perc : y > perc;
38  if (image1) {
39  image1Input_->read_sampled(output, x, y, PixelSampler::Nearest);
40  }
41  else {
42  image2Input_->read_sampled(output, x, y, PixelSampler::Nearest);
43  }
44 }
45 
46 void SplitOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
47 {
48  rcti unused_area = COM_AREA_NONE;
49 
50  const bool determined = this->get_input_socket(0)->determine_canvas(COM_AREA_NONE, unused_area);
51  this->set_canvas_input_index(determined ? 0 : 1);
52 
53  NodeOperation::determine_canvas(preferred_area, r_area);
54 }
55 
57  const rcti &area,
59 {
60  const int percent = x_split_ ? split_percentage_ * this->get_width() / 100.0f :
61  split_percentage_ * this->get_height() / 100.0f;
62  const size_t elem_bytes = COM_data_type_bytes_len(get_output_socket()->get_data_type());
63  for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
64  const bool is_image1 = x_split_ ? it.x > percent : it.y > percent;
65  memcpy(it.out, it.in(is_image1 ? 0 : 1), elem_bytes);
66  }
67 }
68 
69 } // 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
a MemoryBuffer contains access to the data of a chunk
bool determine_canvas(const rcti &preferred_area, rcti &r_area)
void add_output_socket(DataType datatype)
SocketReader * get_input_socket_reader(unsigned int index)
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
void read_sampled(float result[4], float x, float y, PixelSampler sampler)
void add_input_socket(DataType datatype, ResizeMode resize_mode=ResizeMode::Center)
void set_canvas_input_index(unsigned int index)
set the index of the input socket that will determine the canvas of this operation
virtual void determine_canvas(const rcti &preferred_area, rcti &r_area)
void update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span< MemoryBuffer * > inputs) override
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override
calculate a single pixel
void determine_canvas(const rcti &preferred_area, rcti &r_area) override
ccl_global KernelShaderEvalInput ccl_global float * output
static void area(int d1, int d2, int e1, int e2, float weights[2])
typename BuffersIteratorBuilder< T >::Iterator BuffersIterator
constexpr int COM_data_type_bytes_len(DataType data_type)
Definition: COM_defines.h:55
constexpr rcti COM_AREA_NONE
Definition: COM_defines.h:112
static bNodeSocketTemplate inputs[]