Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_GlareThresholdOperation.cc
| Show All 24 Lines | |||||
| GlareThresholdOperation::GlareThresholdOperation() | GlareThresholdOperation::GlareThresholdOperation() | ||||
| { | { | ||||
| this->addInputSocket(DataType::Color, ResizeMode::FitAny); | this->addInputSocket(DataType::Color, ResizeMode::FitAny); | ||||
| this->addOutputSocket(DataType::Color); | this->addOutputSocket(DataType::Color); | ||||
| this->m_inputProgram = nullptr; | this->m_inputProgram = nullptr; | ||||
| } | } | ||||
| void GlareThresholdOperation::determineResolution(unsigned int resolution[2], | void GlareThresholdOperation::determine_canvas(const rcti &preferred_area, rcti &r_area) | ||||
| unsigned int preferredResolution[2]) | |||||
| { | { | ||||
| NodeOperation::determineResolution(resolution, preferredResolution); | NodeOperation::determine_canvas(preferred_area, r_area); | ||||
| resolution[0] = resolution[0] / (1 << this->m_settings->quality); | const int width = BLI_rcti_size_x(&r_area) / (1 << this->m_settings->quality); | ||||
| resolution[1] = resolution[1] / (1 << this->m_settings->quality); | const int height = BLI_rcti_size_y(&r_area) / (1 << this->m_settings->quality); | ||||
| r_area.xmax = r_area.xmin + width; | |||||
| r_area.ymax = r_area.ymin + height; | |||||
| } | } | ||||
| void GlareThresholdOperation::initExecution() | void GlareThresholdOperation::initExecution() | ||||
| { | { | ||||
| this->m_inputProgram = this->getInputSocketReader(0); | this->m_inputProgram = this->getInputSocketReader(0); | ||||
| } | } | ||||
| void GlareThresholdOperation::executePixelSampled(float output[4], | void GlareThresholdOperation::executePixelSampled(float output[4], | ||||
| Show All 18 Lines | void GlareThresholdOperation::executePixelSampled(float output[4], | ||||
| } | } | ||||
| } | } | ||||
| void GlareThresholdOperation::deinitExecution() | void GlareThresholdOperation::deinitExecution() | ||||
| { | { | ||||
| this->m_inputProgram = nullptr; | this->m_inputProgram = nullptr; | ||||
| } | } | ||||
| void GlareThresholdOperation::update_memory_buffer_partial(MemoryBuffer *output, | |||||
| const rcti &area, | |||||
| Span<MemoryBuffer *> inputs) | |||||
| { | |||||
| const float threshold = this->m_settings->threshold; | |||||
| for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) { | |||||
| const float *color = it.in(0); | |||||
| if (IMB_colormanagement_get_luminance(color) >= threshold) { | |||||
| it.out[0] = color[0] - threshold; | |||||
| it.out[1] = color[1] - threshold; | |||||
| it.out[2] = color[2] - threshold; | |||||
| CLAMP3_MIN(it.out, 0.0f); | |||||
| } | |||||
| else { | |||||
| zero_v3(it.out); | |||||
| } | |||||
| } | |||||
| } | |||||
| } // namespace blender::compositor | } // namespace blender::compositor | ||||