[Bf-blender-cvs] [12409b2069d] master: Cleanup: rename get_brush_icon, make it a static function

Campbell Barton noreply at git.blender.org
Mon Jan 4 07:41:49 CET 2021


Commit: 12409b2069d175fd3ebf578d91d190fe75272c87
Author: Campbell Barton
Date:   Mon Jan 4 11:53:05 2021 +1100
Branches: master
https://developer.blender.org/rB12409b2069d175fd3ebf578d91d190fe75272c87

Cleanup: rename get_brush_icon, make it a static function

Group with other icon preview API functions.

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

M	source/blender/blenkernel/BKE_brush.h
M	source/blender/editors/render/render_preview.c

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

diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index e551ed76b6f..452a08bc9c8 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -69,9 +69,6 @@ void BKE_brush_gpencil_weight_presets(struct Main *bmain,
                                       const bool reset);
 void BKE_gpencil_brush_preset_set(struct Main *bmain, struct Brush *brush, const short type);
 
-/* image icon function */
-struct ImBuf *get_brush_icon(struct Brush *brush);
-
 /* jitter */
 void BKE_brush_jitter_pos(const struct Scene *scene,
                           struct Brush *brush,
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 579fd86077e..793b23fcf32 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -105,52 +105,6 @@
 
 static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect);
 
-ImBuf *get_brush_icon(Brush *brush)
-{
-  static const int flags = IB_rect | IB_multilayer | IB_metadata;
-
-  char path[FILE_MAX];
-  const char *folder;
-
-  if (!(brush->icon_imbuf)) {
-    if (brush->flag & BRUSH_CUSTOM_ICON) {
-
-      if (brush->icon_filepath[0]) {
-        /* First use the path directly to try and load the file. */
-
-        BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
-        BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&brush->id));
-
-        /* use default colorspaces for brushes */
-        brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
-
-        /* otherwise lets try to find it in other directories */
-        if (!(brush->icon_imbuf)) {
-          folder = BKE_appdir_folder_id(BLENDER_DATAFILES, "brushicons");
-
-          BLI_make_file_string(
-              BKE_main_blendfile_path_from_global(), path, folder, brush->icon_filepath);
-
-          if (path[0]) {
-            /* use fefault color spaces */
-            brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
-          }
-        }
-
-        if (brush->icon_imbuf) {
-          BKE_icon_changed(BKE_icon_id_ensure(&brush->id));
-        }
-      }
-    }
-  }
-
-  if (!(brush->icon_imbuf)) {
-    brush->id.icon_id = 0;
-  }
-
-  return brush->icon_imbuf;
-}
-
 typedef struct ShaderPreview {
   /* from wmJob */
   void *owner;
@@ -1147,6 +1101,52 @@ static void shader_preview_free(void *customdata)
 
 /* ************************* icon preview ********************** */
 
+static ImBuf *icon_preview_imbuf_from_brush(Brush *brush)
+{
+  static const int flags = IB_rect | IB_multilayer | IB_metadata;
+
+  char path[FILE_MAX];
+  const char *folder;
+
+  if (!(brush->icon_imbuf)) {
+    if (brush->flag & BRUSH_CUSTOM_ICON) {
+
+      if (brush->icon_filepath[0]) {
+        /* First use the path directly to try and load the file. */
+
+        BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
+        BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&brush->id));
+
+        /* use default colorspaces for brushes */
+        brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
+
+        /* otherwise lets try to find it in other directories */
+        if (!(brush->icon_imbuf)) {
+          folder = BKE_appdir_folder_id(BLENDER_DATAFILES, "brushicons");
+
+          BLI_make_file_string(
+              BKE_main_blendfile_path_from_global(), path, folder, brush->icon_filepath);
+
+          if (path[0]) {
+            /* use fefault color spaces */
+            brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
+          }
+        }
+
+        if (brush->icon_imbuf) {
+          BKE_icon_changed(BKE_icon_id_ensure(&brush->id));
+        }
+      }
+    }
+  }
+
+  if (!(brush->icon_imbuf)) {
+    brush->id.icon_id = 0;
+  }
+
+  return brush->icon_imbuf;
+}
+
 static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect)
 {
   struct ImBuf *ima;
@@ -1277,7 +1277,7 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
     else if (idtype == ID_BR) {
       Brush *br = (Brush *)id;
 
-      br->icon_imbuf = get_brush_icon(br);
+      br->icon_imbuf = icon_preview_imbuf_from_brush(br);
 
       memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(uint));



More information about the Bf-blender-cvs mailing list