Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_icons.c
| Show First 20 Lines • Show All 1,943 Lines • ▼ Show 20 Lines | static void ui_id_preview_image_render_size( | ||||
| if (((pi->flag[size] & PRV_CHANGED) || !pi->rect[size])) { | if (((pi->flag[size] & PRV_CHANGED) || !pi->rect[size])) { | ||||
| /* create the rect if necessary */ | /* create the rect if necessary */ | ||||
| icon_set_image(C, scene, id, pi, size, use_job); | icon_set_image(C, scene, id, pi, size, use_job); | ||||
| pi->flag[size] &= ~PRV_CHANGED; | pi->flag[size] &= ~PRV_CHANGED; | ||||
| } | } | ||||
| } | } | ||||
| void UI_icon_render_id_ex(const bContext *C, | |||||
| Scene *scene, | |||||
| ID *id_to_render, | |||||
| const enum eIconSizes size, | |||||
| const bool use_job, | |||||
| PreviewImage *r_preview_image) | |||||
| { | |||||
| ui_id_preview_image_render_size(C, scene, id_to_render, r_preview_image, size, use_job); | |||||
HooglyBoogly: I don't have much experience with this code, but it feels wrong that this function can accept a… | |||||
| } | |||||
| void UI_icon_render_id( | void UI_icon_render_id( | ||||
| const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job) | const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job) | ||||
| { | { | ||||
| PreviewImage *pi = BKE_previewimg_id_ensure(id); | PreviewImage *pi = BKE_previewimg_id_ensure(id); | ||||
| if (pi == NULL) { | if (pi == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| ID *id_to_render = id; | |||||
| /* For objects, first try if a preview can created via the object data. */ | /* For objects, first try if a preview can created via the object data. */ | ||||
| if (GS(id->name) == ID_OB) { | if (GS(id->name) == ID_OB) { | ||||
| Object *ob = (Object *)id; | Object *ob = (Object *)id; | ||||
| if (ED_preview_id_is_supported(ob->data)) { | if (ED_preview_id_is_supported(ob->data)) { | ||||
| id = ob->data; | id_to_render = ob->data; | ||||
| } | } | ||||
| } | } | ||||
| if (!ED_preview_id_is_supported(id)) { | if (!ED_preview_id_is_supported(id_to_render)) { | ||||
| return; | return; | ||||
| } | } | ||||
| ui_id_preview_image_render_size(C, scene, id, pi, size, use_job); | UI_icon_render_id_ex(C, scene, id_to_render, size, use_job, pi); | ||||
| } | } | ||||
| static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs) | static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs) | ||||
| { | { | ||||
| PreviewImage *pi = BKE_previewimg_id_ensure(id); | PreviewImage *pi = BKE_previewimg_id_ensure(id); | ||||
| if (!pi) { | if (!pi) { | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 469 Lines • Show Last 20 Lines | |||||
I don't have much experience with this code, but it feels wrong that this function can accept a null preview_image argument when its main job is to fill a preview with data. Unless there's a good reason not to, I think the null check should be moved to the operator.