[Bf-blender-cvs] [e5fb7eac85f] master: Cleanup: Use Enum Class For PixelSampler.

Jeroen Bakker noreply at git.blender.org
Fri Mar 26 16:03:40 CET 2021


Commit: e5fb7eac85f60a301f7bf742b12bb04a795d0f31
Author: Jeroen Bakker
Date:   Fri Mar 26 12:39:54 2021 +0100
Branches: master
https://developer.blender.org/rBe5fb7eac85f60a301f7bf742b12bb04a795d0f31

Cleanup: Use Enum Class For PixelSampler.

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

M	source/blender/compositor/intern/COM_SocketReader.h
M	source/blender/compositor/operations/COM_BlurBaseOperation.cc
M	source/blender/compositor/operations/COM_BokehBlurOperation.cc
M	source/blender/compositor/operations/COM_CompositorOperation.cc
M	source/blender/compositor/operations/COM_DirectionalBlurOperation.cc
M	source/blender/compositor/operations/COM_DisplaceOperation.cc
M	source/blender/compositor/operations/COM_ImageOperation.cc
M	source/blender/compositor/operations/COM_MapUVOperation.cc
M	source/blender/compositor/operations/COM_MovieClipOperation.cc
M	source/blender/compositor/operations/COM_MovieDistortionOperation.cc
M	source/blender/compositor/operations/COM_MultilayerImageOperation.cc
M	source/blender/compositor/operations/COM_OutputFileOperation.cc
M	source/blender/compositor/operations/COM_PlaneCornerPinOperation.cc
M	source/blender/compositor/operations/COM_PreviewOperation.cc
M	source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cc
M	source/blender/compositor/operations/COM_ReadBufferOperation.cc
M	source/blender/compositor/operations/COM_RenderLayersProg.cc
M	source/blender/compositor/operations/COM_RotateOperation.cc
M	source/blender/compositor/operations/COM_ScaleOperation.cc
M	source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc
M	source/blender/compositor/operations/COM_SplitOperation.cc
M	source/blender/compositor/operations/COM_TranslateOperation.cc
M	source/blender/compositor/operations/COM_TranslateOperation.h
M	source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.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_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
index 7c4132efe60..4074f5e759f 100644
--- a/source/blender/compositor/intern/COM_SocketReader.h
+++ b/source/blender/compositor/intern/COM_SocketReader.h
@@ -29,11 +29,11 @@
 #  include "MEM_guardedalloc.h"
 #endif
 
-typedef enum PixelSampler {
-  COM_PS_NEAREST = 0,
-  COM_PS_BILINEAR = 1,
-  COM_PS_BICUBIC = 2,
-} PixelSampler;
+enum class PixelSampler {
+  Nearest = 0,
+  Bilinear = 1,
+  Bicubic = 2,
+};
 
 class MemoryBuffer;
 
@@ -81,7 +81,7 @@ class SocketReader {
    */
   virtual void executePixel(float output[4], int x, int y, void * /*chunkData*/)
   {
-    executePixelSampled(output, x, y, COM_PS_NEAREST);
+    executePixelSampled(output, x, y, PixelSampler::Nearest);
   }
 
   /**
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cc b/source/blender/compositor/operations/COM_BlurBaseOperation.cc
index fe6ca1cfd4e..b5c60b638d8 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cc
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cc
@@ -167,7 +167,7 @@ void BlurBaseOperation::updateSize()
 {
   if (!this->m_sizeavailable) {
     float result[4];
-    this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
+    this->getInputSocketReader(1)->readSampled(result, 0, 0, PixelSampler::Nearest);
     this->m_size = result[0];
     this->m_sizeavailable = true;
   }
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cc b/source/blender/compositor/operations/COM_BokehBlurOperation.cc
index 7bb8cd49bfc..8041cb2c6cf 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.cc
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cc
@@ -76,7 +76,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
   float tempBoundingBox[4];
   float bokeh[4];
 
-  this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, COM_PS_NEAREST);
+  this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, PixelSampler::Nearest);
   if (tempBoundingBox[0] > 0.0f) {
     float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
     MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
@@ -90,7 +90,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
     zero_v4(color_accum);
 
     if (pixelSize < 2) {
-      this->m_inputProgram->readSampled(color_accum, x, y, COM_PS_NEAREST);
+      this->m_inputProgram->readSampled(color_accum, x, y, PixelSampler::Nearest);
       multiplier_accum[0] = 1.0f;
       multiplier_accum[1] = 1.0f;
       multiplier_accum[2] = 1.0f;
@@ -115,7 +115,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
       for (int nx = minx; nx < maxx; nx += step) {
         float u = this->m_bokehMidX - (nx - x) * m;
         float v = this->m_bokehMidY - (ny - y) * m;
-        this->m_inputBokehProgram->readSampled(bokeh, u, v, COM_PS_NEAREST);
+        this->m_inputBokehProgram->readSampled(bokeh, u, v, PixelSampler::Nearest);
         madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]);
         add_v4_v4(multiplier_accum, bokeh);
         bufferindex += offsetadd;
@@ -127,7 +127,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
     output[3] = color_accum[3] * (1.0f / multiplier_accum[3]);
   }
   else {
-    this->m_inputProgram->readSampled(output, x, y, COM_PS_NEAREST);
+    this->m_inputProgram->readSampled(output, x, y, PixelSampler::Nearest);
   }
 }
 
@@ -224,7 +224,7 @@ void BokehBlurOperation::updateSize()
 {
   if (!this->m_sizeavailable) {
     float result[4];
-    this->getInputSocketReader(3)->readSampled(result, 0, 0, COM_PS_NEAREST);
+    this->getInputSocketReader(3)->readSampled(result, 0, 0, PixelSampler::Nearest);
     this->m_size = result[0];
     CLAMP(this->m_size, 0.0f, 10.0f);
     this->m_sizeavailable = true;
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cc b/source/blender/compositor/operations/COM_CompositorOperation.cc
index 0454bae8b38..e011d81443f 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cc
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cc
@@ -196,14 +196,14 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
     for (x = x1; x < x2 && (!breaked); x++) {
       int input_x = x + dx, input_y = y + dy;
 
-      this->m_imageInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
+      this->m_imageInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
       if (this->m_useAlphaInput) {
-        this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST);
+        this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, PixelSampler::Nearest);
       }
 
       copy_v4_v4(buffer + offset4, color);
 
-      this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
+      this->m_depthInput->readSampled(color, input_x, input_y, PixelSampler::Nearest);
       zbuffer[offset] = color[0];
       offset4 += COM_NUM_CHANNELS_COLOR;
       offset++;
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc
index 1a2701a681d..59f06a96141 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cc
@@ -66,7 +66,7 @@ void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void
   const int iterations = pow(2.0f, this->m_data->iter);
   float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
   float col2[4] = {0.0f, 0.0f, 0.0f, 0.0f};
-  this->m_inputProgram->readSampled(col2, x, y, COM_PS_BILINEAR);
+  this->m_inputProgram->readSampled(col2, x, y, PixelSampler::Bilinear);
   float ltx = this->m_tx;
   float lty = this->m_ty;
   float lsc = this->m_sc;
@@ -82,7 +82,7 @@ void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void
     this->m_inputProgram->readSampled(col,
                                       cs * u + ss * v + this->m_center_x_pix,
                                       cs * v - ss * u + this->m_center_y_pix,
-                                      COM_PS_BILINEAR);
+                                      PixelSampler::Bilinear);
 
     add_v4_v4(col2, col);
 
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cc b/source/blender/compositor/operations/COM_DisplaceOperation.cc
index 12c7d29a210..89ad169785d 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.cc
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.cc
@@ -56,7 +56,7 @@ void DisplaceOperation::executePixelSampled(float output[4],
 
   pixelTransform(xy, uv, deriv);
   if (is_zero_v2(deriv[0]) && is_zero_v2(deriv[1])) {
-    this->m_inputColorProgram->readSampled(output, uv[0], uv[1], COM_PS_BILINEAR);
+    this->m_inputColorProgram->readSampled(output, uv[0], uv[1], PixelSampler::Bilinear);
   }
   else {
     /* EWA filtering (without nearest it gets blurry with NO distortion) */
@@ -76,7 +76,7 @@ bool DisplaceOperation::read_displacement(
   }
 
   float col[4];
-  m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR);
+  m_inputVectorProgram->readSampled(col, x, y, PixelSampler::Bilinear);
   r_u = origin[0] - col[0] * xscale;
   r_v = origin[1] - col[1] * yscale;
   return true;
