Merged changes in the trunk up to revision 47700.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 10 Jun 2012 20:50:43 +0000 (20:50 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 10 Jun 2012 20:50:43 +0000 (20:50 +0000)
Conflicts resolved:
source/blender/blenkernel/BKE_main.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/library.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/interface/resources.c
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/SConscript
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/windowmanager/WM_types.h

47 files changed:
1  2 
source/blender/CMakeLists.txt
source/blender/blenkernel/BKE_main.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/idcode.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/scene.c
source/blender/blenlib/intern/bpath.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/operators/bmo_utils.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform.c
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/SConscript
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_color.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/render/intern/include/render_types.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
source/blender/windowmanager/WM_types.h
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/CMakeLists.txt

Simple merge
index 043d0a9886d27e57db141e66644c3db81a61b9c1,3074e1c0e63d43a27baabc7cac9e46a2e02416b1..ad5541a5a2f35558986193acfc3a095708f74035
@@@ -86,7 -86,7 +86,8 @@@ typedef struct Main 
        ListBase wm;
        ListBase gpencil;
        ListBase movieclip;
+       ListBase mask;
 +      ListBase linestyle;
  
        char id_tag_update[256];
  } Main;
index baa714c9de4da141e58154d2d570c87f6e1aa530,056a6bf586690b9e9757d077d8a1ed48994a19ff..558db1c87423eb33b670e473c446864228fb4563
@@@ -101,7 -101,7 +102,8 @@@ set(SR
        intern/lamp.c
        intern/lattice.c
        intern/library.c
 +      intern/linestyle.c
+       intern/mask.c
        intern/material.c
        intern/mball.c
        intern/mesh.c
        BKE_lamp.h
        BKE_lattice.h
        BKE_library.h
 +      BKE_linestyle.h
+       BKE_mask.h
        BKE_main.h
        BKE_material.h
        BKE_mball.h
Simple merge
index b042c0091d767e1137b1612e97a8697cb1d5ec46,7fc805297533195b07a10ccb1f6ce8f18d471eb4..ec2b8a04c9a8372834f473c63b7ece3b7fb80c78
@@@ -806,13 -809,10 +810,13 @@@ void BKE_animdata_main_cb(Main *mainptr
        
        /* worlds */
        ANIMDATA_IDS_CB(mainptr->world.first);
-       
        /* scenes */
        ANIMDATA_NODETREE_IDS_CB(mainptr->scene.first, Scene);
 -}
 +      
 +      /* line styles */
 +      ANIMDATA_IDS_CB(mainptr->linestyle.first);
 +      }
  
  /* Fix all RNA-Paths throughout the database (directly access the Global.main version)
   * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
index 5cc328212a924b26946ad887fe6cfca34e689534,c81e607ce93aa5c11604394f65001d686a32ad00..2fe6999c6e8c33948647a9fde44853d4e7c5eab2
  #include "BKE_speaker.h"
  #include "BKE_utildefines.h"
  #include "BKE_movieclip.h"
+ #include "BKE_mask.h"
 +#include "BKE_linestyle.h"
  
  #include "RNA_access.h"
  
@@@ -492,8 -488,8 +494,10 @@@ ListBase *which_libbase(Main *mainlib, 
                        return &(mainlib->gpencil);
                case ID_MC:
                        return &(mainlib->movieclip);
+               case ID_MSK:
+                       return &(mainlib->mask);
 +              case ID_LS:
 +                      return &(mainlib->linestyle);
        }
        return NULL;
  }
@@@ -577,7 -573,7 +581,8 @@@ int set_listbasepointers(Main *main, Li
        lb[a++] = &(main->library);
        lb[a++] = &(main->wm);
        lb[a++] = &(main->movieclip);
-       lb[a++]= &(main->linestyle);
+       lb[a++] = &(main->mask);
++      lb[a++] = &(main->linestyle);
        
        lb[a] = NULL;
  
@@@ -689,9 -685,9 +694,12 @@@ static ID *alloc_libblock_notest(short 
                case ID_MC:
                        id = MEM_callocN(sizeof(MovieClip), "Movie Clip");
                        break;
+               case ID_MSK:
+                       id = MEM_callocN(sizeof(Mask), "Mask");
+                       break;
 +              case ID_LS:
 +                      id = MEM_callocN(sizeof(FreestyleLineStyle), "Freestyle Line Style");
 +                      break;
        }
        return id;
  }
@@@ -900,9 -896,9 +908,12 @@@ void BKE_libblock_free(ListBase *lb, vo
                case ID_MC:
                        BKE_movieclip_free((MovieClip *)id);
                        break;
+               case ID_MSK:
+                       BKE_mask_free((Mask *)id);
+                       break;
 +              case ID_LS:
 +                      FRS_free_linestyle((FreestyleLineStyle *)id);
 +                      break;
        }
  
        if (id->properties) {
index 3304ccc73cf0e709a740fc67b2f0d1151a0ea8a4,a01024acfd30da67241db0c55dd00f3ee8da8706..b656cb6d8dea252633635ed9f977a500e7caeebc
  
  #include "GPU_material.h"
  
 +#include "FRS_freestyle.h"
 +
  /* Local function protos */
- static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul);
  float originmat[3][3];  /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */
  
  void BKE_object_workob_clear(Object *workob)
Simple merge
index 6cad85aa2733a4a096b842907ad898f570aa6403,c727717dac8226e9f40c246bf7037a94f335eff9..95ac030a440bc206107bcc636e6dcfafd89fcf8f
@@@ -6188,177 -6199,88 +6213,259 @@@ static void lib_link_movieclip(FileDat
        }
  }
  
