diff options
-rw-r--r-- | source/blender/compositor/intern/COM_NodeOperationBuilder.cc | 73 | ||||
-rw-r--r-- | source/blender/compositor/intern/COM_NodeOperationBuilder.h | 14 |
2 files changed, 36 insertions, 51 deletions
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc index 6fdedfef241..46954e04cb8 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc @@ -69,7 +69,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) */ OpInputInverseMap inverse_input_map; for (InputSocketMap::const_iterator it = m_input_map.begin(); it != m_input_map.end(); ++it) { - inverse_input_map[it->second].push_back(it->first); + inverse_input_map[it->second].append(it->first); } for (const NodeGraph::Link &link : m_graph.links()) { @@ -77,8 +77,9 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) NodeInput *to = link.to; NodeOperationOutput *op_from = find_operation_output(m_output_map, from); - const OpInputs &op_to_list = find_operation_inputs(inverse_input_map, to); - if (!op_from || op_to_list.empty()) { + const blender::Vector<NodeOperationInput *> &op_to_list = find_operation_inputs( + inverse_input_map, to); + if (!op_from || op_to_list.is_empty()) { /* XXX allow this? error/debug message? */ // BLI_assert(false); /* XXX note: this can happen with certain nodes (e.g. OutputFile) @@ -88,8 +89,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) continue; } - for (OpInputs::const_iterator it = op_to_list.begin(); it != op_to_list.end(); ++it) { - NodeOperationInput *op_to = *it; + for (NodeOperationInput *op_to : op_to_list) { addLink(op_from, op_to); } } @@ -154,7 +154,7 @@ void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput return; } - m_links.push_back(Link(from, to)); + m_links.append(Link(from, to)); /* register with the input */ to->setLink(from); @@ -162,15 +162,16 @@ void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput void NodeOperationBuilder::removeInputLink(NodeOperationInput *to) { - for (Links::iterator it = m_links.begin(); it != m_links.end(); ++it) { - Link &link = *it; + int index = 0; + for (Link &link : m_links) { if (link.to() == to) { /* unregister with the input */ to->setLink(nullptr); - m_links.erase(it); + m_links.remove(index); return; } + index++; } } @@ -181,10 +182,10 @@ NodeInput *NodeOperationBuilder::find_node_input(const InputSocketMap &map, return (it != map.end() ? it->second : NULL); } -const NodeOperationBuilder::OpInputs &NodeOperationBuilder::find_operation_inputs( +const blender::Vector<NodeOperationInput *> &NodeOperationBuilder::find_operation_inputs( const OpInputInverseMap &map, NodeInput *node_input) { - static const OpInputs empty_list; + static const blender::Vector<NodeOperationInput *> empty_list; OpInputInverseMap::const_iterator it = map.find(node_input); return (it != map.end() ? it->second : empty_list); } @@ -269,9 +270,8 @@ void NodeOperationBuilder::registerViewer(ViewerOperation *viewer) void NodeOperationBuilder::add_datatype_conversions() { - Links convert_links; + blender::Vector<Link> convert_links; for (const Link &link : m_links) { - /* proxy operations can skip data type conversion */ NodeOperation *from_op = &link.from()->getOperation(); NodeOperation *to_op = &link.to()->getOperation(); @@ -280,7 +280,7 @@ void NodeOperationBuilder::add_datatype_conversions() } if (link.from()->getDataType() != link.to()->getDataType()) { - convert_links.push_back(link); + convert_links.append(link); } } for (const Link &link : convert_links) { @@ -370,19 +370,16 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input, void NodeOperationBuilder::resolve_proxies() { - Links proxy_links; - for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) { - const Link &link = *it; + blender::Vector<Link> proxy_links; + for (const Link &link : m_links) { /* don't replace links from proxy to proxy, since we may need them for replacing others! */ if (link.from()->getOperation().isProxyOperation() && !link.to()->getOperation().isProxyOperation()) { - proxy_links.push_back(link); + proxy_links.append(link); } } - for (Links::const_iterator it = proxy_links.begin(); it != proxy_links.end(); ++it) { - const Link &link = *it; - + for (const Link &link : proxy_links) { NodeOperationInput *to = link.to(); NodeOperationOutput *from = link.from(); do { @@ -423,33 +420,29 @@ void NodeOperationBuilder::determineResolutions() /* add convert resolution operations when needed */ { - Links convert_links; - for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) { - const Link &link = *it; - + blender::Vector<Link> convert_links; + for (const Link &link : m_links) { if (link.to()->getResizeMode() != COM_SC_NO_RESIZE) { NodeOperation &from_op = link.from()->getOperation(); NodeOperation &to_op = link.to()->getOperation(); if (from_op.getWidth() != to_op.getWidth() || from_op.getHeight() != to_op.getHeight()) { - convert_links.push_back(link); + convert_links.append(link); } } } - for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) { - const Link &link = *it; + for (const Link &link : convert_links) { COM_convert_resolution(*this, link.from(), link.to()); } } } -NodeOperationBuilder::OpInputs NodeOperationBuilder::cache_output_links( +blender::Vector<NodeOperationInput *> NodeOperationBuilder::cache_output_links( NodeOperationOutput *output) const { - OpInputs inputs; - for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) { - const Link &link = *it; + blender::Vector<NodeOperationInput *> inputs; + for (const Link &link : m_links) { if (link.from() == output) { - inputs.push_back(link.to()); + inputs.append(link.to()); } } return inputs; @@ -458,8 +451,7 @@ NodeOperationBuilder::OpInputs NodeOperationBuilder::cache_output_links( WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation( NodeOperationOutput *output) const { - for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) { - const Link &link = *it; + for (const Link &link : m_links) { if (link.from() == output) { NodeOperation &op = link.to()->getOperation(); if (op.isWriteBufferOperation()) { @@ -512,15 +504,13 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation, NodeOperationOutput *output) { /* cache connected sockets, so we can safely remove links first before replacing them */ - OpInputs targets = cache_output_links(output); - if (targets.empty()) { + blender::Vector<NodeOperationInput *> targets = cache_output_links(output); + if (targets.is_empty()) { return; } WriteBufferOperation *writeOperation = nullptr; - for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) { - NodeOperationInput *target = *it; - + for (NodeOperationInput *target : targets) { /* try to find existing write buffer operation */ if (target->getOperation().isWriteBufferOperation()) { BLI_assert(writeOperation == nullptr); /* there should only be one write op connected */ @@ -544,8 +534,7 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation, writeOperation->readResolutionFromInputSocket(); /* add readbuffer op for every former connected input */ - for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) { - NodeOperationInput *target = *it; + for (NodeOperationInput *target : targets) { if (&target->getOperation() == writeOperation) { continue; /* skip existing write op links */ } diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.h b/source/blender/compositor/intern/COM_NodeOperationBuilder.h index b502a12d9b1..391c40116a7 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.h +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.h @@ -62,20 +62,16 @@ class NodeOperationBuilder { } }; - typedef std::vector<Link> Links; - typedef std::map<NodeOperationInput *, NodeInput *> InputSocketMap; typedef std::map<NodeOutput *, NodeOperationOutput *> OutputSocketMap; - - typedef std::vector<NodeOperationInput *> OpInputs; - typedef std::map<NodeInput *, OpInputs> OpInputInverseMap; + typedef std::map<NodeInput *, blender::Vector<NodeOperationInput *>> OpInputInverseMap; private: const CompositorContext *m_context; NodeGraph m_graph; blender::Vector<NodeOperation *> m_operations; - Links m_links; + blender::Vector<Link> m_links; blender::Vector<ExecutionGroup *> m_groups; /** Maps operation inputs to node inputs */ @@ -127,8 +123,8 @@ class NodeOperationBuilder { protected: static NodeInput *find_node_input(const InputSocketMap &map, NodeOperationInput *op_input); - static const OpInputs &find_operation_inputs(const OpInputInverseMap &map, - NodeInput *node_input); + static const blender::Vector<NodeOperationInput *> &find_operation_inputs( + const OpInputInverseMap &map, NodeInput *node_input); static NodeOperationOutput *find_operation_output(const OutputSocketMap &map, NodeOutput *node_output); @@ -146,7 +142,7 @@ class NodeOperationBuilder { void determineResolutions(); /** Helper function to store connected inputs for replacement */ - OpInputs cache_output_links(NodeOperationOutput *output) const; + blender::Vector<NodeOperationInput *> cache_output_links(NodeOperationOutput *output) const; /** Find a connected write buffer operation to an OpOutput */ WriteBufferOperation *find_attached_write_buffer_operation(NodeOperationOutput *output) const; /** Add read/write buffer operations around complex operations */ |