[Bf-blender-cvs] [6148ed8cf9c] master: Cleanup: reduce number of UI_icon_draw variations

Brecht Van Lommel noreply at git.blender.org
Thu May 9 19:55:49 CEST 2019


Commit: 6148ed8cf9cadbd913667c2f80e9e44f584c0f1c
Author: Brecht Van Lommel
Date:   Thu May 9 19:19:52 2019 +0200
Branches: master
https://developer.blender.org/rB6148ed8cf9cadbd913667c2f80e9e44f584c0f1c

Cleanup: reduce number of UI_icon_draw variations

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

M	source/blender/editors/include/UI_interface_icons.h
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_file/file_draw.c
M	source/blender/windowmanager/intern/wm_dragdrop.c

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

diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index 8b9f439ec1c..53bd0f01d34 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -53,6 +53,7 @@ typedef struct IconFile {
  */
 void UI_icons_init(void);
 void UI_icons_reload_internal_textures(void);
+
 int UI_icon_get_width(int icon_id);
 int UI_icon_get_height(int icon_id);
 
@@ -65,16 +66,16 @@ int UI_preview_render_size(enum eIconSizes size);
 
 void UI_icon_draw(float x, float y, int icon_id);
 void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha);
-void UI_icon_draw_preview(float x, float y, int icon_id);
-void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect);
-void UI_icon_draw_preview_aspect_size(
-    float x, float y, int icon_id, float aspect, float alpha, int size);
-
-void UI_icon_draw_aspect(
-    float x, float y, int icon_id, float aspect, float alpha, const char mono_color[4]);
-void UI_icon_draw_aspect_color(
-    float x, float y, int icon_id, float aspect, const float rgb[3], const char mono_color[4]);
-void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha);
+void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size);
+
+void UI_icon_draw_ex(float x,
+                     float y,
+                     int icon_id,
+                     float aspect,
+                     float alpha,
+                     float desaturate,
+                     const char mono_color[4]);
+
 void UI_icon_draw_desaturate(float x,
                              float y,
                              int icon_id,
@@ -82,6 +83,7 @@ void UI_icon_draw_desaturate(float x,
                              float alpha,
                              float desaturate,
                              const char mono_color[4]);
+
 void UI_icons_free(void);
 void UI_icons_free_drawinfo(void *drawinfo);
 
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 7fdaa99c464..3b941969fd5 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1467,7 +1467,6 @@ static void icon_draw_rect(float x,
                            int rh,
                            uint *rect,
                            float alpha,
-                           const float rgb[3],
                            const float desaturate)
 {
   ImBuf *ima = NULL;
@@ -1485,12 +1484,6 @@ static void icon_draw_rect(float x,
   /* modulate color */
   float col[4] = {1.0f, 1.0f, 1.0f, alpha};
 
-  if (rgb) {
-    col[0] = rgb[0];
-    col[1] = rgb[1];
-    col[2] = rgb[2];
-  }
-
   /* rect contains image in 'rendersize', we only scale if needed */
   if (rw != w || rh != h) {
     /* preserve aspect ratio and center */
@@ -1766,7 +1759,6 @@ static void icon_draw_size(float x,
                            int icon_id,
                            float aspect,
                            float alpha,
-                           const float rgb[3],
                            enum eIconSizes size,
                            int draw_size,
                            const float desaturate,
@@ -1827,7 +1819,7 @@ static void icon_draw_size(float x,
 
     GPU_blend_set_func_separate(
         GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
-    icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, rgb, desaturate);
+    icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, desaturate);
     GPU_blend_set_func_separate(
         GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
   }
@@ -1847,7 +1839,7 @@ static void icon_draw_size(float x,
                       di->data.texture.w,
                       di->data.texture.h,
                       alpha,
-                      rgb,
+                      NULL,
                       false);
   }
   else if (di->type == ICON_TYPE_MONO_TEXTURE) {
@@ -1866,10 +1858,6 @@ static void icon_draw_size(float x,
       with_border = (btheme->tui.icon_border_intensity > 0.0f);
     }
 
-    if (rgb) {
-      mul_v3_v3(color, rgb);
-    }
-
     mul_v4_fl(color, alpha);
 
     float border_outset = 0.0;
@@ -1903,7 +1891,7 @@ static void icon_draw_size(float x,
       return;
     }
 
-    icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, desaturate);
+    icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, desaturate);
   }
   else if (di->type == ICON_TYPE_PREVIEW) {
     PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
@@ -1920,7 +1908,7 @@ static void icon_draw_size(float x,
       GPU_blend_set_func_separate(
           GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
       icon_draw_rect(
-          x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, rgb, desaturate);
+          x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, desaturate);
       GPU_blend_set_func_separate(
           GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
     }
@@ -2242,71 +2230,30 @@ int UI_idcode_icon_get(const int idcode)
   }
 }
 
-static void icon_draw_at_size(float x,
-                              float y,
-                              int icon_id,
-                              float aspect,
-                              float alpha,
-                              enum eIconSizes size,
-                              const float desaturate,
-                              const char mono_color[4])
-{
-  int draw_size = get_draw_size(size);
-  icon_draw_size(x, y, icon_id, aspect, alpha, NULL, size, draw_size, desaturate, mono_color);
-}
-
-void UI_icon_draw_aspect(
-    float x, float y, int icon_id, float aspect, float alpha, const char mono_color[4])
-{
-  icon_draw_at_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, 0.0f, mono_color);
-}
-
-void UI_icon_draw_aspect_color(
-    float x, float y, int icon_id, float aspect, const float rgb[3], const char mono_color[4])
-{
-  int draw_size = get_draw_size(ICON_SIZE_ICON);
-  icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, ICON_SIZE_ICON, draw_size, false, mono_color);
-}
-
-void UI_icon_draw_desaturate(float x,
-                             float y,
-                             int icon_id,
-                             float aspect,
-                             float alpha,
-                             float desaturate,
-                             const char mono_color[4])
-{
-  icon_draw_at_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, desaturate, mono_color);
-}
-
 /* draws icon with dpi scale factor */
 void UI_icon_draw(float x, float y, int icon_id)
 {
-  UI_icon_draw_aspect(x, y, icon_id, 1.0f / UI_DPI_FAC, 1.0f, NULL);
+  UI_icon_draw_ex(x, y, icon_id, 1.0f / UI_DPI_FAC, 1.0f, 0.0f, NULL);
 }
 
 void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha)
 {
-  UI_icon_draw_aspect(x, y, icon_id, 1.0f / UI_DPI_FAC, alpha, NULL);
+  UI_icon_draw_ex(x, y, icon_id, 1.0f / UI_DPI_FAC, alpha, 0.0f, NULL);
 }
 