+ /* ***************** READ MOVIECLIP *************** */
+ static void direct_link_mask(FileData *fd, Mask *mask)
+ {
+       MaskLayer *masklay;
+       mask->adt = newdataadr(fd, mask->adt);
+       link_list(fd, &mask->masklayers);
+       for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+               MaskSpline *spline;
+               MaskLayerShape *masklay_shape;
+               link_list(fd, &masklay->splines);
+               for (spline = masklay->splines.first; spline; spline = spline->next) {
+                       int i;
+                       spline->points = newdataadr(fd, spline->points);
+                       for (i = 0; i < spline->tot_point; i++) {
+                               MaskSplinePoint *point = &spline->points[i];
+                               if (point->tot_uw)
+                                       point->uw = newdataadr(fd, point->uw);
+                       }
+               }
+               link_list(fd, &masklay->splines_shapes);
+               for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
+                       masklay_shape->data = newdataadr(fd, masklay_shape->data);
+               }
+               masklay->act_spline = newdataadr(fd, masklay->act_spline);
+               masklay->act_point = newdataadr(fd, masklay->act_point);
+       }
+ }
+ static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent)
+ {
+       parent->id = newlibadr_us(fd, mask->id.lib, parent->id);
+ }
+ static void lib_link_mask(FileData *fd, Main *main)
+ {
+       Mask *mask;
+       mask = main->mask.first;
+       while (mask) {
+               if (mask->id.flag & LIB_NEEDLINK) {
+                       MaskLayer *masklay;
+                       if (mask->adt)
+                               lib_link_animdata(fd, &mask->id, mask->adt);
+                       for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+                               MaskSpline *spline;
+                               spline = masklay->splines.first;
+                               while (spline) {
+                                       int i;
+                                       for (i = 0; i < spline->tot_point; i++) {
+                                               MaskSplinePoint *point = &spline->points[i];
+                                               lib_link_mask_parent(fd, mask, &point->parent);
+                                       }
+                                       lib_link_mask_parent(fd, mask, &spline->parent);
+                                       spline = spline->next;
+                               }
+                       }
+                       mask->id.flag -= LIB_NEEDLINK;
+               }
+               mask = mask->id.next;
+       }
+ }
 +/* ************ READ LINE STYLE ***************** */
 +
 +static void lib_link_linestyle(FileData *fd, Main *main)
 +{
 +      FreestyleLineStyle *linestyle;
 +      LineStyleModifier *m;
 +
 +      linestyle = main->linestyle.first;
 +      while (linestyle) {
 +              if (linestyle->id.flag & LIB_NEEDLINK) {
 +                      linestyle->id.flag -= LIB_NEEDLINK;
 +
 +                      if (linestyle->id.properties) IDP_LibLinkProperty(linestyle->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 +                      if (linestyle->adt) lib_link_animdata(fd, &linestyle->id, linestyle->adt);
 +                      for (m = linestyle->color_modifiers.first; m; m = m->next) {
 +                              switch (m->type) {
 +                              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                                      {
 +                                              LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m;
 +                                              cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
 +                                      }
 +                                      break;
 +                              }
 +                      }
 +                      for (m = linestyle->alpha_modifiers.first; m; m = m->next){
 +                              switch (m->type) {
 +                              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                                      {
 +                                              LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m;
 +                                              am->target = newlibadr(fd, linestyle->id.lib, am->target);
 +                                      }
 +                                      break;
 +                              }
 +                      }
 +                      for (m = linestyle->thickness_modifiers.first; m; m = m->next){
 +                              switch (m->type) {
 +                              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                                      {
 +                                              LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m;
 +                                              tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
 +                                      }
 +                                      break;
 +                              }
 +                      }
 +              }
 +              linestyle = linestyle->id.next;
 +      }
 +}
 +
 +static void direct_link_linestyle_color_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +      switch (modifier->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleColorModifier_AlongStroke *m = (LineStyleColorModifier_AlongStroke *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleColorModifier_DistanceFromCamera *m = (LineStyleColorModifier_DistanceFromCamera *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleColorModifier_DistanceFromObject *m = (LineStyleColorModifier_DistanceFromObject *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleColorModifier_Material *m = (LineStyleColorModifier_Material *)modifier;
 +                      m->color_ramp = newdataadr(fd, m->color_ramp);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle_alpha_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +      switch (modifier->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle_thickness_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +      switch (modifier->type) {
 +      case LS_MODIFIER_ALONG_STROKE:
 +              {
 +                      LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +              {
 +                      LineStyleThicknessModifier_DistanceFromCamera *m = (LineStyleThicknessModifier_DistanceFromCamera *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +              {
 +                      LineStyleThicknessModifier_DistanceFromObject *m = (LineStyleThicknessModifier_DistanceFromObject *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      case LS_MODIFIER_MATERIAL:
 +              {
 +                      LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier;
 +                      m->curve = newdataadr(fd, m->curve);
 +                      direct_link_curvemapping(fd, m->curve);
 +              }
 +              break;
 +      }
 +}
 +
 +static void direct_link_linestyle_geometry_modifier(FileData *fd, LineStyleModifier *modifier)
 +{
 +}
 +
 +static void direct_link_linestyle(FileData *fd, FreestyleLineStyle *linestyle)
 +{
 +      LineStyleModifier *modifier;
 +
 +      linestyle->adt= newdataadr(fd, linestyle->adt);
 +      direct_link_animdata(fd, linestyle->adt);
 +      link_list(fd, &linestyle->color_modifiers);
 +      for(modifier=linestyle->color_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_color_modifier(fd, modifier);
 +      link_list(fd, &linestyle->alpha_modifiers);
 +      for(modifier=linestyle->alpha_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_alpha_modifier(fd, modifier);
 +      link_list(fd, &linestyle->thickness_modifiers);
 +      for(modifier=linestyle->thickness_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_thickness_modifier(fd, modifier);
 +      link_list(fd, &linestyle->geometry_modifiers);
 +      for(modifier=linestyle->geometry_modifiers.first; modifier; modifier= modifier->next)
 +              direct_link_linestyle_geometry_modifier(fd, modifier);
 +}
 +
  /* ************** GENERAL & MAIN ******************** */
  
  
@@@ -6565,9 -6486,9 +6672,12 @@@ static BHead *read_libblock(FileData *f
                case ID_MC:
                        direct_link_movieclip(fd, (MovieClip *)id);
                        break;
+               case ID_MSK:
+                       direct_link_mask(fd, (Mask *)id);
+                       break;
 +              case ID_LS:
 +                      direct_link_linestyle(fd, (FreestyleLineStyle *)id);
 +                      break;
        }
        
        /*link direct data of ID properties*/
@@@ -7710,50 -7649,100 +7838,130 @@@ static void do_versions(FileData *fd, L
                }
        }
  
-       
+       if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 9)) {
+               bNodeTreeType *ntreetype = ntreeGetType(NTREE_SHADER);
+               
+               if (ntreetype && ntreetype->foreach_nodetree)
+                       ntreetype->foreach_nodetree(main, NULL, do_version_ntree_image_user_264);
+       }
+       if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 10)) {
+               {
+                       Scene *scene;
+                       // composite redesign
+                       for (scene=main->scene.first; scene; scene=scene->id.next) {
+                               if (scene->nodetree) {
+                                       if (scene->nodetree->chunksize == 0) {
+                                               scene->nodetree->chunksize = 256;
+                                       }
+                               }
+                       }
+               }
+               {
+                       bScreen *sc;
+                       for (sc = main->screen.first; sc; sc = sc->id.next) {
+                               ScrArea *sa;
+                               for (sa = sc->areabase.first; sa; sa = sa->next) {
+                                       SpaceLink *sl;
+                                       for (sl = sa->spacedata.first; sl; sl = sl->next) {
+                                               if (sl->spacetype == SPACE_CLIP) {
+                                                       SpaceClip *sclip = (SpaceClip *)sl;
+                                                       if (sclip->around == 0) {
+                                                               sclip->around = V3D_CENTROID;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               {
+                       MovieClip *clip;
+                       for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+                               clip->start_frame = 1;
+                       }
+               }
+       }
+       if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 11)) {
+               MovieClip *clip;
+               for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+                       MovieTrackingTrack *track;
+                       track = clip->tracking.tracks.first;
+                       while (track) {
+                               int i;
+                               for (i = 0; i < track->markersnr; i++) {
+                                       MovieTrackingMarker *marker = &track->markers[i];
+                                       if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) &&
+                                           is_zero_v2(marker->pattern_corners[3]) && is_zero_v2(marker->pattern_corners[3]))
+                                       {
+                                               marker->pattern_corners[0][0] = track->pat_min[0];
+                                               marker->pattern_corners[0][1] = track->pat_min[1];
+                                               marker->pattern_corners[1][0] = track->pat_max[0];
+                                               marker->pattern_corners[1][1] = track->pat_min[1];
+                                               marker->pattern_corners[2][0] = track->pat_max[0];
+                                               marker->pattern_corners[2][1] = track->pat_max[1];
+                                               marker->pattern_corners[3][0] = track->pat_min[0];
+                                               marker->pattern_corners[3][1] = track->pat_max[1];
+                                       }
+                                       if (is_zero_v2(marker->search_min) && is_zero_v2(marker->search_max)) {
+                                               copy_v2_v2(marker->search_min, track->search_min);
+                                               copy_v2_v2(marker->search_max, track->search_max);
+                                       }
+                               }
+                               track = track->next;
+                       }
+               }
+       }
 +      /* default values in Freestyle settings */
 +      {
 +              Scene *sce;
 +              SceneRenderLayer *srl;
 +              FreestyleLineStyle *linestyle;
 +
 +              for(sce = main->scene.first; sce; sce = sce->id.next) {
 +                      if (sce->r.line_thickness_mode == 0) {
 +                              sce->r.line_thickness_mode= R_LINE_THICKNESS_ABSOLUTE;
 +                              sce->r.unit_line_thickness= 1.f;
 +                      }
 +                      for(srl= sce->r.layers.first; srl; srl= srl->next) {
 +                              if (srl->freestyleConfig.mode == 0)
 +                                      srl->freestyleConfig.mode= FREESTYLE_CONTROL_EDITOR_MODE;
 +                              if (srl->freestyleConfig.raycasting_algorithm == 0)
 +                                      srl->freestyleConfig.raycasting_algorithm= FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE;
 +                      }
 +              }
 +              for(linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
 +                      if (linestyle->thickness_position == 0) {
 +                              linestyle->thickness_position= LS_THICKNESS_CENTER;
 +                              linestyle->thickness_ratio= 0.5f;
 +                      }
 +                      if (linestyle->chaining == 0)
 +                              linestyle->chaining= LS_CHAINING_PLAIN;
 +                      if (linestyle->rounds == 0)
 +                              linestyle->rounds= 3;
 +              }
 +      }
++
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
-       {
-               Scene *scene;
-               // composite redesign
-               for (scene=main->scene.first; scene; scene=scene->id.next) {
-                       if (scene->nodetree) {
-                               if (scene->nodetree->chunksize == 0) {
-                                       scene->nodetree->chunksize = 256;
-                               }
-                       }
-               }
-       }
-       
        /* don't forget to set version number in blender.c! */
  }
  
@@@ -7796,8 -7785,8 +8004,9 @@@ static void lib_link_all(FileData *fd, 
        lib_link_brush(fd, main);
        lib_link_particlesettings(fd, main);
        lib_link_movieclip(fd, main);
-       
+       lib_link_mask(fd, main);
 +      lib_link_linestyle(fd, main);
        lib_link_mesh(fd, main);                /* as last: tpage images with users at zero */
        
        lib_link_library(fd, main);             /* only init users */
index beaf36421c516f921c91c1ca149c52762bf87197,f257994bc1c92ffad3886e504bf2e923117cfe38..332a00f9440d876c209be3f9bde8f099db6cba78
@@@ -2765,205 -2753,59 +2766,258 @@@ static void write_movieclips(WriteData 
        mywrite(wd, MYWRITE_FLUSH, 0);
  }
  
+ static void write_masks(WriteData *wd, ListBase *idbase)
+ {
+       Mask *mask;
+       mask = idbase->first;
+       while (mask) {
+               if (mask->id.us > 0 || wd->current) {
+                       MaskLayer *masklay;
+                       writestruct(wd, ID_MSK, "Mask", 1, mask);
+                       if (mask->adt)
+                               write_animdata(wd, mask->adt);
+                       for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+                               MaskSpline *spline;
+                               MaskLayerShape *masklay_shape;
+                               writestruct(wd, DATA, "MaskLayer", 1, masklay);
+                               for (spline = masklay->splines.first; spline; spline = spline->next) {
+                                       int i;
+                                       void *points_deform = spline->points_deform;
+                                       spline->points_deform = NULL;
+                                       writestruct(wd, DATA, "MaskSpline", 1, spline);
+                                       writestruct(wd, DATA, "MaskSplinePoint", spline->tot_point, spline->points);
+                                       spline->points_deform = points_deform;
+                                       for (i = 0; i < spline->tot_point; i++) {
+                                               MaskSplinePoint *point = &spline->points[i];
+                                               if (point->tot_uw)
+                                                       writestruct(wd, DATA, "MaskSplinePointUW", point->tot_uw, point->uw);
+                                       }
+                               }
+                               for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
+                                       writestruct(wd, DATA, "MaskLayerShape", 1, masklay_shape);
+                                       writedata(wd, DATA, masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, masklay_shape->data);
+                               }
+                       }
+               }
+               mask = mask->id.next;
+       }
+       /* flush helps the compression for undo-save */
+       mywrite(wd, MYWRITE_FLUSH, 0);
+ }
 +static void write_linestyle_color_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      struct_name = "LineStyleColorModifier_AlongStroke";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      struct_name = "LineStyleColorModifier_DistanceFromCamera";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      struct_name = "LineStyleColorModifier_DistanceFromObject";
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      struct_name = "LineStyleColorModifier_Material";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleColorModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      writestruct(wd, DATA, "ColorBand", 1, ((LineStyleColorModifier_Material *)m)->color_ramp);
 +                      break;
 +              }
 +      }
 +}
 +
 +static void write_linestyle_alpha_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      struct_name = "LineStyleAlphaModifier_AlongStroke";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      struct_name = "LineStyleAlphaModifier_DistanceFromCamera";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      struct_name = "LineStyleAlphaModifier_DistanceFromObject";
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      struct_name = "LineStyleAlphaModifier_Material";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleAlphaModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_AlongStroke *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromObject *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      write_curvemapping(wd, ((LineStyleAlphaModifier_Material *)m)->curve);
 +                      break;
 +              }
 +      }
 +}
 +
 +static void write_linestyle_thickness_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      struct_name = "LineStyleThicknessModifier_AlongStroke";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      struct_name = "LineStyleThicknessModifier_DistanceFromCamera";
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      struct_name = "LineStyleThicknessModifier_DistanceFromObject";
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      struct_name = "LineStyleThicknessModifier_Material";
 +                      break;
 +              case LS_MODIFIER_CALLIGRAPHY:
 +                      struct_name = "LineStyleThicknessModifier_Calligraphy";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleThicknessModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_ALONG_STROKE:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_AlongStroke *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_CAMERA:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_DISTANCE_FROM_OBJECT:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromObject *)m)->curve);
 +                      break;
 +              case LS_MODIFIER_MATERIAL:
 +                      write_curvemapping(wd, ((LineStyleThicknessModifier_Material *)m)->curve);
 +                      break;
 +              }
 +      }
 +}
 +
 +static void write_linestyle_geometry_modifiers(WriteData *wd, ListBase *modifiers)
 +{
 +      LineStyleModifier *m;
 +      char *struct_name;
 +
 +      for (m = modifiers->first; m; m = m->next) {
 +              switch (m->type) {
 +              case LS_MODIFIER_SAMPLING:
 +                      struct_name = "LineStyleGeometryModifier_Sampling";
 +                      break;
 +              case LS_MODIFIER_BEZIER_CURVE:
 +                      struct_name = "LineStyleGeometryModifier_BezierCurve";
 +                      break;
 +              case LS_MODIFIER_SINUS_DISPLACEMENT:
 +                      struct_name = "LineStyleGeometryModifier_SinusDisplacement";
 +                      break;
 +              case LS_MODIFIER_SPATIAL_NOISE:
 +                      struct_name = "LineStyleGeometryModifier_SpatialNoise";
 +                      break;
 +              case LS_MODIFIER_PERLIN_NOISE_1D:
 +                      struct_name = "LineStyleGeometryModifier_PerlinNoise1D";
 +                      break;
 +              case LS_MODIFIER_PERLIN_NOISE_2D:
 +                      struct_name = "LineStyleGeometryModifier_PerlinNoise2D";
 +                      break;
 +              case LS_MODIFIER_BACKBONE_STRETCHER:
 +                      struct_name = "LineStyleGeometryModifier_BackboneStretcher";
 +                      break;
 +              case LS_MODIFIER_TIP_REMOVER:
 +                      struct_name = "LineStyleGeometryModifier_TipRemover";
 +                      break;
 +              case LS_MODIFIER_POLYGONIZATION:
 +                      struct_name = "LineStyleGeometryModifier_Polygonalization";
 +                      break;
 +              case LS_MODIFIER_GUIDING_LINES:
 +                      struct_name = "LineStyleGeometryModifier_GuidingLines";
 +                      break;
 +              case LS_MODIFIER_BLUEPRINT:
 +                      struct_name = "LineStyleGeometryModifier_Blueprint";
 +                      break;
 +              case LS_MODIFIER_2D_OFFSET:
 +                      struct_name = "LineStyleGeometryModifier_2DOffset";
 +                      break;
 +              case LS_MODIFIER_2D_TRANSFORM:
 +                      struct_name = "LineStyleGeometryModifier_2DTransform";
 +                      break;
 +              default:
 +                      struct_name = "LineStyleGeometryModifier"; // this should not happen
 +              }
 +              writestruct(wd, DATA, struct_name, 1, m);
 +      }
 +}
 +
 +static void write_linestyles(WriteData *wd, ListBase *idbase)
 +{
 +      FreestyleLineStyle *linestyle;
 +
 +      for(linestyle=idbase->first; linestyle; linestyle= linestyle->id.next) {
 +              if(linestyle->id.us>0 || wd->current) {
 +                      writestruct(wd, ID_LS, "FreestyleLineStyle", 1, linestyle);
 +                      if (linestyle->id.properties) IDP_WriteProperty(linestyle->id.properties, wd);
 +                      if (linestyle->adt) write_animdata(wd, linestyle->adt);
 +                      write_linestyle_color_modifiers(wd, &linestyle->color_modifiers);
 +                      write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers);
 +                      write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers);
 +                      write_linestyle_geometry_modifiers(wd, &linestyle->geometry_modifiers);
 +              }
 +      }
 +}
 +
  /* context is usually defined by WM, two cases where no WM is available:
   * - for forward compatibility, curscreen has to be saved
   * - for undofile, curscene needs to be saved */
