Merging r49400 through r49404 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 30 Jul 2012 17:12:55 +0000 (17:12 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 30 Jul 2012 17:12:55 +0000 (17:12 +0000)
1  2 
release/scripts/startup/bl_ui/space_node.py
source/blender/editors/space_image/image_ops.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c

index 0b063cb6fba304cb436d57aa3d72ccc3b90b8396,ccdf44a7dc2c1be6a9efb99d7e65c9cb5b019526..8598d1e3ca605ec3d5a263411c6e2eebc11766de
@@@ -184,18 -184,6 +184,18 @@@ class NODE_MT_node(Menu)
          layout.operator("node.read_fullsamplelayers")
  
  
 +class NODE_PT_display_properties(Panel):
 +    bl_space_type = 'NODE_EDITOR'
 +    bl_region_type = 'UI'
 +    bl_label = "Display Properties"
 +
 +    def draw(self, context):
 +        layout = self.layout
 +        space = context.space_data
 +
 +        layout.template_colormanaged_view_settings(space, "view_settings", True)
 +
 +
  # Node Backdrop options
  class NODE_PT_properties(Panel):
      bl_space_type = 'NODE_EDITOR'
@@@ -242,13 -230,17 +242,17 @@@ class NODE_PT_quality(bpy.types.Panel)
          snode = context.space_data
          tree = snode.node_tree
  
-         layout.prop(tree, "render_quality", text="Render")
-         layout.prop(tree, "edit_quality", text="Edit")
-         layout.prop(tree, "chunk_size")
-         layout.prop(tree, "use_opencl")
-         layout.prop(tree, "two_pass")
-         layout.prop(snode, "show_highlight")
-   
+         col = layout.column()
+         col.prop(tree, "render_quality", text="Render")
+         col.prop(tree, "edit_quality", text="Edit")
+         col.prop(tree, "chunk_size")
+         col = layout.column()
+         col.prop(tree, "use_opencl")
+         col.prop(tree, "two_pass")
+         col.prop(snode, "show_highlight")
+         col.prop(snode, "use_hidden_preview")
  
  class NODE_MT_node_color_presets(Menu):
      """Predefined node color"""
index 5fd17946bf5bacfd717ff7e70ff9e8c1bc5b2c49,8376a0bf0d34ce00ea67817832881fdc080a8b4a..02469184fef181aa20d8df32a65e27b35d720b3e
@@@ -55,7 -55,6 +55,7 @@@
  #include "BKE_report.h"
  #include "BKE_screen.h"
  
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf.h"
  #include "IMB_imbuf_types.h"
  
@@@ -920,7 -919,7 +920,7 @@@ static int image_open_invoke(bContext *
                        oldptr = RNA_property_pointer_get(&ptr, prop);
                        oldima = (Image *)oldptr.id.data;
                        /* unlikely to fail but better avoid strange crash */
-                       if (oldima && GS(oldima->id.name) != ID_IM) {
+                       if (oldima && GS(oldima->id.name) == ID_IM) {
                                ima = oldima;
                        }
                }
@@@ -1107,14 -1106,12 +1107,14 @@@ static char imtype_best_depth(ImBuf *ib
        }
  }
  
 -static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene, const short guess_path)
 +static int save_image_options_init(bContext *C, SaveImageOptions *simopts, SpaceImage *sima, Scene *scene, const short guess_path)
  {
        void *lock;
        ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
  
        if (ibuf) {
 +              wmWindow *win = CTX_wm_window(C);
 +              const ColorManagedViewSettings *view_settings;
                Image *ima = sima->image;
                short is_depth_set = FALSE;
  
                        }
                        BLI_path_abs(simopts->filepath, G.main->name);
                }
 +
 +              /* color management */
 +              view_settings = IMB_view_settings_get_effective(win, &sima->view_settings);
 +
 +              BKE_color_managed_display_settings_copy(&simopts->im_format.display_settings, &win->display_settings);
 +              BKE_color_managed_view_settings_copy(&simopts->im_format.view_settings, view_settings);
        }
  
        ED_space_image_release_buffer(sima, lock);
