svn merge ^/trunk/blender -r49520:49531
[blender.git] / source / blender / editors / space_node / drawnode.c
index 35c0ad9aeaf8669409cec5c2c0c3f791d15a8b37..3c61f68b9e4931639dbf2265a24279f9618fa7c7 100644 (file)
@@ -63,6 +63,7 @@
 
 #include "UI_resources.h"
 
+#include "IMB_colormanagement.h"
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 
@@ -1326,6 +1327,10 @@ static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA
 
        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.
@@ -1809,6 +1814,11 @@ static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C)
        }
 }
 
+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;
@@ -2661,6 +2671,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
                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;
@@ -3003,7 +3016,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) {
@@ -3011,7 +3024,12 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
                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();
@@ -3030,15 +3048,11 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
                        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;
 
@@ -3066,7 +3080,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
 #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);
@@ -3078,7 +3092,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
                                        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);
@@ -3086,12 +3100,14 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
                                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;