index cebc0e8810efcc69bd9f812a461366213da7fdbb,752e458ef789286aeaa27f1ab02084175c858e62..103b23be46628fd6cf445aea9fbe1cf891510fb8
@@@ -55,8 -55,8 +55,9 @@@
  #include "DNA_camera_types.h"
  #include "DNA_lamp_types.h"
  #include "DNA_lattice_types.h"
 +#include "DNA_linestyle_types.h"
  #include "DNA_key_types.h"
+ #include "DNA_mask_types.h"
  #include "DNA_material_types.h"
  #include "DNA_mesh_types.h"
  #include "DNA_meta_types.h"
index 027655e393fdbe80468ec60feb481b1a42d596f3,02f34873ea77fd82338f6d06c298f0dfebe505fd..f39510666ec73577bff8fedc03e8d9364270c5ca
@@@ -1822,20 -1878,39 +1884,52 @@@ void init_userdef_do_versions(void
                for (btheme = U.themes.first; btheme; btheme = btheme->next)
                        rgba_char_args_set(btheme->tv3d.skin_root, 180, 77, 77, 255);
        }
+       
+       if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) {
+               bTheme *btheme;
+               
+               for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+                       /* DopeSheet Summary */
+                       rgba_char_args_set(btheme->tact.anim_active,    204, 112, 26, 102); 
+                       
+                       /* NLA Colors */
+                       rgba_char_args_set(btheme->tnla.anim_active,    204, 112, 26, 102); /* same as dopesheet above */
+                       rgba_char_args_set(btheme->tnla.anim_non_active,153, 135, 97, 77);
+                       
+                       rgba_char_args_set(btheme->tnla.nla_tweaking,   77, 243, 26, 77);
+                       rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
+                       
+                       rgba_char_args_set(btheme->tnla.nla_transition,     28, 38, 48, 255);
+                       rgba_char_args_set(btheme->tnla.nla_transition_sel, 46, 117, 219, 255);
+                       rgba_char_args_set(btheme->tnla.nla_meta,           51, 38, 66, 255);
+                       rgba_char_args_set(btheme->tnla.nla_meta_sel,       105, 33, 150, 255);
+                       rgba_char_args_set(btheme->tnla.nla_sound,          43, 61, 61, 255);
+                       rgba_char_args_set(btheme->tnla.nla_sound_sel,      31, 122, 122, 255);
+               }
+       }
+       if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
+               bTheme *btheme;
+               for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+                       if (btheme->tseq.movieclip[0] == 0) {
+                               rgba_char_args_set(btheme->tseq.mask,  152, 78, 62, 255);
+                       }
+               }
+       }
  
 +      /* Freestyle color settings */
 +      {
 +              bTheme *btheme;
 +
 +              for(btheme= U.themes.first; btheme; btheme= btheme->next) {
 +                      /* check for alpha==0 is safe, then color was never set */
 +                      if(btheme->tv3d.freestyle_edge_mark[3]==0) {
 +                              rgba_char_args_set(btheme->tv3d.freestyle_edge_mark, 0x7f, 0xff, 0x7f, 255);
 +                              rgba_char_args_set(btheme->tv3d.freestyle_face_mark, 0x7f, 0xff, 0x7f, 51);
 +                      }
 +              }
 +      }
 +
        /* GL Texture Garbage Collection (variable abused above!) */
        if (U.textimeout == 0) {
                U.texcollectrate = 60;
index 814b1d18876064cbd36a18aafddcfe97fcd4f91d,b6fc4f58bd7c45a915ee9045d5b98d1cfeec46eb..46a0f21fde0886e6867aa1c7d000d7de04bb7c2f
@@@ -206,7 -206,7 +206,8 @@@ typedef struct PreviewImage 
  #define ID_GD         MAKE_ID2('G', 'D') /* GreasePencil */
  #define ID_WM         MAKE_ID2('W', 'M') /* WindowManager */
  #define ID_MC         MAKE_ID2('M', 'C') /* MovieClip */
+ #define ID_MSK                MAKE_ID2('M', 'S') /* Mask */
 +#define ID_LS         MAKE_ID2('L', 'S') /* FreestyleLineStyle */
  
        /* NOTE! Fake IDs, needed for g.sipo->blocktype or outliner */
  #define ID_SEQ                MAKE_ID2('S', 'Q')
index a997a6558991512f7ce74662f548bae0fec3ba44,08d5743bb888113a2dac143ce2a1d5074ed6872c..651b69f6aca5ed462126e40098d14a2be989937b
@@@ -527,46 -527,45 +527,46 @@@ typedef struct bDopeSheet 
  
  /* DopeSheet filter-flag */
  typedef enum eDopeSheet_FilterFlag {
-               /* general filtering */
-       ADS_FILTER_ONLYSEL                      = (1<<0),       /* only include channels relating to selected data */
-       
-               /* temporary filters */
-       ADS_FILTER_ONLYDRIVERS          = (1<<1),       /* for 'Drivers' editor - only include Driver data from AnimData */
-       ADS_FILTER_ONLYNLA                      = (1<<2),       /* for 'NLA' editor - only include NLA data from AnimData */
-       ADS_FILTER_SELEDIT                      = (1<<3),       /* for Graph Editor - used to indicate whether to include a filtering flag or not */
-       
-               /* general filtering 2 */
-       ADS_FILTER_SUMMARY                      = (1<<4),       /* for 'DopeSheet' Editors - include 'summary' line */
-       ADS_FILTER_ONLYOBGROUP          = (1<<5),       /* only the objects in the specified object group get used */
-       
-               /* datatype-based filtering */
-       ADS_FILTER_NOSHAPEKEYS          = (1<<6),
-       ADS_FILTER_NOMESH                       = (1<<7),
-       ADS_FILTER_NOOBJ                        = (1<<8),       /* for animdata on object level, if we only want to concentrate on materials/etc. */
-       ADS_FILTER_NOLAT                        = (1<<9),
-       ADS_FILTER_NOCAM                        = (1<<10),
-       ADS_FILTER_NOMAT                        = (1<<11),
-       ADS_FILTER_NOLAM                        = (1<<12),
-       ADS_FILTER_NOCUR                        = (1<<13),
-       ADS_FILTER_NOWOR                        = (1<<14),
-       ADS_FILTER_NOSCE                        = (1<<15),
-       ADS_FILTER_NOPART                       = (1<<16),
-       ADS_FILTER_NOMBA                        = (1<<17),
-       ADS_FILTER_NOARM                        = (1<<18),
-       ADS_FILTER_NONTREE                      = (1<<19),
-       ADS_FILTER_NOTEX                        = (1<<20),
-       ADS_FILTER_NOSPK                        = (1<<21),
-       ADS_FILTER_NOLINESTYLE          = (1<<22),
-       
-               /* NLA-specific filters */
-       ADS_FILTER_NLA_NOACT            = (1<<25),      /* if the AnimData block has no NLA data, don't include to just show Action-line */
-       
-               /* general filtering 3 */
-       ADS_FILTER_INCL_HIDDEN          = (1<<26),      /* include 'hidden' channels too (i.e. those from hidden Objects/Bones) */
-       ADS_FILTER_BY_FCU_NAME          = (1<<27),      /* for F-Curves, filter by the displayed name (i.e. to isolate all Location curves only) */
-       
-               /* combination filters (some only used at runtime) */
-       ADS_FILTER_NOOBDATA = (ADS_FILTER_NOCAM|ADS_FILTER_NOMAT|ADS_FILTER_NOLAM|ADS_FILTER_NOCUR|ADS_FILTER_NOPART|ADS_FILTER_NOARM|ADS_FILTER_NOSPK)
+       /* general filtering */
+       ADS_FILTER_ONLYSEL          = (1 << 0),   /* only include channels relating to selected data */
+       
+       /* temporary filters */
+       ADS_FILTER_ONLYDRIVERS      = (1 << 1),   /* for 'Drivers' editor - only include Driver data from AnimData */
+       ADS_FILTER_ONLYNLA          = (1 << 2),   /* for 'NLA' editor - only include NLA data from AnimData */
+       ADS_FILTER_SELEDIT          = (1 << 3),   /* for Graph Editor - used to indicate whether to include a filtering flag or not */
+       /* general filtering 2 */
+       ADS_FILTER_SUMMARY          = (1 << 4),   /* for 'DopeSheet' Editors - include 'summary' line */
+       ADS_FILTER_ONLYOBGROUP      = (1 << 5),   /* only the objects in the specified object group get used */
+       /* datatype-based filtering */
+       ADS_FILTER_NOSHAPEKEYS      = (1 << 6),
+       ADS_FILTER_NOMESH           = (1 << 7),
+       ADS_FILTER_NOOBJ            = (1 << 8),   /* for animdata on object level, if we only want to concentrate on materials/etc. */
+       ADS_FILTER_NOLAT            = (1 << 9),
+       ADS_FILTER_NOCAM            = (1 << 10),
+       ADS_FILTER_NOMAT            = (1 << 11),
+       ADS_FILTER_NOLAM            = (1 << 12),
+       ADS_FILTER_NOCUR            = (1 << 13),
+       ADS_FILTER_NOWOR            = (1 << 14),
+       ADS_FILTER_NOSCE            = (1 << 15),
+       ADS_FILTER_NOPART           = (1 << 16),
+       ADS_FILTER_NOMBA            = (1 << 17),
+       ADS_FILTER_NOARM            = (1 << 18),
+       ADS_FILTER_NONTREE          = (1 << 19),
+       ADS_FILTER_NOTEX            = (1 << 20),
+       ADS_FILTER_NOSPK            = (1 << 21),
++      ADS_FILTER_NOLINESTYLE      = (1 << 22),
+       /* NLA-specific filters */
+       ADS_FILTER_NLA_NOACT        = (1 << 25),  /* if the AnimData block has no NLA data, don't include to just show Action-line */
+       /* general filtering 3 */
+       ADS_FILTER_INCL_HIDDEN      = (1 << 26),  /* include 'hidden' channels too (i.e. those from hidden Objects/Bones) */
+       ADS_FILTER_BY_FCU_NAME      = (1 << 27),  /* for F-Curves, filter by the displayed name (i.e. to isolate all Location curves only) */
+       
+       /* combination filters (some only used at runtime) */
+       ADS_FILTER_NOOBDATA = (ADS_FILTER_NOCAM | ADS_FILTER_NOMAT | ADS_FILTER_NOLAM | ADS_FILTER_NOCUR | ADS_FILTER_NOPART | ADS_FILTER_NOARM | ADS_FILTER_NOSPK)
  } eDopeSheet_FilterFlag;      
  
  /* DopeSheet general flags */
index 6b965b046850df1107969d0a38c13ed3aeb287dd,b0f8f02ae9fa5a174d7b0cbdc7333d20a1f5ccb8..177db54548370e425bab5c7ea3d35265e5a5ab10
@@@ -132,8 -132,7 +132,9 @@@ static const char *includefiles[] = 
        "DNA_movieclip_types.h",
        "DNA_tracking_types.h",
        "DNA_dynamicpaint_types.h",
+       "DNA_mask_types.h",
 +      "DNA_freestyle_types.h",
 +      "DNA_linestyle_types.h",
  
        // empty string to indicate end of includefiles
        ""
@@@ -1243,6 -1242,5 +1244,7 @@@ int main(int argc, char **argv
  #include "DNA_movieclip_types.h"
  #include "DNA_tracking_types.h"
  #include "DNA_dynamicpaint_types.h"
+ #include "DNA_mask_types.h"
 +#include "DNA_freestyle_types.h"
 +#include "DNA_linestyle_types.h"
  /* end of list */
Simple merge
index 371a0e32155792aaa9fb0d31a1254253a2bc6ddf,29910121e2a9c6285b84a8f60b1e65799a241713..5379de52ca8b6e6bb318202ae59a822096ff35f9
@@@ -11,7 -11,7 +11,8 @@@ incs += ' ../windowmanager ../editors/i
  incs += ' ../render/extern/include #/intern/cycles/blender'
  incs += ' ../nodes'
  incs += ' #/extern/glew/include'
+ incs += ' #/intern/smoke/extern'
 +incs += ' ../freestyle'
  
  incs += ' ../bmesh'
  
index 519e8aff823e25f8c18ce7a4831dd3085e6f1a15,82c0757456d2ca2aa17ff98f2044e7cf7163ae9d..24bf6ff4aa1ed73ad30acc7de7f726cafa3ef143
@@@ -54,8 -54,8 +54,9 @@@ set(DEFSR
        rna_key.c
        rna_lamp.c
        rna_lattice.c
 +      rna_linestyle.c
        rna_main.c
+       rna_mask.c
        rna_material.c
        rna_mesh.c
        rna_meta.c
index daa307e77c21344126c561ce5a0a17c2cdfe3bff,e8e40d307fb99c413187d34a1cca5bedf0d16e0f..a4582406c10a0cf7628b5bed368771706c3accba
@@@ -302,7 -302,7 +303,8 @@@ void RNA_def_main_actions(BlenderRNA *b
  void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop);
  void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop);
  void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop);
+ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop);
 +void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop);
  
  /* ID Properties */
  
