diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-01-04 03:53:05 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-01-04 09:37:44 +0300 |
commit | 12409b2069d175fd3ebf578d91d190fe75272c87 (patch) | |
tree | 1f91b59f2dfe0f024f895b755113af59dbb91e6a /source/blender | |
parent | 01f38c10cb5045de9ca9a4284793966ca5dd5af6 (diff) |
Cleanup: rename get_brush_icon, make it a static function
Group with other icon preview API functions.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_brush.h | 3 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 94 |
2 files changed, 47 insertions, 50 deletions
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)); |