Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Wed, 13 Sep 2017 13:44:13 +0000 (23:44 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 13 Sep 2017 13:44:13 +0000 (23:44 +1000)
1  2 
source/blender/blenkernel/intern/action.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/object/object_bake_api.c
source/blender/editors/space_node/drawnode.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_animation.c
source/blender/makesrna/intern/rna_render.c
source/blender/makesrna/intern/rna_userdef.c
tests/python/CMakeLists.txt

index 00b9e0a283b109d241ae568409b824079a16afce,5bd6085c8f5e2433b45eb3fb6e752516107b4f5e..6f7b3286e40a45fb3466a15604ef4065e1bee318
@@@ -55,6 -55,7 +55,6 @@@
  #include "BKE_animsys.h"
  #include "BKE_constraint.h"
  #include "BKE_deform.h"
 -#include "BKE_depsgraph.h"
  #include "BKE_fcurve.h"
  #include "BKE_global.h"
  #include "BKE_idprop.h"
@@@ -64,8 -65,6 +64,8 @@@
  #include "BKE_main.h"
  #include "BKE_object.h"
  
 +#include "DEG_depsgraph_build.h"
 +
  #include "BIK_api.h"
  
  #include "RNA_access.h"
@@@ -588,8 -587,6 +588,8 @@@ void BKE_pose_copy_data_ex(bPose **dst
                if (pchan->prop) {
                        pchan->prop = IDP_CopyProperty_ex(pchan->prop, flag);
                }
 +
 +              pchan->draw_data = NULL;  /* Drawing cache, no need to copy. */
        }
  
        /* for now, duplicate Bone Groups too when doing this */
@@@ -783,9 -780,6 +783,9 @@@ void BKE_pose_channel_free_ex(bPoseChan
                IDP_FreeProperty(pchan->prop);
                MEM_freeN(pchan->prop);
        }
 +
 +      /* Cached data, for new draw manager rendering code. */
 +      MEM_SAFE_FREE(pchan->draw_data);
  }
  
  void BKE_pose_channel_free(bPoseChannel *pchan)
@@@ -1135,9 -1129,13 +1135,13 @@@ void calc_action_range(const bAction *a
                        if (fcu->totvert) {
                                float nmin, nmax;
                                
-                               /* get extents for this curve */
-                               /* TODO: allow enabling/disabling this? */
-                               calc_fcurve_range(fcu, &nmin, &nmax, false, true);
+                               /* get extents for this curve
+                                * - no "selected only", since this is often used in the backend
+                                * - no "minimum length" (we will apply this later), otherwise
+                                *   single-keyframe curves will increase the overall length by
+                                *   a phantom frame (T50354)
+                                */
+                               calc_fcurve_range(fcu, &nmin, &nmax, false, false);
                                
                                /* compare to the running tally */
                                min = min_ff(min, nmin);
        }
        
        if (foundvert || foundmod) {
+               /* ensure that action is at least 1 frame long (for NLA strips to have a valid length) */
                if (min == max) max += 1.0f;
+               
                *start = min;
                *end = max;
        }
@@@ -1423,7 -1423,7 +1429,7 @@@ void BKE_pose_tag_recalc(Main *bmain, b
        /* Depsgraph components depends on actual pose state,
         * if pose was changed depsgraph is to be updated as well.
         */
 -      DAG_relations_tag_update(bmain);
 +      DEG_relations_tag_update(bmain);
  }
  
  /* For the calculation of the effects of an Action at the given frame on an object 
index f9c90713f400654af6f6c8d7f2c083d840f1b930,68a5dd8a94e472c2e495fb90ef60901b5a1d1cb4..797262c685be3fc7d93ad4782b444d84b3b80684
@@@ -82,7 -82,6 +82,7 @@@ typedef struct bAnimContext 
        struct bDopeSheet *ads; /* dopesheet data for editor (or which is being used) */
        
        struct Scene *scene;    /* active scene */
 +      struct SceneLayer *scene_layer; /* active scene layer */
        struct Object *obact;   /* active object */
        ListBase *markers;      /* active set of markers */
        
@@@ -125,6 -124,15 +125,15 @@@ typedef struct bAnimListElem 
        void   *key_data;       /* motion data - mostly F-Curves, but can be other types too */
        
        
+       /* NOTE: id here is the "IdAdtTemplate"-style datablock (e.g. Object, Material, Texture, NodeTree)
+        *       from which evaluation of the RNA-paths takes place. It's used to figure out how deep
+        *       channels should be nested (e.g. for Textures/NodeTrees) in the tree, and allows property
+        *       lookups (e.g. for sliders and for inserting keyframes) to work. If we had instead used
+        *       bAction or something similar, none of this would be possible: although it's trivial
+        *       to use an IdAdtTemplate type to find the source action a channel (e.g. F-Curve) comes from
+        *       (i.e. in the AnimEditors, it *must* be the active action, as only that can be edited),
+        *       it's impossible to go the other way (i.e. one action may be used in multiple places).
+        */
        struct ID *id;          /* ID block that channel is attached to */
        struct AnimData *adt;   /* source of the animation data attached to ID block (for convenience) */
        
index eb2d1117f1ece9bb32e961c81c5e3f59d468f0f0,d25730d7c109bf8a2ddc07a5f6b2de8dc96a0229..0a4989ebad43c872b9aeb963c4020305a3e58d18
@@@ -57,8 -57,7 +57,8 @@@
  #include "BKE_modifier.h"
  #include "BKE_mesh.h"
  #include "BKE_screen.h"
 -#include "BKE_depsgraph.h"
 +
 +#include "DEG_depsgraph.h"
  
  #include "RE_engine.h"
  #include "RE_pipeline.h"
@@@ -84,7 -83,6 +84,7 @@@ static void bake_set_props(wmOperator *
  typedef struct BakeAPIRender {
        Object *ob;
        Main *main;
 +      Depsgraph *depsgraph;
        Scene *scene;
        ReportList *reports;
        ListBase selected_objects;
@@@ -274,7 -272,7 +274,7 @@@ static void refresh_images(BakeImages *
                Image *ima = bake_images->data[i].image;
                if (ima->ok == IMA_OK_LOADED) {
                        GPU_free_image(ima);
 -                      DAG_id_tag_update(&ima->id, 0);         
 +                      DEG_id_tag_update(&ima->id, 0);         
                }
        }
  }
@@@ -621,19 -619,21 +621,21 @@@ static size_t initialize_internal_image
  }
  
  /* create new mesh with edit mode changes and modifiers applied */
 -static Mesh *bake_mesh_new_from_object(Main *bmain, Scene *scene, Object *ob)
 +static Mesh *bake_mesh_new_from_object(EvaluationContext *eval_ctx, Main *bmain, Scene *scene, Object *ob)
  {
        if (ob->mode & OB_MODE_EDIT)
                ED_object_editmode_load(ob);
  
 -      Mesh *me = BKE_mesh_new_from_object(bmain, scene, ob, 1, 2, 0, 0);
 +      Mesh *me = BKE_mesh_new_from_object(eval_ctx, bmain, scene, ob, 1, 2, 0, 0);
-       BKE_mesh_split_faces(me, true);
+       if (me->flag & ME_AUTOSMOOTH) {
+               BKE_mesh_split_faces(me, true);
+       }
  
        return me;
  }
  
  static int bake(
 -        Render *re, Main *bmain, Scene *scene, Object *ob_low, ListBase *selected_objects, ReportList *reports,
 +        Render *re, Main *bmain, Depsgraph *graph, Scene *scene, Object *ob_low, ListBase *selected_objects, ReportList *reports,
          const ScenePassType pass_type, const int pass_filter, const int margin,
          const BakeSaveMode save_mode, const bool is_clear, const bool is_split_materials,
          const bool is_automatic_name, const bool is_selected_to_active, const bool is_cage,
        size_t num_pixels;
        int tot_materials;
  
 -      RE_bake_engine_set_engine_parameters(re, bmain, scene);
 +      RE_bake_engine_set_engine_parameters(re, bmain, graph, scene);
  
        if (!RE_bake_has_engine(re)) {
                BKE_report(reports, RPT_ERROR, "Current render engine does not support baking");
        }
  
        /* get the mesh as it arrives in the renderer */
 -      me_low = bake_mesh_new_from_object(bmain, scene, ob_low);
 +      me_low = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, ob_low);
  
        /* populate the pixel array with the face data */
        if ((is_selected_to_active && (ob_cage == NULL) && is_cage) == false)
  
                /* prepare cage mesh */
                if (ob_cage) {
 -                      me_cage = bake_mesh_new_from_object(bmain, scene, ob_cage);
 +                      me_cage = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, ob_cage);
                        if ((me_low->totpoly != me_cage->totpoly) || (me_low->totloop != me_cage->totloop)) {
                                BKE_report(reports, RPT_ERROR,
                                           "Invalid cage object, the cage mesh must have the same number "
                        ob_low->modifiers = modifiers_tmp;
  
                        /* get the cage mesh as it arrives in the renderer */
 -                      me_cage = bake_mesh_new_from_object(bmain, scene, ob_low);
 +                      me_cage = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, ob_low);
                        RE_bake_pixels_populate(me_cage, pixel_array_low, num_pixels, &bake_images, uv_layer);
                }
  
                        tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
                        tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP;
  
 -                      highpoly[i].me = bake_mesh_new_from_object(bmain, scene, highpoly[i].ob);
 +                      highpoly[i].me = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, highpoly[i].ob);
                        highpoly[i].ob->restrictflag &= ~OB_RESTRICT_RENDER;
  
                        /* lowpoly to highpoly transformation matrix */
