svn merge ^/trunk/blender -r48527:48537
authorCampbell Barton <ideasman42@gmail.com>
Tue, 3 Jul 2012 14:05:18 +0000 (14:05 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 3 Jul 2012 14:05:18 +0000 (14:05 +0000)
1  2 
source/blender/blenkernel/BKE_image.h
source/blender/blenkernel/intern/image.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_node/drawnode.c

index 5844971cde56808fdc2abdf434d72778df61f94c,909ed471081f995913369af92edfc4ae5c48ab0b..b1ca348be86fb0b774f8c214866bf9e3b134d2f8
@@@ -64,7 -64,6 +64,7 @@@ int     BKE_imtype_is_movie(const char 
  int     BKE_imtype_supports_zbuf(const char imtype);
  int     BKE_imtype_supports_compress(const char imtype);
  int     BKE_imtype_supports_quality(const char imtype);
 +int     BKE_imtype_supports_float(const char imtype);
  char    BKE_imtype_valid_channels(const char imtype);
  char    BKE_imtype_valid_depths(const char imtype);
  
@@@ -158,7 -157,7 +158,7 @@@ void BKE_image_assign_ibuf(struct Imag
  /* called on frame change or before render */
  void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
  void BKE_image_user_check_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr);
- int  BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr);
+ int  BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr, short *r_is_in_range);
  void BKE_image_user_file_path(struct ImageUser *iuser, struct Image *ima, char *path); 
  
  /* sets index offset for multilayer files */
index b568c2ffb0e406a3c07e58ec9c79350cd98fa17d,65747baa3232c2672701663127b93db84b9f6013..733b8bebc9d9850d7f4c05278e1772ac27cc7817
@@@ -1011,20 -1011,6 +1011,20 @@@ int BKE_imtype_supports_quality(const c
        return 0;
  }
  
 +int BKE_imtype_supports_float(const char imtype)
 +{
 +      switch (imtype) {
 +              case R_IMF_IMTYPE_CINEON:
 +              case R_IMF_IMTYPE_DPX:
 +              case R_IMF_IMTYPE_RADHDR:
 +              case R_IMF_IMTYPE_OPENEXR:
 +              case R_IMF_IMTYPE_MULTILAYER:
 +              case R_IMF_IMTYPE_JP2:
 +                      return TRUE;
 +      }
 +      return 0;
 +}
 +
  char BKE_imtype_valid_channels(const char imtype)
  {
        char chan_flag = IMA_CHAN_FLAG_RGB; /* assume all support rgb */
@@@ -2556,11 -2542,7 +2556,11 @@@ static ImBuf *image_get_render_result(I
        /* free rect buffer if float buffer changes, so it can be recreated with
         * the updated result, and also in case we got byte buffer from sequencer,
         * so we don't keep reference to freed buffer */
 -      if (ibuf->rect_float != rectf || rect || !rectf)
 +      
 +      /* todo: this fix breaks save buffers render progress 
 +         if (ibuf->rect_float != rectf || rect || !rectf) */
 +
 +      if (ibuf->rect_float != rectf || rect)
                imb_freerectImBuf(ibuf);
  
        if (rect)
@@@ -2802,10 -2784,14 +2802,14 @@@ ImBuf *BKE_image_get_ibuf(Image *ima, I
        return BKE_image_acquire_ibuf(ima, iuser, NULL);
  }
  
- int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr)
+ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, short *r_is_in_range)
  {
        const int len = (iuser->fie_ima * iuser->frames) / 2;
  
+       if (r_is_in_range) {
+               *r_is_in_range = FALSE;
+       }
        if (len == 0) {
                return 0;
        }
                        cfra = ((cfra) % len);
                        if (cfra < 0) cfra += len;
                        if (cfra == 0) cfra = len;
+                       if (r_is_in_range) {
+                               *r_is_in_range = TRUE;
+                       }
                }
  
-               if (cfra < 0) cfra = 0;
-               else if (cfra > len) cfra = len;
+               if (cfra < 0) {
+                       cfra = 0;
+               }
+               else if (cfra > len) {
+                       cfra = len;
+               }
+               else {
+                       if (r_is_in_range) {
+                               *r_is_in_range = TRUE;
+                       }
+               }
  
                /* convert current frame to current field */
                cfra = 2 * (cfra);
  void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr)
  {
        if (iuser) {
-               const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr);
+               short is_in_range;
+               const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr, &is_in_range);
+               if (is_in_range) {
+                       iuser->flag |= IMA_USER_FRAME_IN_RANGE;
+               }
+               else {
+                       iuser->flag &= ~IMA_USER_FRAME_IN_RANGE;
+               }
  
                /* allows image users to handle redraws */
                if (iuser->flag & IMA_ANIM_ALWAYS)
