diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-03-29 17:54:02 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-03-29 18:10:01 +0300 |
commit | 2db2b7de55836725266e67a7f2f342b032c4fa3a (patch) | |
tree | 99ee5083363a7885d7416a255a03859c66e684a6 /source/blender/compositor/intern | |
parent | fe60062a9910161d411da6e14690755d814c4cb1 (diff) |
Cleanup: Replace `is...Operation()` methods with a flag.
Diffstat (limited to 'source/blender/compositor/intern')
6 files changed, 40 insertions, 65 deletions
diff --git a/source/blender/compositor/intern/COM_Debug.cc b/source/blender/compositor/intern/COM_Debug.cc index ac694768add..1612072a2e8 100644 --- a/source/blender/compositor/intern/COM_Debug.cc +++ b/source/blender/compositor/intern/COM_Debug.cc @@ -135,13 +135,13 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system, else if (operation->isOutputOperation(system->getContext().isRendering())) { fillcolor = "dodgerblue1"; } - else if (operation->isSetOperation()) { + else if (operation->get_flags().is_set_operation()) { fillcolor = "khaki1"; } - else if (operation->isReadBufferOperation()) { + else if (operation->get_flags().is_read_buffer_operation) { fillcolor = "darkolivegreen3"; } - else if (operation->isWriteBufferOperation()) { + else if (operation->get_flags().is_write_buffer_operation) { fillcolor = "darkorange"; } @@ -362,7 +362,7 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma } for (NodeOperation *operation : system->m_operations) { - if (operation->isReadBufferOperation()) { + if (operation->get_flags().is_read_buffer_operation) { ReadBufferOperation *read = (ReadBufferOperation *)operation; WriteBufferOperation *write = read->getMemoryProxy()->getWriteBufferOperation(); std::vector<std::string> &read_groups = op_groups[read]; diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index 9f9effd430d..f44f6e952fb 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -57,7 +57,6 @@ ExecutionGroup::ExecutionGroup() this->m_x_chunks_len = 0; this->m_y_chunks_len = 0; this->m_chunks_len = 0; - this->m_initialized = false; this->m_chunks_finished = 0; BLI_rcti_init(&this->m_viewerBorder, 0, 0, 0, 0); this->m_executionStartTime = 0; @@ -70,17 +69,17 @@ CompositorPriority ExecutionGroup::getRenderPriority() bool ExecutionGroup::can_contain(NodeOperation &operation) { - if (!this->m_initialized) { + if (!m_flags.initialized) { return true; } - if (operation.isReadBufferOperation()) { + if (operation.get_flags().is_read_buffer_operation) { return true; } - if (operation.isWriteBufferOperation()) { + if (operation.get_flags().is_write_buffer_operation) { return false; } - if (operation.isSetOperation()) { + if (operation.get_flags().is_set_operation) { return true; } @@ -103,11 +102,12 @@ bool ExecutionGroup::addOperation(NodeOperation *operation) return false; } - if (!operation->isReadBufferOperation() && !operation->isWriteBufferOperation()) { + if (!operation->get_flags().is_read_buffer_operation && + !operation->get_flags().is_write_buffer_operation) { m_flags.complex = operation->get_flags().complex; m_flags.open_cl = operation->get_flags().open_cl; m_flags.single_threaded = operation->isSingleThreaded(); - m_initialized = true; + m_flags.initialized = true; } m_operations.append(operation); @@ -134,7 +134,7 @@ void ExecutionGroup::initExecution() unsigned int max_offset = 0; for (NodeOperation *operation : m_operations) { - if (operation->isReadBufferOperation()) { + if (operation->get_flags().is_read_buffer_operation) { ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation); this->m_read_operations.append(readOperation); max_offset = MAX2(max_offset, readOperation->getOffset()); @@ -453,7 +453,7 @@ MemoryBuffer *ExecutionGroup::allocateOutputBuffer(rcti &rect) { // we assume that this method is only called from complex execution groups. NodeOperation *operation = this->getOutputOperation(); - if (operation->isWriteBufferOperation()) { + if (operation->get_flags().is_write_buffer_operation) { WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation; MemoryBuffer *buffer = new MemoryBuffer( writeOperation->getMemoryProxy(), rect, MemoryBufferState::Temporary); diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h index f97aa0ff985..a995da38dec 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.h +++ b/source/blender/compositor/intern/COM_ExecutionGroup.h @@ -61,6 +61,7 @@ enum class eChunkExecutionState { }; struct ExecutionGroupFlags { + bool initialized : 1; /** * Is this ExecutionGroup an output ExecutionGroup * An OutputExecution group are groups containing a @@ -82,6 +83,7 @@ struct ExecutionGroupFlags { ExecutionGroupFlags() { + initialized = false; is_output = false; complex = false; open_cl = false; @@ -169,18 +171,6 @@ class ExecutionGroup { blender::Vector<eChunkExecutionState> m_chunk_execution_states; /** - * \brief indicator when this ExecutionGroup has valid Operations in its vector for Execution - * \note When building the ExecutionGroup Operations are added via recursion. - * First a WriteBufferOperations is added, then the. - * \note Operation containing the settings that is important for the ExecutiongGroup is added, - * \note When this occurs, these settings are copied over from the node to the ExecutionGroup - * \note and the Initialized flag is set to true. - * \see complex - * \see openCL - */ - bool m_initialized; - - /** * \brief denotes boundary for border compositing * \note measured in pixel space */ diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cc b/source/blender/compositor/intern/COM_ExecutionSystem.cc index b3adca5ac51..9a3dc6ee56f 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cc +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cc @@ -130,7 +130,7 @@ static void update_read_buffer_offset(blender::Vector<NodeOperation *> &operatio { unsigned int order = 0; for (NodeOperation *operation : operations) { - if (operation->isReadBufferOperation()) { + if (operation->get_flags().is_read_buffer_operation) { ReadBufferOperation *readOperation = (ReadBufferOperation *)operation; readOperation->setOffset(order); order++; @@ -142,7 +142,7 @@ static void init_write_operations_for_execution(blender::Vector<NodeOperation *> const bNodeTree *bTree) { for (NodeOperation *operation : operations) { - if (operation->isWriteBufferOperation()) { + if (operation->get_flags().is_write_buffer_operation) { operation->setbNodeTree(bTree); operation->initExecution(); } @@ -152,7 +152,7 @@ static void init_write_operations_for_execution(blender::Vector<NodeOperation *> static void link_write_buffers(blender::Vector<NodeOperation *> &operations) { for (NodeOperation *operation : operations) { - if (operation->isReadBufferOperation()) { + if (operation->get_flags().is_read_buffer_operation) { ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation); readOperation->updateMemoryBuffer(); } @@ -163,7 +163,7 @@ static void init_non_write_operations_for_execution(blender::Vector<NodeOperatio const bNodeTree *bTree) { for (NodeOperation *operation : operations) { - if (!operation->isWriteBufferOperation()) { + if (!operation->get_flags().is_write_buffer_operation) { operation->setbNodeTree(bTree); operation->initExecution(); } diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index 88f9c49dbf0..6ad97e5eba6 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -204,6 +204,13 @@ struct NodeOperationFlags { */ bool is_resolution_set : 1; + /** + * Is this a set operation (value, color, vector). + */ + bool is_set_operation : 1; + bool is_write_buffer_operation : 1; + bool is_read_buffer_operation : 1; + NodeOperationFlags() { complex = false; @@ -211,6 +218,9 @@ struct NodeOperationFlags { use_render_border = false; use_viewer_border = false; is_resolution_set = false; + is_set_operation = false; + is_read_buffer_operation = false; + is_write_buffer_operation = false; } }; @@ -301,11 +311,11 @@ class NodeOperation { unsigned int preferredResolution[2]); /** - * \brief isOutputOperation determines whether this operation is an output of the ExecutionSystem - * during rendering or editing. + * \brief isOutputOperation determines whether this operation is an output of the + * ExecutionSystem during rendering or editing. * - * Default behavior if not overridden, this operation will not be evaluated as being an output of - * the ExecutionSystem. + * Default behavior if not overridden, this operation will not be evaluated as being an output + * of the ExecutionSystem. * * \see ExecutionSystem * \ingroup check @@ -400,31 +410,6 @@ class NodeOperation { } } - virtual bool isSetOperation() const - { - return false; - } - - /** - * \brief is this operation of type ReadBufferOperation - * \return [true:false] - * \see ReadBufferOperation - */ - virtual bool isReadBufferOperation() const - { - return false; - } - - /** - * \brief is this operation of type WriteBufferOperation - * \return [true:false] - * \see WriteBufferOperation - */ - virtual bool isWriteBufferOperation() const - { - return false; - } - /** * \brief is this operation the active viewer output * user can select an ViewerNode to be active @@ -442,8 +427,8 @@ class NodeOperation { rcti *output); /** - * \brief set the index of the input socket that will determine the resolution of this operation - * \param index: the index to set + * \brief set the index of the input socket that will determine the resolution of this + * operation \param index: the index to set */ void setResolutionInputSocketIndex(unsigned int index); diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc index 920622651b1..24b72fa737a 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc @@ -433,7 +433,7 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation for (const Link &link : m_links) { if (link.from() == output) { NodeOperation &op = link.to()->getOperation(); - if (op.isWriteBufferOperation()) { + if (op.get_flags().is_write_buffer_operation) { return (WriteBufferOperation *)(&op); } } @@ -449,7 +449,7 @@ void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/, } NodeOperationOutput *output = input->getLink(); - if (output->getOperation().isReadBufferOperation()) { + if (output->getOperation().get_flags().is_read_buffer_operation) { /* input is already buffered, no need to add another */ return; } @@ -491,7 +491,7 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation, WriteBufferOperation *writeOperation = nullptr; for (NodeOperationInput *target : targets) { /* try to find existing write buffer operation */ - if (target->getOperation().isWriteBufferOperation()) { + if (target->getOperation().get_flags().is_write_buffer_operation) { BLI_assert(writeOperation == nullptr); /* there should only be one write op connected */ writeOperation = (WriteBufferOperation *)(&target->getOperation()); } @@ -571,7 +571,7 @@ static void find_reachable_operations_recursive(Tags &reachable, NodeOperation * } /* associated write-buffer operations are executed as well */ - if (op->isReadBufferOperation()) { + if (op->get_flags().is_read_buffer_operation) { ReadBufferOperation *read_op = (ReadBufferOperation *)op; MemoryProxy *memproxy = read_op->getMemoryProxy(); find_reachable_operations_recursive(reachable, memproxy->getWriteBufferOperation()); @@ -675,7 +675,7 @@ void NodeOperationBuilder::group_operations() } /* add new groups for associated memory proxies where needed */ - if (op->isReadBufferOperation()) { + if (op->get_flags().is_read_buffer_operation) { ReadBufferOperation *read_op = (ReadBufferOperation *)op; MemoryProxy *memproxy = read_op->getMemoryProxy(); |