@@@ -959,7 -959,7 +961,7 @@@ cage_cleanup
                                                md->mode &= ~eModifierMode_Render;
                                        }
  
 -                                      me_nores = bake_mesh_new_from_object(bmain, scene, ob_low);
 +                                      me_nores = bake_mesh_new_from_object(RE_GetEvalCtx(re), bmain, scene, ob_low);
                                        RE_bake_pixels_populate(me_nores, pixel_array_low, num_pixels, &bake_images, uv_layer);
  
                                        RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_nores, normal_swizzle, ob_low->obmat);
@@@ -1120,7 -1120,6 +1122,7 @@@ static void bake_init_api_data(wmOperat
  
        bkr->ob = CTX_data_active_object(C);
        bkr->main = CTX_data_main(C);
 +      bkr->depsgraph = CTX_data_depsgraph(C);
        bkr->scene = CTX_data_scene(C);
        bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL;
  
@@@ -1204,7 -1203,7 +1206,7 @@@ static int bake_exec(bContext *C, wmOpe
  
        if (bkr.is_selected_to_active) {
                result = bake(
 -                      bkr.render, bkr.main, bkr.scene, bkr.ob, &bkr.selected_objects, bkr.reports,
 +                      bkr.render, bkr.main, bkr.depsgraph, bkr.scene, bkr.ob, &bkr.selected_objects, bkr.reports,
                        bkr.pass_type, bkr.pass_filter, bkr.margin, bkr.save_mode,
                        bkr.is_clear, bkr.is_split_materials, bkr.is_automatic_name, true, bkr.is_cage,
                        bkr.cage_extrusion, bkr.normal_space, bkr.normal_swizzle,
                for (link = bkr.selected_objects.first; link; link = link->next) {
                        Object *ob_iter = link->ptr.data;
                        result = bake(
 -                              bkr.render, bkr.main, bkr.scene, ob_iter, NULL, bkr.reports,
 +                              bkr.render, bkr.main, bkr.depsgraph, bkr.scene, ob_iter, NULL, bkr.reports,
                                bkr.pass_type, bkr.pass_filter, bkr.margin, bkr.save_mode,
                                is_clear, bkr.is_split_materials, bkr.is_automatic_name, false, bkr.is_cage,
                                bkr.cage_extrusion, bkr.normal_space, bkr.normal_swizzle,
@@@ -1262,7 -1261,7 +1264,7 @@@ static void bake_startjob(void *bkv, sh
  
        if (bkr->is_selected_to_active) {
                bkr->result = bake(
 -                      bkr->render, bkr->main, bkr->scene, bkr->ob, &bkr->selected_objects, bkr->reports,
 +                      bkr->render, bkr->main, bkr->depsgraph, bkr->scene, bkr->ob, &bkr->selected_objects, bkr->reports,
                        bkr->pass_type, bkr->pass_filter, bkr->margin, bkr->save_mode,
                        bkr->is_clear, bkr->is_split_materials, bkr->is_automatic_name, true, bkr->is_cage,
                        bkr->cage_extrusion, bkr->normal_space, bkr->normal_swizzle,
                for (link = bkr->selected_objects.first; link; link = link->next) {
                        Object *ob_iter = link->ptr.data;
                        bkr->result = bake(
 -                              bkr->render, bkr->main, bkr->scene, ob_iter, NULL, bkr->reports,
 +                              bkr->render, bkr->main, bkr->depsgraph, bkr->scene, ob_iter, NULL, bkr->reports,
                                bkr->pass_type, bkr->pass_filter, bkr->margin, bkr->save_mode,
                                is_clear, bkr->is_split_materials, bkr->is_automatic_name, false, bkr->is_cage,
                                bkr->cage_extrusion, bkr->normal_space, bkr->normal_swizzle,
index bee2379cd8195523fc6dc2fd23f5648ea9bf8f6f,7ef34669ee2a9790e837ac1d5b227c7ac86a68f9..67584fbe1f152667d9106bc43ac406a384758d18
  #include "BLF_api.h"
  #include "BLT_translation.h"
  
 -#include "BIF_gl.h"
  #include "BIF_glutil.h"
  
 +#include "GPU_draw.h"
 +#include "GPU_immediate.h"
 +#include "GPU_matrix.h"
 +
  #include "RNA_access.h"
  #include "RNA_define.h"
  
@@@ -65,7 -62,6 +65,7 @@@
  #include "WM_types.h"
  
  #include "UI_resources.h"
 +#include "UI_view2d.h"
  
  #include "IMB_colormanagement.h"
  #include "IMB_imbuf_types.h"
@@@ -84,6 -80,49 +84,6 @@@ static void node_socket_button_label(bC
        uiItemL(layout, text, 0);
  }
  
 -
 -/* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
 -
 -#if 0 /* UNUSED */
 -static void node_draw_socket_new(bNodeSocket *sock, float size)
 -{
 -      float x = sock->locx, y = sock->locy;
 -      
 -      /* 16 values of sin function */
 -      static float si[16] = {
 -              0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
 -              0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f,
 -              -0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f,
 -              -0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f
 -      };
 -      /* 16 values of cos function */
 -      static float co[16] = {
 -              1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f,
 -              -0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f,
 -              -0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
 -              0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f,
 -      };
 -      int a;
 -      
 -      glColor3ub(180, 180, 180);
 -      
 -      glBegin(GL_POLYGON);
 -      for (a = 0; a < 16; a++)
 -              glVertex2f(x + size * si[a], y + size * co[a]);
 -      glEnd();
 -      
 -      glColor4ub(0, 0, 0, 150);
 -      glEnable(GL_BLEND);
 -      glEnable(GL_LINE_SMOOTH);
 -      glBegin(GL_LINE_LOOP);
 -      for (a = 0; a < 16; a++)
 -              glVertex2f(x + size * si[a], y + size * co[a]);
 -      glEnd();
 -      glDisable(GL_LINE_SMOOTH);
 -      glDisable(GL_BLEND);
 -}
 -#endif
 -
  /* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */
  
  static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@@ -353,7 -392,6 +353,7 @@@ static void node_draw_frame_label(bNode
        const int font_size = data->label_size / aspect;
        const float margin = (float)(NODE_DY / 4);
        int label_height;
 +      unsigned char color[3];
  
        nodeLabel(ntree, node, label, sizeof(label));
  
        BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
        
        /* title color */
 -      UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10);
 +      UI_GetThemeColorBlendShade3ubv(TH_TEXT, color_id, 0.4f, 10, color);
 +      BLF_color3ubv(fontid, color);
  
        width = BLF_width(fontid, label, sizeof(label));
        ascender = BLF_ascender(fontid);
@@@ -428,7 -465,7 +428,7 @@@ static void node_draw_frame(const bCont
  {
        rctf *rct = &node->totr;
        int color_id = node_get_colorid(node);
 -      unsigned char color[4];
 +      float color[4];
        float alpha;
        
        /* skip if out of view */
                return;
        }
  
 -      UI_GetThemeColor4ubv(TH_NODE_FRAME, color);
 -      alpha = (float)(color[3]) / 255.0f;
 +      UI_GetThemeColor4fv(TH_NODE_FRAME, color);
 +      alpha = color[3];
        
        /* shadow */
        node_draw_shadow(snode, node, BASIS_RAD, alpha);
        
        /* body */
 -      if (node->flag & NODE_CUSTOM_COLOR)
 -              glColor4f(node->color[0], node->color[1], node->color[2], alpha);
 +      if (node->flag & NODE_CUSTOM_COLOR) {
 +              rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], alpha);
 +      }
        else
 -              UI_ThemeColor4(TH_NODE_FRAME);
 -      glEnable(GL_BLEND);
 +              UI_GetThemeColor4fv(TH_NODE_FRAME, color);
 +
        UI_draw_roundbox_corner_set(UI_CNR_ALL);
 -      UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD);
 -      glDisable(GL_BLEND);
 +      UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
  
        /* outline active and selected emphasis */
        if (node->flag & SELECT) {
 -              glEnable(GL_BLEND);
 -              glEnable(GL_LINE_SMOOTH);
 -              
                if (node->flag & NODE_ACTIVE)
 -                      UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40);
 +                      UI_GetThemeColorShadeAlpha4fv(TH_ACTIVE, 0, -40, color);
                else
 -                      UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40);
 -              UI_draw_roundbox_corner_set(UI_CNR_ALL);
 -              UI_draw_roundbox_gl_mode(GL_LINE_LOOP,
 -                        rct->xmin, rct->ymin,
 -                        rct->xmax, rct->ymax, BASIS_RAD);
 -              
 -              glDisable(GL_LINE_SMOOTH);
 -              glDisable(GL_BLEND);
 +                      UI_GetThemeColorShadeAlpha4fv(TH_SELECT, 0, -40, color);
 +
 +              UI_draw_roundbox_aa(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
        }
 -      
 +
        /* label */
        node_draw_frame_label(ntree, node, snode->aspect);
        
@@@ -535,9 -580,15 +535,9 @@@ static void node_draw_reroute_prepare(c
  static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(snode),
                                bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key))
  {
 -      bNodeSocket *sock;
        char showname[128]; /* 128 used below */
        rctf *rct = &node->totr;
  
 -#if 0   /* UNUSED */
 -      float size = NODE_REROUTE_SIZE;
 -#endif
 -      float socket_size = NODE_SOCKSIZE;
 -
        /* skip if out of view */
        if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
            node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax)
         * selection state is indicated by socket outline below!
         */
  #if 0
 +      float size = NODE_REROUTE_SIZE;
 +
        /* body */
 +      float debug_color[4];
        UI_draw_roundbox_corner_set(UI_CNR_ALL);
 -      UI_ThemeColor4(TH_NODE);
 -      glEnable(GL_BLEND);
 -      UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
 -      glDisable(GL_BLEND);
 +      UI_GetThemeColor4fv(TH_NODE, debug_color);
 +      UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size, debug_color);
  
        /* outline active and selected emphasis */
        if (node->flag & SELECT) {
                glEnable(GL_BLEND);
                glEnable(GL_LINE_SMOOTH);
                /* using different shades of TH_TEXT_HI for the empasis, like triangle */
 -              if (node->flag & NODE_ACTIVE)
 -                      UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40);
 -              else
 -                      UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120);
 -              UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
 +              if (node->flag & NODE_ACTIVE) {
 +                      UI_GetThemeColorShadeAlpha4fv(TH_TEXT_HI, 0, -40, debug_color);
 +              }
 +              else {
 +                      UI_GetThemeColorShadeAlpha4fv(TH_TEXT_HI, -20, -120, debug_color);
 +              }
 +              UI_draw_roundbox_4fv(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size, debug_color);
  
                glDisable(GL_LINE_SMOOTH);
                glDisable(GL_BLEND);
        /* only draw input socket. as they all are placed on the same position.
         * highlight also if node itself is selected, since we don't display the node body separately!
         */
 -      for (sock = node->inputs.first; sock; sock = sock->next) {
 -              node_socket_draw(C, ntree, node, sock, socket_size, (sock->flag & SELECT) || (node->flag & SELECT));
 -      }
 +      node_draw_sockets(&ar->v2d, C, ntree, node, false, node->flag & SELECT);
  
        UI_block_end(C, node->block);
        UI_block_draw(C, node->block);
@@@ -748,7 -798,7 +748,7 @@@ static void node_shader_buts_geometry(u
        if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
                PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
  
 -              uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_textures", "", ICON_NONE);
 +              uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_layers", "", ICON_NONE);
                uiItemPointerR(col, ptr, "color_layer", &dataptr, "vertex_colors", "", ICON_NONE);
        }
        else {
@@@ -966,7 -1016,7 +966,7 @@@ static void node_shader_buts_uvmap(uiLa
  
                if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
                        PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
 -                      uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
 +                      uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE);
                }
        }
  }
@@@ -985,7 -1035,7 +985,7 @@@ static void node_shader_buts_normal_map
  
                if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
                        PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
 -                      uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
 +                      uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE);
                }
                else
                        uiItemR(layout, ptr, "uv_map", 0, "", 0);
@@@ -1007,7 -1057,7 +1007,7 @@@ static void node_shader_buts_tangent(ui
  
                if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
                        PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
 -                      uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
 +                      uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE);
                }
                else
                        uiItemR(row, ptr, "uv_map", 0, "", 0);
