Merging r50119 through r50132 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 22 Aug 2012 17:23:02 +0000 (17:23 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 22 Aug 2012 17:23:02 +0000 (17:23 +0000)
1  2 
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_sequencer.c

index ad61fe571c26035dee046eefa10c2a4250b6d7a4,c1a410317b783a205456ee26724088db56efe241..ddea7da929ac1d49aad7174acbe216ba038b9f41
@@@ -63,7 -63,6 +63,7 @@@
  
  #include "UI_resources.h"
  
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf.h"
  #include "IMB_imbuf_types.h"
  
@@@ -858,13 -857,13 +858,13 @@@ static void node_draw_group(const bCont
                        while (gsock && (!sock || sock->groupsock != gsock)) {
                                draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_IN);
                                gsock = gsock->next;
-                               ++index;
+                               index++;
                        }
                        while (sock && gsock && sock->groupsock == gsock) {
                                draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_IN);
                                sock = sock->next;
                                gsock = gsock->next;
-                               ++index;
+                               index++;
                        }
                }
                gsock = ngroup->outputs.first;
                        while (gsock && (!sock || sock->groupsock != gsock)) {
                                draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_OUT);
                                gsock = gsock->next;
-                               ++index;
+                               index++;
                        }
                        while (sock && gsock && sock->groupsock == gsock) {
                                draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_OUT);
                                sock = sock->next;
                                gsock = gsock->next;
-                               ++index;
+                               index++;
                        }
                }
                