@@@ -1197,38 -1188,6 +1197,38 @@@ static void save_image_options_to_op(Sa
        RNA_string_set(op->ptr, "filepath", simopts->filepath);
  }
  
 +static ImBuf *save_image_colormanaged_imbuf_acquire(ImBuf *ibuf, SaveImageOptions *simopts, void **cache_handle)
 +{
 +      ImageFormatData *imf = &simopts->im_format;
 +      ImBuf *colormanaged_ibuf;
 +      int do_colormanagement;
 +
 +      *cache_handle = NULL;
 +      do_colormanagement = !BKE_imtype_supports_float(imf->imtype);
 +
 +      if (do_colormanagement) {
 +              unsigned char *display_buffer =
 +                      IMB_display_buffer_acquire(ibuf, &imf->view_settings, &imf->display_settings, cache_handle);
 +
 +              if (*cache_handle) {
 +                      colormanaged_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0);
 +                      colormanaged_ibuf->rect = (unsigned int *) display_buffer;
 +              }
 +              else {
 +                      /* no cache handle means color management didn't run transformation
 +                       * or performed transformation to image's byte buffer which doesn't
 +                       * require allocating new image buffer
 +                       */
 +                      colormanaged_ibuf = ibuf;
 +              }
 +      }
 +      else {
 +              colormanaged_ibuf = ibuf;
 +      }
 +
 +      return colormanaged_ibuf;
 +}
 +
  /* assumes name is FILE_MAX */
  /* ima->name and ibuf->name should end up the same */
  static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath)
        ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
  
        if (ibuf) {
 +              void *cache_handle;
 +              ImBuf *colormanaged_ibuf;
                const char *relbase = ID_BLEND_PATH(CTX_data_main(C), &ima->id);
                const short relative = (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
                const short save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
                                ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? 32 : 24;
                        }
                }
 -              
 +
 +              colormanaged_ibuf = save_image_colormanaged_imbuf_acquire(ibuf, simopts, &cache_handle);
 +
                if (simopts->im_format.imtype == R_IMF_IMTYPE_MULTILAYER) {
                        Scene *scene = CTX_data_scene(C);
                        RenderResult *rr = BKE_image_acquire_renderresult(scene, ima);
                        BKE_image_release_renderresult(scene, ima);
                }
                else {
 -                      if (BKE_imbuf_write_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
 +                      if (BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
                                ok = TRUE;
                        }
                }
                WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image);
  
                WM_cursor_wait(0);
 +
 +              if (cache_handle) {
 +                      colormanaged_ibuf->rect = NULL;
 +                      IMB_freeImBuf(colormanaged_ibuf);
 +
 +                      IMB_display_buffer_release(cache_handle);
 +              }
        }
  
        ED_space_image_release_buffer(sima, lock);
@@@ -1360,7 -1308,7 +1360,7 @@@ static int image_save_as_exec(bContext 
  
        /* just in case to initialize values,
         * these should be set on invoke or by the caller. */
 -      save_image_options_init(&simopts, sima, CTX_data_scene(C), 0);
 +      save_image_options_init(C, &simopts, sima, CTX_data_scene(C), 0);
  
        save_image_options_from_op(&simopts, op);
  
@@@ -1389,7 -1337,7 +1389,7 @@@ static int image_save_as_invoke(bContex
  
        save_image_options_defaults(&simopts);
  
 -      if (save_image_options_init(&simopts, sima, scene, TRUE) == 0)
 +      if (save_image_options_init(C, &simopts, sima, scene, TRUE) == 0)
                return OPERATOR_CANCELLED;
        save_image_options_to_op(&simopts, op);
  
@@@ -1474,7 -1422,7 +1474,7 @@@ static int image_save_exec(bContext *C
        Scene *scene = CTX_data_scene(C);
        SaveImageOptions simopts;
  
 -      if (save_image_options_init(&simopts, sima, scene, FALSE) == 0)
 +      if (save_image_options_init(C, &simopts, sima, scene, FALSE) == 0)
                return OPERATOR_CANCELLED;
        save_image_options_from_op(&simopts, op);
  
index 5c70376c5531fe779b009b4fb5ee2a87bb6c955b,b9603e2cdb11cd0a5cf9e4e969da539da4245525..2002ad4283824188c0fb4f4380ac79bc021053c5
@@@ -35,7 -35,7 +35,7 @@@
  
  #include "DNA_defs.h"
  #include "DNA_listBase.h"
 -#include "DNA_color_types.h"        /* for Histogram */
 +#include "DNA_color_types.h"        /* for Histogram and color management */
  #include "DNA_vec_types.h"
  #include "DNA_outliner_types.h"     /* for TreeStoreElem */
  #include "DNA_image_types.h"        /* ImageUser */
@@@ -473,9 -473,6 +473,9 @@@ typedef struct SpaceSeq 
        int pad;
  
        struct bGPdata *gpd;        /* grease-pencil data */
 +
 +      /* **** color management **** */
 +      ColorManagedViewSettings view_settings;
  } SpaceSeq;
  
  
@@@ -704,9 -701,6 +704,9 @@@ typedef struct SpaceImage 
        char around;
  
        MaskSpaceInfo mask_info;
 +
 +      /* **** color management **** */
 +      ColorManagedViewSettings view_settings;
  } SpaceImage;
  
  
@@@ -896,9 -890,6 +896,9 @@@ typedef struct SpaceNode 
        ListBase linkdrag;  /* temporary data for modal linking operator */
        
        struct bGPdata *gpd;        /* grease-pencil data */
 +
 +      /* **** color management **** */
 +      ColorManagedViewSettings view_settings;
  } SpaceNode;
  
  /* snode->flag */