@@@ -2154,24 -2204,18 +2154,25 @@@ static void node_composit_backdrop_view
        if (node->custom1 == 0) {
                const float backdropWidth = backdrop->x;
                const float backdropHeight = backdrop->y;
-               const float cx  = x + snode->zoom * backdropWidth * node->custom3;
+               const float cx = x + snode->zoom * backdropWidth  * node->custom3;
                const float cy = y + snode->zoom * backdropHeight * node->custom4;
+               const float cross_size = 12 * U.pixelsize;
  
 -              glColor3f(1.0, 1.0, 1.0);
 +              Gwn_VertFormat *format = immVertexFormat();
 +              unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
  
 -              glBegin(GL_LINES);
 -              glVertex2f(cx - cross_size, cy - cross_size);
 -              glVertex2f(cx + cross_size, cy + cross_size);
 -              glVertex2f(cx + cross_size, cy - cross_size);
 -              glVertex2f(cx - cross_size, cy + cross_size);
 -              glEnd();
 +              immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +
 +              immUniformColor3f(1.0f, 1.0f, 1.0f);
 +
 +              immBegin(GWN_PRIM_LINES, 4);
-               immVertex2f(pos, cx - 25, cy - 25);
-               immVertex2f(pos, cx + 25, cy + 25);
-               immVertex2f(pos, cx + 25, cy - 25);
-               immVertex2f(pos, cx - 25, cy + 25);
++              immVertex2f(pos, cx - cross_size, cy - cross_size);
++              immVertex2f(pos, cx + cross_size, cy + cross_size);
++              immVertex2f(pos, cx + cross_size, cy - cross_size);
++              immVertex2f(pos, cx - cross_size, cy + cross_size);
 +              immEnd();
 +
 +              immUnbindProgram();
        }
  }
  
@@@ -2190,6 -2234,9 +2191,6 @@@ static void node_composit_backdrop_boxm
        float cx, cy, x1, x2, x3, x4;
        float y1, y2, y3, y4;
  
 -
 -      glColor3f(1.0, 1.0, 1.0);
 -
        cx  = x + snode->zoom * backdropWidth * boxmask->x;
        cy = y + snode->zoom * backdropHeight * boxmask->y;
  
        y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
        y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
  
 -      glBegin(GL_LINE_LOOP);
 -      glVertex2f(x1, y1);
 -      glVertex2f(x2, y2);
 -      glVertex2f(x3, y3);
 -      glVertex2f(x4, y4);
 -      glEnd();
 +      Gwn_VertFormat *format = immVertexFormat();
 +      unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 +
 +      immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +
 +      immUniformColor3f(1.0f, 1.0f, 1.0f);
 +
 +      immBegin(GWN_PRIM_LINE_LOOP, 4);
 +      immVertex2f(pos, x1, y1);
 +      immVertex2f(pos, x2, y2);
 +      immVertex2f(pos, x3, y3);
 +      immVertex2f(pos, x4, y4);
 +      immEnd();
 +
 +      immUnbindProgram();
  }
  
  static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
        float cx, cy, x1, x2, x3, x4;
        float y1, y2, y3, y4;
  
 -
 -      glColor3f(1.0, 1.0, 1.0);
 -
        cx  = x + snode->zoom * backdropWidth * ellipsemask->x;
        cy = y + snode->zoom * backdropHeight * ellipsemask->y;
  
        y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
        y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
  
 -      glBegin(GL_LINE_LOOP);
 +      Gwn_VertFormat *format = immVertexFormat();
 +      unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 +
 +      immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +
 +      immUniformColor3f(1.0f, 1.0f, 1.0f);
  
 -      glVertex2f(x1, y1);
 -      glVertex2f(x2, y2);
 -      glVertex2f(x3, y3);
 -      glVertex2f(x4, y4);
 -      glEnd();
 +      immBegin(GWN_PRIM_LINE_LOOP, 4);
 +      immVertex2f(pos, x1, y1);
 +      immVertex2f(pos, x2, y2);
 +      immVertex2f(pos, x3, y3);
 +      immVertex2f(pos, x4, y4);
 +      immEnd();
 +
 +      immUnbindProgram();
  }
  
  static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@@@ -3166,7 -3199,6 +3167,7 @@@ void ED_init_node_socket_type_virtual(b
  void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeInstanceKey parent_key)
  {
        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;
        void *lock;
        ImBuf *ibuf;
        ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
        if (ibuf) {
                float x, y; 
 -              
 -              glMatrixMode(GL_PROJECTION);
 -              glPushMatrix();
 -              glMatrixMode(GL_MODELVIEW);
 -              glPushMatrix();
 -              
 +
 +              gpuPushProjectionMatrix();
 +              gpuPushMatrix();
 +
                /* somehow the offset has to be calculated inverse */
                
                glaDefine2DArea(&ar->winrct);
                        unsigned char *display_buffer = NULL;
                        void *cache_handle = NULL;
                        
 -                      if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) {
 -                              int ofs;
 -                              
 -                              display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
 -                              
 -#ifdef __BIG_ENDIAN__
 -                              if      (snode->flag & SNODE_SHOW_R) ofs = 0;
 -                              else if (snode->flag & SNODE_SHOW_G) ofs = 1;
 -                              else                                 ofs = 2;
 -#else
 -                              if      (snode->flag & SNODE_SHOW_R) ofs = 1;
 -                              else if (snode->flag & SNODE_SHOW_G) ofs = 2;
 -                              else                                 ofs = 3;
 -#endif
 +                      if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B | SNODE_SHOW_ALPHA)) {
                                
 -                              glPixelZoom(snode->zoom, snode->zoom);
 -                              /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
 -                              
 -                              glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT,
 -                                                display_buffer - (4 - ofs));
 -                              
 -                              glPixelZoom(1.0f, 1.0f);
 -                      }
 -                      else if (snode->flag & SNODE_SHOW_ALPHA) {
                                display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
 -                              
 -                              glPixelZoom(snode->zoom, snode->zoom);
 -                              /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
 -#ifdef __BIG_ENDIAN__
 -                              glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
 -#endif
 -                              glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer);
 -                              
 -#ifdef __BIG_ENDIAN__
 -                              glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
 -#endif
 -                              glPixelZoom(1.0f, 1.0f);
 +
 +                              if (snode->flag & SNODE_SHOW_R)
 +                                      shuffle[0] = 1.0f;
 +                              else if (snode->flag & SNODE_SHOW_G)
 +                                      shuffle[1] = 1.0f;
 +                              else if (snode->flag & SNODE_SHOW_B)
 +                                      shuffle[2] = 1.0f;
 +                              else
 +                                      shuffle[3] = 1.0f;
 +
 +                              IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
 +                              GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle);
 +
 +                              immDrawPixelsTex(&state, x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST,
 +                                               display_buffer, snode->zoom, snode->zoom, NULL);
 +
 +                              GPU_shader_unbind();
                        }
                        else if (snode->flag & SNODE_USE_ALPHA) {
                                glEnable(GL_BLEND);
                                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 -                              glPixelZoom(snode->zoom, snode->zoom);
 -                              
 -                              glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST);
 -                              
 -                              glPixelZoom(1.0f, 1.0f);
 +
 +                              glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
 +
                                glDisable(GL_BLEND);
                        }
                        else {
 -                              glPixelZoom(snode->zoom, snode->zoom);
 -                              
 -                              glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST);
 -                              
 -                              glPixelZoom(1.0f, 1.0f);
 +                              glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
                        }
                        
                        if (cache_handle)
                            viewer_border->ymin < viewer_border->ymax)
                        {
                                rcti pixel_border;
 -                              UI_ThemeColor(TH_ACTIVE);
                                BLI_rcti_init(&pixel_border,
                                              x + snode->zoom * viewer_border->xmin * ibuf->x,
                                              x + snode->zoom * viewer_border->xmax * ibuf->x,
                                              y + snode->zoom * viewer_border->ymin * ibuf->y,
                                              y + snode->zoom * viewer_border->ymax * ibuf->y);
 -                              glaDrawBorderCorners(&pixel_border, 1.0f, 1.0f);
 +
 +                              unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 +                              immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +                              immUniformThemeColor(TH_ACTIVE);
 +
 +                              immDrawBorderCorners(pos, &pixel_border, 1.0f, 1.0f);
 +
 +                              immUnbindProgram();
                        }
                }
 -              
 -              glMatrixMode(GL_PROJECTION);
 -              glPopMatrix();
 -              glMatrixMode(GL_MODELVIEW);
 -              glPopMatrix();
 +
 +              gpuPopProjectionMatrix();
 +              gpuPopMatrix();
        }
        
        BKE_image_release_ibuf(ima, ibuf, lock);
