Merge branch 'master' into blender2.8

Conflicts:
	source/blender/blenkernel/BKE_mesh.h
	source/blender/blenkernel/intern/mesh_convert.c
	source/blender/editors/interface/interface_eyedropper_color.c
	source/blender/editors/object/object_add.c
	source/blender/editors/space_image/image_ops.c
	source/blender/makesrna/intern/rna_image.c
	source/blender/windowmanager/intern/wm_draw.c
This commit is contained in:
Bastien Montagne 2018-06-11 16:02:46 +02:00
commit 204c167c72
44 changed files with 182 additions and 152 deletions

View File

@ -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);

View File

@ -145,10 +145,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, bool temporary);
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, bool temporary);
void BKE_mesh_from_nurbs(struct Main *bmain, struct Object *ob);
void BKE_mesh_to_curve_nurblist(const struct Mesh *me, struct ListBase *nurblist, const int edge_users_test);
void BKE_mesh_to_curve(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_mesh_to_curve(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
void BKE_mesh_material_index_remove(struct Mesh *me, short index);
void BKE_mesh_material_index_clear(struct Mesh *me);
void BKE_mesh_material_remap(struct Mesh *me, const unsigned int *remap, unsigned int remap_len);

View File

@ -293,7 +293,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);
@ -371,7 +371,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);
/** \} */

View File

@ -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);
}
}

View File

@ -498,7 +498,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) {
@ -516,7 +516,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);
}
}
@ -615,7 +615,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];
@ -624,10 +624,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) ||
@ -646,12 +646,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,
@ -753,7 +753,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;
@ -762,7 +762,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);
@ -931,12 +931,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;
@ -990,17 +990,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)
@ -1013,7 +1013,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
@ -1023,14 +1023,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);
@ -1066,11 +1066,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);
}
@ -2548,17 +2548,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)
@ -2709,7 +2709,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;
@ -2771,7 +2771,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;
@ -2783,13 +2783,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;
@ -2841,7 +2841,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);
}
@ -3533,7 +3533,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));
}
}
}
@ -4371,7 +4371,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)

View File

@ -544,9 +544,9 @@ Mesh *BKE_mesh_new_nomain_from_curve(Object *ob)
}
/* 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, bool temporary)
void BKE_mesh_from_nurbs_displist(
Main *bmain, Object *ob, ListBase *dispbase, const bool use_orco_uv, const char *obdata_name, bool temporary)
{
Main *bmain = G.main;
Object *ob1;
DerivedMesh *dm = ob->derivedFinal;
Mesh *me;
@ -642,7 +642,7 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use
}
}
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;
@ -652,7 +652,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, false);
BKE_mesh_from_nurbs_displist(bmain, ob, &disp, use_orco_uv, cu->id.name, false);
}
typedef struct EdgeLink {
@ -812,7 +812,7 @@ void BKE_mesh_to_curve_nurblist(const Mesh *me, ListBase *nurblist, const int ed
}
}
void BKE_mesh_to_curve(Depsgraph *depsgraph, Scene *scene, Object *ob)
void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
{
/* make new mesh data from the original copy */
Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_MESH);
@ -823,7 +823,7 @@ void BKE_mesh_to_curve(Depsgraph *depsgraph, Scene *scene, Object *ob)
BKE_mesh_to_curve_nurblist(me_eval, &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;
@ -929,7 +929,7 @@ 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, true);
BKE_mesh_from_nurbs_displist(bmain, tmpobj, &dispbase, uv_from_orco, tmpcu->id.name + 2, true);
tmpmesh = tmpobj->data;

View File

@ -2050,11 +2050,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);

View File

@ -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);

View File

@ -1085,7 +1085,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;

View File

@ -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 {

View File

@ -43,7 +43,7 @@ struct ViewLayer;
/* image_edit.c, exported for transform */
struct Image *ED_space_image(struct SpaceImage *sima);
void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
struct Mask *ED_space_image_get_mask(struct SpaceImage *sima);
void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);

View File

@ -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__ */

View File

@ -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);
bScreen *screen = CTX_wm_screen(C);
ScrArea *sa = BKE_screen_find_area_xy(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;
}
}

View File