-void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha)
+void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size)
 {
-  icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, ICON_SIZE_ICON, size, false, NULL);
+  icon_draw_size(x, y, icon_id, aspect, alpha, ICON_SIZE_PREVIEW, size, false, NULL);
 }
 
-void UI_icon_draw_preview(float x, float y, int icon_id)
+void UI_icon_draw_ex(float x,
+                     float y,
+                     int icon_id,
+                     float aspect,
+                     float alpha,
+                     float desaturate,
+                     const char mono_color[4])
 {
-  icon_draw_at_size(x, y, icon_id, 1.0f, 1.0f, ICON_SIZE_PREVIEW, false, NULL);
-}
-
-void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect)
-{
-  icon_draw_at_size(x, y, icon_id, aspect, 1.0f, ICON_SIZE_PREVIEW, false, NULL);
-}
-
-void UI_icon_draw_preview_aspect_size(
-    float x, float y, int icon_id, float aspect, float alpha, int size)
-{
-  icon_draw_size(x, y, icon_id, aspect, alpha, NULL, ICON_SIZE_PREVIEW, size, false, NULL);
+  int draw_size = get_draw_size(ICON_SIZE_ICON);
+  icon_draw_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, draw_size, desaturate, mono_color);
 }
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 87e58a4b3b5..66fb609335d 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -765,12 +765,13 @@ void ui_draw_aligned_panel(uiStyle *style,
     panel_title_color_get(show_background, col_title);
 
     GPU_blend(true);
-    UI_icon_draw_aspect(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect),
-                        headrect.ymin + (5.0f / block->aspect),
-                        (panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED,
-                        (block->aspect / UI_DPI_FAC),
-                        1.0f,
-                        (const char *)col_title);
+    UI_icon_draw_ex(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect),
+                    headrect.ymin + (5.0f / block->aspect),
+                    (panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED,
+                    (block->aspect / UI_DPI_FAC),
+                    1.0f,
+                    0.0f,
+                    (const char *)col_title);
     GPU_blend(false);
   }
 
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 60aa360e923..62fc785a432 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1421,7 +1421,7 @@ static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect)
     int x = rect->xmin + w / 2 - size / 2;
     int y = rect->ymin + h / 2 - size / 2;
 
-    UI_icon_draw_preview_aspect_size(x, y, icon, 1.0f, alpha, size);
+    UI_icon_dra

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list