Cleanup: convert camelCase naming to snake_case in Compositor

To convert old code to the current convention and
use a single code style.
This commit is contained in:
2021-10-13 23:01:15 +02:00
parent a2ee3c3a9f
commit 1c42d4930a
456 changed files with 10870 additions and 10727 deletions

View File

@@ -22,66 +22,69 @@ namespace blender::compositor {
BoxMaskOperation::BoxMaskOperation()
{
this->addInputSocket(DataType::Value);
this->addInputSocket(DataType::Value);
this->addOutputSocket(DataType::Value);
inputMask_ = nullptr;
inputValue_ = nullptr;
this->add_input_socket(DataType::Value);
this->add_input_socket(DataType::Value);
this->add_output_socket(DataType::Value);
input_mask_ = nullptr;
input_value_ = nullptr;
cosine_ = 0.0f;
sine_ = 0.0f;
}
void BoxMaskOperation::initExecution()
void BoxMaskOperation::init_execution()
{
inputMask_ = this->getInputSocketReader(0);
inputValue_ = this->getInputSocketReader(1);
input_mask_ = this->get_input_socket_reader(0);
input_value_ = this->get_input_socket_reader(1);
const double rad = (double)data_->rotation;
cosine_ = cos(rad);
sine_ = sin(rad);
aspectRatio_ = ((float)this->getWidth()) / this->getHeight();
aspect_ratio_ = ((float)this->get_width()) / this->get_height();
}
void BoxMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
void BoxMaskOperation::execute_pixel_sampled(float output[4],
float x,
float y,
PixelSampler sampler)
{
float inputMask[4];
float inputValue[4];
float input_mask[4];
float input_value[4];
float rx = x / this->getWidth();
float ry = y / this->getHeight();
float rx = x / this->get_width();
float ry = y / this->get_height();
const float dy = (ry - data_->y) / aspectRatio_;
const float dy = (ry - data_->y) / aspect_ratio_;
const float dx = rx - data_->x;
rx = data_->x + (cosine_ * dx + sine_ * dy);
ry = data_->y + (-sine_ * dx + cosine_ * dy);
inputMask_->readSampled(inputMask, x, y, sampler);
inputValue_->readSampled(inputValue, x, y, sampler);
input_mask_->read_sampled(input_mask, x, y, sampler);
input_value_->read_sampled(input_value, x, y, sampler);
float halfHeight = data_->height / 2.0f;
float halfWidth = data_->width / 2.0f;
bool inside = (rx > data_->x - halfWidth && rx < data_->x + halfWidth &&
ry > data_->y - halfHeight && ry < data_->y + halfHeight);
float half_height = data_->height / 2.0f;
float half_width = data_->width / 2.0f;
bool inside = (rx > data_->x - half_width && rx < data_->x + half_width &&
ry > data_->y - half_height && ry < data_->y + half_height);
switch (maskType_) {
switch (mask_type_) {
case CMP_NODE_MASKTYPE_ADD:
if (inside) {
output[0] = MAX2(inputMask[0], inputValue[0]);
output[0] = MAX2(input_mask[0], input_value[0]);
}
else {
output[0] = inputMask[0];
output[0] = input_mask[0];
}
break;
case CMP_NODE_MASKTYPE_SUBTRACT:
if (inside) {
output[0] = inputMask[0] - inputValue[0];
output[0] = input_mask[0] - input_value[0];
CLAMP(output[0], 0, 1);
}
else {
output[0] = inputMask[0];
output[0] = input_mask[0];
}
break;
case CMP_NODE_MASKTYPE_MULTIPLY:
if (inside) {
output[0] = inputMask[0] * inputValue[0];
output[0] = input_mask[0] * input_value[0];
}
else {
output[0] = 0;
@@ -89,15 +92,15 @@ void BoxMaskOperation::executePixelSampled(float output[4], float x, float y, Pi
break;
case CMP_NODE_MASKTYPE_NOT:
if (inside) {
if (inputMask[0] > 0.0f) {
if (input_mask[0] > 0.0f) {
output[0] = 0;
}
else {
output[0] = inputValue[0];
output[0] = input_value[0];
}
}
else {
output[0] = inputMask[0];
output[0] = input_mask[0];
}
break;
}
@@ -108,7 +111,7 @@ void BoxMaskOperation::update_memory_buffer_partial(MemoryBuffer *output,
Span<MemoryBuffer *> inputs)
{
MaskFunc mask_func;
switch (maskType_) {
switch (mask_type_) {
case CMP_NODE_MASKTYPE_ADD:
mask_func = [](const bool is_inside, const float *mask, const float *value) {
return is_inside ? MAX2(mask[0], value[0]) : mask[0];
@@ -141,13 +144,13 @@ void BoxMaskOperation::apply_mask(MemoryBuffer *output,
Span<MemoryBuffer *> inputs,
MaskFunc mask_func)
{
const float op_w = this->getWidth();
const float op_h = this->getHeight();
const float op_w = this->get_width();
const float op_h = this->get_height();
const float half_w = data_->width / 2.0f;
const float half_h = data_->height / 2.0f;
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
const float op_ry = it.y / op_h;
const float dy = (op_ry - data_->y) / aspectRatio_;
const float dy = (op_ry - data_->y) / aspect_ratio_;
const float op_rx = it.x / op_w;
const float dx = op_rx - data_->x;
const float rx = data_->x + (cosine_ * dx + sine_ * dy);
@@ -161,10 +164,10 @@ void BoxMaskOperation::apply_mask(MemoryBuffer *output,
}
}
void BoxMaskOperation::deinitExecution()
void BoxMaskOperation::deinit_execution()
{
inputMask_ = nullptr;
inputValue_ = nullptr;
input_mask_ = nullptr;
input_value_ = nullptr;
}
} // namespace blender::compositor