[Bf-blender-cvs] [b4a325f535e] master: Cleanup: use unsigned char for theme colors

Campbell Barton noreply at git.blender.org
Mon Aug 5 20:35:42 CEST 2019


Commit: b4a325f535e56e37f1a22c12f189b39552fd6ba7
Author: Campbell Barton
Date:   Tue Aug 6 04:20:17 2019 +1000
Branches: master
https://developer.blender.org/rBb4a325f535e56e37f1a22c12f189b39552fd6ba7

Cleanup: use unsigned char for theme colors

Nearly all byte-color functions use 'uchar'
causing casts when then colors were passed in.

Declare as uchar to remove the need for casts.

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

M	source/blender/blenkernel/intern/action.c
M	source/blender/blenlib/BLI_math_color.h
M	source/blender/blenlib/intern/math_color_inline.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/draw/intern/draw_armature.c
M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/include/UI_interface_icons.h
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_region_tooltip.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/interface/resources.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/windowmanager/intern/wm_dragdrop.c

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

diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 984de700ce7..57a7379eeae 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -236,9 +236,9 @@ void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp)
        */
       else if (grp->cs.solid[0] == 0) {
         /* define for setting colors in theme below */
-        rgba_char_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255);
-        rgba_char_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255);
-        rgba_char_args_set(grp->cs.active, 0x18, 0xb6, 0xe0, 255);
+        rgba_uchar_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255);
+        rgba_uchar_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255);
+        rgba_uchar_args_set(grp->cs.active, 0x18, 0xb6, 0xe0, 255);
       }
     }
   }
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 03eb2b890cf..3bc3be8b022 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -140,12 +140,18 @@ MINLINE void float_to_byte_dither_v3(
 #define rgba_float_args_set_ch(col, r, g, b, a) \
   rgba_float_args_set(col, (r) / 255.0f, (g) / 255.0f, (b) / 255.0f, (a) / 255.0f)
 
-MINLINE void rgba_char_args_set(
-    char col[4], const char r, const char g, const char b, const char a);
+MINLINE void rgba_uchar_args_set(unsigned char col[4],
+                                 const unsigned char r,
+                                 const unsigned char g,
+                                 const unsigned char b,
+                                 const unsigned char a);
 MINLINE void rgba_float_args_set(
     float col[4], const float r, const float g, const float b, const float a);
-MINLINE void rgba_char_args_test_set(
-    char col[4], const char r, const char g, const char b, const char a);
+MINLINE void rgba_uchar_args_test_set(unsigned char col[4],
+                                      const unsigned char r,
+                                      const unsigned char g,
+                                      const unsigned char b,
+                                      const unsigned char a);
 MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack);
 
 void blackbody_temperature_to_rgb_table(float *r_table, int width, float min, float max);
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index d7a2d681f33..f5aaddc0ea3 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -225,8 +225,8 @@ MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned
   srgb_to_linearrgb_predivide_v4(linear, fsrgb);
 }
 
-MINLINE void rgba_char_args_set(
-    char col[4], const char r, const char g, const char b, const char a)
+MINLINE void rgba_uchar_args_set(
+    uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a)
 {
   col[0] = r;
   col[1] = g;
@@ -243,8 +243,8 @@ MINLINE void rgba_float_args_set(
   col[3] = a;
 }
 
-MINLINE void rgba_char_args_test_set(
-    char col[4], const char r, const char g, const char b, const char a)
+MINLINE void rgba_uchar_args_test_set(
+    uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a)
 {
   if (col[3] == 0) {
     col[0] = r;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 44bb07d87f8..516cead37c1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9395,8 +9395,8 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd)
     /* Themes for Node and Sequence editor were not using grid color,
      * but back. we copy this over then. */
     for (btheme = user->themes.first; btheme; btheme = btheme->next) {
-      copy_v4_v4_char(btheme->space_node.grid, btheme->space_node.back);
-      copy_v4_v4_char(btheme->space_sequencer.grid, btheme->space_sequencer.back);
+      copy_v4_v4_uchar(btheme->space_node.grid, btheme->space_node.back);
+      copy_v4_v4_uchar(btheme->space_sequencer.grid, btheme->space_sequencer.back);
     }
   }
 
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index e42a9bc9f95..e987a623d0b 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -51,12 +51,12 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
     memcpy(btheme, &U_theme_default, sizeof(*btheme));
   }
 