index 5b2d8ddbeeecec434b3bc7cddec0219b3b589072,6ac032e5d999f6cfc03d749e152354a72687a529..6f8545099eabea910a7db0aa8e6f8bdc17893a4d
@@@ -253,12 -253,12 +253,18 @@@ static void rna_Main_movieclips_begin(C
        rna_iterator_listbase_begin(iter, &bmain->movieclip, NULL);
  }
  
+ static void rna_Main_masks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+ {
+       Main *bmain= (Main*)ptr->data;
+       rna_iterator_listbase_begin(iter, &bmain->mask, NULL);
+ }
 +static void rna_Main_linestyle_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 +{
 +      Main *bmain= (Main*)ptr->data;
 +      rna_iterator_listbase_begin(iter, &bmain->linestyle, NULL);
 +}
 +
  #ifdef UNIT_TEST
  
  static PointerRNA rna_Test_test_get(PointerRNA *ptr)
@@@ -322,7 -322,7 +328,8 @@@ void RNA_def_main(BlenderRNA *brna
                {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks", RNA_def_main_particles},
                {"grease_pencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks", RNA_def_main_gpencil},
                {"movieclips", "MovieClip", "rna_Main_movieclips_begin", "Movie Clips", "Movie Clip datablocks", RNA_def_main_movieclips},
+               {"masks", "Mask", "rna_Main_masks_begin", "Masks", "Masks datablocks", RNA_def_main_masks},
 +              {"linestyles", "FreestyleLineStyle", "rna_Main_linestyle_begin", "Line Styles", "Line Style datablocks", RNA_def_main_linestyles},
                {NULL, NULL, NULL, NULL, NULL, NULL}
        };
  
index 53cfe684203c36a20764f4606e383a7b7b054ab3,98b3c0ab9f4323157a1fd191a14860023f05f2c7..ed45b378228dc700fd07859f24c21e0be94028dd
@@@ -67,7 -69,7 +69,8 @@@
  #include "BKE_depsgraph.h"
  #include "BKE_speaker.h"
  #include "BKE_movieclip.h"
+ #include "BKE_mask.h"
 +#include "BKE_linestyle.h"
  
  #include "DNA_armature_types.h"
  #include "DNA_camera_types.h"
@@@ -540,23 -543,22 +544,39 @@@ void rna_Main_movieclips_remove(Main *b
        /* XXX python now has invalid pointer? */
  }
  
+ Mask *rna_Main_mask_new(Main *UNUSED(bmain), const char *name)
+ {
+       Mask *mask;
+       mask = BKE_mask_new("Mask");
+       return mask;
+ }
+ void rna_Main_masks_remove(Main *bmain, Mask *mask)
+ {
+       BKE_mask_unlink(bmain, mask);
+       BKE_libblock_free(&bmain->mask, mask);
+       /* XXX python now has invalid pointer? */
+ }
 +FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char* name)
 +{
 +      FreestyleLineStyle *linestyle = FRS_new_linestyle(name, bmain);
 +      id_us_min(&linestyle->id);
 +      return linestyle;
 +}
 +
 +void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineStyle *linestyle)
 +{
 +      if(ID_REAL_USERS(linestyle) <= 0)
 +              BKE_libblock_free(&bmain->linestyle, linestyle);
 +      else
 +              BKE_reportf(reports, RPT_ERROR, "Line style \"%s\" must have zero users to be removed, found %d.", linestyle->id.name+2, ID_REAL_USERS(linestyle));
 +
 +      /* XXX python now has invalid pointer? */
 +}
 +
  /* tag functions, all the same */
  void rna_Main_cameras_tag(Main *bmain, int value) { tag_main_lb(&bmain->camera, value); }
  void rna_Main_scenes_tag(Main *bmain, int value) { tag_main_lb(&bmain->scene, value); }
