Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_BokehBlurOperation.cc
| Show All 28 Lines | |||||
| constexpr int IMAGE_INPUT_INDEX = 0; | constexpr int IMAGE_INPUT_INDEX = 0; | ||||
| constexpr int BOKEH_INPUT_INDEX = 1; | constexpr int BOKEH_INPUT_INDEX = 1; | ||||
| constexpr int BOUNDING_BOX_INPUT_INDEX = 2; | constexpr int BOUNDING_BOX_INPUT_INDEX = 2; | ||||
| constexpr int SIZE_INPUT_INDEX = 3; | constexpr int SIZE_INPUT_INDEX = 3; | ||||
| BokehBlurOperation::BokehBlurOperation() | BokehBlurOperation::BokehBlurOperation() | ||||
| { | { | ||||
| this->addInputSocket(DataType::Color); | this->addInputSocket(DataType::Color); | ||||
| this->addInputSocket(DataType::Color, ResizeMode::None); | this->addInputSocket(DataType::Color, ResizeMode::Align); | ||||
| this->addInputSocket(DataType::Value); | this->addInputSocket(DataType::Value); | ||||
| this->addInputSocket(DataType::Value); | this->addInputSocket(DataType::Value); | ||||
| this->addOutputSocket(DataType::Color); | this->addOutputSocket(DataType::Color); | ||||
| flags.complex = true; | flags.complex = true; | ||||
| flags.open_cl = true; | flags.open_cl = true; | ||||
| this->m_size = 1.0f; | this->m_size = 1.0f; | ||||
| ▲ Show 20 Lines • Show All 215 Lines • ▼ Show 20 Lines | case eExecutionModel::FullFrame: { | ||||
| CLAMP(m_size, 0.0f, 10.0f); | CLAMP(m_size, 0.0f, 10.0f); | ||||
| } /* Else use default. */ | } /* Else use default. */ | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| this->m_sizeavailable = true; | this->m_sizeavailable = true; | ||||
| } | } | ||||
| void BokehBlurOperation::determineResolution(unsigned int resolution[2], | void BokehBlurOperation::determine_canvas(const rcti &preferred_area, rcti &r_area) | ||||
| unsigned int preferredResolution[2]) | |||||
| { | { | ||||
| if (!m_extend_bounds) { | if (!m_extend_bounds) { | ||||
| NodeOperation::determineResolution(resolution, preferredResolution); | NodeOperation::determine_canvas(preferred_area, r_area); | ||||
| return; | return; | ||||
| } | } | ||||
| switch (execution_model_) { | switch (execution_model_) { | ||||
| case eExecutionModel::Tiled: { | case eExecutionModel::Tiled: { | ||||
| NodeOperation::determineResolution(resolution, preferredResolution); | NodeOperation::determine_canvas(preferred_area, r_area); | ||||
| const float max_dim = MAX2(resolution[0], resolution[1]); | const float max_dim = MAX2(BLI_rcti_size_x(&r_area), BLI_rcti_size_y(&r_area)); | ||||
| resolution[0] += 2 * this->m_size * max_dim / 100.0f; | r_area.xmax += 2 * this->m_size * max_dim / 100.0f; | ||||
| resolution[1] += 2 * this->m_size * max_dim / 100.0f; | r_area.ymax += 2 * this->m_size * max_dim / 100.0f; | ||||
| break; | break; | ||||
| } | } | ||||
| case eExecutionModel::FullFrame: { | case eExecutionModel::FullFrame: { | ||||
| set_determined_resolution_modifier([=](unsigned int res[2]) { | set_determined_canvas_modifier([=](rcti &canvas) { | ||||
| const float max_dim = MAX2(res[0], res[1]); | const float max_dim = MAX2(BLI_rcti_size_x(&canvas), BLI_rcti_size_y(&canvas)); | ||||
| /* Rounding to even prevents image jiggling in backdrop while switching size values. */ | /* Rounding to even prevents image jiggling in backdrop while switching size values. */ | ||||
| float add_size = round_to_even(2 * this->m_size * max_dim / 100.0f); | float add_size = round_to_even(2 * this->m_size * max_dim / 100.0f); | ||||
| res[0] += add_size; | canvas.xmax += add_size; | ||||
| res[1] += add_size; | canvas.ymax += add_size; | ||||
| }); | }); | ||||
| NodeOperation::determineResolution(resolution, preferredResolution); | NodeOperation::determine_canvas(preferred_area, r_area); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void BokehBlurOperation::get_area_of_interest(const int input_idx, | void BokehBlurOperation::get_area_of_interest(const int input_idx, | ||||
| const rcti &output_area, | const rcti &output_area, | ||||
| rcti &r_input_area) | rcti &r_input_area) | ||||
| { | { | ||||
| switch (input_idx) { | switch (input_idx) { | ||||
| case IMAGE_INPUT_INDEX: { | case IMAGE_INPUT_INDEX: { | ||||
| const float max_dim = MAX2(this->getWidth(), this->getHeight()); | const float max_dim = MAX2(this->getWidth(), this->getHeight()); | ||||
| const float add_size = m_size * max_dim / 100.0f; | const float add_size = m_size * max_dim / 100.0f; | ||||
| r_input_area.xmin = output_area.xmin - add_size; | r_input_area.xmin = output_area.xmin - add_size; | ||||
| r_input_area.xmax = output_area.xmax + add_size; | r_input_area.xmax = output_area.xmax + add_size; | ||||
| r_input_area.ymin = output_area.ymin - add_size; | r_input_area.ymin = output_area.ymin - add_size; | ||||
| r_input_area.ymax = output_area.ymax + add_size; | r_input_area.ymax = output_area.ymax + add_size; | ||||
| break; | break; | ||||
| } | } | ||||
| case BOKEH_INPUT_INDEX: { | case BOKEH_INPUT_INDEX: { | ||||
| NodeOperation *bokeh_input = getInputOperation(BOKEH_INPUT_INDEX); | NodeOperation *bokeh_input = getInputOperation(BOKEH_INPUT_INDEX); | ||||
| r_input_area.xmin = 0; | r_input_area = bokeh_input->get_canvas(); | ||||
| r_input_area.xmax = bokeh_input->getWidth(); | |||||
| r_input_area.ymin = 0; | |||||
| r_input_area.ymax = bokeh_input->getHeight(); | |||||
| break; | break; | ||||
| } | } | ||||
| case BOUNDING_BOX_INPUT_INDEX: | case BOUNDING_BOX_INPUT_INDEX: | ||||
| r_input_area = output_area; | r_input_area = output_area; | ||||
| break; | break; | ||||
| case SIZE_INPUT_INDEX: { | case SIZE_INPUT_INDEX: { | ||||
| r_input_area = COM_SINGLE_ELEM_AREA; | r_input_area = COM_CONSTANT_INPUT_AREA_OF_INTEREST; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void BokehBlurOperation::update_memory_buffer_partial(MemoryBuffer *output, | void BokehBlurOperation::update_memory_buffer_partial(MemoryBuffer *output, | ||||
| const rcti &area, | const rcti &area, | ||||
| Span<MemoryBuffer *> inputs) | Span<MemoryBuffer *> inputs) | ||||
| ▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines | |||||