[Bf-blender-cvs] [868573451f8] master: Cleanup: use unsigned char for UI_view2d_text_cache_add

Campbell Barton noreply at git.blender.org
Mon Mar 16 01:55:06 CET 2020


Commit: 868573451f8bfacac25b1b6d53ff05e831508087
Author: Campbell Barton
Date:   Mon Mar 16 11:53:08 2020 +1100
Branches: master
https://developer.blender.org/rB868573451f8bfacac25b1b6d53ff05e831508087

Cleanup: use unsigned char for UI_view2d_text_cache_add

Avoids casts when used with other UI code
where the color is often unsigned.

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

M	source/blender/editors/include/UI_view2d.h
M	source/blender/editors/interface/view2d.c
M	source/blender/editors/space_nla/nla_draw.c
M	source/blender/editors/space_sequencer/sequencer_draw.c

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

diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index ecdae3ead6b..ff9719d4674 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -250,13 +250,17 @@ char UI_view2d_rect_in_scrollers(const struct ARegion *region,
                                  const struct rcti *rect);
 
 /* cached text drawing in v2d, to allow pixel-aligned draw as post process */
-void UI_view2d_text_cache_add(
-    struct View2D *v2d, float x, float y, const char *str, size_t str_len, const char col[4]);
+void UI_view2d_text_cache_add(struct View2D *v2d,
+                              float x,
+                              float y,
+                              const char *str,
+                              size_t str_len,
+                              const unsigned char col[4]);
 void UI_view2d_text_cache_add_rectf(struct View2D *v2d,
                                     const struct rctf *rect_view,
                                     const char *str,
                                     size_t str_len,
-                                    const char col[4]);
+                                    const unsigned char col[4]);
 void UI_view2d_text_cache_draw(struct ARegion *region);
 
 /* operators */
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 8ea1bd3ede6..ad2e32149d8 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -2146,7 +2146,7 @@ static MemArena *g_v2d_strings_arena = NULL;
 static View2DString *g_v2d_strings = NULL;
 
 void UI_view2d_text_cache_add(
-    View2D *v2d, float x, float y, const char *str, size_t str_len, const char col[4])
+    View2D *v2d, float x, float y, const char *str, size_t str_len, const uchar col[4])
 {
   int mval[2];
 
@@ -2177,7 +2177,7 @@ void UI_view2d_text_cache_add(
 
 /* no clip (yet) */
 void UI_view2d_text_cache_add_rectf(
-    View2D *v2d, const rctf *rect_view, const char *str, size_t str_len, const char col[4])
+    View2D *v2d, const rctf *rect_view, const char *str, size_t str_len, const uchar col[4])
 {
   rcti rect;
 
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 905e3eddc97..56176c1cb92 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -604,7 +604,7 @@ static void nla_draw_strip_text(AnimData *adt,
                          (nlt->flag & NLATRACK_SOLO) == 0);
   char str[256];
   size_t str_len;
-  char col[4];
+  uchar col[4];
 
   /* just print the name and the range */
   if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
@@ -652,7 +652,7 @@ static void nla_draw_strip_frames_text(
     NlaTrack *UNUSED(nlt), NlaStrip *strip, View2D *v2d, float UNUSED(yminc), float ymaxc)
 {
   const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */
-  const char col[4] = {220, 220, 220, 255}; /* light gray */
+  const uchar col[4] = {220, 220, 220, 255}; /* light gray */
   char numstr[32];
   size_t numstr_len;
 
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index ef192f6c9db..864e518f182 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -542,7 +542,7 @@ static void draw_seq_handle(View2D *v2d,
   }
 
   if ((G.moving & G_TRANSFORM_SEQ) || (seq->flag & whichsel)) {
-    const char col[4] = {255, 255, 255, 255};
+    const uchar col[4] = {255, 255, 255, 255};
     char numstr[32];
     size_t numstr_len;
 
@@ -574,7 +574,7 @@ static void draw_seq_text(View2D *v2d,
   char str[32 + FILE_MAX];
   size_t str_len;
   const char *name = seq->name + 2;
-  char col[4];
+  uchar col[4];
 
   /* note, all strings should include 'name' */
   if (name[0] == '\0') {



More information about the Bf-blender-cvs mailing list