Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_MixOperation.cc
| Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | void MixBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) | ||||
| } | } | ||||
| float valuem = 1.0f - value; | float valuem = 1.0f - value; | ||||
| output[0] = valuem * (inputColor1[0]) + value * (inputColor2[0]); | output[0] = valuem * (inputColor1[0]) + value * (inputColor2[0]); | ||||
| output[1] = valuem * (inputColor1[1]) + value * (inputColor2[1]); | output[1] = valuem * (inputColor1[1]) + value * (inputColor2[1]); | ||||
| output[2] = valuem * (inputColor1[2]) + value * (inputColor2[2]); | output[2] = valuem * (inputColor1[2]) + value * (inputColor2[2]); | ||||
| output[3] = inputColor1[3]; | output[3] = inputColor1[3]; | ||||
| } | } | ||||
| void MixBaseOperation::determineResolution(unsigned int resolution[2], | void MixBaseOperation::determine_canvas(const rcti &preferred_area, rcti &r_area) | ||||
| unsigned int preferredResolution[2]) | |||||
| { | { | ||||
| NodeOperationInput *socket; | NodeOperationInput *socket; | ||||
| unsigned int tempPreferredResolution[2] = {0, 0}; | rcti temp_area; | ||||
| unsigned int tempResolution[2]; | |||||
| socket = this->getInputSocket(1); | socket = this->getInputSocket(1); | ||||
| socket->determineResolution(tempResolution, tempPreferredResolution); | bool determined = socket->determine_canvas(COM_AREA_NONE, temp_area); | ||||
| if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) { | if (determined) { | ||||
| this->setResolutionInputSocketIndex(1); | this->set_canvas_input_index(1); | ||||
| } | } | ||||
| else { | else { | ||||
| socket = this->getInputSocket(2); | socket = this->getInputSocket(2); | ||||
| socket->determineResolution(tempResolution, tempPreferredResolution); | determined = socket->determine_canvas(COM_AREA_NONE, temp_area); | ||||
| if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) { | if (determined) { | ||||
| this->setResolutionInputSocketIndex(2); | this->set_canvas_input_index(2); | ||||
| } | } | ||||
| else { | else { | ||||
| this->setResolutionInputSocketIndex(0); | this->set_canvas_input_index(0); | ||||
| } | } | ||||
| } | } | ||||
| NodeOperation::determineResolution(resolution, preferredResolution); | NodeOperation::determine_canvas(preferred_area, r_area); | ||||
| } | } | ||||
| void MixBaseOperation::deinitExecution() | void MixBaseOperation::deinitExecution() | ||||
| { | { | ||||
| this->m_inputValueOperation = nullptr; | this->m_inputValueOperation = nullptr; | ||||
| this->m_inputColor1Operation = nullptr; | this->m_inputColor1Operation = nullptr; | ||||
| this->m_inputColor2Operation = nullptr; | this->m_inputColor2Operation = nullptr; | ||||
| } | } | ||||
| void MixBaseOperation::update_memory_buffer_partial(MemoryBuffer *output, | void MixBaseOperation::update_memory_buffer_partial(MemoryBuffer *output, | ||||
| const rcti &area, | const rcti &area, | ||||
| Span<MemoryBuffer *> inputs) | Span<MemoryBuffer *> inputs) | ||||
| { | { | ||||
| const MemoryBuffer *input_value = inputs[0]; | const MemoryBuffer *input_value = inputs[0]; | ||||
| const MemoryBuffer *input_color1 = inputs[1]; | const MemoryBuffer *input_color1 = inputs[1]; | ||||
| const MemoryBuffer *input_color2 = inputs[2]; | const MemoryBuffer *input_color2 = inputs[2]; | ||||
| const int width = BLI_rcti_size_x(&area); | const int width = BLI_rcti_size_x(&area); | ||||
| PixelCursor p; | PixelCursor p; | ||||
| p.out_stride = output->elem_stride; | p.out_stride = output->elem_stride; | ||||
| p.value_stride = input_value->elem_stride; | p.value_stride = input_value->elem_stride; | ||||
| p.color1_stride = input_color1->elem_stride; | p.color1_stride = input_color1->elem_stride; | ||||
| p.color2_stride = input_color2->elem_stride; | p.color2_stride = input_color2->elem_stride; | ||||
| for (const int y : YRange(area)) { | for (int y = area.ymin; y < area.ymax; y++) { | ||||
| p.out = output->get_elem(area.xmin, y); | p.out = output->get_elem(area.xmin, y); | ||||
| p.row_end = p.out + width * output->elem_stride; | p.row_end = p.out + width * output->elem_stride; | ||||
| p.value = input_value->get_elem(area.xmin, y); | p.value = input_value->get_elem(area.xmin, y); | ||||
| p.color1 = input_color1->get_elem(area.xmin, y); | p.color1 = input_color1->get_elem(area.xmin, y); | ||||
| p.color2 = input_color2->get_elem(area.xmin, y); | p.color2 = input_color2->get_elem(area.xmin, y); | ||||
| update_memory_buffer_row(p); | update_memory_buffer_row(p); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,287 Lines • Show Last 20 Lines | |||||