@@@ -3381,7 -3434,6 +3382,7 @@@ void node_draw_link_bezier(View2D *v2d
                float linew;
                float arrow[2], arrow1[2], arrow2[2];
                glGetFloatv(GL_LINE_WIDTH, &linew);
 +              unsigned int pos;
                
                /* we can reuse the dist variable here to increment the GL curve eval amount*/
                dist = 1.0f / (float)LINK_RESOL;
                        arrow[0] = coord_array[LINK_ARROW][0];
                        arrow[1] = coord_array[LINK_ARROW][1];
                }
 +
 +              if (do_triple || drawarrow || (!do_shaded)) {
 +                      pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 +                      immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +              }
 +
                if (do_triple) {
 -                      UI_ThemeColorShadeAlpha(th_col3, -80, -120);
 +                      immUniformThemeColorShadeAlpha(th_col3, -80, -120);
                        glLineWidth(4.0f);
 -                      
 -                      glBegin(GL_LINE_STRIP);
 +
 +                      immBegin(GWN_PRIM_LINE_STRIP, (LINK_RESOL + 1));
 +
                        for (i = 0; i <= LINK_RESOL; i++) {
 -                              glVertex2fv(coord_array[i]);
 +                              immVertex2fv(pos, coord_array[i]);
                        }
 -                      glEnd();
 +
 +                      immEnd();
 +
                        if (drawarrow) {
 -                              glBegin(GL_LINE_STRIP);
 -                              glVertex2fv(arrow1);
 -                              glVertex2fv(arrow);
 -                              glVertex2fv(arrow2);
 -                              glEnd();
 +                              immBegin(GWN_PRIM_LINE_STRIP, 3);
 +                              immVertex2fv(pos, arrow1);
 +                              immVertex2fv(pos, arrow);
 +                              immVertex2fv(pos, arrow2);
 +                              immEnd();
                        }
                }
 -              
 -              /* XXX using GL_LINES for shaded node lines is a workaround
 -               * for Intel hardware, this breaks with GL_LINE_STRIP and
 -               * changing color in begin/end blocks.
 -               */
 +
                glLineWidth(1.5f);
 -              if (do_shaded) {
 -                      glBegin(GL_LINES);
 -                      for (i = 0; i < LINK_RESOL; i++) {
 -                              UI_ThemeColorBlend(th_col1, th_col2, spline_step);
 -                              glVertex2fv(coord_array[i]);
 -                              
 -                              UI_ThemeColorBlend(th_col1, th_col2, spline_step + dist);
 -                              glVertex2fv(coord_array[i + 1]);
 -                              
 -                              spline_step += dist;
 -                      }
 -                      glEnd();
 +
 +              if (drawarrow) {
 +                      immUniformThemeColorBlend(th_col1, th_col2, 0.5f);
 +
 +                      immBegin(GWN_PRIM_LINE_STRIP, 3);
 +                      immVertex2fv(pos, arrow1);
 +                      immVertex2fv(pos, arrow);
 +                      immVertex2fv(pos, arrow2);
 +                      immEnd();
                }
 -              else {
 -                      UI_ThemeColor(th_col1);
 -                      glBegin(GL_LINE_STRIP);
 +
 +              if (!do_shaded) {
 +                      immUniformThemeColor(th_col1);
 +
 +                      immBegin(GWN_PRIM_LINE_STRIP, (LINK_RESOL + 1));
 +
                        for (i = 0; i <= LINK_RESOL; i++) {
 -                              glVertex2fv(coord_array[i]);
 +                              immVertex2fv(pos, coord_array[i]);
                        }
 -                      glEnd();
 +
 +                      immEnd();
                }
 -              
 -              if (drawarrow) {
 -                      glBegin(GL_LINE_STRIP);
 -                      glVertex2fv(arrow1);
 -                      glVertex2fv(arrow);
 -                      glVertex2fv(arrow2);
 -                      glEnd();
 +
 +              if (do_triple || drawarrow || (!do_shaded)) {
 +                      immUnbindProgram();
                }
 -              
 -              glDisable(GL_LINE_SMOOTH);
 -      }
 -}
  
 -#if 0 /* not used in 2.5x yet */
 -static void node_link_straight_points(View2D *UNUSED(v2d), SpaceNode *snode, bNodeLink *link, float coord_array[][2])
 -{
 -      if (link->fromsock) {
 -              coord_array[0][0] = link->fromsock->locx;
 -              coord_array[0][1] = link->fromsock->locy;
 -      }
 -      else {
 -              if (snode == NULL) return;
 -              coord_array[0][0] = snode->mx;
 -              coord_array[0][1] = snode->my;
 -      }
 -      if (link->tosock) {
 -              coord_array[1][0] = link->tosock->locx;
 -              coord_array[1][1] = link->tosock->locy;
 -      }
 -      else {
 -              if (snode == NULL) return;
 -              coord_array[1][0] = snode->mx;
 -              coord_array[1][1] = snode->my;
 -      }
 -}
 +              if (do_shaded) {
 +                      unsigned char col[3];
  
 -void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link,
 -                             int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3)
 -{
 -      float coord_array[2][2];
 -      int i;
 -      
 -      node_link_straight_points(v2d, snode, link, coord_array);
 -      
 -      glEnable(GL_LINE_SMOOTH);
 -      
 -      if (do_triple) {
 -              UI_ThemeColorShadeAlpha(th_col3, -80, -120);
 -              glLineWidth(4.0f);
 -              
 -              glBegin(GL_LINES);
 -              glVertex2fv(coord_array[0]);
 -              glVertex2fv(coord_array[1]);
 -              glEnd();
 -      }
 -      
 -      UI_ThemeColor(th_col1);
 -      glLineWidth(1.5f);
 -      
 -      /* XXX using GL_LINES for shaded node lines is a workaround
 -       * for Intel hardware, this breaks with GL_LINE_STRIP and
 -       * changing color in begin/end blocks.
 -       */
 -      if (do_shaded) {
 -              glBegin(GL_LINES);
 -              for (i = 0; i < LINK_RESOL - 1; ++i) {
 -                      float t = (float)i / (float)(LINK_RESOL - 1);
 -                      UI_ThemeColorBlend(th_col1, th_col2, t);
 -                      glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
 -                                 (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
 -                      
 -                      t = (float)(i + 1) / (float)(LINK_RESOL - 1);
 -                      UI_ThemeColorBlend(th_col1, th_col2, t);
 -                      glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
 -                                 (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
 -              }
 -              glEnd();
 -      }
 -      else {
 -              glBegin(GL_LINE_STRIP);
 -              for (i = 0; i < LINK_RESOL; ++i) {
 -                      float t = (float)i / (float)(LINK_RESOL - 1);
 -                      glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
 -                                 (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
 +                      Gwn_VertFormat *format = immVertexFormat();
 +                      pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 +                      unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
 +
 +                      immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
 +
 +                      immBegin(GWN_PRIM_LINE_STRIP, (LINK_RESOL + 1));
 +
 +                      for (i = 0; i <= LINK_RESOL; i++) {
 +                              UI_GetThemeColorBlend3ubv(th_col1, th_col2, spline_step, col);
 +                              immAttrib3ubv(color, col);
 +
 +                              immVertex2fv(pos, coord_array[i]);
 +
 +                              spline_step += dist;
 +                      }
 +
 +                      immEnd();
 +
 +                      immUnbindProgram();
                }
 -              glEnd();
 +              
 +              glDisable(GL_LINE_SMOOTH);
        }
 -      
 -      glDisable(GL_LINE_SMOOTH);
  }
 -#endif
  
  /* note; this is used for fake links in groups too */
  void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
  //    node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3);
  }
  
 -void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border)
 +void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, unsigned pos)
  {
 -      glBegin(GL_LINES);
 +      immBegin(GWN_PRIM_LINES, 4);
        
        if (border & (NODE_LEFT | NODE_RIGHT)) {
 -              glVertex2f(cent[0], v2d->cur.ymin);
 -              glVertex2f(cent[0], v2d->cur.ymax);
 +              immVertex2f(pos, cent[0], v2d->cur.ymin);
 +              immVertex2f(pos, cent[0], v2d->cur.ymax);
        }
        else {
 -              glVertex2f(cent[0], cent[1] - size);
 -              glVertex2f(cent[0], cent[1] + size);
 +              immVertex2f(pos, cent[0], cent[1] - size);
 +              immVertex2f(pos, cent[0], cent[1] + size);
        }
        
        if (border & (NODE_TOP | NODE_BOTTOM)) {
 -              glVertex2f(v2d->cur.xmin, cent[1]);
 -              glVertex2f(v2d->cur.xmax, cent[1]);
 +              immVertex2f(pos, v2d->cur.xmin, cent[1]);
 +              immVertex2f(pos, v2d->cur.xmax, cent[1]);
        }
        else {
 -              glVertex2f(cent[0] - size, cent[1]);
 -              glVertex2f(cent[0] + size, cent[1]);
 +              immVertex2f(pos, cent[0] - size, cent[1]);
 +              immVertex2f(pos, cent[0] + size, cent[1]);
        }
        
 -      glEnd();
 +      immEnd();
  }
index 1c6172ef667ca36369da8e2330ad2d2c738d830c,bf767d47994365840c7216b348a37d89344dd3d1..90b7ffd71bb8f54ec565b481f8a50ddb2de4c320
@@@ -74,7 -74,6 +74,7 @@@ EnumPropertyItem rna_enum_id_type_items
        {ID_PC, "PAINTCURVE", ICON_CURVE_BEZCURVE, "Paint Curve", ""},
        {ID_PAL, "PALETTE", ICON_COLOR, "Palette", ""},
        {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""},
 +      {ID_LT, "LIGHT_PROBE", ICON_RADIO, "Light Probe", ""},
        {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""},
        {ID_SCR, "SCREEN", ICON_SPLITSCREEN, "Screen", ""},
        {ID_SO, "SOUND", ICON_PLAY_AUDIO, "Sound", ""},
@@@ -83,7 -82,6 +83,7 @@@
        {ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Texture", ""},
        {ID_WM, "WINDOWMANAGER", ICON_FULLSCREEN, "Window Manager", ""},
        {ID_WO, "WORLD", ICON_WORLD_DATA, "World", ""},
 +      {ID_WS, "WORKSPACE", ICON_NONE, "Workspace", ""},
        {0, NULL, 0, NULL, NULL}
  };
  
  #include "BKE_library_remap.h"
  #include "BKE_animsys.h"
  #include "BKE_material.h"
 -#include "BKE_depsgraph.h"
  #include "BKE_global.h"  /* XXX, remove me */
  
 +#include "DEG_depsgraph.h"
 +#include "DEG_depsgraph_build.h"
 +
  #include "WM_api.h"
  
  /* name functions that ignore the first two ID characters */
@@@ -140,56 -136,48 +140,56 @@@ static int rna_ID_name_editable(Pointer
        return PROP_EDITABLE;
  }
  
 -short RNA_type_to_ID_code(StructRNA *type)
 +short RNA_type_to_ID_code(const StructRNA *type)
  {
 -      if (RNA_struct_is_a(type, &RNA_Action)) return ID_AC;
 -      if (RNA_struct_is_a(type, &RNA_Armature)) return ID_AR;
 -      if (RNA_struct_is_a(type, &RNA_Brush)) return ID_BR;
 -      if (RNA_struct_is_a(type, &RNA_CacheFile)) return ID_CF;
 -      if (RNA_struct_is_a(type, &RNA_Camera)) return ID_CA;
 -      if (RNA_struct_is_a(type, &RNA_Curve)) return ID_CU;
 -      if (RNA_struct_is_a(type, &RNA_GreasePencil)) return ID_GD;
 -      if (RNA_struct_is_a(type, &RNA_Group)) return ID_GR;
 -      if (RNA_struct_is_a(type, &RNA_Image)) return ID_IM;
 -      if (RNA_struct_is_a(type, &RNA_Key)) return ID_KE;
 -      if (RNA_struct_is_a(type, &RNA_Lamp)) return ID_LA;
 -      if (RNA_struct_is_a(type, &RNA_Library)) return ID_LI;
 -      if (RNA_struct_is_a(type, &RNA_FreestyleLineStyle)) return ID_LS;
 -      if (RNA_struct_is_a(type, &RNA_Lattice)) return ID_LT;
 -      if (RNA_struct_is_a(type, &RNA_Material)) return ID_MA;
 -      if (RNA_struct_is_a(type, &RNA_MetaBall)) return ID_MB;
 -      if (RNA_struct_is_a(type, &RNA_MovieClip)) return ID_MC;
 -      if (RNA_struct_is_a(type, &RNA_Mesh)) return ID_ME;
 -      if (RNA_struct_is_a(type, &RNA_Mask)) return ID_MSK;
 -      if (RNA_struct_is_a(type, &RNA_NodeTree)) return ID_NT;
 -      if (RNA_struct_is_a(type, &RNA_Object)) return ID_OB;
 -      if (RNA_struct_is_a(type, &RNA_ParticleSettings)) return ID_PA;
 -      if (RNA_struct_is_a(type, &RNA_Palette)) return ID_PAL;
 -      if (RNA_struct_is_a(type, &RNA_PaintCurve)) return ID_PC;
 -      if (RNA_struct_is_a(type, &RNA_Scene)) return ID_SCE;
 -      if (RNA_struct_is_a(type, &RNA_Screen)) return ID_SCR;
 -      if (RNA_struct_is_a(type, &RNA_Sound)) return ID_SO;
 -      if (RNA_struct_is_a(type, &RNA_Speaker)) return ID_SPK;
 -      if (RNA_struct_is_a(type, &RNA_Texture)) return ID_TE;
 -      if (RNA_struct_is_a(type, &RNA_Text)) return ID_TXT;
 -      if (RNA_struct_is_a(type, &RNA_VectorFont)) return ID_VF;
 -      if (RNA_struct_is_a(type, &RNA_World)) return ID_WO;
 -      if (RNA_struct_is_a(type, &RNA_WindowManager)) return ID_WM;
 +      const StructRNA *base_type = RNA_struct_base_child_of(type, &RNA_ID);
 +      if (UNLIKELY(base_type == NULL)) {
 +              return 0;
 +      }
 +      if (base_type == &RNA_Action) return ID_AC;
 +      if (base_type == &RNA_Armature) return ID_AR;
 +      if (base_type == &RNA_Brush) return ID_BR;
 +      if (base_type == &RNA_CacheFile) return ID_CF;
 +      if (base_type == &RNA_Camera) return ID_CA;
 +      if (base_type == &RNA_Curve) return ID_CU;
 +      if (base_type == &RNA_GreasePencil) return ID_GD;
 +      if (base_type == &RNA_Group) return ID_GR;
 +      if (base_type == &RNA_Image) return ID_IM;
 +      if (base_type == &RNA_Key) return ID_KE;
 +      if (base_type == &RNA_Lamp) return ID_LA;
 +      if (base_type == &RNA_Library) return ID_LI;
 +      if (base_type == &RNA_FreestyleLineStyle) return ID_LS;
 +      if (base_type == &RNA_Lattice) return ID_LT;
 +      if (base_type == &RNA_Material) return ID_MA;
 +      if (base_type == &RNA_MetaBall) return ID_MB;
 +      if (base_type == &RNA_MovieClip) return ID_MC;
 +      if (base_type == &RNA_Mesh) return ID_ME;
 +      if (base_type == &RNA_Mask) return ID_MSK;
 +      if (base_type == &RNA_NodeTree) return ID_NT;
 +      if (base_type == &RNA_Object) return ID_OB;
 +      if (base_type == &RNA_ParticleSettings) return ID_PA;
 +      if (base_type == &RNA_Palette) return ID_PAL;
 +      if (base_type == &RNA_PaintCurve) return ID_PC;
 +      if (base_type == &RNA_LightProbe) return ID_LP;
 +      if (base_type == &RNA_Scene) return ID_SCE;
 +      if (base_type == &RNA_Screen) return ID_SCR;
 +      if (base_type == &RNA_Sound) return ID_SO;
 +      if (base_type == &RNA_Speaker) return ID_SPK;
 +      if (base_type == &RNA_Texture) return ID_TE;
 +      if (base_type == &RNA_Text) return ID_TXT;
 +      if (base_type == &RNA_VectorFont) return ID_VF;
 +      if (base_type == &RNA_WorkSpace) return ID_WS;
 +      if (base_type == &RNA_World) return ID_WO;
 +      if (base_type == &RNA_WindowManager) return ID_WM;
  
        return 0;
  }
  
  StructRNA *ID_code_to_RNA_type(short idcode)
  {
 -      switch (idcode) {
 +      /* Note, this switch doesn't use a 'default',
 +       * so adding new ID's causes a warning. */
 +      switch ((ID_Type)idcode) {
                case ID_AC: return &RNA_Action;
                case ID_AR: return &RNA_Armature;
                case ID_BR: return &RNA_Brush;
                case ID_PA: return &RNA_ParticleSettings;
                case ID_PAL: return &RNA_Palette;
                case ID_PC: return &RNA_PaintCurve;
 +              case ID_LP: return &RNA_LightProbe;
                case ID_SCE: return &RNA_Scene;
                case ID_SCR: return &RNA_Screen;
                case ID_SO: return &RNA_Sound;
                case ID_VF: return &RNA_VectorFont;
                case ID_WM: return &RNA_WindowManager;
                case ID_WO: return &RNA_World;
 +              case ID_WS: return &RNA_WorkSpace;
  
 -              default: return &RNA_ID;
 +              /* deprecated */
 +              case ID_IP: break;
        }
 +
 +      return &RNA_ID;
  }
  
  StructRNA *rna_ID_refine(PointerRNA *ptr)
@@@ -267,9 -250,10 +267,10 @@@ void rna_PropertyGroup_unregister(Main 
        RNA_struct_free(&BLENDER_RNA, type);
  }
  
- StructRNA *rna_PropertyGroup_register(Main *UNUSED(bmain), ReportList *reports, void *data, const char *identifier,
-                                       StructValidateFunc validate, StructCallbackFunc UNUSED(call),
-                                       StructFreeFunc UNUSED(free))
+ StructRNA *rna_PropertyGroup_register(
+         Main *UNUSED(bmain), ReportList *reports, void *data, const char *identifier,
+         StructValidateFunc validate, StructCallbackFunc UNUSED(call),
+         StructFreeFunc UNUSED(free))
  {
        PointerRNA dummyptr;
  
@@@ -348,7 -332,7 +349,7 @@@ static void rna_ID_update_tag(ID *id, R
                }
        }
  
 -      DAG_id_tag_update(id, flag);
 +      DEG_id_tag_update(id, flag);
  }
  
  static void rna_ID_user_clear(ID *id)
@@@ -384,24 -368,16 +385,24 @@@ static struct ID *rna_ID_make_local(str
  static AnimData * rna_ID_animation_data_create(ID *id, Main *bmain)
  {
        AnimData *adt = BKE_animdata_add_id(id);
 -      DAG_relations_tag_update(bmain);
 +      DEG_relations_tag_update(bmain);
        return adt;
  }
  
  static void rna_ID_animation_data_free(ID *id, Main *bmain)
  {
        BKE_animdata_free(id, true);
 -      DAG_relations_tag_update(bmain);
 +      DEG_relations_tag_update(bmain);
  }
  
 +#ifdef WITH_PYTHON
 +void **rna_ID_instance(PointerRNA *ptr)
 +{
 +      ID *id = (ID *)ptr->data;
 +      return &id->py_instance;
 +}
 +#endif
 +
  static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
  {
        IDProperty *prop = (IDProperty *)ptr->data;
@@@ -457,7 -433,7 +458,7 @@@ static Material *rna_IDMaterials_pop_id
                return NULL;
        }
  
 -      DAG_id_tag_update(id, OB_RECALC_DATA);
 +      DEG_id_tag_update(id, OB_RECALC_DATA);
        WM_main_add_notifier(NC_OBJECT | ND_DRAW, id);
        WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id);
  
@@@ -468,7 -444,7 +469,7 @@@ static void rna_IDMaterials_clear_id(I
  {
        BKE_material_clear_id(G.main, id, remove_material_slot);
  
 -      DAG_id_tag_update(id, OB_RECALC_DATA);
 +      DEG_id_tag_update(id, OB_RECALC_DATA);
        WM_main_add_notifier(NC_OBJECT | ND_DRAW, id);
        WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, id);
  }
@@@ -1079,10 -1055,6 +1080,10 @@@ static void rna_def_ID(BlenderRNA *brna
                                        "Tag the ID to update its display data, "
                                        "e.g. when calling :class:`bpy.types.Scene.update`");
        RNA_def_enum_flag(func, "refresh", update_flag_items, 0, "", "Type of updates to perform");
 +
 +#ifdef WITH_PYTHON
 +      RNA_def_struct_register_funcs(srna, NULL, NULL, "rna_ID_instance");
 +#endif
  }
  
  static void rna_def_library(BlenderRNA *brna)