@@@ -912,6 -903,7 +912,7 @@@ typedef enum eSpaceNode_Flag 
        SNODE_SHOW_B         = (1 << 9),
        SNODE_AUTO_RENDER    = (1 << 5),
        SNODE_SHOW_HIGHLIGHT = (1 << 6),
+       SNODE_USE_HIDDEN_PREVIEW = (1 << 10),
  } eSpaceNode_Flag;
  
  /* snode->texfrom */
@@@ -1041,9 -1033,6 +1042,9 @@@ typedef struct SpaceClip 
        int around, pad4;             /* pivot point for transforms */
  
        MaskSpaceInfo mask_info;
 +
 +      /* **** color management **** */
 +      ColorManagedViewSettings view_settings;
  } SpaceClip;
  
  /* SpaceClip->flag */
index df98be71cfe89cc6db676325248dd4ecf3b0f9a9,74f6b16a111b4960a9b4d000eaaf89163ab83a2a..73661937fcda3665b7adfc7d3b900ea781212322
@@@ -152,7 -152,6 +152,7 @@@ EnumPropertyItem clip_editor_mode_items
  #include "ED_sequencer.h"
  #include "ED_clip.h"
  
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf_types.h"
  
  static StructRNA *rna_Space_refine(struct PointerRNA *ptr)
@@@ -1922,7 -1921,7 +1922,7 @@@ static void rna_def_space_buttons(Blend
                {SB_TEXC_MAT_OR_LAMP, "MATERIAL", ICON_MATERIAL, "Material", "Material"},
                {0, NULL, 0, NULL, NULL}
        };                             /*actually populated dynamically trough a function */
 -              
 +
        srna = RNA_def_struct(brna, "SpaceProperties", "Space");
        RNA_def_struct_sdna(srna, "SpaceButs");
        RNA_def_struct_ui_text(srna, "Properties Space", "Properties space data");
@@@ -2078,11 -2077,6 +2078,11 @@@ static void rna_def_space_image(Blender
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Show UV Editor", "Show UV editing related properties");
  
 +      prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
 +      RNA_def_property_ui_text(prop, "View Settings", "Color management settings used for displaying images on the display");
 +
        rna_def_space_image_uv(brna);
  
        /* mask */
@@@ -2197,11 -2191,6 +2197,11 @@@ static void rna_def_space_sequencer(Ble
        RNA_def_property_struct_type(prop, "GreasePencil");
        RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
 +
 +      prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
 +      RNA_def_property_ui_text(prop, "View Settings", "Color management settings used for displaying images on the display");
  }
  
  static void rna_def_space_text(BlenderRNA *brna)
@@@ -2996,15 -2985,15 +2996,20 @@@ static void rna_def_space_node(BlenderR
        RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
  
 +      prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
 +      RNA_def_property_ui_text(prop, "View Settings", "Color management settings used for displaying images on the display");
 +
        prop = RNA_def_property(srna, "show_highlight", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_SHOW_HIGHLIGHT);
        RNA_def_property_ui_text(prop, "Highlight", "Highlight nodes that are being calculated");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
+       prop = RNA_def_property(srna, "use_hidden_preview", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_USE_HIDDEN_PREVIEW);
+       RNA_def_property_ui_text(prop, "Hide Preview", "Hide preview for newly creating nodes");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
  }
  
  static void rna_def_space_logic(BlenderRNA *brna)
@@@ -3313,12 -3302,6 +3318,12 @@@ static void rna_def_space_clip(BlenderR
        RNA_def_property_enum_items(prop, pivot_items);
        RNA_def_property_ui_text(prop, "Pivot Point", "Pivot center for rotation/scaling");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
 +
 +      /* color management view settings */
 +      prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
 +      RNA_def_property_ui_text(prop, "View Settings", "Color management settings used for displaying images on the display");
  }