Commit: 8eb050c05895c790022a746e6e935575ee9d02ff
Author: Dalai Felinto
Date:   Thu Nov 20 10:48:47 2014 -0200
Branches: multiview
https://developer.blender.org/rB8eb050c05895c790022a746e6e935575ee9d02ff

Merge remote-tracking branch 'origin/master' into multiview

Include manual fixes for BLI_listbase renames

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/image.c
index fee62ea,54f5cb7..fc3d188
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@@ -2356,62 -2149,6 +2356,62 @@@ Image *BKE_image_verify_viewer(int type
        return ima;
  }
  
 +static void image_viewer_create_views(const RenderData *rd, Image *ima)
 +{
 +      SceneRenderView *srv;
 +      ImageView *iv;
 +      for (srv = rd->views.first; srv; srv = srv->next) {
 +              if (BKE_scene_render_view_active(rd, srv) == false)
 +                      continue;
 +              iv = MEM_mallocN(sizeof(ImageView), "Viewer Image View");
 +              BLI_strncpy(iv->name, srv->name, sizeof(iv->name));
 +              BLI_addtail(&ima->views, iv);
 +      }
 +}
 +
 +/* Reset the image cache and views when the Viewer Nodes views don't match 
the scene views */
 +void BKE_image_verify_viewer_views(const RenderData *rd, Image *ima, 
ImageUser *iuser)
 +{
 +      bool do_reset;
 +
 +      BLI_lock_thread(LOCK_DRAW_IMAGE);
 +
 +      if (BKE_scene_is_stereo3d(rd)) {
 +              ima->flag |= IMA_IS_STEREO;
 +              ima->flag |= IMA_IS_MULTIVIEW;
 +      }
 +      else {
 +              ima->flag &= ~IMA_IS_STEREO;
 +              ima->flag &= ~IMA_IS_MULTIVIEW;
 +              iuser->flag &= ~IMA_SHOW_STEREO;
 +      }
 +
 +      /* see if all scene render views are in the image view list */
-       do_reset = (BKE_scene_num_views(rd) != BLI_countlist(&ima->views));
++      do_reset = (BKE_scene_num_views(rd) != BLI_listbase_count(&ima->views));
 +      if (!do_reset) {
 +              SceneRenderView *srv;
 +              ImageView *iv;
 +
 +              for (iv = ima->views.first; iv; iv = iv->next) {
 +                      srv = BLI_findstring(&rd->views, iv->name, 
offsetof(SceneRenderView, name));
 +                      if ((srv == NULL) || (BKE_scene_render_view_active(rd, 
srv) == false)) {
 +                              do_reset = true;
 +                              break;
 +                      }
 +              }
 +      }
 +
 +      if (do_reset) {
 +              image_free_cached_frames(ima);
 +              BKE_image_free_views(ima);
 +
 +              /* add new views */
 +              image_viewer_create_views(rd, ima);
 +      }
 +
 +      BLI_unlock_thread(LOCK_DRAW_IMAGE);
 +}
 +
  void BKE_image_assign_ibuf(Image *ima, ImBuf *ibuf)
  {
        image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
@@@ -2564,31 -2274,17 +2564,31 @@@ void BKE_image_signal(Image *ima, Image
  
                case IMA_SIGNAL_RELOAD:
                        /* try to repack file */
 -                      if (ima->packedfile) {
 -                              PackedFile *pf;
 -                              pf = newPackedFile(NULL, ima->name, 
ID_BLEND_PATH(G.main, &ima->id));
 -                              if (pf) {
 -                                      freePackedFile(ima->packedfile);
 -                                      ima->packedfile = pf;
 -                                      BKE_image_free_buffers(ima);
 +                      if (BKE_image_has_packedfile(ima)) {
 +                              const size_t totfiles = image_num_files(ima);
 +
-                               if (totfiles != 
BLI_countlist(&ima->packedfiles)) {
++                              if (totfiles != 
BLI_listbase_count(&ima->packedfiles)) {
 +                                      /* in case there are new available 
files to be loaded */
 +                                      image_free_packedfiles(ima);
 +                                      BKE_image_packfiles(NULL, ima, 
ID_BLEND_PATH(G.main, &ima->id));
                                }
                                else {
 -                                      printf("ERROR: Image not available. 
Keeping packed image\n");
 +                                      ImagePackedFile *imapf;
 +                                      for (imapf = ima->packedfiles.first; 
imapf; imapf = imapf->next) {
 +                                              PackedFile *pf;
 +                                              pf = newPackedFile(NULL, 
imapf->filepath, ID_BLEND_PATH(G.main, &ima->id));
 +                                              if (pf) {
 +                                                      
freePackedFile(imapf->packedfile);
 +                                                      imapf->packedfile = pf;
 +                                              }
 +                                              else {
 +                                                      printf("ERROR: Image 
\"%s\" not available. Keeping packed image\n", imapf->filepath);
 +                                              }
 +                                      }
                                }
 +
 +                              if (BKE_image_has_packedfile(ima))
 +                                      BKE_image_free_buffers(ima);
                        }
                        else
                                BKE_image_free_buffers(ima);
@@@ -2682,68 -2366,10 +2682,68 @@@ RenderPass *BKE_image_multilayer_index(
        return rpass;
  }
  
 +void BKE_image_multiview_index(Image *ima, ImageUser *iuser)
 +{
 +      if (iuser) {
 +              bool is_stereo = (ima->flag & IMA_IS_STEREO) && (iuser->flag & 
IMA_SHOW_STEREO);
 +              if (is_stereo) {
 +                      iuser->multi_index = iuser->eye;
 +              }
 +              else {
-                       if ((iuser->view < 0) || (iuser->view >= 
BLI_countlist(&ima->views))) {
++                      if ((iuser->view < 0) || (iuser->view >= 
BLI_listbase_count(&ima->views))) {
 +                              iuser->multi_index = iuser->view = 0;
 +                      }
 +                      else {
 +                              iuser->multi_index = iuser->view;
 +                      }
 +              }
 +      }
 +}
 +
 +/* if layer or pass changes, we need an index for the imbufs list */
 +/* note it is called for rendered results, but it doesnt use the index! */
 +/* and because rendered results use fake layer/passes, don't correct for 
wrong indices here */
 +bool BKE_image_is_multilayer(Image *ima)
 +{
 +      if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE)) {
 +              if (ima->type == IMA_TYPE_MULTILAYER) {
 +                      return true;
 +              }
 +      }
 +      else if (ima->source == IMA_SRC_VIEWER) {
 +              if (ima->type == IMA_TYPE_R_RESULT) {
 +                      return true;
 +              }
 +      }
 +      return false;
 +}
 +
 +static void image_init_multilayer_multiview_flag(Image *ima, RenderResult *rr)
 +{
 +      if (rr) {
 +              if (RE_RenderResult_is_stereo(rr)) {
 +                      ima->flag |= IMA_IS_STEREO;
 +                      ima->flag |= IMA_IS_MULTIVIEW;
 +              }
 +              else {
 +                      ima->flag &= ~IMA_IS_STEREO;
-                       if (BLI_countlist(&rr->views) > 1)
++                      if (BLI_listbase_count(&rr->views) > 1)
 +                              ima->flag |= IMA_IS_MULTIVIEW;
 +                      else
 +                              ima->flag &= IMA_IS_MULTIVIEW;
 +              }
 +      }
 +      else {
 +              ima->flag &= ~IMA_IS_STEREO;
 +              ima->flag &= ~IMA_IS_MULTIVIEW;
 +      }
 +}
 +
  RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima)
  {
 +      RenderResult *rr = NULL;
        if (ima->rr) {
 -              return ima->rr;
 +              rr = ima->rr;
        }
        else if (ima->type == IMA_TYPE_R_RESULT) {
                if (ima->render_slot == ima->last_render_slot)
@@@ -2799,134 -2412,6 +2799,134 @@@ void BKE_image_backup_render(Scene *sce
        ima->last_render_slot = slot;
  }
  
 +/**************************** multiview save openexr 
*********************************/
 +static const char *image_get_view_cb(void *base, const size_t view_id)
 +{
 +      Image *ima = base;
 +      ImageView *iv = BLI_findlink(&ima->views, view_id);
 +      return iv ? iv->name : "";
 +}
 +
 +static ImBuf *image_get_buffer_cb(void *base, const size_t view_id)
 +{
 +      Image *ima = base;
 +      ImageUser iuser = {0};
 +
 +      iuser.view = view_id;
 +      iuser.ok = 1;
 +
 +      BKE_image_multiview_index(ima, &iuser);
 +
 +      return image_acquire_ibuf(ima, &iuser, NULL);
 +}
 +
 +bool BKE_image_save_openexr_multiview(Image *ima, ImBuf *ibuf, const char 
*filepath, const int flags)
 +{
 +      char name[FILE_MAX];
 +      bool ok;
 +
 +      BLI_strncpy(name, filepath, sizeof(name));
 +      BLI_path_abs(name, G.main->name);
 +
 +      ibuf->userdata = ima;
-       ok = IMB_exr_multiview_save(ibuf, name, flags, 
BLI_countlist(&ima->views), image_get_view_cb, image_get_buffer_cb);
++      ok = IMB_exr_multiview_save(ibuf, name, flags, 
BLI_listbase_count(&ima->views), image_get_view_cb, image_get_buffer_cb);
 +      ibuf->userdata = NULL;
 +
 +      return ok;
 +}
 +
 +/**************************** multiview load openexr 
*********************************/
 +static void image_add_view_cb(void *base, const char *str)
 +{
 +      Image *ima = base;
 +      ImageView *iv;
 +
 +      iv = MEM_mallocN(sizeof(ImageView), "Viewer Image View");
 +      BLI_strncpy(iv->name, str, sizeof(iv->name));
 +
 +      /* For stereo drawing we need to ensure:
 +       * STEREO_LEFT_NAME  == STEREO_LEFT_ID and
 +       * STEREO_RIGHT_NAME == STEREO_RIGHT_ID */
 +
 +      if (STREQ(str, STEREO_LEFT_NAME)) {
 +              BLI_addhead(&ima->views, iv);
 +      }
 +      else if (STREQ(str, STEREO_RIGHT_NAME)) {
 +              ImageView *left_iv = BLI_findstring(&ima->views, 
STEREO_LEFT_NAME, offsetof(ImageView, name));
 +
 +              if (left_iv == NULL) {
 +                      BLI_addhead(&ima->views, iv);
 +              }
 +              else {
 +                      BLI_insertlinkafter(&ima->views, left_iv, iv);
 +              }
 +      }
 +      else {
 +              BLI_addtail(&ima->views, iv);
 +      }
 +}
 +
 +static void image_add_buffer_cb(void *base, const char *str, ImBuf *ibuf, 
const int frame)
 +{
 +      Image *ima = base;
 +      size_t id;
 +      bool predivide = (ima->alpha_mode == IMA_ALPHA_PREMUL);
 +      const char *colorspace = ima->colorspace_settings.name;
 +      const char *to_colorspace = 
IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
 +      
 +      if (ibuf == NULL)
 +              return;
 +      
 +      id = BLI_findstringindex(&ima->views, str, offsetof(ImageView, name));
 +      
 +      if (id == -1)
 +              return;
 +
 +      if (ibuf->channels >= 3)
 +              IMB_colormanagement_transform(ibuf->rect_float, ibuf->x, 
ibuf->y, ibuf->channels,
 +                                            colorspace, to_colorspace, 
predivide);
 +
 +      image_assign_ibuf(ima, ibuf, id, frame);
 +      IMB_freeImBuf(ibuf);
 +}
 +
 +static void image_update_multiview_flags(Image *ima)
 +{
-       if (BLI_countlist(&ima->views) > 1) {
++      if (BLI_listbase_count(&ima->views) > 1) {
 +              ima->flag |= IMA_IS_MULTIVIEW;
 +
 +              if (BLI_findstring(&ima->views, STEREO_LEFT_NAME, 
offsetof(ImageView, name)) &&
 +                  BLI_findstring(&ima->views, STEREO_RIGHT_NAME, 
offsetof(ImageView, name)))
 +              {
 +                      ima->flag |= IMA_IS_STEREO;
 +              }
 +              else {
 +                      ima->flag &= ~IMA_IS_STEREO;
 +              }
 +      }
 +      else {
 +              ima->flag &= ~IMA_IS_STEREO;
 +              ima->flag &= ~IMA_IS_MULTIVIEW;
 +      }
 +}
 +
 +/* after imbuf load, openexr type can return with a exrhandle open */
 +/* in that case we have to build a render-result */
 +static void image_create_multiview(Image *ima, ImBuf *ibuf, const int frame)
 +{
 +      image_free_views(ima);
 +
 +#ifdef WITH_OPENEXR
 +      IMB_exr_multiview_convert(ibuf->userdata, ima, image_add_view_cb, 
image_add_buffer_cb, frame);
 +#endif
 +
 +      image_update_multiview_flags(ima);
 +
 +#ifdef WITH_OPENEXR
 +      IMB_exr_close(ibuf->userdata);
 +#endif
 +}
 +
  /* after imbuf load, openexr type can return with a exrhandle open */
  /* in that case we have to build a render-result */
  static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr)
@@@ -2978,39 -2461,11 +2978,39 @@@ static int imbuf_alpha_flags_for_image(
        return flag;
  }
  
 +/* the number of files will vary according to the stereo format */
 +static size_t image_num_files(Image *ima)
 +{
 +      const bool is_multiview = (ima->flag & IMA_IS_MULTIVIEW) != 0;
 +
 +      if (!is_multiview) {
 +              return 1;
 +      }
 +      else if (ima->views_format == R_IMF_VIEWS_STEREO_3D) {
 +              return 1;
 +      }
 +      /* R_IMF_VIEWS_INDIVIDUAL */
 +      else {
-               return BLI_countlist(&ima->views);
++              return BLI_listbase_count(&ima->views);
 +      }
 +}
 +
  static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int 
frame)
  {
 -      struct ImBuf *ibuf;
 -      char name[FILE_MAX];
 +      struc

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to