Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_edit.c
| Show All 36 Lines | |||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_build.h" | |||||
| #include "DEG_depsgraph_query.h" | |||||
| #include "RE_engine.h" | #include "RE_engine.h" | ||||
| #include "RE_pipeline.h" | #include "RE_pipeline.h" | ||||
| #include "ED_node.h" /* own include */ | #include "ED_node.h" /* own include */ | ||||
| #include "ED_select_utils.h" | #include "ED_select_utils.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_render.h" | #include "ED_render.h" | ||||
| Show All 21 Lines | |||||
| /* ***************** composite job manager ********************** */ | /* ***************** composite job manager ********************** */ | ||||
| enum { | enum { | ||||
| COM_RECALC_COMPOSITE = 1, | COM_RECALC_COMPOSITE = 1, | ||||
| COM_RECALC_VIEWER = 2, | COM_RECALC_VIEWER = 2, | ||||
| }; | }; | ||||
| typedef struct CompoJob { | typedef struct CompoJob { | ||||
| /* Input parameters. */ | |||||
| Main *bmain; | Main *bmain; | ||||
| Scene *scene; | Scene *scene; | ||||
| ViewLayer *view_layer; | |||||
| bNodeTree *ntree; | bNodeTree *ntree; | ||||
| int recalc_flags; | |||||
| /* Evaluated state/ */ | |||||
| Depsgraph *compositor_depsgraph; | |||||
| bNodeTree *localtree; | bNodeTree *localtree; | ||||
| /* Jon system integration. */ | |||||
| const short *stop; | const short *stop; | ||||
| short *do_update; | short *do_update; | ||||
| float *progress; | float *progress; | ||||
| int recalc_flags; | |||||
| } CompoJob; | } CompoJob; | ||||
| static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags) | static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags) | ||||
| { | { | ||||
| bNode *node; | bNode *node; | ||||
| for (node = nodetree->nodes.first; node; node = node->next) { | for (node = nodetree->nodes.first; node; node = node->next) { | ||||
| if (node->type == CMP_NODE_COMPOSITE) { | if (node->type == CMP_NODE_COMPOSITE) { | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
| static void compo_freejob(void *cjv) | static void compo_freejob(void *cjv) | ||||
| { | { | ||||
| CompoJob *cj = cjv; | CompoJob *cj = cjv; | ||||
| if (cj->localtree) { | if (cj->localtree) { | ||||
| ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree); | ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree); | ||||
| } | } | ||||
| if (cj->compositor_depsgraph != NULL) { | |||||
| DEG_graph_free(cj->compositor_depsgraph); | |||||
| } | |||||
| MEM_freeN(cj); | MEM_freeN(cj); | ||||
| } | } | ||||
| /* only now we copy the nodetree, so adding many jobs while | /* only now we copy the nodetree, so adding many jobs while | ||||
| * sliding buttons doesn't frustrate */ | * sliding buttons doesn't frustrate */ | ||||
| static void compo_initjob(void *cjv) | static void compo_initjob(void *cjv) | ||||
| { | { | ||||
| CompoJob *cj = cjv; | CompoJob *cj = cjv; | ||||
| Main *bmain = cj->bmain; | |||||
| Scene *scene = cj->scene; | |||||
| ViewLayer *view_layer = cj->view_layer; | |||||
| cj->compositor_depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER); | |||||
| DEG_graph_build_for_compositor_preview( | |||||
| cj->compositor_depsgraph, bmain, scene, view_layer, cj->ntree); | |||||
| DEG_evaluate_on_framechange(bmain, cj->compositor_depsgraph, CFRA); | |||||
| bNodeTree *ntree_eval = (bNodeTree *)DEG_get_evaluated_id(cj->compositor_depsgraph, | |||||
| &cj->ntree->id); | |||||
| cj->localtree = ntreeLocalize(cj->ntree); | cj->localtree = ntreeLocalize(ntree_eval); | ||||
| if (cj->recalc_flags) { | if (cj->recalc_flags) { | ||||
| compo_tag_output_nodes(cj->localtree, cj->recalc_flags); | compo_tag_output_nodes(cj->localtree, cj->recalc_flags); | ||||
| } | } | ||||
| } | } | ||||
| /* called before redraw notifiers, it moves finished previews over */ | /* called before redraw notifiers, it moves finished previews over */ | ||||
| static void compo_updatejob(void *UNUSED(cjv)) | static void compo_updatejob(void *UNUSED(cjv)) | ||||
| ▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
| * \note only call from spaces `refresh` callbacks, not direct! - use with care. | * \note only call from spaces `refresh` callbacks, not direct! - use with care. | ||||
| */ | */ | ||||
| void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene *scene_owner) | void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene *scene_owner) | ||||
| { | { | ||||
| wmJob *wm_job; | wmJob *wm_job; | ||||
| CompoJob *cj; | CompoJob *cj; | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | |||||
| /* to fix bug: [#32272] */ | /* to fix bug: [#32272] */ | ||||
| if (G.is_rendering) { | if (G.is_rendering) { | ||||
| return; | return; | ||||
| } | } | ||||
| #ifdef USE_ESC_COMPO | #ifdef USE_ESC_COMPO | ||||
| G.is_break = false; | G.is_break = false; | ||||
| #endif | #endif | ||||
| BKE_image_backup_render( | BKE_image_backup_render( | ||||
| scene, BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result"), false); | scene, BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result"), false); | ||||
| wm_job = WM_jobs_get(CTX_wm_manager(C), | wm_job = WM_jobs_get(CTX_wm_manager(C), | ||||
| CTX_wm_window(C), | CTX_wm_window(C), | ||||
| scene_owner, | scene_owner, | ||||
| "Compositing", | "Compositing", | ||||
| WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, | WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, | ||||
| WM_JOB_TYPE_COMPOSITE); | WM_JOB_TYPE_COMPOSITE); | ||||
| cj = MEM_callocN(sizeof(CompoJob), "compo job"); | cj = MEM_callocN(sizeof(CompoJob), "compo job"); | ||||
| /* customdata for preview thread */ | /* customdata for preview thread */ | ||||
| cj->bmain = bmain; | cj->bmain = bmain; | ||||
| cj->scene = scene; | cj->scene = scene; | ||||
| cj->view_layer = view_layer; | |||||
| cj->ntree = nodetree; | cj->ntree = nodetree; | ||||
| cj->recalc_flags = compo_get_recalc_flags(C); | cj->recalc_flags = compo_get_recalc_flags(C); | ||||
| /* setup job */ | /* setup job */ | ||||
| WM_jobs_customdata_set(wm_job, cj, compo_freejob); | WM_jobs_customdata_set(wm_job, cj, compo_freejob); | ||||
| WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_COMPO_RESULT, NC_SCENE | ND_COMPO_RESULT); | WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_COMPO_RESULT, NC_SCENE | ND_COMPO_RESULT); | ||||
| WM_jobs_callbacks(wm_job, compo_startjob, compo_initjob, compo_updatejob, NULL); | WM_jobs_callbacks(wm_job, compo_startjob, compo_initjob, compo_updatejob, NULL); | ||||
| ▲ Show 20 Lines • Show All 2,468 Lines • Show Last 20 Lines | |||||