diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-11 16:40:37 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-11 16:40:37 +0300 |
commit | 78a8d3685bd3487eb0b5dd55793f94fe7235e377 (patch) | |
tree | 77f9ba0ddd9613eb7e9dbb8e0402f977548a281f /source/blender/blenkernel | |
parent | b763c34e80d3b20f9a7f0a592e479e5fa7ab295f (diff) |
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 ;)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/bpath.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 62 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_convert.c | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/packedFile.c | 2 |
8 files changed, 57 insertions, 57 deletions
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); |