svn merge ^/trunk/blender -r48674:48681
[blender.git] / source / blender / editors / space_node / drawnode.c
index 218d11f30359e75d974430988773dce874446fa5..625d2343dff49fd744c838b5200a734e8d8e0cdc 100644 (file)
@@ -52,6 +52,7 @@
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_node.h"
+#include "BKE_tracking.h"
 
 #include "BLF_api.h"
 #include "BLF_translation.h"
@@ -77,6 +78,7 @@
 #include "UI_interface.h"
 #include "UI_resources.h"
 
+#include "IMB_colormanagement.h"
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 
@@ -2479,6 +2481,7 @@ static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), Poi
        uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "despill_factor", 0, NULL, ICON_NONE);
+       uiItemR(layout, ptr, "despill_balance", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "edge_kernel_radius", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "edge_kernel_tolerance", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE);
@@ -2489,6 +2492,41 @@ static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), Poi
        uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE);
 }
 
+static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+       bNode *node= ptr->data;
+
+       uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
+
+       if (node->id) {
+               MovieClip *clip = (MovieClip *) node->id;
+               MovieTracking *tracking = &clip->tracking;
+               MovieTrackingObject *object;
+               uiLayout *col;
+               PointerRNA tracking_ptr;
+               NodeTrackPosData *data = node->storage;
+
+               RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
+
+               col = uiLayoutColumn(layout, 0);
+               uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
+
+               object = BKE_tracking_object_get_named(tracking, data->tracking_object);
+               if (object) {
+                       PointerRNA object_ptr;
+
+                       RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
+
+                       uiItemPointerR(col, ptr, "track_name", &object_ptr, "tracks", "", ICON_ANIM_DATA);
+               }
+               else {
+                       uiItemR(layout, ptr, "track_name", 0, "", ICON_ANIM_DATA);
+               }
+
+               uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE);
+       }
+}
+
 /* only once called */
 static void node_composit_set_butfunc(bNodeType *ntype)
 {
@@ -2687,6 +2725,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
                case CMP_NODE_KEYING:
                        ntype->uifunc = node_composit_buts_keying;
                        break;
+               case CMP_NODE_TRACKPOS:
+                       ntype->uifunc = node_composit_buts_trackpos;
+                       break;
                default:
                        ntype->uifunc = NULL;
        }
@@ -2915,7 +2956,7 @@ void ED_init_node_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) {
@@ -2923,7 +2964,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();
@@ -2942,15 +2988,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;
 
@@ -2977,7 +3019,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);
@@ -2989,7 +3031,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);
@@ -2997,12 +3039,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;