From 78a8d3685bd3487eb0b5dd55793f94fe7235e377 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 11 Jun 2018 15:40:37 +0200 Subject: Cleanup: remove moar ugly G.main usages... BKE_image was an ugly nest, could fix all but the ones from compositor, so moved ugly G.main there, at least we know where the Evil is that way ;) --- source/blender/blenkernel/BKE_image.h | 18 +++---- source/blender/blenkernel/BKE_mesh.h | 6 +-- source/blender/blenkernel/BKE_node.h | 4 +- source/blender/blenkernel/intern/bpath.c | 2 +- source/blender/blenkernel/intern/image.c | 62 +++++++++++----------- source/blender/blenkernel/intern/mesh_convert.c | 16 +++--- source/blender/blenkernel/intern/node.c | 4 +- source/blender/blenkernel/intern/packedFile.c | 2 +- source/blender/collada/DocumentImporter.cpp | 2 +- .../operations/COM_CompositorOperation.cpp | 3 +- source/blender/editors/include/ED_node.h | 2 +- .../editors/interface/interface_eyedropper_color.c | 4 +- source/blender/editors/object/object_add.c | 4 +- source/blender/editors/render/render_internal.c | 10 ++-- source/blender/editors/render/render_opengl.c | 4 +- source/blender/editors/render/render_view.c | 4 +- .../editors/sculpt_paint/paint_image_proj.c | 4 +- source/blender/editors/space_image/image_edit.c | 2 +- source/blender/editors/space_image/image_ops.c | 37 +++++++------ source/blender/editors/space_node/drawnode.c | 3 +- source/blender/editors/space_node/node_add.c | 3 +- source/blender/editors/space_node/node_edit.c | 14 +++-- source/blender/editors/space_node/node_view.c | 16 +++--- source/blender/makesrna/intern/rna_color.c | 2 +- source/blender/makesrna/intern/rna_image.c | 22 ++++---- source/blender/makesrna/intern/rna_image_api.c | 5 +- source/blender/makesrna/intern/rna_main_api.c | 2 +- source/blender/makesrna/intern/rna_nodetree.c | 2 +- source/blender/makesrna/intern/rna_scene.c | 4 +- .../blender/nodes/composite/node_composite_tree.c | 4 +- .../composite/nodes/node_composite_splitViewer.c | 3 +- .../nodes/composite/nodes/node_composite_viewer.c | 3 +- source/blender/nodes/shader/node_shader_tree.c | 2 +- source/blender/nodes/texture/node_texture_tree.c | 2 +- .../blender/render/intern/source/convertblender.c | 4 +- source/blender/render/intern/source/pipeline.c | 2 +- source/blender/windowmanager/intern/wm_draw.c | 4 +- source/blender/windowmanager/intern/wm_operators.c | 2 +- 38 files changed, 156 insertions(+), 133 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 1af123759e6..fc018dbfe81 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -190,25 +190,25 @@ void BKE_image_alpha_mode_from_extension(struct Image *image); /* returns a new image or NULL if it can't load */ struct Image *BKE_image_load(struct Main *bmain, const char *filepath); /* returns existing Image when filename/type is same (frame optional) */ -struct Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists); -struct Image *BKE_image_load_exists(const char *filepath); +struct Image *BKE_image_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists); +struct Image *BKE_image_load_exists(struct Main *bmain, const char *filepath); /* adds image, adds ibuf, generates color or pattern */ struct Image *BKE_image_add_generated( struct Main *bmain, unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, const float color[4], const bool stereo3d); /* adds image from imbuf, owns imbuf */ -struct Image *BKE_image_add_from_imbuf(struct ImBuf *ibuf, const char *name); +struct Image *BKE_image_add_from_imbuf(struct Main *bmain, struct ImBuf *ibuf, const char *name); /* for reload, refresh, pack */ void BKE_image_init_imageuser(struct Image *ima, struct ImageUser *iuser); -void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal); +void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal); void BKE_image_walk_all_users(const struct Main *mainp, void *customdata, void callback(struct Image *ima, struct ImageUser *iuser, void *customdata)); /* ensures an Image exists for viewing nodes or render */ -struct Image *BKE_image_verify_viewer(int type, const char *name); +struct Image *BKE_image_verify_viewer(struct Main *bmain, int type, const char *name); /* ensures the view node cache is compatible with the scene views */ void BKE_image_verify_viewer_views(const struct RenderData *rd, struct Image *ima, struct ImageUser *iuser); @@ -242,27 +242,27 @@ void BKE_image_backup_render(struct Scene *scene, struct Image *ima, bool free_c bool BKE_image_save_openexr_multiview(struct Image *ima, struct ImBuf *ibuf, const char *filepath, const int flags); /* goes over all textures that use images */ -void BKE_image_free_all_textures(void); +void BKE_image_free_all_textures(struct Main *bmain); /* does one image! */ void BKE_image_free_anim_ibufs(struct Image *ima, int except_frame); /* does all images with type MOVIE or SEQUENCE */ -void BKE_image_all_free_anim_ibufs(int except_frame); +void BKE_image_all_free_anim_ibufs(struct Main *bmain, int except_frame); void BKE_image_memorypack(struct Image *ima); void BKE_image_packfiles(struct ReportList *reports, struct Image *ima, const char *basepath); void BKE_image_packfiles_from_mem(struct ReportList *reports, struct Image *ima, char *data, const size_t data_len); /* prints memory statistics for images */ -void BKE_image_print_memlist(void); +void BKE_image_print_memlist(struct Main *bmain); /* empty image block, of similar type and filename */ void BKE_image_copy_data(struct Main *bmain, struct Image *ima_dst, const struct Image *ima_src, const int flag); struct Image *BKE_image_copy(struct Main *bmain, const struct Image *ima); /* merge source into dest, and free source */ -void BKE_image_merge(struct Image *dest, struct Image *source); +void BKE_image_merge(struct Main *bmain, struct Image *dest, struct Image *source); /* scale the image */ bool BKE_image_scale(struct Image *image, int width, int height); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 2c7ba845960..3d69358960f 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -154,10 +154,10 @@ int BKE_mesh_nurbs_displist_to_mdata( struct MLoop **r_allloop, struct MPoly **r_allpoly, struct MLoopUV **r_alluv, int *r_totloop, int *r_totpoly); void BKE_mesh_from_nurbs_displist( - struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name); -void BKE_mesh_from_nurbs(struct Object *ob); + struct Main *bmain, struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name); +void BKE_mesh_from_nurbs(struct Main *bmain, struct Object *ob); void BKE_mesh_to_curve_nurblist(struct DerivedMesh *dm, struct ListBase *nurblist, const int edge_users_test); -void BKE_mesh_to_curve(struct Scene *scene, struct Object *ob); +void BKE_mesh_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob); struct Mesh *BKE_mesh_new_from_object( struct Main *bmain, struct Scene *sce, struct Object *ob, diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 7a3bf81a2af..5439b16e211 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -291,7 +291,7 @@ typedef struct bNodeTreeType { /* calls allowing threaded composite */ void (*localize)(struct bNodeTree *localtree, struct bNodeTree *ntree); void (*local_sync)(struct bNodeTree *localtree, struct bNodeTree *ntree); - void (*local_merge)(struct bNodeTree *localtree, struct bNodeTree *ntree); + void (*local_merge)(struct Main *bmain, struct bNodeTree *localtree, struct bNodeTree *ntree); /* Tree update. Overrides nodetype->updatetreefunc! */ void (*update)(struct bNodeTree *ntree); @@ -369,7 +369,7 @@ int ntreeOutputExists(struct bNode *node, struct bNodeSocket *testso void ntreeNodeFlagSet(const bNodeTree *ntree, const int flag, const bool enable); struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree); void ntreeLocalSync(struct bNodeTree *localtree, struct bNodeTree *ntree); -void ntreeLocalMerge(struct bNodeTree *localtree, struct bNodeTree *ntree); +void ntreeLocalMerge(struct Main *bmain, struct bNodeTree *localtree, struct bNodeTree *ntree); /** \} */ diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index e6be42088db..0b191e1f69b 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -442,7 +442,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int /* image may have been painted onto (and not saved, T44543) */ !BKE_image_is_dirty(ima)) { - BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD); BKE_image_walk_all_users(bmain, ima, bpath_traverse_image_user_cb); } } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 1d909ba1a76..95fb96c875f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -500,7 +500,7 @@ void BKE_image_make_local(Main *bmain, Image *ima, const bool lib_local) BKE_id_make_local_generic(bmain, &ima->id, true, lib_local); } -void BKE_image_merge(Image *dest, Image *source) +void BKE_image_merge(Main *bmain, Image *dest, Image *source) { /* sanity check */ if (dest && source && dest != source) { @@ -518,7 +518,7 @@ void BKE_image_merge(Image *dest, Image *source) } BLI_spin_unlock(&image_spin); - BKE_libblock_free(G.main, source); + BKE_libblock_free(bmain, source); } } @@ -617,7 +617,7 @@ Image *BKE_image_load(Main *bmain, const char *filepath) /* otherwise creates new. */ /* does not load ibuf itself */ /* pass on optional frame for #name images */ -Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists) +Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exists) { Image *ima; char str[FILE_MAX], strtest[FILE_MAX]; @@ -626,10 +626,10 @@ Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists) BLI_path_abs(str, BKE_main_blendfile_path_from_global()); /* first search an identical filepath */ - for (ima = G.main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) { STRNCPY(strtest, ima->name); - BLI_path_abs(strtest, ID_BLEND_PATH(G.main, &ima->id)); + BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &ima->id)); if (BLI_path_cmp(strtest, str) == 0) { if ((BKE_image_has_anim(ima) == false) || @@ -648,12 +648,12 @@ Image *BKE_image_load_exists_ex(const char *filepath, bool *r_exists) if (r_exists) *r_exists = false; - return BKE_image_load(G.main, filepath); + return BKE_image_load(bmain, filepath); } -Image *BKE_image_load_exists(const char *filepath) +Image *BKE_image_load_exists(Main *bmain, const char *filepath) { - return BKE_image_load_exists_ex(filepath, NULL); + return BKE_image_load_exists_ex(bmain, filepath, NULL); } static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short gen_type, @@ -755,7 +755,7 @@ Image *BKE_image_add_generated( /* Create an image image from ibuf. The refcount of ibuf is increased, * caller should take care to drop its reference by calling * IMB_freeImBuf if needed. */ -Image *BKE_image_add_from_imbuf(ImBuf *ibuf, const char *name) +Image *BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name) { /* on save, type is changed to FILE in editsima.c */ Image *ima; @@ -764,7 +764,7 @@ Image *BKE_image_add_from_imbuf(ImBuf *ibuf, const char *name) name = BLI_path_basename(ibuf->name); } - ima = image_alloc(G.main, name, IMA_SRC_FILE, IMA_TYPE_IMAGE); + ima = image_alloc(bmain, name, IMA_SRC_FILE, IMA_TYPE_IMAGE); if (ima) { STRNCPY(ima->name, ibuf->name); @@ -933,12 +933,12 @@ void BKE_image_tag_time(Image *ima) } #if 0 -static void tag_all_images_time() +static void tag_all_images_time(Main *bmain) { Image *ima; int ctime = PIL_check_seconds_timer_i(); - ima = G.main->image.first; + ima = bmain->image.first; while (ima) { if (ima->bindcode || ima->repbind || ima->ibufs.first) { ima->lastused = ctime; @@ -992,17 +992,17 @@ static uintptr_t image_mem_size(Image *image) return size; } -void BKE_image_print_memlist(void) +void BKE_image_print_memlist(Main *bmain) { Image *ima; uintptr_t size, totsize = 0; - for (ima = G.main->image.first; ima; ima = ima->id.next) + for (ima = bmain->image.first; ima; ima = ima->id.next) totsize += image_mem_size(ima); printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024)); - for (ima = G.main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { size = image_mem_size(ima); if (size) @@ -1015,7 +1015,7 @@ static bool imagecache_check_dirty(ImBuf *ibuf, void *UNUSED(userkey), void *UNU return (ibuf->userflags & IB_BITMAPDIRTY) == 0; } -void BKE_image_free_all_textures(void) +void BKE_image_free_all_textures(Main *bmain) { #undef CHECK_FREED_SIZE @@ -1025,14 +1025,14 @@ void BKE_image_free_all_textures(void) uintptr_t tot_freed_size = 0; #endif - for (ima = G.main->image.first; ima; ima = ima->id.next) + for (ima = bmain->image.first; ima; ima = ima->id.next) ima->id.tag &= ~LIB_TAG_DOIT; - for (tex = G.main->tex.first; tex; tex = tex->id.next) + for (tex = bmain->tex.first; tex; tex = tex->id.next) if (tex->ima) tex->ima->id.tag |= LIB_TAG_DOIT; - for (ima = G.main->image.first; ima; ima = ima->id.next) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { if (ima->cache && (ima->id.tag & LIB_TAG_DOIT)) { #ifdef CHECK_FREED_SIZE uintptr_t old_size = image_mem_size(ima); @@ -1068,11 +1068,11 @@ void BKE_image_free_anim_ibufs(Image *ima, int except_frame) BLI_spin_unlock(&image_spin); } -void BKE_image_all_free_anim_ibufs(int cfra) +void BKE_image_all_free_anim_ibufs(Main *bmain, int cfra) { Image *ima; - for (ima = G.main->image.first; ima; ima = ima->id.next) + for (ima = bmain->image.first; ima; ima = ima->id.next) if (BKE_image_is_animated(ima)) BKE_image_free_anim_ibufs(ima, cfra); } @@ -2552,17 +2552,17 @@ struct anim *openanim(const char *name, int flags, int streamindex, char colorsp /* forces existence of 1 Image for renderout or nodes, returns Image */ /* name is only for default, when making new one */ -Image *BKE_image_verify_viewer(int type, const char *name) +Image *BKE_image_verify_viewer(Main *bmain, int type, const char *name) { Image *ima; - for (ima = G.main->image.first; ima; ima = ima->id.next) + for (ima = bmain->image.first; ima; ima = ima->id.next) if (ima->source == IMA_SRC_VIEWER) if (ima->type == type) break; if (ima == NULL) - ima = image_alloc(G.main, name, IMA_SRC_VIEWER, type); + ima = image_alloc(bmain, name, IMA_SRC_VIEWER, type); /* happens on reload, imagewindow cannot be image user when hidden*/ if (ima->id.us == 0) @@ -2713,7 +2713,7 @@ void BKE_image_init_imageuser(Image *ima, ImageUser *iuser) image_init_imageuser(ima, iuser); } -void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) +void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) { if (ima == NULL) return; @@ -2775,7 +2775,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) if (iuser) iuser->ok = 1; - BKE_image_walk_all_users(G.main, ima, image_tag_frame_recalc); + BKE_image_walk_all_users(bmain, ima, image_tag_frame_recalc); break; @@ -2787,13 +2787,13 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) if (totfiles != BLI_listbase_count_at_most(&ima->packedfiles, totfiles + 1)) { /* in case there are new available files to be loaded */ image_free_packedfiles(ima); - BKE_image_packfiles(NULL, ima, ID_BLEND_PATH(G.main, &ima->id)); + BKE_image_packfiles(NULL, ima, ID_BLEND_PATH(bmain, &ima->id)); } else { ImagePackedFile *imapf; for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) { PackedFile *pf; - pf = newPackedFile(NULL, imapf->filepath, ID_BLEND_PATH(G.main, &ima->id)); + pf = newPackedFile(NULL, imapf->filepath, ID_BLEND_PATH(bmain, &ima->id)); if (pf) { freePackedFile(imapf->packedfile); imapf->packedfile = pf; @@ -2845,7 +2845,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) * this also makes sure all scenes are accounted for. */ { Scene *scene; - for (scene = G.main->scene.first; scene; scene = scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->nodetree) { nodeUpdateID(scene->nodetree, &ima->id); } @@ -3537,7 +3537,7 @@ static ImBuf *load_image_single( BLI_addtail(&ima->packedfiles, imapf); STRNCPY(imapf->filepath, filepath); - imapf->packedfile = newPackedFile(NULL, filepath, ID_BLEND_PATH(G.main, &ima->id)); + imapf->packedfile = newPackedFile(NULL, filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); } } } @@ -4375,7 +4375,7 @@ void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath) BLI_stringenc(filepath, head, tail, numlen, frame); } - BLI_path_abs(filepath, ID_BLEND_PATH(G.main, &ima->id)); + BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); } bool BKE_image_has_alpha(struct Image *image) diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index e9ef7638da3..d376c90f1c2 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -481,9 +481,9 @@ int BKE_mesh_nurbs_displist_to_mdata( /* this may fail replacing ob->data, be sure to check ob->type */ -void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use_orco_uv, const char *obdata_name) +void BKE_mesh_from_nurbs_displist( + Main *bmain, Object *ob, ListBase *dispbase, const bool use_orco_uv, const char *obdata_name) { - Main *bmain = G.main; Object *ob1; DerivedMesh *dm = ob->derivedFinal; Mesh *me; @@ -571,7 +571,7 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use BKE_libblock_free_us(bmain, cu); } -void BKE_mesh_from_nurbs(Object *ob) +void BKE_mesh_from_nurbs(Main *bmain, Object *ob) { Curve *cu = (Curve *) ob->data; bool use_orco_uv = (cu->flag & CU_UV_ORCO) != 0; @@ -581,7 +581,7 @@ void BKE_mesh_from_nurbs(Object *ob) disp = ob->curve_cache->disp; } - BKE_mesh_from_nurbs_displist(ob, &disp, use_orco_uv, cu->id.name); + BKE_mesh_from_nurbs_displist(bmain, ob, &disp, use_orco_uv, cu->id.name); } typedef struct EdgeLink { @@ -741,7 +741,7 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e } } -void BKE_mesh_to_curve(Scene *scene, Object *ob) +void BKE_mesh_to_curve(Main *bmain, Scene *scene, Object *ob) { /* make new mesh data from the original copy */ DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH); @@ -752,7 +752,7 @@ void BKE_mesh_to_curve(Scene *scene, Object *ob) BKE_mesh_to_curve_nurblist(dm, &nurblist, 1); if (nurblist.first) { - Curve *cu = BKE_curve_add(G.main, ob->id.name + 2, OB_CURVE); + Curve *cu = BKE_curve_add(bmain, ob->id.name + 2, OB_CURVE); cu->flag |= CU_3D; cu->nurb = nurblist; @@ -849,14 +849,14 @@ Mesh *BKE_mesh_new_from_object( /* convert object type to mesh */ uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0; - BKE_mesh_from_nurbs_displist(tmpobj, &dispbase, uv_from_orco, tmpcu->id.name + 2); + BKE_mesh_from_nurbs_displist(bmain, tmpobj, &dispbase, uv_from_orco, tmpcu->id.name + 2); tmpmesh = tmpobj->data; BKE_displist_free(&dispbase); /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked. - * if it didn't the curve did not have any segments or otherwise + * if it didn't the curve did not have any segments or otherwise * would have generated an empty mesh */ if (tmpobj->type != OB_MESH) { BKE_libblock_free_us(bmain, tmpobj); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 062b8572be1..d03c11c7b2a 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2070,11 +2070,11 @@ void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree) /* merge local tree results back, and free local tree */ /* we have to assume the editor already changed completely */ -void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree) +void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree) { if (ntree && localtree) { if (ntree->typeinfo->local_merge) - ntree->typeinfo->local_merge(localtree, ntree); + ntree->typeinfo->local_merge(bmain, localtree, ntree); ntreeFreeTree(localtree); MEM_freeN(localtree); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index baa88f00985..07cd28da556 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -622,7 +622,7 @@ int unpackImage(Main *bmain, ReportList *reports, Image *ima, int how) } if (ret_value == RET_OK) { - BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD); } return(ret_value); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 4173a024552..b77fdf09b20 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -1134,7 +1134,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image) workpath = imagepath.c_str(); } - Image *ima = BKE_image_load_exists(workpath); + Image *ima = BKE_image_load_exists(CTX_data_main(mContext), workpath); if (!ima) { fprintf(stderr, "Cannot create image: %s\n", workpath); return true; diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 241ae20ce33..16e33c908d6 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -22,6 +22,7 @@ #include "COM_CompositorOperation.h" #include "BLI_listbase.h" +#include "BKE_global.h" #include "BKE_image.h" extern "C" { @@ -109,7 +110,7 @@ void CompositorOperation::deinitExecution() } BLI_thread_lock(LOCK_DRAW_IMAGE); - BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE); + BKE_image_signal(G.main, BKE_image_verify_viewer(G.main, IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE); BLI_thread_unlock(LOCK_DRAW_IMAGE); } else { diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index c8e89afc18a..4d203ebe4ef 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -107,7 +107,7 @@ void ED_node_composite_job(const struct bContext *C, struct bNodeTree *nodetree, void ED_operatormacros_node(void); /* node_view.c */ -bool ED_space_node_color_sample(struct SpaceNode *snode, struct ARegion *ar, int mval[2], float r_col[3]); +bool ED_space_node_color_sample(struct Main *bmain, struct SpaceNode *snode, struct ARegion *ar, int mval[2], float r_col[3]); #endif /* __ED_NODE_H__ */ diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index 052da74623f..7ba4b15a88f 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -38,6 +38,7 @@ #include "BLI_math_vector.h" #include "BKE_context.h" +#include "BKE_main.h" #include "BKE_screen.h" #include "RNA_access.h" @@ -131,6 +132,7 @@ static void eyedropper_exit(bContext *C, wmOperator *op) void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) { /* we could use some clever */ + Main *bmain = CTX_data_main(C); wmWindow *win = CTX_wm_window(C); ScrArea *sa = BKE_screen_find_area_xy(win->screen, SPACE_TYPE_ANY, mx, my); const char *display_device = CTX_data_scene(C)->display_settings.display_device; @@ -156,7 +158,7 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; - if (ED_space_node_color_sample(snode, ar, mval, r_col)) { + if (ED_space_node_color_sample(bmain, snode, ar, mval, r_col)) { return; } } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index c6da37d692e..519f5910624 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1570,7 +1570,7 @@ static void convert_ensure_curve_cache(Main *bmain, Scene *scene, Object *ob) static void curvetomesh(Main *bmain, Scene *scene, Object *ob) { convert_ensure_curve_cache(bmain, scene, ob); - BKE_mesh_from_nurbs(ob); /* also does users */ + BKE_mesh_from_nurbs(bmain, ob); /* also does users */ if (ob->type == OB_MESH) { BKE_object_free_modifiers(ob, 0); @@ -1724,7 +1724,7 @@ static int convert_exec(bContext *C, wmOperator *op) newob = ob; } - BKE_mesh_to_curve(scene, newob); + BKE_mesh_to_curve(bmain, scene, newob); if (newob->type == OB_CURVE) { BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */ diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 8a15179a46e..59538df7a05 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -314,8 +314,8 @@ static int screen_render_exec(bContext *C, wmOperator *op) G.is_break = false; RE_test_break_cb(re, NULL, render_break); - ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); - BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); + ima = BKE_image_verify_viewer(mainp, IMA_TYPE_R_RESULT, "Render Result"); + BKE_image_signal(mainp, ima, NULL, IMA_SIGNAL_FREE); BKE_image_backup_render(scene, ima, true); /* cleanup sequencer caches before starting user triggered render. @@ -551,7 +551,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec else if (rj->image_outdated) { /* update entire render */ rj->image_outdated = false; - BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE); + BKE_image_signal(rj->main, ima, NULL, IMA_SIGNAL_COLORMANAGE); *(rj->do_update) = true; return; } @@ -974,8 +974,8 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even WM_jobs_callbacks(wm_job, render_startjob, NULL, NULL, render_endjob); /* get a render result image, and make sure it is empty */ - ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); - BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); + ima = BKE_image_verify_viewer(mainp, IMA_TYPE_R_RESULT, "Render Result"); + BKE_image_signal(rj->main, ima, NULL, IMA_SIGNAL_FREE); BKE_image_backup_render(rj->scene, ima, true); rj->image = ima; diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index fa3b74d81ea..78cedf099a1 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -698,8 +698,8 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) oglrender->re = RE_NewSceneRender(scene); /* create image and image user */ - oglrender->ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); - BKE_image_signal(oglrender->ima, NULL, IMA_SIGNAL_FREE); + oglrender->ima = BKE_image_verify_viewer(oglrender->bmain, IMA_TYPE_R_RESULT, "Render Result"); + BKE_image_signal(oglrender->bmain, oglrender->ima, NULL, IMA_SIGNAL_FREE); BKE_image_backup_render(oglrender->scene, oglrender->ima, true); oglrender->iuser.scene = scene; diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index de1194fe93d..ffb982ce8c2 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -37,6 +37,7 @@ #include "BKE_context.h" #include "BKE_image.h" #include "BKE_global.h" +#include "BKE_main.h" #include "BKE_screen.h" #include "BKE_report.h" @@ -129,6 +130,7 @@ static ScrArea *find_area_image_empty(bContext *C) /* new window uses x,y to set position */ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); wmWindow *win = NULL; ScrArea *sa = NULL; @@ -211,7 +213,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) sima = sa->spacedata.first; /* get the correct image, and scale it */ - sima->image = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); + sima->image = BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result"); /* if we're rendering to full screen, set appropriate hints on image editor diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index a24599f813f..bf77c69a7f5 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -5473,7 +5473,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - image = BKE_image_add_from_imbuf(ibuf, "image_view"); + image = BKE_image_add_from_imbuf(bmain, ibuf, "image_view"); /* Drop reference to ibuf so that the image owns it */ IMB_freeImBuf(ibuf); @@ -5744,7 +5744,7 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) if (ima) { BKE_texpaint_slot_refresh_cache(scene, ma); - BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE); WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima); DAG_id_tag_update(&ma->id, 0); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 39a029fb9f0..087f3cdc7fe 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -78,7 +78,7 @@ void ED_space_image_set(Main *bmain, SpaceImage *sima, Scene *scene, Object *obe } if (sima->image) - BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); + BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); id_us_ensure_real((ID *)sima->image); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index bfebc850b08..2ce7da2126c 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1175,14 +1175,14 @@ static int image_sequence_get_len(ListBase *frames, int *ofs) } static Image *image_open_single( - wmOperator *op, const char *filepath, const char *relbase, + Main *bmain, wmOperator *op, const char *filepath, const char *relbase, bool is_relative_path, bool use_multiview, int frame_seq_len) { bool exists = false; Image *ima = NULL; errno = 0; - ima = BKE_image_load_exists_ex(filepath, &exists); + ima = BKE_image_load_exists_ex(bmain, filepath, &exists); if (!ima) { if (op->customdata) MEM_freeN(op->customdata); @@ -1263,7 +1263,7 @@ static int image_open_exec(bContext *C, wmOperator *op) } Image *ima_range = image_open_single( - op, filepath_range, BKE_main_blendfile_path(bmain), + bmain, op, filepath_range, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview, frame_range_seq_len); /* take the first image */ @@ -1278,7 +1278,7 @@ static int image_open_exec(bContext *C, wmOperator *op) else { /* for drag & drop etc. */ ima = image_open_single( - op, filepath, BKE_main_blendfile_path(bmain), + bmain, op, filepath, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview, 1); } @@ -1343,7 +1343,7 @@ static int image_open_exec(bContext *C, wmOperator *op) /* XXX unpackImage frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), bmain); - BKE_image_signal(ima, iuser, IMA_SIGNAL_RELOAD); + BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_RELOAD); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); MEM_freeN(op->customdata); @@ -1515,6 +1515,7 @@ void IMAGE_OT_match_movie_length(wmOperatorType *ot) static int image_replace_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); SpaceImage *sima = CTX_wm_space_image(C); char str[FILE_MAX]; @@ -1528,7 +1529,7 @@ static int image_replace_exec(bContext *C, wmOperator *op) if (sima->image->source == IMA_SRC_GENERATED) { sima->image->source = IMA_SRC_FILE; - BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE); + BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE); } if (BLI_testextensie_array(str, imb_ext_movie)) @@ -1540,7 +1541,7 @@ static int image_replace_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); BKE_icon_changed(BKE_icon_id_ensure(&sima->image->id)); - BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_RELOAD); + BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_RELOAD); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image); return OPERATOR_FINISHED; @@ -1731,7 +1732,7 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op) } static void save_image_post( - wmOperator *op, ImBuf *ibuf, Image *ima, int ok, int save_copy, + Main *bmain, wmOperator *op, ImBuf *ibuf, Image *ima, int ok, int save_copy, const char *relbase, int relative, int do_newpath, const char *filepath) { if (ok) { @@ -1777,7 +1778,7 @@ static void save_image_post( if (!BKE_color_managed_colorspace_settings_equals(&old_colorspace_settings, &ima->colorspace_settings)) { - BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE); } } } @@ -1808,6 +1809,7 @@ static void save_imbuf_post(ImBuf *ibuf, ImBuf *colormanaged_ibuf) */ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, bool do_newpath) { + Main *bmain = CTX_data_main(C); Image *ima = ED_space_image(sima); void *lock; ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); @@ -1885,7 +1887,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI if (imf->views_format == R_IMF_VIEWS_MULTIVIEW && is_exr_rr) { /* save render result */ ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, sima->iuser.layer); - save_image_post(op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath); + save_image_post(bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath); ED_space_image_release_buffer(sima, ibuf, lock); } /* regular mono pipeline */ @@ -1898,7 +1900,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI ok = BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, imf, save_copy); save_imbuf_post(ibuf, colormanaged_ibuf); } - save_image_post(op, ibuf, ima, ok, (is_exr_rr ? true : save_copy), relbase, relative, do_newpath, simopts->filepath); + save_image_post(bmain, op, ibuf, ima, ok, (is_exr_rr ? true : save_copy), relbase, relative, do_newpath, simopts->filepath); ED_space_image_release_buffer(sima, ibuf, lock); } /* individual multiview images */ @@ -1920,7 +1922,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI if (is_exr_rr) { BKE_scene_multiview_view_filepath_get(&scene->r, simopts->filepath, view, filepath); ok_view = RE_WriteRenderResult(op->reports, rr, filepath, imf, view, -1); - save_image_post(op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath); + save_image_post(bmain, op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath); } else { /* copy iuser to get the correct ibuf for this view */ @@ -1941,7 +1943,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, true, &imf->view_settings, &imf->display_settings, imf); ok_view = BKE_imbuf_write_as(colormanaged_ibuf, filepath, &simopts->im_format, save_copy); save_imbuf_post(ibuf, colormanaged_ibuf); - save_image_post(op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath); + save_image_post(bmain, op, ibuf, ima, ok_view, true, relbase, relative, do_newpath, filepath); BKE_image_release_ibuf(sima->image, ibuf, lock); } ok &= ok_view; @@ -1955,7 +1957,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI else if (simopts->im_format.views_format == R_IMF_VIEWS_STEREO_3D) { if (imf->imtype == R_IMF_IMTYPE_MULTILAYER) { ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, imf, NULL, -1); - save_image_post(op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath); + save_image_post(bmain, op, ibuf, ima, ok, true, relbase, relative, do_newpath, simopts->filepath); ED_space_image_release_buffer(sima, ibuf, lock); } else { @@ -2333,6 +2335,7 @@ void IMAGE_OT_save_sequence(wmOperatorType *ot) static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); Image *ima = CTX_data_edit_image(C); SpaceImage *sima = CTX_wm_space_image(C); @@ -2343,7 +2346,7 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); // XXX other users? - BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_RELOAD); + BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_RELOAD); DAG_id_tag_update(&ima->id, 0); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); @@ -2482,7 +2485,7 @@ static int image_new_exec(bContext *C, wmOperator *op) } } - BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE); + BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE); WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima); @@ -3604,7 +3607,7 @@ static int image_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) SpaceImage *sima = CTX_wm_space_image(C); Image *ima; - ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); + ima = BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result"); if (sima->image == NULL) { ED_space_image_set(bmain, sima, scene, NULL, ima); } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 4d12ebfb16b..63bd305c13d 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3234,6 +3234,7 @@ void ED_init_node_socket_type_virtual(bNodeSocketType *stype) void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeInstanceKey parent_key) { + Main *bmain = CTX_data_main(C); bNodeInstanceKey active_viewer_key = (snode->nodetree ? snode->nodetree->active_viewer_key : NODE_INSTANCE_KEY_NONE); Image *ima; void *lock; @@ -3245,7 +3246,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b if (parent_key.value != active_viewer_key.value) return; - ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf) { float x, y; diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index edd19617a0f..10dbda08280 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -304,6 +304,7 @@ void NODE_OT_add_reroute(wmOperatorType *ot) static int node_add_file_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); SpaceNode *snode = CTX_wm_space_node(C); bNode *node; Image *ima; @@ -353,7 +354,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) * to get proper image source. */ if (RNA_struct_property_is_set(op->ptr, "filepath")) { - BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 1cb387bb527..388c403d42e 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -87,6 +87,7 @@ enum { }; typedef struct CompoJob { + Main *bmain; Scene *scene; bNodeTree *ntree; bNodeTree *localtree; @@ -182,7 +183,7 @@ static void compo_freejob(void *cjv) CompoJob *cj = cjv; if (cj->localtree) { - ntreeLocalMerge(cj->localtree, cj->ntree); + ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree); } MEM_freeN(cj); } @@ -266,6 +267,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene { wmJob *wm_job; CompoJob *cj; + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); /* to fix bug: [#32272] */ @@ -277,13 +279,14 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene G.is_break = false; #endif - BKE_image_backup_render(scene, BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), false); + BKE_image_backup_render(scene, BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result"), false); wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene_owner, "Compositing", WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, WM_JOB_TYPE_COMPOSITE); cj = MEM_callocN(sizeof(CompoJob), "compo job"); /* customdata for preview thread */ + cj->bmain = bmain; cj->scene = scene; cj->ntree = nodetree; cj->recalc_flags = compo_get_recalc_flags(C); @@ -687,7 +690,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) ED_node_tag_update_nodetree(bmain, ntree, node); /* addnode() doesnt link this yet... */ - node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + node->id = (ID *)BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); } else if (node->type == CMP_NODE_R_LAYERS) { Scene *scene; @@ -2501,13 +2504,14 @@ static void viewer_border_corner_to_backdrop(SpaceNode *snode, ARegion *ar, int static int viewer_border_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Image *ima; void *lock; ImBuf *ibuf; - ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); + ED_preview_kill_jobs(CTX_wm_manager(C), bmain); - ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf) { diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index d52a6a89413..00eab0c69c1 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -36,8 +36,9 @@ #include "BKE_context.h" #include "BKE_image.h" -#include "BKE_screen.h" +#include "BKE_main.h" #include "BKE_node.h" +#include "BKE_screen.h" #include "ED_node.h" /* own include */ #include "ED_screen.h" @@ -238,6 +239,7 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + Main *bmain = CTX_data_main(C); SpaceNode *snode = CTX_wm_space_node(C); ARegion *ar = CTX_wm_region(C); NodeViewMove *nvm; @@ -247,7 +249,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent * void *lock; - ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf == NULL) { @@ -331,6 +333,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot) static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); SpaceNode *snode = CTX_wm_space_node(C); ARegion *ar = CTX_wm_region(C); @@ -343,7 +346,7 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op)) float facx, facy; - ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if ((ibuf == NULL) || (ibuf->x == 0) || (ibuf->y == 0)) { @@ -421,7 +424,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) /* Returns color in linear space, matching ED_space_image_color_sample(). * And here we've got recursion in the comments tips... */ -bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float r_col[3]) +bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *ar, int mval[2], float r_col[3]) { void *lock; Image *ima; @@ -436,7 +439,7 @@ bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], floa return false; } - ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (!ibuf) { return false; @@ -477,6 +480,7 @@ bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], floa static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) { + Main *bmain = CTX_data_main(C); SpaceNode *snode = CTX_wm_space_node(C); ARegion *ar = CTX_wm_region(C); ImageSampleInfo *info = op->customdata; @@ -485,7 +489,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) ImBuf *ibuf; float fx, fy, bufx, bufy; - ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (!ibuf) { info->draw = 0; diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index dbd61cf6450..1d85ba43995 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -583,7 +583,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain, Scene DAG_id_tag_update(&ima->id, 0); - BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE); WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id); WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 741e3dfae60..bab8c18439f 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -104,12 +104,12 @@ static void rna_Image_source_set(PointerRNA *ptr, int value) if (value != ima->source) { ima->source = value; - BKE_image_signal(ima, NULL, IMA_SIGNAL_SRC_CHANGE); + BKE_image_signal(G.main, ima, NULL, IMA_SIGNAL_SRC_CHANGE); DAG_id_tag_update(&ima->id, 0); } } -static void rna_Image_fields_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Image_fields_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Image *ima = ptr->id.data; ImBuf *ibuf; @@ -124,36 +124,36 @@ static void rna_Image_fields_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P if ((ima->flag & IMA_FIELDS) && !(ibuf->flags & IB_fields)) nr = 1; if (nr) - BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE); } BKE_image_release_ibuf(ima, ibuf, lock); } -static void rna_Image_reload_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Image_reload_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Image *ima = ptr->id.data; - BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD); WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id); DAG_id_tag_update(&ima->id, 0); } -static void rna_Image_generated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Image_generated_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Image *ima = ptr->id.data; - BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE); } -static void rna_Image_colormanage_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Image_colormanage_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { Image *ima = ptr->id.data; - BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_COLORMANAGE); DAG_id_tag_update(&ima->id, 0); WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id); WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id); } -static void rna_Image_views_format_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +static void rna_Image_views_format_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Image *ima = ptr->id.data; ImBuf *ibuf; @@ -164,7 +164,7 @@ static void rna_Image_views_format_update(Main *UNUSED(bmain), Scene *scene, Poi if (ibuf) { ImageUser iuser = {NULL}; iuser.scene = scene; - BKE_image_signal(ima, &iuser, IMA_SIGNAL_FREE); + BKE_image_signal(bmain, ima, &iuser, IMA_SIGNAL_FREE); } BKE_image_release_ibuf(ima, ibuf, lock); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index b50e263e01d..cb8fa6c6c85 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -192,9 +192,9 @@ static void rna_Image_unpack(Image *image, Main *bmain, ReportList *reports, int } } -static void rna_Image_reload(Image *image) +static void rna_Image_reload(Image *image, Main *bmain) { - BKE_image_signal(image, NULL, IMA_SIGNAL_RELOAD); + BKE_image_signal(bmain, image, NULL, IMA_SIGNAL_RELOAD); } static void rna_Image_update(Image *image, ReportList *reports) @@ -336,6 +336,7 @@ void RNA_api_image(StructRNA *srna) RNA_def_enum(func, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "method", "How to unpack"); func = RNA_def_function(srna, "reload", "rna_Image_reload"); + RNA_def_function_flag(func, FUNC_USE_MAIN); RNA_def_function_ui_description(func, "Reload the image from its source path"); func = RNA_def_function(srna, "update", "rna_Image_update"); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 7d5c327f25a..6d5ec5f508e 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -338,7 +338,7 @@ static Image *rna_Main_images_load(Main *bmain, ReportList *reports, const char errno = 0; if (check_existing) { - ima = BKE_image_load_exists(filepath); + ima = BKE_image_load_exists(bmain, filepath); } else { ima = BKE_image_load(bmain, filepath); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index e2a581821f3..9bb5117cba3 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2634,7 +2634,7 @@ static void rna_Node_image_layer_update(Main *bmain, Scene *scene, PointerRNA *p ImageUser *iuser = node->storage; BKE_image_multilayer_index(ima->rr, iuser); - BKE_image_signal(ima, iuser, IMA_SIGNAL_SRC_CHANGE); + BKE_image_signal(bmain, ima, iuser, IMA_SIGNAL_SRC_CHANGE); rna_Node_update(bmain, scene, ptr); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index cb5844f1b03..8db03d7a437 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2141,7 +2141,7 @@ static void rna_GPUDOFSettings_update(Main *UNUSED(bmain), Scene *scene, Pointer WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); } -static void rna_Stereo3dFormat_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Stereo3dFormat_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { ID *id = ptr->id.data; @@ -2156,7 +2156,7 @@ static void rna_Stereo3dFormat_update(Main *UNUSED(bmain), Scene *UNUSED(scene), ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf) { - BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); + BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_FREE); } BKE_image_release_ibuf(ima, ibuf, lock); } diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 4779fdd33d2..ab9d041198c 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -134,7 +134,7 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) BKE_node_preview_sync_tree(ntree, localtree); } -static void local_merge(bNodeTree *localtree, bNodeTree *ntree) +static void local_merge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree) { bNode *lnode; bNodeSocket *lsock; @@ -147,7 +147,7 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) if (ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { if (lnode->id && (lnode->flag & NODE_DO_OUTPUT)) { /* image_merge does sanity check for pointers */ - BKE_image_merge((Image *)lnode->new_node->id, (Image *)lnode->id); + BKE_image_merge(bmain, (Image *)lnode->new_node->id, (Image *)lnode->id); } } else if (lnode->type == CMP_NODE_MOVIEDISTORTION) { diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index dbe47066f66..f7008bc9ae4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -33,6 +33,7 @@ #include "node_composite_util.h" #include "BKE_image.h" +#include "BKE_global.h" /* **************** SPLIT VIEWER ******************** */ static bNodeSocketTemplate cmp_node_splitviewer_in[] = { @@ -50,7 +51,7 @@ static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node iuser->ok = 1; node->custom1 = 50; /* default 50% split */ - node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + node->id = (ID *)BKE_image_verify_viewer(G.main, IMA_TYPE_COMPOSITE, "Viewer Node"); } void register_node_type_cmp_splitviewer(void) diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index a10ba02b38e..f82b0d7206a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -33,6 +33,7 @@ #include "node_composite_util.h" #include "BKE_image.h" +#include "BKE_global.h" /* **************** VIEWER ******************** */ @@ -53,7 +54,7 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node) node->custom3 = 0.5f; node->custom4 = 0.5f; - node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + node->id = (ID *)BKE_image_verify_viewer(G.main, IMA_TYPE_COMPOSITE, "Viewer Node"); } void register_node_type_cmp_viewer(void) diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 34ec76df710..e63dd1d9990 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -157,7 +157,7 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) BKE_node_preview_sync_tree(ntree, localtree); } -static void local_merge(bNodeTree *localtree, bNodeTree *ntree) +static void local_merge(Main *UNUSED(bmain), bNodeTree *localtree, bNodeTree *ntree) { BKE_node_preview_merge_tree(ntree, localtree, true); } diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index b77e0a32fbc..abaaf338ed7 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -163,7 +163,7 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) BKE_node_preview_sync_tree(ntree, localtree); } -static void local_merge(bNodeTree *localtree, bNodeTree *ntree) +static void local_merge(Main *UNUSED(bmain), bNodeTree *localtree, bNodeTree *ntree) { BKE_node_preview_merge_tree(ntree, localtree, true); } diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 8105f94cb31..ba4bca35a34 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -4779,7 +4779,7 @@ void RE_Database_Free(Render *re) /* statistics for debugging render memory usage */ if ((G.debug & G_DEBUG) && (G.is_rendering)) { if ((re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0) { - BKE_image_print_memlist(); + BKE_image_print_memlist(re->main); MEM_printmemlist_stats(); } } @@ -4841,7 +4841,7 @@ void RE_Database_Free(Render *re) if (re->scene) if (re->scene->r.scemode & R_FREE_IMAGE) if ((re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0) - BKE_image_free_all_textures(); + BKE_image_free_all_textures(re->main); if (re->memArena) { BLI_memarena_free(re->memArena); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 707f126b202..1df21e47c66 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2879,7 +2879,7 @@ static void do_render_all_options(Render *re) re->i.starttime = PIL_check_seconds_timer(); /* ensure no images are in memory from previous animated sequences */ - BKE_image_all_free_anim_ibufs(re->r.cfra); + BKE_image_all_free_anim_ibufs(re->main, re->r.cfra); BKE_sequencer_all_free_anim_ibufs(re->r.cfra); if (RE_engine_render(re, 1)) { diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index b9f44a00df7..aa89cd6d1ef 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -48,6 +48,7 @@ #include "BKE_context.h" #include "BKE_image.h" +#include "BKE_main.h" #include "GHOST_C-api.h" @@ -689,6 +690,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoViews sview) { + Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); wmDrawData *drawdata; wmDrawTriple *triple_data, *triple_all; @@ -754,7 +756,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV { SpaceNode *snode = sa->spacedata.first; if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) { - Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); ima->eye = sview; } break; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index fa3dddb9e30..208a9e1ee06 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1319,7 +1319,7 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i errno = 0; if (idcode == ID_IM) { - id = (ID *)BKE_image_load_exists_ex(path, &exists); + id = (ID *)BKE_image_load_exists_ex(bmain, path, &exists); } else { BLI_assert(0); -- cgit v1.2.3