Workspace: Move engines to workspace and Properties Editor cleanup
[blender.git] / source / blender / editors / space_view3d / view3d_draw.c
index ed4d7861d6d6dd8a3437ca69eff1a7ce7a9a2028..ec2dcc75bc0535120afdf7e3fad6cbef6d2fa588 100644 (file)
@@ -1880,10 +1880,11 @@ static void view3d_draw_view(const bContext *C, ARegion *ar)
 void view3d_main_region_draw(const bContext *C, ARegion *ar)
 {
        Scene *scene = CTX_data_scene(C);
+       WorkSpace *workspace = CTX_wm_workspace(C);
        View3D *v3d = CTX_wm_view3d(C);
        RegionView3D *rv3d = ar->regiondata;
-       /* XXX: In the future we should get RE from Layers/Depsgraph */
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       ViewRender *view_render = BKE_viewrender_get(scene, workspace);
+       RenderEngineType *type = RE_engines_find(view_render->engine_id);
 
        /* Provisory Blender Internal drawing */
        if (type->flag & RE_USE_LEGACY_PIPELINE) {
@@ -1931,7 +1932,7 @@ static void view3d_stereo3d_setup_offscreen(
 
 void ED_view3d_draw_offscreen_init(const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d)
 {
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       RenderEngineType *type = eval_ctx->engine;
        if (type->flag & RE_USE_LEGACY_PIPELINE) {
                /* shadow buffers, before we setup matrices */
                if (draw_glsl_material(scene, sl, NULL, v3d, v3d->drawtype)) {
@@ -1959,7 +1960,8 @@ static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar)
  * stuff like shadow buffers
  */
 void ED_view3d_draw_offscreen(
-        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, int winx, int winy,
+        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer,
+        View3D *v3d, ARegion *ar, int winx, int winy,
         float viewmat[4][4], float winmat[4][4],
         bool do_bgpic, bool do_sky, bool is_persp, const char *viewname,
         GPUFX *fx, GPUFXSettings *fx_settings,
@@ -2013,7 +2015,7 @@ void ED_view3d_draw_offscreen(
                view3d_main_region_setup_view(eval_ctx, scene, v3d, ar, viewmat, winmat, NULL);
 
        /* main drawing call */
-       RenderEngineType *type = RE_engines_find(scene->r.engine);
+       RenderEngineType *type = eval_ctx->engine;
        if (type->flag & RE_USE_LEGACY_PIPELINE) {
 
                /* framebuffer fx needed, we need to draw offscreen first */
@@ -2055,8 +2057,8 @@ void ED_view3d_draw_offscreen(
        }
        else {
                /* XXX, should take depsgraph as arg */
-               Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl);
-               DRW_draw_render_loop_offscreen(depsgraph, ar, v3d, ofs);
+               Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer);
+               DRW_draw_render_loop_offscreen(depsgraph, eval_ctx->engine, ar, v3d, ofs);
        }
 
        /* restore size */
@@ -2079,7 +2081,8 @@ void ED_view3d_draw_offscreen(
  * (avoids re-creating when doing multiple GL renders).
  */
 ImBuf *ED_view3d_draw_offscreen_imbuf(
-        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *ar, int sizex, int sizey,
+        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer,
+        View3D *v3d, ARegion *ar, int sizex, int sizey,
         unsigned int flag, bool draw_background,
         int alpha_mode, int samples, bool full_samples, const char *viewname,
         /* output vars */
@@ -2108,7 +2111,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
                }
        }
 
-       ED_view3d_draw_offscreen_init(eval_ctx, scene, sl, v3d);
+       ED_view3d_draw_offscreen_init(eval_ctx, scene, scene_layer, v3d);
 
        GPU_offscreen_bind(ofs, true);
 
@@ -2150,7 +2153,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
        if ((samples && full_samples) == 0) {
                /* Single-pass render, common case */
                ED_view3d_draw_offscreen(
-                       eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat,
+                       eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, NULL, winmat,
                        draw_background, draw_sky, !is_ortho, viewname,
                        fx, &fx_settings, ofs);
 
@@ -2174,7 +2177,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
 
                /* first sample buffer, also initializes 'rv3d->persmat' */
                ED_view3d_draw_offscreen(
-                       eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat,
+                       eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, NULL, winmat,
                        draw_background, draw_sky, !is_ortho, viewname,
                        fx, &fx_settings, ofs);
                GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp);
@@ -2193,7 +2196,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
                                (jit_ofs[j][1] * 2.0f) / sizey);
 
                        ED_view3d_draw_offscreen(
-                               eval_ctx, scene, sl, v3d, ar, sizex, sizey, NULL, winmat_jitter,
+                               eval_ctx, scene, scene_layer, v3d, ar, sizex, sizey, NULL, winmat_jitter,
                                draw_background, draw_sky, !is_ortho, viewname,
                                fx, &fx_settings, ofs);
                        GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp);
@@ -2244,7 +2247,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
  * \note used by the sequencer
  */
 ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
-        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, Object *camera, int width, int height,
+        const EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer,
+        Object *camera, int width, int height,
         unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background,
         int alpha_mode, int samples, bool full_samples, const char *viewname,
         GPUFX *fx, GPUOffScreen *ofs, char err_out[256])
@@ -2298,7 +2302,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
        invert_m4_m4(rv3d.persinv, rv3d.viewinv);
 
        return ED_view3d_draw_offscreen_imbuf(
-               eval_ctx, scene, sl, &v3d, &ar, width, height, flag,
+               eval_ctx, scene, scene_layer, &v3d, &ar, width, height, flag,
                draw_background, alpha_mode, samples, full_samples, viewname,
                fx, ofs, err_out);
 }