[Bf-blender-cvs] [2db2b7de558] master: Cleanup: Replace `is...Operation()` methods with a flag.

Jeroen Bakker noreply at git.blender.org
Mon Mar 29 17:14:24 CEST 2021


Commit: 2db2b7de55836725266e67a7f2f342b032c4fa3a
Author: Jeroen Bakker
Date:   Mon Mar 29 16:54:02 2021 +0200
Branches: master
https://developer.blender.org/rB2db2b7de55836725266e67a7f2f342b032c4fa3a

Cleanup: Replace `is...Operation()` methods with a flag.

===================================================================

M	source/blender/compositor/intern/COM_Debug.cc
M	source/blender/compositor/intern/COM_ExecutionGroup.cc
M	source/blender/compositor/intern/COM_ExecutionGroup.h
M	source/blender/compositor/intern/COM_ExecutionSystem.cc
M	source/blender/compositor/intern/COM_NodeOperation.h
M	source/blender/compositor/intern/COM_NodeOperationBuilder.cc
M	source/blender/compositor/operations/COM_ReadBufferOperation.cc
M	source/blender/compositor/operations/COM_ReadBufferOperation.h
M	source/blender/compositor/operations/COM_SetColorOperation.cc
M	source/blender/compositor/operations/COM_SetColorOperation.h
M	source/blender/compositor/operations/COM_SetValueOperation.cc
M	source/blender/compositor/operations/COM_SetValueOperation.h
M	source/blender/compositor/operations/COM_SetVectorOperation.cc
M	source/blender/compositor/operations/COM_SetVectorOperation.h
M	source/blender/compositor/operations/COM_TrackPositionOperation.cc
M	source/blender/compositor/operations/COM_TrackPositionOperation.h
M	source/blender/compositor/operations/COM_WriteBufferOperation.cc
M	source/blender/compositor/operations/COM_WriteBufferOperation.h

===================================================================

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;
@@ -168,18 +170,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
    *

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list