index 60469a31a8c815ccedf4942973d9578ab8c8f20f,7133f79f880b04125193b6483db53e964f0723d4..f9413383577e9760adc370045dd01fbe95a2654c
@@@ -5533,6 -5533,11 +5533,11 @@@ void lib_link_screen_restore(Main *newm
                                                if (ads->filter_grp)
                                                        ads->filter_grp = restore_pointer_by_name(newmain, (ID *)ads->filter_grp, 0);
                                        }
+                                       
+                                       /* force recalc of list of channels (i.e. includes calculating F-Curve colors)
+                                        * thus preventing the "black curves" problem post-undo
+                                        */
+                                       sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
                                }
                                else if (sl->spacetype == SPACE_BUTS) {
                                        SpaceButs *sbuts = (SpaceButs *)sl;
                                        SpaceAction *saction = (SpaceAction *)sl;
                                        
                                        saction->action = restore_pointer_by_name(newmain, (ID *)saction->action, 1);
-                                       saction->ads.source= restore_pointer_by_name(newmain, (ID *)saction->ads.source, 1);
+                                       saction->ads.source = restore_pointer_by_name(newmain, (ID *)saction->ads.source, 1);
                                        
                                        if (saction->ads.filter_grp)
-                                               saction->ads.filter_grp= restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, 0);
+                                               saction->ads.filter_grp = restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, 0);
                                                
                                        
                                        /* force recalc of list of channels, potentially updating the active action 
@@@ -8016,7 -8021,7 +8021,7 @@@ BlendFileData *blo_read_file_internal(F
        fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */
        
        link_global(fd, bfd);   /* as last */
 -      
 +
        return bfd;
  }
  
index 944c8afed10493956aa40d26767eca14af4476c5,92c339d767284219778b7dac392ad04da2b64fdf..b92f4829cd32de72e0335f997589c5edc00e6013
@@@ -148,7 -148,7 +148,7 @@@ static void image_info(Scene *scene, Im
        /* the frame number, even if we cant */
        if (ima->source == IMA_SRC_SEQUENCE) {
                /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
-               const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0);
+               const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL);
                ofs += sprintf(str + ofs, IFACE_(", Frame: %d"), framenr);
        }
  
@@@ -798,14 -798,11 +798,14 @@@ void uiTemplateImageSettings(uiLayout *
  {
        ImageFormatData *imf = imfptr->data;
        ID *id = imfptr->id.data;
 +      PointerRNA display_settings_ptr, view_settings_ptr;
 +      PropertyRNA *prop;
        const int depth_ok = BKE_imtype_valid_depths(imf->imtype);
        /* some settings depend on this being a scene thats rendered */
        const short is_render_out = (id && GS(id->name) == ID_SCE);
  
        uiLayout *col, *row, *split, *sub;
 +      int show_preview = FALSE;
  
        col = uiLayoutColumn(layout, FALSE);
  
        }
  
        if (is_render_out && (imf->imtype == R_IMF_IMTYPE_OPENEXR)) {
 +              show_preview = TRUE;
                uiItemR(row, imfptr, "use_preview", 0, NULL, ICON_NONE);
        }
  
                uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE);
  #endif
        }
 +
 +      /* color management */
 +      if (!BKE_imtype_supports_float(imf->imtype) ||
 +          (show_preview && imf->flag & R_IMF_FLAG_PREVIEW_JPG))
 +      {
 +              prop = RNA_struct_find_property(imfptr, "display_settings");
 +              display_settings_ptr = RNA_property_pointer_get(imfptr, prop);
 +
 +              prop = RNA_struct_find_property(imfptr, "view_settings");
 +              view_settings_ptr = RNA_property_pointer_get(imfptr, prop);
 +
 +              col = uiLayoutColumn(layout, FALSE);
 +              uiItemL(col, IFACE_("Color Management"), ICON_NONE);
 +
 +              uiItemR(col, &display_settings_ptr, "display_device", 0, NULL, ICON_NONE);
 +
 +              uiItemR(col, &view_settings_ptr, "view_transform", 0, NULL, ICON_NONE);
 +              uiItemR(col, &view_settings_ptr, "exposure", 0, NULL, ICON_NONE);
 +              uiItemR(col, &view_settings_ptr, "gamma", 0, NULL, ICON_NONE);
 +      }
  }
  
  void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)
index 731304a3b9dd0efe605c57769356a262f961443b,daab0ce0f5f91083e7cd1133d5cff01a040170ef..d28e3ac5507871b872a76ac31a23afc76482161a
@@@ -52,7 -52,6 +52,7 @@@
  #include "BKE_library.h"
  #include "BKE_main.h"
  #include "BKE_node.h"
 +#include "BKE_tracking.h"
  
  #include "BLF_api.h"
  #include "BLF_translation.h"
