Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_PreviewOperation.cc
| Show All 35 Lines | |||||
| namespace blender::compositor { | namespace blender::compositor { | ||||
| PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings, | PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings, | ||||
| const ColorManagedDisplaySettings *displaySettings, | const ColorManagedDisplaySettings *displaySettings, | ||||
| const unsigned int defaultWidth, | const unsigned int defaultWidth, | ||||
| const unsigned int defaultHeight) | const unsigned int defaultHeight) | ||||
| { | { | ||||
| this->addInputSocket(DataType::Color, ResizeMode::None); | this->addInputSocket(DataType::Color, ResizeMode::Align); | ||||
| this->m_preview = nullptr; | this->m_preview = nullptr; | ||||
| this->m_outputBuffer = nullptr; | this->m_outputBuffer = nullptr; | ||||
| this->m_input = nullptr; | this->m_input = nullptr; | ||||
| this->m_divider = 1.0f; | this->m_divider = 1.0f; | ||||
| this->m_viewSettings = viewSettings; | this->m_viewSettings = viewSettings; | ||||
| this->m_displaySettings = displaySettings; | this->m_displaySettings = displaySettings; | ||||
| this->m_defaultWidth = defaultWidth; | this->m_defaultWidth = defaultWidth; | ||||
| this->m_defaultHeight = defaultHeight; | this->m_defaultHeight = defaultHeight; | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, | ||||
| newInput.xmin = input->xmin / this->m_divider; | newInput.xmin = input->xmin / this->m_divider; | ||||
| newInput.xmax = input->xmax / this->m_divider; | newInput.xmax = input->xmax / this->m_divider; | ||||
| newInput.ymin = input->ymin / this->m_divider; | newInput.ymin = input->ymin / this->m_divider; | ||||
| newInput.ymax = input->ymax / this->m_divider; | newInput.ymax = input->ymax / this->m_divider; | ||||
| return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); | return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); | ||||
| } | } | ||||
| void PreviewOperation::determineResolution(unsigned int resolution[2], | void PreviewOperation::determine_canvas(const rcti &UNUSED(preferred_area), rcti &r_area) | ||||
| unsigned int /*preferredResolution*/[2]) | |||||
| { | { | ||||
| /* Use default preview resolution as preferred ensuring it has size so that | /* Use default preview resolution as preferred ensuring it has size so that | ||||
| * generated inputs (which don't have resolution on their own) are displayed */ | * generated inputs (which don't have resolution on their own) are displayed */ | ||||
| BLI_assert(this->m_defaultWidth > 0 && this->m_defaultHeight > 0); | BLI_assert(this->m_defaultWidth > 0 && this->m_defaultHeight > 0); | ||||
| unsigned int previewPreferredRes[2] = {this->m_defaultWidth, this->m_defaultHeight}; | rcti local_preferred; | ||||
| NodeOperation::determineResolution(resolution, previewPreferredRes); | BLI_rcti_init(&local_preferred, 0, m_defaultWidth, 0, m_defaultHeight); | ||||
| NodeOperation::determine_canvas(local_preferred, r_area); | |||||
| /* If resolution is 0 there are two possible scenarios: | /* If resolution is 0 there are two possible scenarios: | ||||
| * - Either node is not connected at all | * - Either node is not connected at all | ||||
| * - Or it is connected to an input which has no resolution. | * - Or it is connected to an input which has no resolution. | ||||
| * | * | ||||
| * In the former case we rely on the execution system to not evaluate this node. | * In the former case we rely on the execution system to not evaluate this node. | ||||
| * | * | ||||
| * The latter case would only happen if an input doesn't set any resolution ignoring output | * The latter case would only happen if an input doesn't set any resolution ignoring output | ||||
| * preferred resolution. In such case preview size will be 0 too. | * preferred resolution. In such case preview size will be 0 too. | ||||
| */ | */ | ||||
| int width = resolution[0]; | int width = BLI_rcti_size_x(&r_area); | ||||
| int height = resolution[1]; | int height = BLI_rcti_size_y(&r_area); | ||||
| this->m_divider = 0.0f; | this->m_divider = 0.0f; | ||||
| if (width > 0 && height > 0) { | if (width > 0 && height > 0) { | ||||
| if (width > height) { | if (width > height) { | ||||
| this->m_divider = (float)COM_PREVIEW_SIZE / (width); | this->m_divider = (float)COM_PREVIEW_SIZE / (width); | ||||
| } | } | ||||
| else { | else { | ||||
| this->m_divider = (float)COM_PREVIEW_SIZE / (height); | this->m_divider = (float)COM_PREVIEW_SIZE / (height); | ||||
| } | } | ||||
| } | } | ||||
| width = width * this->m_divider; | width = width * this->m_divider; | ||||
| height = height * this->m_divider; | height = height * this->m_divider; | ||||
| resolution[0] = width; | BLI_rcti_init(&r_area, r_area.xmin, r_area.xmin + width, r_area.ymin, r_area.ymin + height); | ||||
| resolution[1] = height; | |||||
| } | } | ||||
| eCompositorPriority PreviewOperation::getRenderPriority() const | eCompositorPriority PreviewOperation::getRenderPriority() const | ||||
| { | { | ||||
| return eCompositorPriority::Low; | return eCompositorPriority::Low; | ||||
| } | } | ||||
| void PreviewOperation::get_area_of_interest(const int input_idx, | void PreviewOperation::get_area_of_interest(const int input_idx, | ||||
| Show All 39 Lines | |||||