@@@ -1325,10 -1324,6 +1325,10 @@@ static void node_shader_buts_tex_image(
  
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
        uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
 +      uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
 +
 +      if(RNA_enum_get(ptr, "projection") == SHD_PROJ_BOX)
 +              uiItemR(layout, ptr, "projection_blend", 0, "Blend", ICON_NONE);
  
        /* note: image user properties used directly here, unlike compositor image node,
         * which redefines them in the node struct RNA to get proper updates.
@@@ -1817,15 -1812,6 +1817,15 @@@ static void node_composit_buts_inpaint(
        uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
  }
  
 +static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiLayout *col;
 +
 +      col = uiLayoutColumn(layout, FALSE);
 +      uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
 +      uiItemR(col, ptr, "threshold_neighbour", 0, NULL, ICON_NONE);
 +}
 +
  static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
  {
        uiLayout *col;
@@@ -2008,7 -1994,7 +2008,7 @@@ static void node_composit_buts_file_out
        int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
        
        node_composit_buts_file_output(layout, C, ptr);
 -      uiTemplateImageSettings(layout, &imfptr);
 +      uiTemplateImageSettings(layout, &imfptr, TRUE);
        
        uiItemS(layout);
        
                        
                        col = uiLayoutColumn(layout, FALSE);
                        uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE);
 -                      uiTemplateImageSettings(col, &imfptr);
 +                      uiTemplateImageSettings(col, &imfptr, TRUE);
                }
        }
  }
@@@ -2688,9 -2674,6 +2688,9 @@@ static void node_composit_set_butfunc(b
                case CMP_NODE_INPAINT:
                        ntype->uifunc = node_composit_buts_inpaint;
                        break;
 +              case CMP_NODE_DESPECKLE:
 +                      ntype->uifunc = node_composit_buts_despeckle;
 +                      break;
                case CMP_NODE_OUTPUT_FILE:
                        ntype->uifunc = node_composit_buts_file_output;
                        ntype->uifuncbut = node_composit_buts_file_output_details;
@@@ -3036,7 -3019,7 +3036,7 @@@ void ED_node_init_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);
                        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) {
 +                      display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
 +
 +                      if (display_buffer) {
                                if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) {
                                        int ofs;
  
  #ifdef __BIG_ENDIAN__
                                        glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
  #endif
 -                                      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);
  
  #ifdef __BIG_ENDIAN__
                                        glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
                                        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;
index 9319baf99f7541b58d3088b07721bbd600db4f17,0f559b0cbfc410455c684cfb7eb8131519148c2f..0f4332e70243fee3d09afaf543363efb28751675
@@@ -226,12 -226,12 +226,12 @@@ void ED_node_sort(bNodeTree *ntree
                        while (a < k && b < k && node_b) {
                                if (compare_nodes(node_a, node_b) == 0) {
                                        node_a = node_a->next;
-                                       ++a;
+                                       a++;
                                }
                                else {
                                        tmp = node_b;
                                        node_b = node_b->next;
-                                       ++b;
+                                       b++;
                                        BLI_remlink(&ntree->nodes, tmp);
                                        BLI_insertlinkbefore(&ntree->nodes, node_a, tmp);
                                }
@@@ -1091,6 -1091,8 +1091,6 @@@ void drawnodespace(const bContext *C, A
  {
        View2DScrollers *scrollers;
        SpaceNode *snode = CTX_wm_space_node(C);
 -      Scene *scene = CTX_data_scene(C);
 -      int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
        bNodeLinkDrag *nldrag;
        LinkData *linkdata;
        
        UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2);
  
        /* backdrop */
 -      draw_nodespace_back_pix(ar, snode, color_manage);
 +      draw_nodespace_back_pix(C, ar, snode);
        
        /* nodes */
        snode_set_context(snode, CTX_data_scene(C));
index 29288612aa61513950b048601c0d40a0447bfe81,6a732cc26491ddaa1610a13fe29a1d3ad49f489a..7a385103fe380f1426633e591d9c064bf314af40
@@@ -1518,15 -1518,6 +1518,15 @@@ static void def_sh_tex_image(StructRNA 
                {0, NULL, 0, NULL, NULL}
        };
  
 +      static const EnumPropertyItem prop_projection_items[] = {
 +              {SHD_PROJ_FLAT, "FLAT", 0, "Flat",
 +                              "Image is projected flat using the X and Y coordinates of the texture vector"},
 +              {SHD_PROJ_BOX,  "BOX", 0, "Box",
 +                              "Image is projected using different components for each side of the object space bounding box"},
 +              {0, NULL, 0, NULL, NULL}
 +      };
 +
 +
        PropertyRNA *prop;
  
        prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
        RNA_def_property_ui_text(prop, "Color Space", "Image file color space");
        RNA_def_property_update(prop, 0, "rna_Node_update");
  
 +      prop = RNA_def_property(srna, "projection", PROP_ENUM, PROP_NONE);
 +      RNA_def_property_enum_items(prop, prop_projection_items);
 +      RNA_def_property_ui_text(prop, "Projection", "Method to project 2D image on object with a 3D texture vector");
 +      RNA_def_property_update(prop, 0, "rna_Node_update");
 +
 +      prop = RNA_def_property(srna, "projection_blend", PROP_FLOAT, PROP_FACTOR);
 +      RNA_def_property_ui_text(prop, "Projection Blend", "For box projection, amount of blend to use between sides");
 +      RNA_def_property_update(prop, 0, "rna_Node_update");
 +
        prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
        RNA_def_property_flag(prop, PROP_NEVER_NULL);
        RNA_def_property_pointer_sdna(prop, NULL, "iuser");
@@@ -2166,23 -2148,6 +2166,23 @@@ static void def_cmp_inpaint(StructRNA *
        RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
  }
  
 +static void def_cmp_despeckle(StructRNA *srna)
 +{
 +      PropertyRNA *prop;
 +
 +      prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "custom3");
 +      RNA_def_property_range(prop, 0.0, 1.0f);
 +      RNA_def_property_ui_text(prop, "Threshold", "Threshold for detecting pixels to despeckle");
 +      RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 +
 +      prop = RNA_def_property(srna, "threshold_neighbour", PROP_FLOAT, PROP_NONE);
 +      RNA_def_property_float_sdna(prop, NULL, "custom4");
 +      RNA_def_property_range(prop, 0.0, 1.0f);
 +      RNA_def_property_ui_text(prop, "Neighbour", "Threshold for the number of neighbour pixels that must match");
 +      RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 +}
 +
  static void def_cmp_scale(StructRNA *srna)
  {
        PropertyRNA *prop;
@@@ -3746,7 -3711,7 +3746,7 @@@ static void def_cmp_keying(StructRNA *s
        RNA_def_property_float_sdna(prop, NULL, "clip_white");
        RNA_def_property_range(prop, 0.0f, 1.0f);
        RNA_def_property_ui_text(prop, "Clip White", "Value of non-scaled matte pixel which considers as fully foreground pixel");
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+       RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
  
        prop = RNA_def_property(srna, "blur_pre", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "blur_pre");
@@@ -3825,12 -3790,12 +3825,12 @@@ static void def_cmp_trackpos(StructRNA 
        prop = RNA_def_property(srna, "tracking_object", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "tracking_object");
        RNA_def_property_ui_text(prop, "Tracking Object", "");
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+       RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
  
        prop = RNA_def_property(srna, "track_name", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "track_name");
        RNA_def_property_ui_text(prop, "Track", "");
-       RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+       RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
  }
  
  /* -- Texture Nodes --------------------------------------------------------- */
index 5717fe697b10a05330a7c313ae92266f843dcb59,3e841f81450cd06fff3145934d4309060b508a06..aeb72553bf76f0aa2dbb2a54456ce99197e1d50b
@@@ -62,7 -62,7 +62,7 @@@ typedef struct EffectInfo 
  EnumPropertyItem sequence_modifier_type_items[] = {
        {seqModifierType_ColorBalance, "COLOR_BALANCE", ICON_NONE, "Color Balance", ""},
        {seqModifierType_Curves, "CURVES", ICON_NONE, "Curves", ""},
-       {seqModifierType_HueCorrect,"HUE_CORRECT", ICON_NONE, "Hue Correct", ""},
+       {seqModifierType_HueCorrect, "HUE_CORRECT", ICON_NONE, "Hue Correct", ""},
        {0, NULL, 0, NULL, NULL}
  };
  
@@@ -659,7 -659,7 +659,7 @@@ static void rna_Sequence_update_reopen_
        Scene *scene = (Scene *) ptr->id.data;
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
  
 -      BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE, FALSE);
 +      BKE_sequencer_free_imbuf(scene, &ed->seqbase, FALSE);
  
        if (RNA_struct_is_a(ptr->type, &RNA_SoundSequence))
                BKE_sequencer_update_sound_bounds(scene, ptr->data);