@@ -88,9 +88,9 @@ void DisplaceOperation::pixelTransform(const float xy[2], float r_uv[2], float r
   float uv[2]; /* temporary variables for derivative estimation */
   int num;
 
-  m_inputScaleXProgram->readSampled(col, xy[0], xy[1], COM_PS_NEAREST);
+  m_inputScaleXProgram->readSampled(col, xy[0], xy[1], PixelSampler::Nearest);
   float xs = col[0];
-  m_inputScaleYProgram->readSampled(col, xy[0], xy[1], COM_PS_NEAREST);
+  m_inputScaleYProgram->readSampled(col, xy[0], xy[1], PixelSampler::Nearest);
   float ys = col[0];
   /* clamp x and y displacement to triple image resolution -
    * to prevent hangs from huge values mistakenly plugged in eg. z buffers */
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cc b/source/blender/compositor/operations/COM_ImageOperation.cc
index 06e8db7b467..6245f97fdb4 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cc
+++ b/source/blender/compositor/operations/COM_ImageOperation.cc
@@ -123,13 +123,13 @@ static void sampleImageAtLocation(
 {
   if (ibuf->rect_float) {
     switch (sampler) {
-      case COM_PS_NEAREST:
+      case PixelSampler::Nearest:
         nearest_interpolation_color(ibuf, nullptr, color, x, y);
         break;
-      case COM_PS_BILINEAR:
+      case PixelSampler::Bilinear:
         bilinear_interpolation_color(ibuf, nullptr, color, x, y);
         break;
-      case COM_PS_BICUBIC:
+      case PixelSampler::Bicubic:
         bicubic_interpolation_color(ibuf, nullptr, color, x, y);
         break;
     }
@@ -137,13 +137,13 @@ static void sampleImageAtLocation(
   else {
     unsigned char byte_color[4];
     switch (sampler) {
-      case COM_PS_NEAREST:
+      case PixelSampler::Nearest:
         nearest_interpolation_color(ibuf, byte_color, nullptr, x, y);
         break;
-      case COM_PS_BILINEAR:
+      case PixelSampler::Bilinear:
         bilinear_interpolation_color(ibuf, byte_color, nullptr, x, y);
         break;
-      case COM_PS_BICUBIC:
+      case PixelSampler::Bicubic:
         bicubic_interpolation_color(ibuf, byte_color, nullptr, x, y);
         break;
     }
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cc b/source/blender/compositor/operations/COM_MapUVOperation.cc
index 7328de7f49f..dd0fbf89e3a 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.cc
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cc
@@ -89,7 +89,7 @@ bool MapUVOperation::read_uv(float x, float y, float &r_u, float &r_v, float &r_
   }
 
   float vector[3];
-  m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR);
+  m_inputUVProgram->readSampled(vector, x, y, PixelSampler::Bilinear);
   r_u = vect

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list