index 9745d8fae56c48d47aae8932a791af9c21c674a6,47b2c84a67f6621eae727db02c5694d249a9f1f0..1f5ddddb74fc091be9fc964fc53fbb5fd849461c
@@@ -73,11 -73,10 +73,11 @@@ EnumPropertyItem rna_enum_keying_flag_i
  #include "BLI_math_base.h"
  
  #include "BKE_animsys.h"
 -#include "BKE_depsgraph.h"
  #include "BKE_fcurve.h"
  #include "BKE_nla.h"
  
 +#include "DEG_depsgraph.h"
 +
  #include "DNA_object_types.h"
  
  #include "WM_api.h"
@@@ -89,7 -88,7 +89,7 @@@ static void rna_AnimData_update(Main *U
        /* tag for refresh so that scheduled updates (e.g. action changed) will 
         * get computed and reflected in the scene [#34869] 
         */
 -      DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA);
 +      DEG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA);
  }
  
  static int rna_AnimData_action_editable(PointerRNA *ptr, const char **UNUSED(r_info))
@@@ -115,7 -114,7 +115,7 @@@ static void rna_AnimData_action_set(Poi
        adt = BKE_animdata_from_id(ownerId);
        if (adt) {
                adt->recalc |= ADT_RECALC_ANIM;
 -              DAG_id_tag_update(ownerId, OB_RECALC_TIME);
 +              DEG_id_tag_update(ownerId, OB_RECALC_TIME);
        }
  }
  
