diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-07 14:31:25 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-07 14:31:31 +0300 |
commit | 820b6b37310fe5245f8858392a3284614451cea5 (patch) | |
tree | 8e835f02b7a398c0b633fc6d936152d58ace02c9 /source/blender/editors | |
parent | 3f05797333dd86279f33e1868b3dd737a1f3a825 (diff) |
Ensure mat/tex/etc. previews are generated/saved in .blend files when enabled in userprefs.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D970
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_render.h | 1 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface_icons.h | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 26 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 20 |
4 files changed, 40 insertions, 10 deletions
diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index 0227ae3e85a..32fa641e3ae 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -72,6 +72,7 @@ void ED_preview_init_dbase(void); void ED_preview_free_dbase(void); void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, struct MTex *slot, int sizex, int sizey, int method); +void ED_preview_icon_render(const struct bContext *C, void *owner, struct ID *id, unsigned int *rect, int sizex, int sizey); void ED_preview_icon_job(const struct bContext *C, void *owner, struct ID *id, unsigned int *rect, int sizex, int sizey); void ED_preview_kill_jobs(struct wmWindowManager *wm, struct Main *bmain); diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h index 6104505ef58..2ba3d309aa7 100644 --- a/source/blender/editors/include/UI_interface_icons.h +++ b/source/blender/editors/include/UI_interface_icons.h @@ -33,6 +33,7 @@ #define __UI_INTERFACE_ICONS_H__ struct bContext; +struct ID; struct Image; struct ImBuf; struct World; @@ -63,6 +64,8 @@ void UI_icons_init(int first_dyn_id); int UI_icon_get_width(int icon_id); int UI_icon_get_height(int icon_id); +void UI_id_icon_render(const struct bContext *C, struct ID *id, const bool big, const bool use_job); + void UI_icon_draw(float x, float y, int icon_id); 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); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index cb5a26b1be3..bebc515df8e 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -931,7 +931,7 @@ static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size) /* only called when icon has changed */ /* only call with valid pointer from UI_icon_draw */ -static void icon_set_image(const bContext *C, ID *id, PreviewImage *prv_img, enum eIconSizes size) +static void icon_set_image(const bContext *C, ID *id, PreviewImage *prv_img, enum eIconSizes size, const bool use_job) { if (!prv_img) { if (G.debug & G_DEBUG) @@ -941,8 +941,14 @@ static void icon_set_image(const bContext *C, ID *id, PreviewImage *prv_img, enu icon_create_rect(prv_img, size); - ED_preview_icon_job(C, prv_img, id, prv_img->rect[size], - prv_img->w[size], prv_img->h[size]); + if (use_job) { + /* Job (background) version */ + ED_preview_icon_job(C, prv_img, id, prv_img->rect[size], prv_img->w[size], prv_img->h[size]); + } + else { + /* Immediate version */ + ED_preview_icon_render(C, prv_img, id, prv_img->rect[size], prv_img->w[size], prv_img->h[size]); + } } PreviewImage *UI_icon_to_preview(int icon_id) @@ -1149,25 +1155,25 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al } } -static void ui_id_preview_image_render_size(const bContext *C, ID *id, PreviewImage *pi, int size) +static void ui_id_preview_image_render_size(const bContext *C, ID *id, PreviewImage *pi, int size, const bool use_job) { if ((pi->changed[size] || !pi->rect[size])) { /* changed only ever set by dynamic icons */ /* create the rect if necessary */ - icon_set_image(C, id, pi, size); + icon_set_image(C, id, pi, size, use_job); pi->changed[size] = 0; } } -static void ui_id_icon_render(const bContext *C, ID *id, const bool big) +void UI_id_icon_render(const bContext *C, ID *id, const bool big, const bool use_job) { PreviewImage *pi = BKE_previewimg_get(id); if (pi) { if (big) - ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_PREVIEW); /* bigger preview size */ + ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_PREVIEW, use_job); /* bigger preview size */ else - ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_ICON); /* icon size */ + ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_ICON, use_job); /* icon size */ } } @@ -1183,7 +1189,7 @@ static void ui_id_brush_render(const bContext *C, ID *id) /* check if rect needs to be created; changed * only set by dynamic icons */ if ((pi->changed[i] || !pi->rect[i])) { - icon_set_image(C, id, pi, i); + icon_set_image(C, id, pi, i, false); pi->changed[i] = 0; } } @@ -1259,7 +1265,7 @@ int ui_id_icon_get(const bContext *C, ID *id, const bool big) case ID_LA: /* fall through */ iconid = BKE_icon_getid(id); /* checks if not exists, or changed */ - ui_id_icon_render(C, id, big); + UI_id_icon_render(C, id, big, true); break; default: break; diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index b36e4e22f01..8833d76fde2 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1098,6 +1098,26 @@ static void icon_preview_free(void *customdata) MEM_freeN(ip); } +void ED_preview_icon_render(const bContext *C, void *UNUSED(owner), ID *id, unsigned int *rect, int sizex, int sizey) +{ + IconPreview ip = {0}; + short stop = false, update = false; + float progress = 0.0f; + + /* customdata for preview thread */ + ip.scene = CTX_data_scene(C); + ip.owner = id; + ip.id = id; + + icon_preview_add_size(&ip, rect, sizex, sizey); + + icon_preview_startjob_all_sizes(&ip, &stop, &update, &progress); + + icon_preview_endjob(&ip); + + BLI_freelistN(&ip.sizes); +} + void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *rect, int sizex, int sizey) { wmJob *wm_job; |