Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/intern/COM_NodeOperationBuilder.cc
| Show All 27 Lines | |||||
| #include "COM_NodeOperation.h" | #include "COM_NodeOperation.h" | ||||
| #include "COM_PreviewOperation.h" | #include "COM_PreviewOperation.h" | ||||
| #include "COM_ReadBufferOperation.h" | #include "COM_ReadBufferOperation.h" | ||||
| #include "COM_SetColorOperation.h" | #include "COM_SetColorOperation.h" | ||||
| #include "COM_SetValueOperation.h" | #include "COM_SetValueOperation.h" | ||||
| #include "COM_SetVectorOperation.h" | #include "COM_SetVectorOperation.h" | ||||
| #include "COM_SocketProxyOperation.h" | #include "COM_SocketProxyOperation.h" | ||||
| #include "COM_TranslateOperation.h" | |||||
| #include "COM_ViewerOperation.h" | #include "COM_ViewerOperation.h" | ||||
| #include "COM_WriteBufferOperation.h" | #include "COM_WriteBufferOperation.h" | ||||
| #include "COM_ConstantFolder.h" | #include "COM_ConstantFolder.h" | ||||
| #include "COM_NodeOperationBuilder.h" /* own include */ | #include "COM_NodeOperationBuilder.h" /* own include */ | ||||
| namespace blender::compositor { | namespace blender::compositor { | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) | ||||
| add_datatype_conversions(); | add_datatype_conversions(); | ||||
| if (m_context->get_execution_model() == eExecutionModel::FullFrame) { | if (m_context->get_execution_model() == eExecutionModel::FullFrame) { | ||||
| save_graphviz("compositor_prior_folding"); | save_graphviz("compositor_prior_folding"); | ||||
| ConstantFolder folder(*this); | ConstantFolder folder(*this); | ||||
| folder.fold_operations(); | folder.fold_operations(); | ||||
| } | } | ||||
| determineResolutions(); | determine_canvases(); | ||||
| save_graphviz("compositor_prior_merging"); | save_graphviz("compositor_prior_merging"); | ||||
| merge_equal_operations(); | merge_equal_operations(); | ||||
| if (m_context->get_execution_model() == eExecutionModel::Tiled) { | if (m_context->get_execution_model() == eExecutionModel::Tiled) { | ||||
| /* surround complex ops with read/write buffer */ | /* surround complex ops with read/write buffer */ | ||||
| add_complex_operation_buffers(); | add_complex_operation_buffers(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 300 Lines • ▼ Show 20 Lines | for (const Link &link : proxy_links) { | ||||
| * in that case it just gets dropped | * in that case it just gets dropped | ||||
| */ | */ | ||||
| if (from) { | if (from) { | ||||
| addLink(from, to); | addLink(from, to); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void NodeOperationBuilder::determineResolutions() | void NodeOperationBuilder::determine_canvases() | ||||
| { | { | ||||
| /* determine all resolutions of the operations (Width/Height) */ | /* Determine all canvas areas of the operations. */ | ||||
| const rcti &preferred_area = COM_AREA_NONE; | |||||
| for (NodeOperation *op : m_operations) { | for (NodeOperation *op : m_operations) { | ||||
| if (op->isOutputOperation(m_context->isRendering()) && !op->get_flags().is_preview_operation) { | if (op->isOutputOperation(m_context->isRendering()) && !op->get_flags().is_preview_operation) { | ||||
| unsigned int resolution[2] = {0, 0}; | rcti canvas = COM_AREA_NONE; | ||||
| unsigned int preferredResolution[2] = {0, 0}; | op->determine_canvas(preferred_area, canvas); | ||||
| op->determineResolution(resolution, preferredResolution); | op->set_canvas(canvas); | ||||
| op->setResolution(resolution); | |||||
| } | } | ||||
| } | } | ||||
| for (NodeOperation *op : m_operations) { | for (NodeOperation *op : m_operations) { | ||||
| if (op->isOutputOperation(m_context->isRendering()) && op->get_flags().is_preview_operation) { | if (op->isOutputOperation(m_context->isRendering()) && op->get_flags().is_preview_operation) { | ||||
| unsigned int resolution[2] = {0, 0}; | rcti canvas = COM_AREA_NONE; | ||||
| unsigned int preferredResolution[2] = {0, 0}; | op->determine_canvas(preferred_area, canvas); | ||||
| op->determineResolution(resolution, preferredResolution); | op->set_canvas(canvas); | ||||
| op->setResolution(resolution); | |||||
| } | } | ||||
| } | } | ||||
| /* add convert resolution operations when needed */ | /* Convert operation canvases when needed. */ | ||||
| { | { | ||||
| Vector<Link> convert_links; | Vector<Link> convert_links; | ||||
| for (const Link &link : m_links) { | for (const Link &link : m_links) { | ||||
| if (link.to()->getResizeMode() != ResizeMode::None) { | if (link.to()->getResizeMode() != ResizeMode::None) { | ||||
| NodeOperation &from_op = link.from()->getOperation(); | const rcti &from_canvas = link.from()->getOperation().get_canvas(); | ||||
| NodeOperation &to_op = link.to()->getOperation(); | const rcti &to_canvas = link.to()->getOperation().get_canvas(); | ||||
| if (from_op.getWidth() != to_op.getWidth() || from_op.getHeight() != to_op.getHeight()) { | |||||
| bool needs_conversion; | |||||
| if (link.to()->getResizeMode() == ResizeMode::Align) { | |||||
| needs_conversion = from_canvas.xmin != to_canvas.xmin || | |||||
| from_canvas.ymin != to_canvas.ymin; | |||||
| } | |||||
| else { | |||||
| needs_conversion = !BLI_rcti_compare(&from_canvas, &to_canvas); | |||||
| } | |||||
| if (needs_conversion) { | |||||
| convert_links.append(link); | convert_links.append(link); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (const Link &link : convert_links) { | for (const Link &link : convert_links) { | ||||
| COM_convert_resolution(*this, link.from(), link.to()); | COM_convert_canvas(*this, link.from(), link.to()); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static Vector<NodeOperationHash> generate_hashes(Span<NodeOperation *> operations) | static Vector<NodeOperationHash> generate_hashes(Span<NodeOperation *> operations) | ||||
| { | { | ||||
| Vector<NodeOperationHash> hashes; | Vector<NodeOperationHash> hashes; | ||||
| for (NodeOperation *op : operations) { | for (NodeOperation *op : operations) { | ||||
| ▲ Show 20 Lines • Show All 358 Lines • Show Last 20 Lines | |||||