@@@ -247,8 -246,9 +247,9 @@@ static void rna_KeyingSetInfo_unregiste
        ANIM_keyingset_info_unregister(bmain, ksi);
  }
  
- static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
-                                              StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+ static StructRNA *rna_KeyingSetInfo_register(
+         Main *bmain, ReportList *reports, void *data, const char *identifier,
+         StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
  {
        KeyingSetInfo dummyksi = {NULL};
        KeyingSetInfo *ksi;
index 7bcf116d6b770dbb932e1d5de0148f13502384c8,e1066e1bea9c32136a43d2c9ba5a5f1f7987f679..130dbad8b930f225537be655504be429e9ee27f2
@@@ -33,8 -33,6 +33,8 @@@
  #include "BLI_utildefines.h"
  #include "BLI_path_util.h"
  
 +#include "DEG_depsgraph.h"
 +
  #include "BKE_scene.h"
  
  #include "RNA_define.h"
@@@ -145,7 -143,7 +145,7 @@@ static void engine_unbind_display_space
        IMB_colormanagement_finish_glsl_draw();
  }
  
 -static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene)
 +static void engine_update(RenderEngine *engine, Main *bmain, Depsgraph *graph, Scene *scene)
  {
        extern FunctionRNA rna_RenderEngine_update_func;
        PointerRNA ptr;
  
        RNA_parameter_list_create(&list, &ptr, func);
        RNA_parameter_set_lookup(&list, "data", &bmain);
 +      RNA_parameter_set_lookup(&list, "depsgraph", &graph);
        RNA_parameter_set_lookup(&list, "scene", &scene);
        engine->type->ext.call(NULL, &ptr, func, &list);
  
        RNA_parameter_list_free(&list);
  }
  
 -static void engine_render(RenderEngine *engine, struct Scene *scene)
 +static void engine_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
  {
 -      extern FunctionRNA rna_RenderEngine_render_func;
 +      extern FunctionRNA rna_RenderEngine_render_to_image_func;
        PointerRNA ptr;
        ParameterList list;
        FunctionRNA *func;
  
        RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
 -      func = &rna_RenderEngine_render_func;
 +      func = &rna_RenderEngine_render_to_image_func;
  
        RNA_parameter_list_create(&list, &ptr, func);
 -      RNA_parameter_set_lookup(&list, "scene", &scene);
 +      RNA_parameter_set_lookup(&list, "depsgraph", &depsgraph);
        engine->type->ext.call(NULL, &ptr, func, &list);
  
        RNA_parameter_list_free(&list);
@@@ -226,15 -223,15 +226,15 @@@ static void engine_view_update(RenderEn
        RNA_parameter_list_free(&list);
  }
  
 -static void engine_view_draw(RenderEngine *engine, const struct bContext *context)
 +static void engine_render_to_view(RenderEngine *engine, const struct bContext *context)
  {
 -      extern FunctionRNA rna_RenderEngine_view_draw_func;
 +      extern FunctionRNA rna_RenderEngine_render_to_view_func;
        PointerRNA ptr;
        ParameterList list;
        FunctionRNA *func;
  
        RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
 -      func = &rna_RenderEngine_view_draw_func;
 +      func = &rna_RenderEngine_render_to_view_func;
  
        RNA_parameter_list_create(&list, &ptr, func);
        RNA_parameter_set_lookup(&list, "context", &context);
@@@ -261,23 -258,6 +261,23 @@@ static void engine_update_script_node(R
        RNA_parameter_list_free(&list);
  }
  
 +static void engine_collection_settings_create(RenderEngine *engine, struct IDProperty *props)
 +{
 +      extern FunctionRNA rna_RenderEngine_collection_settings_create_func;
 +      PointerRNA ptr;
 +      ParameterList list;
 +      FunctionRNA *func;
 +
 +      RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
 +      func = &rna_RenderEngine_collection_settings_create_func;
 +
 +      RNA_parameter_list_create(&list, &ptr, func);
 +      RNA_parameter_set_lookup(&list, "props", &props);
 +      engine->type->ext.call(NULL, &ptr, func, &list);
 +
 +      RNA_parameter_list_free(&list);
 +}
 +
  static void engine_update_render_passes(RenderEngine *engine, struct Scene *scene, struct SceneRenderLayer *srl)
  {
        extern FunctionRNA rna_RenderEngine_update_render_passes_func;
@@@ -310,13 -290,14 +310,14 @@@ static void rna_RenderEngine_unregister
        BLI_freelinkN(&R_engines, et);
  }
  
- static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
-                                             StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+ static StructRNA *rna_RenderEngine_register(
+         Main *bmain, ReportList *reports, void *data, const char *identifier,
+         StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
  {
        RenderEngineType *et, dummyet = {NULL};
        RenderEngine dummyengine = {NULL};
        PointerRNA dummyptr;
 -      int have_function[7];
 +      int have_function[8];
  
        /* setup dummy engine & engine type to store static properties in */
        dummyengine.type = &dummyet;
        RNA_struct_blender_type_set(et->ext.srna, et);
  
        et->update = (have_function[0]) ? engine_update : NULL;
 -      et->render = (have_function[1]) ? engine_render : NULL;
 +      et->render_to_image = (have_function[1]) ? engine_render_to_image : NULL;
        et->bake = (have_function[2]) ? engine_bake : NULL;
        et->view_update = (have_function[3]) ? engine_view_update : NULL;
 -      et->view_draw = (have_function[4]) ? engine_view_draw : NULL;
 +      et->render_to_view = (have_function[4]) ? engine_render_to_view : NULL;
        et->update_script_node = (have_function[5]) ? engine_update_script_node : NULL;
        et->update_render_passes = (have_function[6]) ? engine_update_render_passes : NULL;
 +      et->collection_settings_create = (have_function[7]) ? engine_collection_settings_create : NULL;
  
 -      BLI_addtail(&R_engines, et);
 +      RE_engines_register(bmain, et);
  
        return et->ext.srna;
  }
@@@ -392,16 -372,6 +393,16 @@@ static PointerRNA rna_RenderEngine_rend
        }
  }
  
 +static PointerRNA rna_RenderEngine_scene_layer_get(PointerRNA *ptr)
 +{
 +      RenderEngine *engine = (RenderEngine *)ptr->data;
 +      if (engine->re != NULL) {
 +              SceneLayer* scene_layer = RE_engine_get_scene_layer(engine->re);
 +              return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, scene_layer);
 +      }
 +      return rna_pointer_inherit_refine(ptr, &RNA_SceneLayer, NULL);
 +}
 +
  static PointerRNA rna_RenderEngine_camera_override_get(PointerRNA *ptr)
  {
        RenderEngine *engine = (RenderEngine *)ptr->data;
@@@ -500,13 -470,12 +501,13 @@@ static void rna_def_render_engine(Blend
        RNA_def_function_ui_description(func, "Export scene data for render");
        RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
        RNA_def_pointer(func, "data", "BlendData", "", "");
 +      RNA_def_pointer(func, "depsgraph", "Depsgraph", "", "");
        RNA_def_pointer(func, "scene", "Scene", "", "");
  
 -      func = RNA_def_function(srna, "render", NULL);
 +      func = RNA_def_function(srna, "render_to_image", NULL);
        RNA_def_function_ui_description(func, "Render scene into an image");
        RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
 -      RNA_def_pointer(func, "scene", "Scene", "", "");
 +      RNA_def_pointer(func, "desgraph", "Depsgraph", "", "");
  
        func = RNA_def_function(srna, "bake", NULL);
        RNA_def_function_ui_description(func, "Bake passes");
        RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
        RNA_def_pointer(func, "context", "Context", "", "");
  
 -      func = RNA_def_function(srna, "view_draw", NULL);
 +      func = RNA_def_function(srna, "render_to_view", NULL);
        RNA_def_function_ui_description(func, "Draw viewport render");
        RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
        RNA_def_pointer(func, "context", "Context", "", "");
        parm = RNA_def_pointer(func, "node", "Node", "", "");
        RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
  
 +      func = RNA_def_function(srna, "update_render_passes", NULL);
 +      RNA_def_function_ui_description(func, "Update the render passes that will be generated");
 +      RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
 +      parm = RNA_def_pointer(func, "scene", "Scene", "", "");
 +      parm = RNA_def_pointer(func, "renderlayer", "SceneRenderLayer", "", "");
 +
 +      /* per-collection engine settings initialization */
 +      func = RNA_def_function(srna, "collection_settings_create", NULL);
 +      RNA_def_function_ui_description(func, "Create the per collection settings for the engine");
 +      RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
 +      parm = RNA_def_pointer(func, "collection_settings", "LayerCollectionSettings", "", "");
 +      RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
 +
        /* tag for redraw */
        func = RNA_def_function(srna, "tag_redraw", "engine_tag_redraw");
        RNA_def_function_ui_description(func, "Request redraw for viewport rendering");
        func = RNA_def_function(srna, "tag_update", "engine_tag_update");
        RNA_def_function_ui_description(func, "Request update call for viewport rendering");
  
 -      func = RNA_def_function(srna, "update_render_passes", NULL);
 -      RNA_def_function_ui_description(func, "Update the render passes that will be generated");
 -      RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
 -      parm = RNA_def_pointer(func, "scene", "Scene", "", "");
 -      parm = RNA_def_pointer(func, "renderlayer", "SceneRenderLayer", "", "");
 -
        func = RNA_def_function(srna, "begin_result", "RE_engine_begin_result");
        RNA_def_function_ui_description(func, "Create render result to write linear floating point render layers and passes");
        parm = RNA_def_int(func, "x", 0, 0, INT_MAX, "X", "", 0, INT_MAX);
        prop = RNA_def_enum(func, "type", render_pass_type_items, SOCK_FLOAT, "Type", "");
        RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
  
 +      prop = RNA_def_property(srna, "scene_layer", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_struct_type(prop, "SceneLayer");
 +      RNA_def_property_pointer_funcs(prop, "rna_RenderEngine_scene_layer_get", NULL, NULL, NULL);
 +      RNA_def_property_ui_text(prop, "Scene layer", "");
 +
        /* registration */
  
        prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
index a2cc808f90b870c374e0be6f48ca02f100cbe019,b50cbee4885152d39819cf3d714cfb4461153169..6a8b42913bd640cfbab999ec066a21d9e098dba9
@@@ -98,14 -98,13 +98,14 @@@ static EnumPropertyItem rna_enum_langua
  #include "DNA_screen_types.h"
  
  #include "BKE_blender.h"
 -#include "BKE_depsgraph.h"
  #include "BKE_global.h"
  #include "BKE_main.h"
  #include "BKE_idprop.h"
  #include "BKE_pbvh.h"
  #include "BKE_paint.h"
  
 +#include "DEG_depsgraph.h"
 +
  #include "GPU_draw.h"
  #include "GPU_select.h"
  
@@@ -176,12 -175,10 +176,12 @@@ static void rna_userdef_show_manipulato
                        for (sl = sa->spacedata.first; sl; sl = sl->next) {
                                if (sl->spacetype == SPACE_VIEW3D) {
                                        View3D *v3d = (View3D *)sl;
 -                                      if (userdef->tw_flag & V3D_USE_MANIPULATOR)
 -                                              v3d->twflag |= V3D_USE_MANIPULATOR;
 -                                      else
 -                                              v3d->twflag &= ~V3D_USE_MANIPULATOR;
 +                                      if (userdef->manipulator_flag & USER_MANIPULATOR_DRAW) {
 +                                              v3d->twflag |= V3D_MANIPULATOR_DRAW;
 +                                      }
 +                                      else {
 +                                              v3d->twflag &= ~V3D_MANIPULATOR_DRAW;
 +                                      }
                                }
                        }
                }
@@@ -366,7 -363,7 +366,7 @@@ static void rna_UserDef_weight_color_up
  
        for (ob = bmain->object.first; ob; ob = ob->id.next) {
                if (ob->mode & OB_MODE_WEIGHT_PAINT)
 -                      DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 +                      DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
        }
  
        rna_userdef_update(bmain, scene, ptr);
@@@ -505,7 -502,7 +505,7 @@@ static void rna_userdef_opensubdiv_upda
                if (object->derivedFinal != NULL &&
                    object->derivedFinal->type == DM_TYPE_CCGDM)
                {
 -                      DAG_id_tag_update(&object->id, OB_RECALC_OB);
 +                      DEG_id_tag_update(&object->id, OB_RECALC_OB);
                }
        }
  }
