Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_VectorBlurOperation.cc
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | VectorBlurOperation::VectorBlurOperation() | ||||
| this->addInputSocket(DataType::Color); // SPEED | this->addInputSocket(DataType::Color); // SPEED | ||||
| this->addOutputSocket(DataType::Color); | this->addOutputSocket(DataType::Color); | ||||
| this->m_settings = nullptr; | this->m_settings = nullptr; | ||||
| this->m_cachedInstance = nullptr; | this->m_cachedInstance = nullptr; | ||||
| this->m_inputImageProgram = nullptr; | this->m_inputImageProgram = nullptr; | ||||
| this->m_inputSpeedProgram = nullptr; | this->m_inputSpeedProgram = nullptr; | ||||
| this->m_inputZProgram = nullptr; | this->m_inputZProgram = nullptr; | ||||
| flags.complex = true; | flags.complex = true; | ||||
| flags.is_fullframe_operation = true; | |||||
| } | } | ||||
| void VectorBlurOperation::initExecution() | void VectorBlurOperation::initExecution() | ||||
| { | { | ||||
| initMutex(); | initMutex(); | ||||
| this->m_inputImageProgram = getInputSocketReader(0); | this->m_inputImageProgram = getInputSocketReader(0); | ||||
| this->m_inputZProgram = getInputSocketReader(1); | this->m_inputZProgram = getInputSocketReader(1); | ||||
| this->m_inputSpeedProgram = getInputSocketReader(2); | this->m_inputSpeedProgram = getInputSocketReader(2); | ||||
| this->m_cachedInstance = nullptr; | this->m_cachedInstance = nullptr; | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | if (this->m_cachedInstance == nullptr) { | ||||
| newInput.ymax = this->getHeight(); | newInput.ymax = this->getHeight(); | ||||
| newInput.ymin = 0; | newInput.ymin = 0; | ||||
| return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); | return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| void VectorBlurOperation::get_area_of_interest(const int UNUSED(input_idx), | |||||
| const rcti &UNUSED(output_area), | |||||
| rcti &r_input_area) | |||||
| { | |||||
| r_input_area.xmin = 0; | |||||
| r_input_area.xmax = this->getWidth(); | |||||
| r_input_area.ymin = 0; | |||||
| r_input_area.ymax = this->getHeight(); | |||||
| } | |||||
| void VectorBlurOperation::update_memory_buffer(MemoryBuffer *output, | |||||
| const rcti &area, | |||||
| Span<MemoryBuffer *> inputs) | |||||
| { | |||||
| /* TODO(manzanilla): once tiled implementation is removed, run multi-threaded where possible. */ | |||||
| if (!m_cachedInstance) { | |||||
| MemoryBuffer *image = inputs[IMAGE_INPUT_INDEX]; | |||||
| const bool is_image_inflated = image->is_a_single_elem(); | |||||
| image = is_image_inflated ? image->inflate() : image; | |||||
| /* Must be a copy because it's modified in #generateVectorBlur. */ | |||||
| MemoryBuffer *speed = inputs[SPEED_INPUT_INDEX]; | |||||
| speed = speed->is_a_single_elem() ? speed->inflate() : new MemoryBuffer(*speed); | |||||
| MemoryBuffer *z = inputs[Z_INPUT_INDEX]; | |||||
| const bool is_z_inflated = z->is_a_single_elem(); | |||||
| z = is_z_inflated ? z->inflate() : z; | |||||
| m_cachedInstance = (float *)MEM_dupallocN(image->getBuffer()); | |||||
| this->generateVectorBlur(m_cachedInstance, image, speed, z); | |||||
| if (is_image_inflated) { | |||||
| delete image; | |||||
| } | |||||
| delete speed; | |||||
| if (is_z_inflated) { | |||||
| delete z; | |||||
| } | |||||
| } | |||||
| const int num_channels = COM_data_type_num_channels(getOutputSocket()->getDataType()); | |||||
| MemoryBuffer buf(m_cachedInstance, num_channels, this->getWidth(), this->getHeight()); | |||||
| output->copy_from(&buf, area); | |||||
| } | |||||
| void VectorBlurOperation::generateVectorBlur(float *data, | void VectorBlurOperation::generateVectorBlur(float *data, | ||||
| MemoryBuffer *inputImage, | MemoryBuffer *inputImage, | ||||
| MemoryBuffer *inputSpeed, | MemoryBuffer *inputSpeed, | ||||
| MemoryBuffer *inputZ) | MemoryBuffer *inputZ) | ||||
| { | { | ||||
| NodeBlurData blurdata; | NodeBlurData blurdata; | ||||
| blurdata.samples = this->m_settings->samples / QualityStepHelper::getStep(); | blurdata.samples = this->m_settings->samples / QualityStepHelper::getStep(); | ||||
| blurdata.maxspeed = this->m_settings->maxspeed; | blurdata.maxspeed = this->m_settings->maxspeed; | ||||
| ▲ Show 20 Lines • Show All 772 Lines • Show Last 20 Lines | |||||