From 8a7f317666caa41aad0428b5ed3f399cdfbbd816 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 25 Jun 2018 12:32:48 +0200 Subject: Cleanup: Nuke most of G.main from GPU code. --- source/blender/editors/sculpt_paint/paint_image.c | 10 +++++----- source/blender/editors/space_outliner/outliner_edit.c | 2 +- source/blender/editors/space_view3d/view3d_draw.c | 6 +++--- source/blender/editors/space_view3d/view3d_view.c | 8 +++++--- 4 files changed, 14 insertions(+), 12 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index cee7801a9cb..2ada62b028b 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1024,6 +1024,7 @@ static int texture_paint_toggle_poll(bContext *C) static int texture_paint_toggle_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_TEXTURE_PAINT; @@ -1039,14 +1040,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) ob->mode &= ~mode_flag; if (U.glreslimit != 0) - GPU_free_images(); - GPU_paint_set_mipmap(1); + GPU_free_images(bmain); + GPU_paint_set_mipmap(bmain, 1); toggle_paint_cursor(C, 0); } else { bScreen *sc; - Main *bmain = CTX_data_main(C); Image *ima = NULL; ImagePaintSettings *imapaint = &scene->toolsettings->imapaint; @@ -1089,8 +1089,8 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) BKE_paint_init(bmain, scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT); if (U.glreslimit != 0) - GPU_free_images(); - GPU_paint_set_mipmap(0); + GPU_free_images(bmain); + GPU_paint_set_mipmap(bmain, 0); toggle_paint_cursor(C, 1); } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 7d5ff560b28..d547b419d48 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -435,7 +435,7 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op) DAG_scene_relations_rebuild(bmain, scene); /* free gpu materials, some materials depend on existing objects, such as lamps so freeing correctly refreshes */ - GPU_materials_free(); + GPU_materials_free(bmain); WM_event_add_notifier(C, NC_WINDOW, NULL); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index bf92fcfff33..fbf2bd33638 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -3021,7 +3021,7 @@ static void view3d_draw_objects( } if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) { - GPU_free_images_old(); + GPU_free_images_old(bmain); } } @@ -3206,7 +3206,7 @@ void ED_view3d_draw_offscreen( if ((v3d->flag2 & V3D_RENDER_SHADOW) == 0) { /* free images which can have changed on frame-change * warning! can be slow so only free animated images - campbell */ - GPU_free_images_anim(); + GPU_free_images_anim(bmain); } /* setup view matrices before fx or unbinding the offscreen buffers will cause issues */ @@ -3260,7 +3260,7 @@ void ED_view3d_draw_offscreen( } /* freeing the images again here could be done after the operator runs, leaving for now */ - GPU_free_images_anim(); + GPU_free_images_anim(bmain); } /* restore size */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 608580c0a08..0f09d7fefa2 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1319,12 +1319,13 @@ void VIEW3D_OT_localview(wmOperatorType *ot) static ListBase queue_back; static void game_engine_save_state(bContext *C, wmWindow *win) { + Main *bmain = CTX_data_main(C); Object *obact = CTX_data_active_object(C); glPushAttrib(GL_ALL_ATTRIB_BITS); if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) - GPU_paint_set_mipmap(1); + GPU_paint_set_mipmap(bmain, 1); queue_back = win->queue; @@ -1333,10 +1334,11 @@ static void game_engine_save_state(bContext *C, wmWindow *win) static void game_engine_restore_state(bContext *C, wmWindow *win) { + Main *bmain = CTX_data_main(C); Object *obact = CTX_data_active_object(C); if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) - GPU_paint_set_mipmap(0); + GPU_paint_set_mipmap(bmain, 0); /* check because closing win can set to NULL */ if (win) { @@ -1358,7 +1360,7 @@ static void game_set_commmandline_options(GameData *gm) if ((syshandle = SYS_GetSystem())) { /* User defined settings */ test = (U.gameflags & USER_DISABLE_MIPMAP); - GPU_set_mipmap(!test); + GPU_set_mipmap(G_MAIN, !test); SYS_WriteCommandLineInt(syshandle, "nomipmap", test); /* File specific settings: */ -- cgit v1.2.3