@ -1635,10 +1635,10 @@ static void convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *scene, Objec
}
}
static void curvetomesh(Depsgraph *depsgraph, Scene *scene, Object *ob)
static void curvetomesh(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
{
convert_ensure_curve_cache(depsgraph, 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);
@ -1785,7 +1785,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = ob;
}
BKE_mesh_to_curve(depsgraph, scene, newob);
BKE_mesh_to_curve(bmain, depsgraph, scene, newob);
if (newob->type == OB_CURVE) {
BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
@ -1887,7 +1887,7 @@ static int convert_exec(bContext *C, wmOperator *op)
BKE_curve_curve_dimension_update(cu);
if (target == OB_MESH) {
curvetomesh(depsgraph, scene, newob);
curvetomesh(bmain, depsgraph, scene, newob);
/* meshes doesn't use displist */
BKE_object_free_curve_cache(newob);
@ -1911,7 +1911,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = ob;
}
curvetomesh(depsgraph, scene, newob);
curvetomesh(bmain, depsgraph, scene, newob);
/* meshes doesn't use displist */
BKE_object_free_curve_cache(newob);

View File

@ -332,8 +332,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.
@ -570,7 +570,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;
}
@ -1002,8 +1002,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(bmain, 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;

View File

@ -705,8 +705,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;

View File

@ -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"
@ -131,6 +132,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;
@ -213,7 +215,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

View File

@ -1109,7 +1109,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
if (!sima->pin) {
Object *obedit = CTX_data_edit_object(C);
ED_space_image_set(sima, scene, obedit, ima);
ED_space_image_set(bmain, sima, scene, obedit, ima);
}
}
}

View File

@ -5437,6 +5437,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
ImBuf *ibuf;
char filename[FILE_MAX];
Main *bmain = CTX_data_main(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
@ -5466,7 +5467,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);
@ -5698,7 +5699,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);
DEG_id_tag_update(&ma->id, 0);
ED_area_tag_redraw(CTX_wm_area(C));

View File

@ -64,7 +64,7 @@ Image *ED_space_image(SpaceImage *sima)
}
/* called to assign images to UV faces */
void ED_space_image_set(SpaceImage *sima, Scene *UNUSED(scene), Object *obedit, Image *ima)
void ED_space_image_set(Main *bmain, SpaceImage *sima, Scene *UNUSED(scene), Object *obedit, Image *ima)
{
/* change the space ima after because uvedit_face_visible_test uses the space ima
* to check if the face is displayed in UV-localview */
@ -77,7 +77,7 @@ void ED_space_image_set(SpaceImage *sima, Scene *UNUSED(scene), Object *obedit,
}
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);

View File

@ -1179,14 +1179,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);
@ -1267,7 +1267,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 */
@ -1282,7 +1282,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);
}
@ -1308,7 +1308,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
}
else if (sa && sa->spacetype == SPACE_IMAGE) {
SpaceImage *sima = sa->spacedata.first;
ED_space_image_set(sima, scene, obedit, ima);
ED_space_image_set(bmain, sima, scene, obedit, ima);
iuser = &sima->iuser;
}
else {
@ -1349,7 +1349,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);
@ -1521,6 +1521,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];
@ -1534,7 +1535,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))
@ -1546,7 +1547,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;
@ -1737,7 +1738,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) {
@ -1783,7 +1784,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);
}
}
}
@ -1814,6 +1815,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);
@ -1891,7 +1893,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 */
@ -1904,7 +1906,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 */
@ -1926,7 +1928,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 */
@ -1947,7 +1949,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;
@ -1961,7 +1963,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 {
@ -2339,6 +2341,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);
@ -2349,7 +2352,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);
DEG_id_tag_update(&ima->id, 0);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
@ -2441,7 +2444,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
RNA_property_update(C, &ptr, prop);
}
else if (sima) {
ED_space_image_set(sima, scene, obedit, ima);
ED_space_image_set(bmain, sima, scene, obedit, ima);
}
else if (gen_context == GEN_CONTEXT_PAINT_CANVAS) {
bScreen *sc;
@ -2460,7 +2463,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
SpaceImage *sima_other = (SpaceImage *)sl;
if (!sima_other->pin) {
ED_space_image_set(sima_other, scene, obedit, ima);
ED_space_image_set(bmain, sima_other, scene, obedit, ima);
}
}
}
@ -2487,7 +2490,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,13 +3607,14 @@ void IMAGE_OT_change_frame(wmOperatorType *ot)
/* goes over all scenes, reads render layers */
static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
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(sima, scene, NULL, ima);
ED_space_image_set(bmain, sima, scene, NULL, ima);
}
RE_ReadRenderResult(scene, scene);

View File

@ -3151,6 +3151,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);
float shuffle[4] = {0.0f, 0.0f, 0.0f, 0.0f};
Image *ima;
@ -3163,7 +3164,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;

View File

@ -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;
@ -343,7 +344,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);
}

View File

