Cleanup: rename get_brush_icon, make it a static function
Group with other icon preview API functions.
This commit is contained in:
parent
01f38c10cb
commit
12409b2069
|
@ -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,
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
Loading…
Reference in New Issue