void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *rect, int sizex, int sizey) { wmJob *wm_job; IconPreview *ip, *old_ip; /* suspended start means it starts after 1 timer step, see WM_jobs_timer below */ wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER | WM_JOB_SUSPEND, WM_JOB_TYPE_RENDER_PREVIEW); ip = MEM_callocN(sizeof(IconPreview), "icon preview"); /* render all resolutions from suspended job too */ old_ip = WM_jobs_customdata_get(wm_job); if (old_ip) BLI_movelisttolist(&ip->sizes, &old_ip->sizes); /* customdata for preview thread */ ip->scene = CTX_data_scene(C); ip->owner = id; ip->id = id; icon_preview_add_size(ip, rect, sizex, sizey); /* setup job */ WM_jobs_customdata_set(wm_job, ip, icon_preview_free); WM_jobs_timer(wm_job, 0.1, NC_MATERIAL, NC_MATERIAL); WM_jobs_callbacks(wm_job, icon_preview_startjob_all_sizes, NULL, NULL, icon_preview_endjob); WM_jobs_start(CTX_wm_manager(C), wm_job); }
void ED_preview_icon_job( const bContext *C, void *owner, ID *id, unsigned int *rect, int sizex, int sizey) { wmJob *wm_job; IconPreview *ip, *old_ip; ED_preview_ensure_dbase(); /* suspended start means it starts after 1 timer step, see WM_jobs_timer below */ wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER | WM_JOB_SUSPEND, WM_JOB_TYPE_RENDER_PREVIEW); ip = MEM_callocN(sizeof(IconPreview), "icon preview"); /* render all resolutions from suspended job too */ old_ip = WM_jobs_customdata_get(wm_job); if (old_ip) { BLI_movelisttolist(&ip->sizes, &old_ip->sizes); } /* customdata for preview thread */ ip->bmain = CTX_data_main(C); ip->scene = CTX_data_scene(C); ip->depsgraph = CTX_data_depsgraph(C); ip->owner = owner; ip->id = id; ip->id_copy = duplicate_ids(id); icon_preview_add_size(ip, rect, sizex, sizey); /* Special threading hack: * warn main code that this preview is being rendered and cannot be freed... */ { PreviewImage *prv_img = owner; if (prv_img->tag & PRV_TAG_DEFFERED) { prv_img->tag |= PRV_TAG_DEFFERED_RENDERING; } } /* setup job */ WM_jobs_customdata_set(wm_job, ip, icon_preview_free); WM_jobs_timer(wm_job, 0.1, NC_WINDOW, NC_WINDOW); WM_jobs_callbacks(wm_job, icon_preview_startjob_all_sizes, NULL, NULL, icon_preview_endjob); WM_jobs_start(CTX_wm_manager(C), wm_job); }
void ED_preview_icon_render(Scene *scene, ID *id, unsigned int *rect, int sizex, int sizey) { IconPreview ip = {NULL}; short stop = false, update = false; float progress = 0.0f; ip.scene = scene; 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_render( Main *bmain, Scene *scene, ID *id, unsigned int *rect, int sizex, int sizey) { IconPreview ip = {NULL}; short stop = false, update = false; float progress = 0.0f; ED_preview_ensure_dbase(); ip.bmain = bmain; ip.scene = scene; ip.owner = BKE_previewimg_id_ensure(id); ip.id = id; ip.id_copy = duplicate_ids(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); }