[Bf-blender-cvs] [fe60062a991] master: Cleanup: Use Bitflags For Booleans.

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


Commit: fe60062a9910161d411da6e14690755d814c4cb1
Author: Jeroen Bakker
Date:   Mon Mar 29 16:45:49 2021 +0200
Branches: master
https://developer.blender.org/rBfe60062a9910161d411da6e14690755d814c4cb1

Cleanup: Use Bitflags For Booleans.

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

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.cc
M	source/blender/compositor/intern/COM_NodeOperation.h
M	source/blender/compositor/intern/COM_NodeOperationBuilder.cc
M	source/blender/compositor/intern/COM_SingleThreadedOperation.cc
M	source/blender/compositor/intern/COM_WorkScheduler.cc
M	source/blender/compositor/intern/COM_WorkScheduler.h
M	source/blender/compositor/operations/COM_AntiAliasOperation.cc
M	source/blender/compositor/operations/COM_BilateralBlurOperation.cc
M	source/blender/compositor/operations/COM_BlurBaseOperation.cc
M	source/blender/compositor/operations/COM_BokehBlurOperation.cc
M	source/blender/compositor/operations/COM_CalculateMeanOperation.cc
M	source/blender/compositor/operations/COM_CompositorOperation.cc
M	source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc
M	source/blender/compositor/operations/COM_CryptomatteOperation.cc
M	source/blender/compositor/operations/COM_DespeckleOperation.cc
M	source/blender/compositor/operations/COM_DilateErodeOperation.cc
M	source/blender/compositor/operations/COM_DirectionalBlurOperation.cc
M	source/blender/compositor/operations/COM_DisplaceOperation.cc
M	source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc
M	source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
M	source/blender/compositor/operations/COM_GaussianXBlurOperation.h
M	source/blender/compositor/operations/COM_GaussianYBlurOperation.h
M	source/blender/compositor/operations/COM_IDMaskOperation.cc
M	source/blender/compositor/operations/COM_InpaintOperation.cc
M	source/blender/compositor/operations/COM_KeyingBlurOperation.cc
M	source/blender/compositor/operations/COM_KeyingClipOperation.cc
M	source/blender/compositor/operations/COM_KeyingScreenOperation.cc
M	source/blender/compositor/operations/COM_MapUVOperation.cc
M	source/blender/compositor/operations/COM_NormalizeOperation.cc
M	source/blender/compositor/operations/COM_OutputFileOperation.h
M	source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc
M	source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cc
M	source/blender/compositor/operations/COM_PreviewOperation.cc
M	source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc
M	source/blender/compositor/operations/COM_SMAAOperation.cc
M	source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc
M	source/blender/compositor/operations/COM_SunBeamsOperation.cc
M	source/blender/compositor/operations/COM_TextureOperation.cc
M	source/blender/compositor/operations/COM_TonemapOperation.cc
M	source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc
M	source/blender/compositor/operations/COM_VectorBlurOperation.cc
M	source/blender/compositor/operations/COM_ViewerOperation.cc
M	source/blender/compositor/operations/COM_WriteBufferOperation.cc

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

diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc
index 071b1d41941..9f9effd430d 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cc
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc
@@ -50,8 +50,6 @@ namespace blender::compositor {
 
 ExecutionGroup::ExecutionGroup()
 {
-  this->m_is_output = false;
-  this->m_complex = false;
   this->m_bTree = nullptr;
   this->m_height = 0;
   this->m_width = 0;
@@ -60,8 +58,6 @@ ExecutionGroup::ExecutionGroup()
   this->m_y_chunks_len = 0;
   this->m_chunks_len = 0;
   this->m_initialized = false;
-  this->m_openCL = false;
-  this->m_singleThreaded = false;
   this->m_chunks_finished = 0;
   BLI_rcti_init(&this->m_viewerBorder, 0, 0, 0, 0);
   this->m_executionStartTime = 0;
@@ -89,12 +85,12 @@ bool ExecutionGroup::can_contain(NodeOperation &operation)
   }
 
   /* complex groups don't allow further ops (except read buffer and values, see above) */
-  if (m_complex) {
+  if (m_flags.complex) {
     return false;
   }
   /* complex ops can't be added to other groups (except their own, which they initialize, see
    * above) */
-  if (operation.isComplex()) {
+  if (operation.get_flags().complex) {
     return false;
   }
 
@@ -108,9 +104,9 @@ bool ExecutionGroup::addOperation(NodeOperation *operation)
   }
 
   if (!operation->isReadBufferOperation() && !operation->isWriteBufferOperation()) {
-    m_complex = operation->isComplex();
-    m_openCL = operation->isOpenCL();
-    m_singleThreaded = operation->isSingleThreaded();
+    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;
   }
 
@@ -168,7 +164,7 @@ void ExecutionGroup::determineResolution(unsigned int resolution[2])
 
 void ExecutionGroup::determineNumberOfChunks()
 {
-  if (this->m_singleThreaded) {
+  if (this->m_flags.single_threaded) {
     this->m_x_chunks_len = 1;
     this->m_y_chunks_len = 1;
     this->m_chunks_len = 1;
@@ -429,7 +425,7 @@ inline void ExecutionGroup::determineChunkRect(rcti *rect,
   const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
   const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
 
-  if (this->m_singleThreaded) {
+  if (this->m_flags.single_threaded) {
     BLI_rcti_init(
         rect, this->m_viewerBorder.xmin, border_width, this->m_viewerBorder.ymin, border_height);
   }
@@ -468,7 +464,7 @@ MemoryBuffer *ExecutionGroup::allocateOutputBuffer(rcti &rect)
 
 bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area)
 {
-  if (this->m_singleThreaded) {
+  if (this->m_flags.single_threaded) {
     return scheduleChunkWhenPossible(graph, 0, 0);
   }
   // find all chunks inside the rect
@@ -560,16 +556,10 @@ void ExecutionGroup::determineDependingAreaOfInterest(rcti *input,
   this->getOutputOperation()->determineDependingAreaOfInterest(input, readOperation, output);
 }
 
-bool ExecutionGroup::isOpenCL()
-{
-  return this->m_openCL;
-}
-
 void ExecutionGroup::setViewerBorder(float xmin, float xmax, float ymin, float ymax)
 {
-  NodeOperation *operation = this->getOutputOperation();
-
-  if (operation->isViewerOperation() || operation->isPreviewOperation()) {
+  const NodeOperation &operation = *this->getOutputOperation();
+  if (operation.get_flags().use_viewer_border) {
     BLI_rcti_init(&this->m_viewerBorder,
                   xmin * this->m_width,
                   xmax * this->m_width,
@@ -580,33 +570,13 @@ void ExecutionGroup::setViewerBorder(float xmin, float xmax, float ymin, float y
 
 void ExecutionGroup::setRenderBorder(float xmin, float xmax, float ymin, float ymax)
 {
-  NodeOperation *operation = this->getOutputOperation();
-
-  if (operation->isOutputOperation(true)) {
-    /* Basically, setting border need to happen for only operations
-     * which operates in render resolution buffers (like compositor
-     * output nodes).
-     *
-     * In this cases adding border will lead to mapping coordinates
-     * from output buffer space to input buffer spaces when executing
-     * operation.
-     *
-     * But nodes like viewer and file output just shall display or
-     * safe the same exact buffer which goes to their input, no need
-     * in any kind of coordinates mapping.
-     */
-
-    bool operationNeedsBorder = !(operation->isViewerOperation() ||
-                                  operation->isPreviewOperation() ||
-                                  operation->isFileOutputOperation());
-
-    if (operationNeedsBorder) {
-      BLI_rcti_init(&this->m_viewerBorder,
-                    xmin * this->m_width,
-                    xmax * this->m_width,
-                    ymin * this->m_height,
-                    ymax * this->m_height);
-    }
+  const NodeOperation &operation = *this->getOutputOperation();
+  if (operation.isOutputOperation(true) && operation.get_flags().use_render_border) {
+    BLI_rcti_init(&this->m_viewerBorder,
+                  xmin * this->m_width,
+                  xmax * this->m_width,
+                  ymin * this->m_height,
+                  ymax * this->m_height);
   }
 }
 
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index f8bc5f43e31..f97aa0ff985 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -60,6 +60,35 @@ enum class eChunkExecutionState {
   EXECUTED = 2,
 };
 
+struct ExecutionGroupFlags {
+  /**
+   * Is this ExecutionGroup an output ExecutionGroup
+   * An OutputExecution group are groups containing a
+   * ViewerOperation, CompositeOperation, PreviewOperation.
+   */
+  bool is_output : 1;
+  bool complex : 1;
+
+  /**
+   * Can this ExecutionGroup be scheduled on an OpenCLDevice.
+   */
+  bool open_cl : 1;
+
+  /**
+   * Schedule this execution group as a single chunk. This
+   * chunk will be executed by a single thread.
+   */
+  bool single_threaded : 1;
+
+  ExecutionGroupFlags()
+  {
+    is_output = false;
+    complex = false;
+    open_cl = false;
+    single_threaded = false;
+  }
+};
+
 /**
  * \brief Class ExecutionGroup is a group of Operations that are executed as one.
  * This grouping is used to combine Operations that can be executed as one whole when
@@ -75,12 +104,7 @@ class ExecutionGroup {
    */
   blender::Vector<NodeOperation *> m_operations;
 
-  /**
-   * \brief is this ExecutionGroup an input ExecutionGroup
-   * an input execution group is a group that is at the end of the calculation
-   * (the output is important for the user).
-   */
-  bool m_is_output;
+  ExecutionGroupFlags m_flags;
 
   /**
    * \brief Width of the output
@@ -113,21 +137,6 @@ class ExecutionGroup {
    */
   unsigned int m_chunks_len;
 
-  /**
-   * \brief contains this ExecutionGroup a complex NodeOperation.
-   */
-  bool m_complex;
-
-  /**
-   * \brief can this ExecutionGroup be scheduled on an OpenCLDevice
-   */
-  bool m_openCL;
-
-  /**
-   * \brief Is this Execution group SingleThreaded
-   */
-  bool m_singleThreaded;
-
   /**
    * \brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup.
    * \note this is used to construct the MemoryBuffers that will be passed during execution.
@@ -261,6 +270,11 @@ class ExecutionGroup {
   // constructors
   ExecutionGroup();
 
+  const ExecutionGroupFlags get_flags() const
+  {
+    return m_flags;
+  }
+
   // methods
   /**
    * \brief add an operation to this ExecutionGroup
@@ -272,24 +286,13 @@ class ExecutionGroup {
    */
   bool addOperation(NodeOperation *operation);
 
-  /**
-   * \brief is this ExecutionGroup an output ExecutionGroup
-   * \note An OutputExecution group are groups containing a
-   * \note ViewerOperation, CompositeOperation, PreviewOperation.
-   * \see NodeOperation.isOutputOperation
-   */
-  bool isOutputExecutionGroup() const
-  {
-    return this->m_is_output;
-  }
-
   /**
    * \brief set whether this ExecutionGroup is an output
    * \param isOutput:
    */
   void setOutputExecutionGroup(bool is_output)
   {
-    this->m_is_output = is_output;
+    this->m_flags.is_output = is_output;
   }
 
   /**
@@ -324,14 +327,6 @@ class ExecutionGroup {
     return m_height;
   }
 
-  /**
-   * \brief does this ExecutionGroup contains a complex NodeOperation
-   */
-  bool isComplex() const
-  {
-    return m_complex;
-  }
-
   /**
    * \brief get the output operation of this ExecutionGroup
    * \return NodeOperation *output operation
@@ -412,12 +407,6 @@ class ExecutionGroup {
    */
   void determineChunkRect(rcti *rect, const unsigned int chunkNumber) const;
 
-  /**
-   * \brief can this ExecutionGroup be scheduled on an OpenCLDevice
-   * \see WorkScheduler.schedule
-   */
-  bool isOpenCL();
-
   void setChunksize(int chunksize)
   {
     this->m_chunkSize = chunksize;
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cc b/source/blender/compositor/intern/COM_ExecutionSystem.cc
index c8e3b11160b..b3adca5ac51 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cc
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cc
@@ -215,7 +215,7 @@ void ExecutionSystem::execute()
 void ExecutionSystem::execute_groups(CompositorPriority priority)
 {
   for (ExecutionGroup *execution_group : m_groups) {
-    if (execution_group->isOutputExecutionGroup() &&
+    if (execution_group->get_flags().is_output &&
         execution_group->getRenderPriority() == priority) {
       execution_group->execute(this);
     }
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cc b/source/blender/compositor/intern/COM_NodeOperation.cc
index a16e2d359f1..cb2134ae5f1 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cc
+++ b/source/blender/compositor/intern/COM_NodeOperation.cc
@@ -33,11 +33,8 @@ namespace blender::compositor {
 NodeOperation::NodeOperation()
 {
   this->m_resolutionInputSocketIndex = 0;
-  this->m_complex = false;
   this->m_width = 0;
   this->m_height = 0;
-  this->m_isResolutionSet = false;
-  this->m_openCL = false;
   this->m_btree =

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list