@@@ -519,6 -516,7 +519,6 @@@ static EnumPropertyItem *rna_userdef_au
        int totitem = 0;
        EnumPropertyItem *item = NULL;
  
 -#ifdef WITH_SYSTEM_AUDASPACE
        int i;
  
        char **names = BKE_sound_get_device_names();
                EnumPropertyItem new_item = {i, names[i], 0, names[i], names[i]};
                RNA_enum_item_add(&item, &totitem, &new_item);
        }
 -#else
 -      /* NONE */
 -      RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
 -
 -#ifdef WITH_SDL
 -#  ifdef WITH_SDL_DYNLOAD
 -      if (sdlewInit() == SDLEW_SUCCESS)
 -#  endif
 -      {
 -              RNA_enum_item_add(&item, &totitem, &audio_device_items[index]);
 -      }
 -      index++;
 -#endif
 -
 -#ifdef WITH_OPENAL
 -      RNA_enum_item_add(&item, &totitem, &audio_device_items[index++]);
 -#endif
 -
 -#ifdef WITH_JACK
 -      if (BKE_sound_is_jack_supported()) {
 -              RNA_enum_item_add(&item, &totitem, &audio_device_items[index]);
 -      }
 -      index++;
 -#endif
 -#endif
  
        /* may be unused */
        UNUSED_VARS(index, audio_device_items);
