Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-06-11 16:40:37 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-06-11 16:40:37 +0300
commit78a8d3685bd3487eb0b5dd55793f94fe7235e377 (patch)
tree77f9ba0ddd9613eb7e9dbb8e0402f977548a281f /source/blender/blenkernel/intern/image.c
parentb763c34e80d3b20f9a7f0a592e479e5fa7ab295f (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/intern/image.c')
-rw-r--r--source/blender/blenkernel/intern/image.c62
1 files changed, 31 insertions, 31 deletions
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)