@@@ -78,7 -77,6 +78,7 @@@
  #include "UI_interface.h"
  #include "UI_resources.h"
  
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf.h"
  #include "IMB_imbuf_types.h"
  
@@@ -1215,7 -1213,7 +1215,7 @@@ static void node_buts_image_user(uiLayo
                Scene *scene = CTX_data_scene(C);
                ImageUser *iuser = iuserptr->data;
                char numstr[32];
-               const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0);
+               const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL);
                BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
                uiItemL(layout, numstr, ICON_NONE);
        }
@@@ -2491,41 -2489,6 +2491,41 @@@ static void node_composit_buts_keying(u
        uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE);
  }
  
 +static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRNA *ptr)
 +{
 +      bNode *node= ptr->data;
 +
 +      uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
 +
 +      if (node->id) {
 +              MovieClip *clip = (MovieClip *) node->id;
 +              MovieTracking *tracking = &clip->tracking;
 +              MovieTrackingObject *object;
 +              uiLayout *col;
 +              PointerRNA tracking_ptr;
 +              NodeTrackPosData *data = node->storage;
 +
 +              RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
 +
 +              col = uiLayoutColumn(layout, 0);
 +              uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
 +
 +              object = BKE_tracking_object_get_named(tracking, data->tracking_object);
 +              if (object) {
 +                      PointerRNA object_ptr;
 +
 +                      RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
 +
 +                      uiItemPointerR(col, ptr, "track_name", &object_ptr, "tracks", "", ICON_ANIM_DATA);
 +              }
 +              else {
 +                      uiItemR(layout, ptr, "track_name", 0, "", ICON_ANIM_DATA);
 +              }
 +
 +              uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE);
 +      }
 +}
 +
  /* only once called */
  static void node_composit_set_butfunc(bNodeType *ntype)
  {
                case CMP_NODE_KEYING:
                        ntype->uifunc = node_composit_buts_keying;
                        break;
 +              case CMP_NODE_TRACKPOS:
 +                      ntype->uifunc = node_composit_buts_trackpos;
 +                      break;
                default:
                        ntype->uifunc = NULL;
        }
@@@ -2955,7 -2915,7 +2955,7 @@@ void ED_init_node_butfuncs(void
  
  /* ************** Generic drawing ************** */
  
 -void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
 +void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
  {
        
        if ((snode->flag & SNODE_BACKDRAW) && snode->treetype == NTREE_COMPOSIT) {
                void *lock;
                ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
                if (ibuf) {
 +                      SpaceNode *snode = CTX_wm_space_node(C);
 +                      wmWindow *win = CTX_wm_window(C);
 +                      const ColorManagedViewSettings *view_settings;
                        float x, y; 
 +                      unsigned char *display_buffer;
 +                      void *cache_handle;
                        
                        glMatrixMode(GL_PROJECTION);
                        glPushMatrix();
                        x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
                        y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
                        
 -                      if (!ibuf->rect) {
 -                              if (color_manage)
 -                                      ibuf->profile = IB_PROFILE_LINEAR_RGB;
 -                              else
 -                                      ibuf->profile = IB_PROFILE_NONE;
 -                              IMB_rect_from_float(ibuf);
 -                      }
  
 -                      if (ibuf->rect) {
 +                      view_settings = IMB_view_settings_get_effective(win, &snode->view_settings);
 +                      display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, &win->display_settings, &cache_handle);
 +
 +                      if (display_buffer) {
                                if (snode->flag & SNODE_SHOW_ALPHA) {
                                        glPixelZoom(snode->zoom, snode->zoom);
                                        /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
                                        if (ENDIAN_ORDER == B_ENDIAN)
                                                glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
                                        
 -                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ibuf->rect);
 +                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer);
                                        
                                        glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
                                        glPixelZoom(1.0f, 1.0f);
                                        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                                        glPixelZoom(snode->zoom, snode->zoom);
                                        
 -                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
 +                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
                                        
                                        glPixelZoom(1.0f, 1.0f);
                                        glDisable(GL_BLEND);
                                else {
                                        glPixelZoom(snode->zoom, snode->zoom);
                                        
 -                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
 +                                      glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
                                        
                                        glPixelZoom(1.0f, 1.0f);
                                }
                        }
  
 +                      IMB_display_buffer_release(cache_handle);
 +
                        /// @note draw selected info on backdrop
                        if (snode->edittree) {
                                bNode *node = snode->edittree->nodes.first;