@@@ -591,8 -614,9 +591,9 @@@ static void rna_AddonPref_unregister(Ma
        WM_main_add_notifier(NC_WINDOW, NULL);
  }
  
- static StructRNA *rna_AddonPref_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
-                                          StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+ static StructRNA *rna_AddonPref_register(
+         Main *bmain, ReportList *reports, void *data, const char *identifier,
+         StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
  {
        bAddonPrefType *apt, dummyapt = {{'\0'}};
        bAddon dummyaddon = {NULL};
@@@ -1046,37 -1070,6 +1047,37 @@@ static void rna_def_userdef_theme_ui(Bl
        RNA_def_property_array(prop, 3);
        RNA_def_property_ui_text(prop, "Z Axis", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 +
 +      /* Generic manipulator colors. */
 +      prop = RNA_def_property(srna, "manipulator_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
 +      RNA_def_property_float_sdna(prop, NULL, "manipulator_hi");
 +      RNA_def_property_array(prop, 3);
 +      RNA_def_property_ui_text(prop, "Manipulator Highlight", "");
 +      RNA_def_property_update(prop, 0, "rna_userdef_update");
 +
 +      prop = RNA_def_property(srna, "manipulator_primary", PROP_FLOAT, PROP_COLOR_GAMMA);
 +      RNA_def_property_float_sdna(prop, NULL, "manipulator_primary");
 +      RNA_def_property_array(prop, 3);
 +      RNA_def_property_ui_text(prop, "Manipulator Primary", "");
 +      RNA_def_property_update(prop, 0, "rna_userdef_update");
 +
 +      prop = RNA_def_property(srna, "manipulator_secondary", PROP_FLOAT, PROP_COLOR_GAMMA);
 +      RNA_def_property_float_sdna(prop, NULL, "manipulator_secondary");
 +      RNA_def_property_array(prop, 3);
 +      RNA_def_property_ui_text(prop, "Manipulator Secondary", "");
 +      RNA_def_property_update(prop, 0, "rna_userdef_update");
 +
 +      prop = RNA_def_property(srna, "manipulator_a", PROP_FLOAT, PROP_COLOR_GAMMA);
 +      RNA_def_property_float_sdna(prop, NULL, "manipulator_a");
 +      RNA_def_property_array(prop, 3);
 +      RNA_def_property_ui_text(prop, "Manipulator A", "");
 +      RNA_def_property_update(prop, 0, "rna_userdef_update");
 +
 +      prop = RNA_def_property(srna, "manipulator_b", PROP_FLOAT, PROP_COLOR_GAMMA);
 +      RNA_def_property_float_sdna(prop, NULL, "manipulator_b");
 +      RNA_def_property_array(prop, 3);
 +      RNA_def_property_ui_text(prop, "Manipulator B", "");
 +      RNA_def_property_update(prop, 0, "rna_userdef_update");
  }
  
  static void rna_def_userdef_theme_space_common(StructRNA *srna)
@@@ -1280,7 -1273,7 +1281,7 @@@ static void rna_def_userdef_theme_space
        RNA_def_property_update(prop, 0, "rna_userdef_update");
  
        prop = RNA_def_property(srna, "vertex_size", PROP_INT, PROP_NONE);
 -      RNA_def_property_range(prop, 1, 10);
 +      RNA_def_property_range(prop, 1, 32);
        RNA_def_property_ui_text(prop, "Vertex Size", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
  
@@@ -1502,7 -1495,7 +1503,7 @@@ static void rna_def_userdef_theme_space
                RNA_def_property_update(prop, 0, "rna_userdef_update");
  
                prop = RNA_def_property(srna, "handle_vertex_size", PROP_INT, PROP_NONE);
 -              RNA_def_property_range(prop, 0, 255);
 +              RNA_def_property_range(prop, 1, 100);
                RNA_def_property_ui_text(prop, "Handle Vertex Size", "");
                RNA_def_property_update(prop, 0, "rna_userdef_update");
        }
@@@ -3354,6 -3347,11 +3355,6 @@@ static void rna_def_userdef_view(Blende
        RNA_def_property_ui_text(prop, "Display Object Info", "Display objects name and frame number in 3D view");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
  
 -      prop = RNA_def_property(srna, "use_global_scene", PROP_BOOLEAN, PROP_NONE);
 -      RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_SCENEGLOBAL);
 -      RNA_def_property_ui_text(prop, "Global Scene", "Force the current Scene to be displayed in all Screens");
 -      RNA_def_property_update(prop, 0, "rna_userdef_update");
 -
        prop = RNA_def_property(srna, "show_large_cursors", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "curssize", 0);
        RNA_def_property_ui_text(prop, "Large Cursors", "Use large mouse cursors when available");
  
        /* 3D transform widget */
        prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE);
 -      RNA_def_property_boolean_sdna(prop, NULL, "tw_flag", V3D_USE_MANIPULATOR);
 +      RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_DRAW);
        RNA_def_property_ui_text(prop, "Manipulator", "Use 3D transform manipulator");
        RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update");
  
 +      /* TODO, expose once it's working. */
 +#if 0
 +      prop = RNA_def_property(srna, "show_manipulator_shaded", PROP_BOOLEAN, PROP_NONE);
 +      RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_SHADED);
 +      RNA_def_property_ui_text(prop, "Manipulator Shaded", "Use 3D transform manipulator");
 +      RNA_def_property_update(prop, 0, "rna_userdef_update");
 +#endif
 +
        prop = RNA_def_property(srna, "manipulator_size", PROP_INT, PROP_PIXEL);
 -      RNA_def_property_int_sdna(prop, NULL, "tw_size");
 +      RNA_def_property_int_sdna(prop, NULL, "manipulator_size");
        RNA_def_property_range(prop, 10, 200);
        RNA_def_property_int_default(prop, 75);
        RNA_def_property_ui_text(prop, "Manipulator Size", "Diameter of the manipulator");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
  
 -      prop = RNA_def_property(srna, "manipulator_handle_size", PROP_INT, PROP_PERCENTAGE);
 -      RNA_def_property_int_sdna(prop, NULL, "tw_handlesize");
 -      RNA_def_property_range(prop, 2, 40);
 -      RNA_def_property_int_default(prop, 25);
 -      RNA_def_property_ui_text(prop, "Manipulator Handle Size", "Size of manipulator handles as percentage of the radius");
 -      RNA_def_property_update(prop, 0, "rna_userdef_update");
 -
 -      prop = RNA_def_property(srna, "manipulator_hotspot", PROP_INT, PROP_PIXEL);
 -      RNA_def_property_int_sdna(prop, NULL, "tw_hotspot");
 -      RNA_def_property_range(prop, 4, 40);
 -      RNA_def_property_int_default(prop, 14);
 -      RNA_def_property_ui_text(prop, "Manipulator Hotspot", "Distance around the handles to accept mouse clicks");
 -
        prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL);
        RNA_def_property_int_sdna(prop, NULL, "obcenter_dia");
        RNA_def_property_range(prop, 4, 10);
index 4d5c0934cf26071fd8d467d151b8f1a2c6fe279e,7e42f36c6e49d91fa86e10cf3884cd8beff4cfd3..a3460823e69496d22dae7170a6a74afc532394b5
@@@ -534,6 -534,7 +534,7 @@@ if(WITH_CYCLES
                if(WITH_OPENGL_TESTS)
                        add_cycles_render_test(opengl)
                endif()
+               add_cycles_render_test(bake)
                add_cycles_render_test(denoise)
                add_cycles_render_test(displacement)
                add_cycles_render_test(image_data_types)
@@@ -590,5 -591,3 +591,5 @@@ if(WITH_ALEMBIC
                --with-legacy-depsgraph=${WITH_LEGACY_DEPSGRAPH}
        )
  endif()
 +
 +add_subdirectory(render_layer)