Commit: 255c7f26af60debde0cf1fc16143d912c885c9f1
Author: Jeroen Bakker
Date:   Fri Dec 9 12:12:55 2022 +0100
Branches: master
https://developer.blender.org/rB255c7f26af60debde0cf1fc16143d912c885c9f1

Cleanup: Use enum class for image drawing flags.

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

M       source/blender/draw/engines/image/image_drawing_mode.hh
A       source/blender/draw/engines/image/image_enums.hh
M       source/blender/draw/engines/image/image_private.hh
M       source/blender/draw/engines/image/image_shader_params.hh
M       source/blender/draw/engines/image/image_space_image.hh
M       source/blender/draw/engines/image/image_space_node.hh

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

diff --git a/source/blender/draw/engines/image/image_drawing_mode.hh 
b/source/blender/draw/engines/image/image_drawing_mode.hh
index 49205e633c9..a7a482053d4 100644
--- a/source/blender/draw/engines/image/image_drawing_mode.hh
+++ b/source/blender/draw/engines/image/image_drawing_mode.hh
@@ -166,7 +166,7 @@ template<typename TextureMethod> class 
ScreenSpaceDrawingMode : public AbstractD
     DRWShadingGroup *shgrp = DRW_shgroup_create(shader, 
instance_data->passes.image_pass);
     DRW_shgroup_uniform_vec2_copy(shgrp, "farNearDistances", 
sh_params.far_near);
     DRW_shgroup_uniform_vec4_copy(shgrp, "shuffle", sh_params.shuffle);
-    DRW_shgroup_uniform_int_copy(shgrp, "drawFlags", sh_params.flags);
+    DRW_shgroup_uniform_int_copy(shgrp, "drawFlags", 
static_cast<int32_t>(sh_params.flags));
     DRW_shgroup_uniform_bool_copy(shgrp, "imgPremultiplied", 
sh_params.use_premul_alpha);
     DRW_shgroup_uniform_texture(shgrp, "depth_texture", dtxl->depth);
     float image_mat[4][4];
diff --git a/source/blender/draw/engines/image/image_enums.hh 
b/source/blender/draw/engines/image/image_enums.hh
new file mode 100644
index 00000000000..3b0eb5cb1c6
--- /dev/null
+++ b/source/blender/draw/engines/image/image_enums.hh
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2021 Blender Foundation. */
+
+/** \file
+ * \ingroup draw_engine
+ */
+
+#pragma once
+
+#include "BLI_utildefines.h"
+
+namespace blender::draw::image_engine {
+
+/* Shader parameters. */
+enum class ImageDrawFlags {
+  Default = 0,
+  ShowAlpha = (1 << 0),
+  ApplyAlpha = (1 << 1),
+  Shuffling = (1 << 2),
+  Depth = (1 << 3)
+};
+ENUM_OPERATORS(ImageDrawFlags, ImageDrawFlags::Depth);
+
+}  // namespace blender::draw::image_engine
diff --git a/source/blender/draw/engines/image/image_private.hh 
b/source/blender/draw/engines/image/image_private.hh
index ec514dfd50d..7fa58f43d06 100644
--- a/source/blender/draw/engines/image/image_private.hh
+++ b/source/blender/draw/engines/image/image_private.hh
@@ -34,11 +34,6 @@ struct IMAGE_Data {
   IMAGE_InstanceData *instance_data;
 };
 