-#define FROM_DEFAULT_V4_UCHAR(member) copy_v4_v4_char(btheme->member, U_theme_default.member)
+#define FROM_DEFAULT_V4_UCHAR(member) copy_v4_v4_uchar(btheme->member, U_theme_default.member)
 
   if (!USER_VERSION_ATLEAST(280, 25)) {
-    copy_v4_v4_char(btheme->space_action.anim_preview_range, btheme->space_action.anim_active);
-    copy_v4_v4_char(btheme->space_nla.anim_preview_range, btheme->space_nla.anim_active);
-    copy_v4_v4_char(btheme->space_graph.anim_preview_range, btheme->space_action.anim_active);
+    copy_v4_v4_uchar(btheme->space_action.anim_preview_range, btheme->space_action.anim_active);
+    copy_v4_v4_uchar(btheme->space_nla.anim_preview_range, btheme->space_nla.anim_active);
+    copy_v4_v4_uchar(btheme->space_graph.anim_preview_range, btheme->space_action.anim_active);
   }
 
   if (!USER_VERSION_ATLEAST(280, 26)) {
@@ -102,8 +102,8 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
 
   if (!USER_VERSION_ATLEAST(280, 40)) {
     FROM_DEFAULT_V4_UCHAR(space_preferences.navigation_bar);
-    copy_v4_v4_char(btheme->space_preferences.execution_buts,
-                    btheme->space_preferences.navigation_bar);
+    copy_v4_v4_uchar(btheme->space_preferences.execution_buts,
+                     btheme->space_preferences.navigation_bar);
   }
 
   if (!USER_VERSION_ATLEAST(280, 41)) {
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 30e51333f0f..865cfea14e3 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -694,17 +694,17 @@ static bool set_pchan_color(short colCode,
         uchar cp[4] = {255};
 
         if (boneflag & BONE_DRAW_ACTIVE) {
-          copy_v3_v3_char((char *)cp, bcolor->active);
+          copy_v3_v3_uchar(cp, bcolor->active);
           if (!(boneflag & BONE_SELECTED)) {
             cp_shade_color3ub(cp, -80);
           }
         }
         else if (boneflag & BONE_SELECTED) {
-          copy_v3_v3_char((char *)cp, bcolor->select);
+          copy_v3_v3_uchar(cp, bcolor->select);
         }
         else {
           /* a bit darker than solid */
-          copy_v3_v3_char((char *)cp, bcolor->solid);
+          copy_v3_v3_uchar(cp, bcolor->solid);
           cp_shade_color3ub(cp, -50);
         }
 
@@ -742,16 +742,16 @@ static bool set_pchan_color(short colCode,
       if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) {
         uchar cp[4];
         if (constflag & PCHAN_HAS_TARGET) {
-          rgba_char_args_set((char *)cp, 255, 150, 0, 80);
+          rgba_uchar_args_set(cp, 255, 150, 0, 80);
         }
         else if (constflag & PCHAN_HAS_IK) {
-          rgba_char_args_set((char *)cp, 255, 255, 0, 80);
+          rgba_uchar_args_set(cp, 255, 255, 0, 80);
         }
         else if (constflag & PCHAN_HAS_SPLINEIK) {
-          rgba_char_args_set((char *)cp, 200, 255, 0, 80);
+          rgba_uchar_args_set(cp, 200, 255, 0, 80);
         }
         else if (constflag & PCHAN_HAS_CONST) {
-          rgba_char_args_set((char *)cp, 0, 255, 120, 80);
+          rgba_uchar_args_set(cp, 0, 255, 120, 80);
         }
         else {
           return false;
@@ -768,13 +768,13 @@ static bool set_pchan_color(short colCode,
         uchar cp[4] = {255};
 
         if (boneflag & BONE_DRAW_ACTIVE) {
-          copy_v3_v3_char((char *)cp, bcolor->active);
+          copy_v3_v3_uchar(cp, bcolor->active);
         }
         else if (boneflag & BONE_SELECTED) {
-          copy_v3_v3_char((char *)cp, bcolor->select);
+          copy_v3_v3_uchar(cp, bcolor->select);
         }
         else {
-          copy_v3_v3_char((char *)cp, bcolor->solid);
+          copy_v3_v3_uchar(cp, bcolor->solid);
         }
 
         rgb_uchar_to_float(fcolor, cp);
@@ -798,15 +798,15 @@ static bool set_pchan_color(short colCode,
         uchar cp[4] = {255};
 
         if (boneflag & BONE_DRAW_ACTIVE) {
-          copy_v3_v3_char((char *)cp, bcolor->active);
+          copy_v3_v3_uchar(cp, bcolor->active);
           cp_shade_color3ub(cp, 10);
         }
         else if (boneflag & BONE_SELECTED) {
-          copy_v3_v3_char((char *)cp, bcolor->select);
+          copy_v3_v3_uchar(cp, bcolor->select);
           cp_shade_color3ub(cp, -30);
         }
         else {
-          copy_v3_v3_char((char *)cp, bcolor->solid);
+          copy_v3_v3_uchar(cp, bcolor->solid);
           cp_shade_color3ub(cp, -30);
         }
 
@@ -830,16 +830,16 @@ static bool set_pchan_color(short colCode,
       if ((constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS))) {
         uchar cp[4];
         if (constflag & PCHAN_HAS_TARGET) {
-          rgba_char_args_set((char *)cp, 255, 150, 0, 255);
+          rgba_uchar_args_set(cp, 255, 150, 0, 255);
         }
         else if (constflag & PCHAN_HAS_IK) {
-          rgba_char_args_set((char *)cp, 255, 255, 0, 255);
+          rgba_uchar_args_set(cp, 255, 255, 0, 255);
         }
         else if (constflag & PCHAN_HAS_SPLINEIK) {
-          rgba_char_args_set((char *)cp, 200, 255, 0, 255);
+          rgba_uchar_args_set(cp, 200, 255, 0, 255);
         }
         else if (constflag & PCHAN_HAS_CONST) {
-          rgba_char_args_set((char *)cp, 0, 255, 120, 255);
+          rgba_uchar_args_set(cp, 0, 255, 120, 255);
         }
         else if (constflag) {
           UI_GetThemeColor4ubv(TH_BONE_POSE, cp);
@@ -849,7 +849,7 @@ static bool set_pchan_color(short colCode,
       }
       else {
         if (bcolor) {
-    

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list