@@@ -587,7 -589,7 +607,8 @@@ void rna_Main_actions_tag(Main *bmain, 
  void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); }
  void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); }
  void rna_Main_movieclips_tag(Main *bmain, int value) { tag_main_lb(&bmain->movieclip, value); }
+ void rna_Main_masks_tag(Main *bmain, int value) { tag_main_lb(&bmain->mask, value); }
 +void rna_Main_linestyle_tag(Main *bmain, int value) { tag_main_lb(&bmain->linestyle, value); }
  
  static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA); }
  static int rna_Main_scenes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCE); }
@@@ -1539,30 -1541,34 +1560,60 @@@ void RNA_def_main_movieclips(BlenderRN
        RNA_def_function_return(func, parm);
  }
  
+ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop)
+ {
+       StructRNA *srna;
+       FunctionRNA *func;
+       PropertyRNA *parm;
+       RNA_def_property_srna(cprop, "BlendDataMasks");
+       srna= RNA_def_struct(brna, "BlendDataMasks", NULL);
+       RNA_def_struct_sdna(srna, "Main");
+       RNA_def_struct_ui_text(srna, "Main Masks", "Collection of masks");
+       func= RNA_def_function(srna, "tag", "rna_Main_masks_tag");
+       parm= RNA_def_boolean(func, "value", 0, "Value", "");
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       /* new func */
+       func = RNA_def_function(srna, "new", "rna_Main_mask_new");
+       RNA_def_function_ui_description(func, "Add a new mask with a given name to the main database");
+       parm = RNA_def_string_file_path(func, "name", "", MAX_ID_NAME - 2, "Mask", "Name of new mask datablock");
+       /* return type */
+       parm = RNA_def_pointer(func, "mask", "Mask", "", "New mask datablock");
+       RNA_def_function_return(func, parm);
+       /* remove func */
+       func= RNA_def_function(srna, "remove", "rna_Main_masks_remove");
+       RNA_def_function_ui_description(func, "Remove a masks from the current blendfile.");
+       parm= RNA_def_pointer(func, "mask", "Mask", "", "Mask to remove");
+       RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
+ }
 +void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop)
 +{
 +      StructRNA *srna;
 +      FunctionRNA *func;
 +      PropertyRNA *parm;
 +
 +      RNA_def_property_srna(cprop, "BlendDataLineStyles");
 +      srna= RNA_def_struct(brna, "BlendDataLineStyles", NULL);
 +      RNA_def_struct_sdna(srna, "Main");
 +      RNA_def_struct_ui_text(srna, "Main Line Styles", "Collection of line styles");
 +
 +      func= RNA_def_function(srna, "new", "rna_Main_linestyles_new");
 +      RNA_def_function_ui_description(func, "Add a new line style instance to the main database");
 +      parm= RNA_def_string(func, "name", "FreestyleLineStyle", 0, "", "New name for the datablock");
 +      RNA_def_property_flag(parm, PROP_REQUIRED);
 +      /* return type */
 +      parm= RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "New line style datablock");
 +      RNA_def_function_return(func, parm);
 +
 +      func= RNA_def_function(srna, "remove", "rna_Main_linestyles_remove");
 +      RNA_def_function_flag(func, FUNC_USE_REPORTS);
 +      RNA_def_function_ui_description(func, "Remove a line style instance from the current blendfile");
 +      parm= RNA_def_pointer(func, "linestyle", "FreestyleLineStyle", "", "Line style to remove");
 +      RNA_def_property_flag(parm, PROP_REQUIRED);
 +}
 +
  #endif
index a3bc4f87b6077722efb16627b22ae4c2642fee1f,a15d020c2306e56c6a67bc2f7e65a68363b565e5..72d2bf9d1f124405197f80b6981467d3c6d4969b
@@@ -167,7 -167,7 +167,8 @@@ typedef struct wmNotifier 
  #define NC_ID                         (18<<24)
  #define NC_LOGIC                      (19<<24)
  #define NC_MOVIECLIP                  (20<<24)
- #define NC_LINESTYLE                  (21<<24)
+ #define NC_MASK                               (21<<24)
++#define NC_LINESTYLE                  (22<<24)
  
  /* data type, 256 entries is enough, it can overlap */
  #define NOTE_DATA                     0x00FF0000
Simple merge