@ -88,6 +88,7 @@ enum {
};
typedef struct CompoJob {
Main *bmain;
Scene *scene;
bNodeTree *ntree;
bNodeTree *localtree;
@ -183,7 +184,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);
}
@ -267,6 +268,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] */
@ -278,13 +280,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);
@ -673,7 +676,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_COMPOSITE) {
if (was_output == 0) {
@ -2437,13 +2440,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) {

View File

@ -31,6 +31,7 @@
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "ED_screen.h"
#include "ED_manipulator_library.h"
@ -140,13 +141,14 @@ static void WIDGETGROUP_node_transform_setup(const bContext *UNUSED(C), wmManipu
static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
Main *bmain = CTX_data_main(C);
wmManipulator *cage = ((wmManipulatorWrapper *)mgroup->customdata)->manipulator;
const ARegion *ar = CTX_wm_region(C);
/* center is always at the origin */
const float origin[3] = {ar->winx / 2, ar->winy / 2};
void *lock;
Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
@ -340,11 +342,12 @@ static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmManipulatorG
static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
Main *bmain = CTX_data_main(C);
struct NodeCropWidgetGroup *crop_group = mgroup->customdata;
wmManipulator *mpr = crop_group->border;
void *lock;
Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
@ -451,11 +454,12 @@ static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmManipulator
static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
Main *bmain = CTX_data_main(C);
struct NodeSunBeamsWidgetGroup *sbeam_group = mgroup->customdata;
wmManipulator *mpr = sbeam_group->manipulator;
void *lock;
Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {
@ -563,10 +567,11 @@ static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmManipu
static void WIDGETGROUP_node_corner_pin_refresh(const bContext *C, wmManipulatorGroup *mgroup)
{
Main *bmain = CTX_data_main(C);
struct NodeCornerPinWidgetGroup *cpin_group = mgroup->customdata;
void *lock;
Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
Image *ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf) {

View File

@ -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;

View File

@ -557,7 +557,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain, Scene
DEG_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);

View File

@ -92,12 +92,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);
DEG_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;
@ -112,36 +112,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);
DEG_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);
DEG_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;
@ -152,7 +152,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);

View File

@ -189,9 +189,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)
@ -335,6 +335,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");

View File

@ -346,7 +346,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);

View File

@ -160,7 +160,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s
if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
if (!sima->pin) {
ED_space_image_set(sima, scene, obedit, image);
ED_space_image_set(bmain, sima, scene, obedit, image);
}
}
}

View File

@ -2620,7 +2620,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);

View File

@ -1981,7 +1981,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;
@ -1996,7 +1996,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);
}

View File

@ -412,7 +412,7 @@ static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr))
SpaceImage *sima = (SpaceImage *)slink;
if (!sima->pin)
ED_space_image_set(sima, scene, obedit, ima);
ED_space_image_set(bmain, sima, scene, obedit, ima);
}
}
}

View File

@ -920,7 +920,7 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
Scene *scene = ED_screen_scene_find_with_window(sc, G.main->wm.first, &win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
ED_space_image_set(sima, scene, obedit, (Image *)value.data);
ED_space_image_set(G.main, sima, scene, obedit, (Image *)value.data);
}
static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value)

View File

@ -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) {

View File

@ -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)

View File

@ -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)

View File

@ -153,7 +153,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);
}

View File

@ -141,7 +141,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);
}

View File

@ -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);

View File

@ -1835,7 +1835,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)) {

View File

@ -50,6 +50,7 @@
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_screen.h"
#include "BKE_scene.h"
#include "BKE_workspace.h"
@ -118,7 +119,7 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
}
static bool wm_draw_region_stereo_set(ScrArea *sa, ARegion *ar, eStereoViews sview)
static bool wm_draw_region_stereo_set(Main *bmain, ScrArea *sa, ARegion *ar, eStereoViews sview)
{
/* We could detect better when stereo is actually needed, by inspecting the
* image in the image editor and sequencer. */
@ -149,7 +150,7 @@ static bool wm_draw_region_stereo_set(ScrArea *sa, ARegion *ar, eStereoViews svi
{
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;
return true;
}
@ -488,6 +489,7 @@ GPUViewport *WM_draw_region_get_bound_viewport(ARegion *ar)
static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
bScreen *screen = WM_window_get_active_screen(win);
@ -512,7 +514,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
CTX_wm_region_set(C, ar);
bool use_viewport = wm_region_use_viewport(sa, ar);
if (stereo && wm_draw_region_stereo_set(sa, ar, STEREO_LEFT_ID)) {
if (stereo && wm_draw_region_stereo_set(bmain, sa, ar, STEREO_LEFT_ID)) {
wm_draw_region_buffer_create(ar, true, use_viewport);
for (int view = 0; view < 2; view++) {
@ -522,7 +524,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
}
else {
sview = STEREO_RIGHT_ID;
wm_draw_region_stereo_set(sa, ar, sview);
wm_draw_region_stereo_set(bmain, sa, ar, sview);
}
wm_draw_region_bind(ar, view);

View File

@ -1421,7 +1421,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);