-/* Shader parameters. */
-#define IMAGE_DRAW_FLAG_SHOW_ALPHA (1 << 0)
-#define IMAGE_DRAW_FLAG_APPLY_ALPHA (1 << 1)
-#define IMAGE_DRAW_FLAG_SHUFFLING (1 << 2)
-#define IMAGE_DRAW_FLAG_DEPTH (1 << 3)
 
 /**
  * Abstract class for a drawing mode of the image engine.
diff --git a/source/blender/draw/engines/image/image_shader_params.hh 
b/source/blender/draw/engines/image/image_shader_params.hh
index 41159d85e05..f2515783b45 100644
--- a/source/blender/draw/engines/image/image_shader_params.hh
+++ b/source/blender/draw/engines/image/image_shader_params.hh
@@ -17,19 +17,20 @@
 
 #include "BLI_math.h"
 
+#include "image_enums.hh"
 #include "image_space.hh"
 
 namespace blender::draw::image_engine {
 
 struct ShaderParameters {
-  int flags = 0;
+  ImageDrawFlags flags = ImageDrawFlags::Default;
   float shuffle[4];
   float far_near[2];
   bool use_premul_alpha = false;
 
   void update(AbstractSpaceAccessor *space, const Scene *scene, Image *image, 
ImBuf *image_buffer)
   {
-    flags = 0;
+    flags = ImageDrawFlags::Default;
     copy_v4_fl(shuffle, 1.0f);
     copy_v2_fl2(far_near, 100.0f, 0.0f);
 
diff --git a/source/blender/draw/engines/image/image_space_image.hh 
b/source/blender/draw/engines/image/image_space_image.hh
index c9563d464cc..0356e1213f6 100644
--- a/source/blender/draw/engines/image/image_space_image.hh
+++ b/source/blender/draw/engines/image/image_space_image.hh
@@ -44,40 +44,40 @@ class SpaceImageAccessor : public AbstractSpaceAccessor {
     const int sima_flag = sima->flag & 
ED_space_image_get_display_channel_mask(image_buffer);
     if ((sima_flag & SI_USE_ALPHA) != 0) {
       /* Show RGBA */
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHOW_ALPHA | 
IMAGE_DRAW_FLAG_APPLY_ALPHA;
+      r_shader_parameters.flags |= ImageDrawFlags::ShowAlpha | 
ImageDrawFlags::ApplyAlpha;
     }
     else if ((sima_flag & SI_SHOW_ALPHA) != 0) {
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHUFFLING;
+      r_shader_parameters.flags |= ImageDrawFlags::Shuffling;
       copy_v4_fl4(r_shader_parameters.shuffle, 0.0f, 0.0f, 0.0f, 1.0f);
     }
     else if ((sima_flag & SI_SHOW_ZBUF) != 0) {
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_DEPTH | 
IMAGE_DRAW_FLAG_SHUFFLING;
+      r_shader_parameters.flags |= ImageDrawFlags::Depth | 
ImageDrawFlags::Shuffling;
       copy_v4_fl4(r_shader_parameters.shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
     }
     else if ((sima_flag & SI_SHOW_R) != 0) {
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHUFFLING;
+      r_shader_parameters.flags |= ImageDrawFlags::Shuffling;
       if (IMB_alpha_affects_rgb(image_buffer)) {
-        r_shader_parameters.flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
+        r_shader_parameters.flags |= ImageDrawFlags::ApplyAlpha;
       }
       copy_v4_fl4(r_shader_parameters.shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
     }
     else if ((sima_flag & SI_SHOW_G) != 0) {
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHUFFLING;
+      r_shader_parameters.flags |= ImageDrawFlags::Shuffling;
       if (IMB_alpha_affects_rgb(image_buffer)) {
-        r_shader_parameters.flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
+        r_shader_parameters.flags |= ImageDrawFlags::ApplyAlpha;
       }
       copy_v4_fl4(r_shader_parameters.shuffle, 0.0f, 1.0f, 0.0f, 0.0f);
     }
     else if ((sima_flag & SI_SHOW_B) != 0) {
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHUFFLING;
+      r_shader_parameters.flags |= ImageDrawFlags::Shuffling;
       if (IMB_alpha_affects_rgb(image_buffer)) {
-        r_shader_parameters.flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
+        r_shader_parameters.flags |= ImageDrawFlags::ApplyAlpha;
       }
       copy_v4_fl4(r_shader_parameters.shuffle, 0.0f, 0.0f, 1.0f, 0.0f);
     }
     else /* RGB */ {
       if (IMB_alpha_affects_rgb(image_buffer)) {
-        r_shader_parameters.flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
+        r_shader_parameters.flags |= ImageDrawFlags::ApplyAlpha;
       }
     }
   }
diff --git a/source/blender/draw/engines/image/image_space_node.hh 
b/source/blender/draw/engines/image/image_space_node.hh
index d4d56527267..c4adb9eb91e 100644
--- a/source/blender/draw/engines/image/image_space_node.hh
+++ b/source/blender/draw/engines/image/image_space_node.hh
@@ -43,36 +43,36 @@ class SpaceNodeAccessor : public AbstractSpaceAccessor {
   {
     if ((snode->flag & SNODE_USE_ALPHA) != 0) {
       /* Show RGBA */
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHOW_ALPHA | 
IMAGE_DRAW_FLAG_APPLY_ALPHA;
+      r_shader_parameters.flags |= ImageDrawFlags::ShowAlpha | 
ImageDrawFlags::ApplyAlpha;
     }
     else if ((snode->flag & SNODE_SHOW_ALPHA) != 0) {
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHUFFLING;
+      r_shader_parameters.flags |= ImageDrawFlags::Shuffling;
       copy_v4_fl4(r_shader_parameters.shuffle, 0.0f, 0.0f, 0.0f, 1.0f);
     }
     else if ((snode->flag & SNODE_SHOW_R) != 0) {
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHUFFLING;
+      r_shader_parameters.flags |= ImageDrawFlags::Shuffling;
       if (IMB_alpha_affects_rgb(ibuf)) {
-        r_shader_parameters.flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
+        r_shader_parameters.flags |= ImageDrawFlags::ApplyAlpha;
       }
       copy_v4_fl4(r_shader_parameters.shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
     }
     else if ((snode->flag & SNODE_SHOW_G) != 0) {
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHUFFLING;
+      r_shader_parameters.flags |= ImageDrawFlags::Shuffling;
       if (IMB_alpha_affects_rgb(ibuf)) {
-        r_shader_parameters.flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
+        r_shader_parameters.flags |= ImageDrawFlags::ApplyAlpha;
       }
       copy_v4_fl4(r_shader_parameters.shuffle, 0.0f, 1.0f, 0.0f, 0.0f);
     }
     else if ((snode->flag & SNODE_SHOW_B) != 0) {
-      r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHUFFLING;
+      r_shader_parameters.flags |= ImageDrawFlags::Shuffling;
       if (IMB_alpha_affects_rgb(ibuf)) {
-        r_shader_parameters.flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
+        r_shader_parameters.flags |= ImageDrawFlags::ApplyAlpha;
       }
       copy_v4_fl4(r_shader_parameters.shuffle, 0.0f, 0.0f, 1.0f, 0.0f);
     }
     else /* RGB */ {
       if (IMB_alpha_affects_rgb(ibuf)) {
-        r_shader_parameters.flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA;
+        r_shader_parameters.flags |= ImageDrawFlags::ApplyAlpha;
       }
     }
   }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to