svn merge ^/trunk/blender -r49573:49601
authorCampbell Barton <ideasman42@gmail.com>
Mon, 6 Aug 2012 09:33:43 +0000 (09:33 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 6 Aug 2012 09:33:43 +0000 (09:33 +0000)
1  2 
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/intern/mask.c
source/blender/blenkernel/intern/node.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/windowmanager/intern/wm_init_exit.c

index 0b9aa7e4f644c218e00644bceb98182531555cc0,0d867bbbb519f9a5f57540540450ec3929307712..61845619452840871d1c874a57f6abe985699b3f
@@@ -359,6 -359,7 +359,7 @@@ void            nodeInternalRelink(stru
  
  void            nodeToView(struct bNode *node, float x, float y, float *rx, float *ry);
  void            nodeFromView(struct bNode *node, float x, float y, float *rx, float *ry);
+ int             nodeAttachNodeCheck(struct bNode *node, struct bNode *parent);
  void            nodeAttachNode(struct bNode *node, struct bNode *parent);
  void            nodeDetachNode(struct bNode *node);
  
@@@ -385,11 -386,13 +386,13 @@@ int             nodeSocketIsHidden(stru
  void            nodeSocketSetType(struct bNodeSocket *sock, int type);
  
  /* Node Clipboard */
- void nodeClipboardClear(void);
- void nodeClipboardAddNode(struct bNode *node);
- void nodeClipboardAddLink(struct bNodeLink *link);
- const struct ListBase *nodeClipboardGetNodes(void);
- const struct ListBase *nodeClipboardGetLinks(void);
+ void                   BKE_node_clipboard_init(struct bNodeTree *ntree);
+ void                   BKE_node_clipboard_clear(void);
+ void                   BKE_node_clipboard_add_node(struct bNode *node);
+ void                   BKE_node_clipboard_add_link(struct bNodeLink *link);
+ const struct ListBase *BKE_node_clipboard_get_nodes(void);
+ const struct ListBase *BKE_node_clipboard_get_links(void);
+ int                    BKE_node_clipboard_get_type(void);
  
  /* ************** NODE TYPE ACCESS *************** */
  
@@@ -668,7 -671,6 +671,7 @@@ void            ntreeGPUMaterialNodes(s
  #define CMP_NODE_KEYINGSCREEN         269
  #define CMP_NODE_KEYING                       270
  #define CMP_NODE_TRACKPOS             271
 +#define CMP_NODE_INPAINT                272
  
  #define CMP_NODE_GLARE                301
  #define CMP_NODE_TONEMAP      302
index 8bb3a0fd30671cf671ed0c190c6ac0938c78e3f9,f41d8feef0b3c2d849559695cad5cb7d297dd771..01aa9fa9fa9fe05344c17775202cae28d84d1fb2
@@@ -1287,12 -1287,13 +1287,13 @@@ MaskSplinePointUW *BKE_mask_point_sort_
  void BKE_mask_point_add_uw(MaskSplinePoint *point, float u, float w)
  {
        if (!point->uw)
-               point->uw = MEM_callocN(sizeof(*point->uw), "mask point uw");
+               point->uw = MEM_mallocN(sizeof(*point->uw), "mask point uw");
        else
                point->uw = MEM_reallocN(point->uw, (point->tot_uw + 1) * sizeof(*point->uw));
  
        point->uw[point->tot_uw].u = u;
        point->uw[point->tot_uw].w = w;
+       point->uw[point->tot_uw].flag = 0;
  
        point->tot_uw++;
  
@@@ -1527,7 -1528,6 +1528,7 @@@ void BKE_mask_layer_free(MaskLayer *mas
        MEM_freeN(masklay);
  }
  
 +
  void BKE_mask_layer_free_list(ListBase *masklayers)
  {
        MaskLayer *masklay = masklayers->first;
  
                masklay = masklay_next;
        }
 +
  }
  
  void BKE_mask_free(Mask *mask)
index afe0b9ec81f0f75c6297f5a80dfc60625456a3dd,ed33a52e29aa32e1d023cb187372172495911424..8f3c76c33571b4893ed23f7d0f64069764af090a
@@@ -592,9 -592,25 +592,25 @@@ void nodeFromView(bNode *node, float x
        }
  }
  
+ int nodeAttachNodeCheck(bNode *node, bNode *parent)
+ {
+       bNode *parent_recurse;
+       for (parent_recurse = node; parent_recurse; parent_recurse = parent_recurse->parent) {
+               if (parent_recurse == parent) {
+                       return TRUE;
+               }
+       }
+       return FALSE;
+ }
  void nodeAttachNode(bNode *node, bNode *parent)
  {
        float locx, locy;
+       BLI_assert(parent->type == NODE_FRAME);
+       BLI_assert(nodeAttachNodeCheck(parent, node) == FALSE);
        nodeToView(node, 0.0f, 0.0f, &locx, &locy);
        
        node->parent = parent;
@@@ -607,6 -623,9 +623,9 @@@ void nodeDetachNode(struct bNode *node
        float locx, locy;
        
        if (node->parent) {
+               BLI_assert(node->parent->type == NODE_FRAME);
                /* transform to view space */
                nodeToView(node, 0.0f, 0.0f, &locx, &locy);
                node->locx = locx;
@@@ -1409,11 -1428,17 +1428,17 @@@ void nodeSocketSetType(bNodeSocket *soc
  typedef struct bNodeClipboard {
        ListBase nodes;
        ListBase links;
+       int type;
  } bNodeClipboard;
  
  bNodeClipboard node_clipboard;
  
- void nodeClipboardClear(void)
+ void BKE_node_clipboard_init(struct bNodeTree *ntree)
+ {
+       node_clipboard.type = ntree->type;
+ }
+ void BKE_node_clipboard_clear(void)
  {
        bNode *node, *node_next;
        bNodeLink *link, *link_next;
        node_clipboard.nodes.first = node_clipboard.nodes.last = NULL;
  }
  
- void nodeClipboardAddNode(bNode *node)
+ void BKE_node_clipboard_add_node(bNode *node)
  {
        BLI_addtail(&node_clipboard.nodes, node);
  }
  
- void nodeClipboardAddLink(bNodeLink *link)
+ void BKE_node_clipboard_add_link(bNodeLink *link)
  {
        BLI_addtail(&node_clipboard.links, link);
  }
  
- const ListBase *nodeClipboardGetNodes(void)
+ const ListBase *BKE_node_clipboard_get_nodes(void)
  {
        return &node_clipboard.nodes;
  }
  
- const ListBase *nodeClipboardGetLinks(void)
+ const ListBase *BKE_node_clipboard_get_links(void)
  {
        return &node_clipboard.links;
  }
  
+ int BKE_node_clipboard_get_type(void)
+ {
+       return node_clipboard.type;
+ }
  /* ************** dependency stuff *********** */
  
  /* node is guaranteed to be not checked before */
@@@ -1960,7 -1990,6 +1990,7 @@@ static void registerCompositNodes(bNode
        register_node_type_cmp_bilateralblur(ttype);
        register_node_type_cmp_vecblur(ttype);
        register_node_type_cmp_dilateerode(ttype);
 +      register_node_type_cmp_inpaint(ttype);
        register_node_type_cmp_defocus(ttype);
        
        register_node_type_cmp_valtorgb(ttype);
index 8c40eaa4836a988b4d2595398c0dc4c30b96b1f3,de882bd3635ea4203a6b97099c466ee7af85b81d..54c7d0b21003917c79a1d8c8c13a672cd92401ca
@@@ -63,7 -63,6 +63,7 @@@
  
  #include "UI_resources.h"
  
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf.h"
  #include "IMB_imbuf_types.h"
  
@@@ -997,9 -996,7 +997,7 @@@ static void node_draw_frame(const bCont
        float alpha;
        
        /* skip if out of view */
-       if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
-           node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) {
-               
+       if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == FALSE) {
                uiEndBlock(C, node->block);
                node->block = NULL;
                return;
@@@ -1327,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.
@@@ -1814,11 -1807,6 +1812,11 @@@ static void node_composit_buts_dilateer
        }
  }
  
 +static void node_composit_buts_inpaint(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 +{
 +      uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
 +}
 +
  static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
  {
        uiLayout *col;
@@@ -2671,9 -2659,6 +2669,9 @@@ static void node_composit_set_butfunc(b
                case CMP_NODE_DILATEERODE:
                        ntype->uifunc = node_composit_buts_dilateerode;
                        break;
 +              case CMP_NODE_INPAINT:
 +                      ntype->uifunc = node_composit_buts_inpaint;
 +                      break;
                case CMP_NODE_OUTPUT_FILE:
                        ntype->uifunc = node_composit_buts_file_output;
                        ntype->uifuncbut = node_composit_buts_file_output_details;
@@@ -3016,7 -3001,7 +3014,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);
 +                      wmWindow *win = CTX_wm_window(C);
 +                      const ColorManagedViewSettings *view_settings;
                        float x, y; 
 +                      unsigned char *display_buffer;
 +                      void *cache_handle;
                        
                        glMatrixMode(GL_PROJECTION);
                        glPushMatrix();
                        
                        glaDefine2DArea(&ar->winrct);
                        /* ortho at pixel level curarea */
-                       wmOrtho2(-0.375, ar->winx - 0.375, -0.375, ar->winy - 0.375);
+                       wmOrtho2(-GLA_PIXEL_OFS, ar->winx - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, ar->winy - GLA_PIXEL_OFS);
                        
                        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_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 f1ba81acf903b7768673e8e3a228521f67625d4b,ed52a14ec986078b6bed19c284341448c2647aaf..71e7e53eb4f1af86aef2c68f3faa4e813ec72996
@@@ -681,9 -681,7 +681,7 @@@ static void node_draw_basis(const bCont
                nodeShaderSynchronizeID(node, 0);
        
        /* skip if out of view */
-       if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
-           node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax)
-       {
+       if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == FALSE) {
                uiEndBlock(C, node->block);
                node->block = NULL;
                return;
@@@ -1078,6 -1076,8 +1076,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 f6b6c70dbf21702030a5940f37487f2aeff83c30,a03c9aa70c41120a8646f9a295cf9c8cec6e0e39..c1bc8912425be3c2e4f9ac2908b57068cd0158c8
@@@ -58,6 -58,7 +58,7 @@@
  #include "BKE_library.h"
  #include "BKE_main.h"
  #include "BKE_mball.h"
+ #include "BKE_node.h"
  #include "BKE_report.h"
  
  #include "BKE_packedFile.h"
@@@ -66,6 -67,7 +67,6 @@@
  #include "BKE_tracking.h" /* free tracking clipboard */
  
  #include "BLI_listbase.h"
 -#include "BLI_math_color.h"
  #include "BLI_string.h"
  #include "BLI_utildefines.h"
  
  #include "BKE_depsgraph.h"
  #include "BKE_sound.h"
  
 +#include "IMB_colormanagement.h"
 +
  static void wm_init_reports(bContext *C)
  {
        BKE_reports_init(CTX_wm_reports(C), RPT_STORE);
@@@ -148,8 -148,8 +149,8 @@@ void WM_init(bContext *C, int argc, con
        BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
        BLF_lang_init();
  
 -      /* initialize color stuff */
 -      BLI_init_srgb_conversion();
 +      /* initialize color management stuff */
 +      IMB_colormanagement_init();
  
        /* get the default database, plus a wm */
        WM_read_homefile(C, NULL, G.factory_startup);
@@@ -335,10 -335,10 +336,10 @@@ static void free_openrecent(void
  /* bad stuff*/
  
  // XXX copy/paste buffer stuff...
- extern void free_anim_copybuf(void); 
- extern void free_anim_drivers_copybuf(void); 
- extern void free_fmodifiers_copybuf(void); 
- extern void free_posebuf(void); 
+ extern void free_anim_copybuf(void);
+ extern void free_anim_drivers_copybuf(void);
+ extern void free_fmodifiers_copybuf(void);
+ extern void free_posebuf(void);
  
  #if WIN32
  /* Read console events until there is a key event.  Also returns on any error. */
@@@ -371,7 -371,6 +372,7 @@@ void WM_exit_ext(bContext *C, const sho
  
        sound_exit();
  
 +      IMB_colormanagement_exit();
  
        /* first wrap up running stuff, we assume only the active WM is running */
        /* modal handlers are on window level freed, others too? */
        free_anim_drivers_copybuf();
        free_fmodifiers_copybuf();
        free_posebuf();
+       BKE_node_clipboard_clear();
  
        BLF_exit();