Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / render / render_internal.c
index 9d98a3676ac156e5aacda3d35415626eedcb2417..f3987b8eb397adb2fe9e812f57731b40d97adfce 100644 (file)
@@ -54,7 +54,6 @@
 #include "BKE_camera.h"
 #include "BKE_context.h"
 #include "BKE_colortools.h"
-#include "BKE_depsgraph.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
 #include "BKE_library.h"
@@ -66,6 +65,8 @@
 #include "BKE_screen.h"
 #include "BKE_scene.h"
 
+#include "DEG_depsgraph.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -81,6 +82,7 @@
 #include "IMB_colormanagement.h"
 #include "IMB_imbuf_types.h"
 
+#include "GPU_shader.h"
 
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
@@ -306,6 +308,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
        }
 
        re = RE_NewRender(scene->id.name);
+       RE_SetDepsgraph(re, CTX_data_depsgraph(C));
        lay_override = (v3d && v3d->lay != scene->lay) ? v3d->lay : 0;
 
        G.is_break = false;
@@ -489,8 +492,9 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr,
        for (wm = rj->main->wm.first; wm && matched_sa == NULL; wm = wm->id.next) { /* only 1 wm */
                wmWindow *win;
                for (win = wm->windows.first; win && matched_sa == NULL; win = win->next) {
-                       ScrArea *sa;
-                       for (sa = win->screen->areabase.first; sa; sa = sa->next) {
+                       const bScreen *screen = WM_window_get_active_screen(win);
+
+                       for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                                if (sa->spacetype == SPACE_IMAGE) {
                                        SpaceImage *sima = sa->spacedata.first;
                                        // sa->spacedata might be empty when toggling fullscreen mode.
@@ -616,8 +620,9 @@ static void render_image_restore_layer(RenderJob *rj)
        for (wm = rj->main->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
                wmWindow *win;
                for (win = wm->windows.first; win; win = win->next) {
-                       ScrArea *sa;
-                       for (sa = win->screen->areabase.first; sa; sa = sa->next) {
+                       const bScreen *screen = WM_window_get_active_screen(win);
+
+                       for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
                                if (sa == rj->sa) {
                                        if (sa->spacetype == SPACE_IMAGE) {
                                                SpaceImage *sima = sa->spacedata.first;
@@ -718,7 +723,7 @@ static void render_endjob(void *rjv)
                        scene->lay_updated = 0;
                }
 
-               DAG_on_visible_update(G.main, false);
+               DEG_on_visible_update(G.main, false);
        }
 }
 
@@ -782,7 +787,7 @@ static void screen_render_cancel(bContext *C, wmOperator *op)
        WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_RENDER);
 }
 
-static void clean_viewport_memory(Main *bmain, Scene *scene, int renderlay)
+static void clean_viewport_memory(Main *bmain, Scene *scene)
 {
        Object *object;
        Scene *sce_iter;
@@ -793,7 +798,7 @@ static void clean_viewport_memory(Main *bmain, Scene *scene, int renderlay)
        }
 
        for (SETLOOPER(scene, sce_iter, base)) {
-               if ((base->lay & renderlay) == 0) {
+               if ((base->flag & BASE_VISIBLED) == 0) {
                        continue;
                }
                if (RE_allow_render_generic_object(base->object)) {
@@ -930,8 +935,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
 
        /* Lock the user interface depending on render settings. */
        if (scene->r.use_lock_interface) {
-               int renderlay = rj->lay_override ? rj->lay_override : scene->lay;
-
                WM_set_locked_interface(CTX_wm_manager(C), true);
 
                /* Set flag interface need to be unlocked.
@@ -945,7 +948,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
                rj->interface_locked = true;
 
                /* Clean memory used by viewport? */
-               clean_viewport_memory(rj->main, scene, renderlay);
+               clean_viewport_memory(rj->main, scene);
        }
 
        /* setup job */
@@ -971,6 +974,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
        RE_current_scene_update_cb(re, rj, current_scene_update);
        RE_stats_draw_cb(re, rj, image_renderinfo_cb);
        RE_progress_cb(re, rj, render_progress_update);
+       RE_SetDepsgraph(re, CTX_data_depsgraph(C));
 
        rj->re = re;
        G.is_break = false;
@@ -1542,11 +1546,10 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C)
                if (force_fallback == false) {
                        if (IMB_colormanagement_setup_glsl_draw(&scene->view_settings, &scene->display_settings, dither, true)) {
                                glEnable(GL_BLEND);
-                               glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-                               glPixelZoom(scale_x, scale_y);
-                               glaDrawPixelsTex(xof, yof, rres.rectx, rres.recty,
-                                                GL_RGBA, GL_FLOAT, GL_NEAREST, rres.rectf);
-                               glPixelZoom(1.0f, 1.0f);
+                               IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
+                               immDrawPixelsTex(&state, xof, yof, rres.rectx, rres.recty,
+                                                GL_RGBA, GL_FLOAT, GL_NEAREST, rres.rectf,
+                                                scale_x, scale_y, NULL);;
                                glDisable(GL_BLEND);
 
                                IMB_colormanagement_finish_glsl_draw();
@@ -1563,12 +1566,11 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C)
                                                                      4, dither, &scene->view_settings, &scene->display_settings);
 
                        glEnable(GL_BLEND);
-                       glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-                       glPixelZoom(scale_x, scale_y);
-                       glaDrawPixelsAuto(xof, yof, rres.rectx, rres.recty,
-                                         GL_RGBA, GL_UNSIGNED_BYTE,
-                                         GL_NEAREST, display_buffer);
-                       glPixelZoom(1.0f, 1.0f);
+                       IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
+                       immDrawPixelsTex(&state, xof, yof, rres.rectx, rres.recty,
+                                        GL_RGBA, GL_UNSIGNED_BYTE,
+                                        GL_NEAREST, display_buffer,
+                                        scale_x, scale_y, NULL);
                        glDisable(GL_BLEND);
 
                        MEM_freeN(display_buffer);