Merging r49451 through r49462 from trunk into soc-2011-tomato
[blender.git] / source / blender / compositor / operations / COM_ViewerBaseOperation.cpp
index f443c33cd541577552fe9bdc05b89d85e5739311..1d913b96196f70d8c7954c1e441229b1d4c7446c 100644 (file)
@@ -34,6 +34,7 @@ extern "C" {
        #include "MEM_guardedalloc.h"
        #include "IMB_imbuf.h"
        #include "IMB_imbuf_types.h"
+       #include "IMB_colormanagement.h"
 }
 
 
@@ -60,7 +61,7 @@ void ViewerBaseOperation::initImage()
 {
        Image *anImage = this->m_image;
        ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->m_imageUser, &this->m_lock);
-       
+
        if (!ibuf) return;
        BLI_lock_thread(LOCK_DRAW_IMAGE);
        if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
@@ -74,26 +75,41 @@ void ViewerBaseOperation::initImage()
                imb_addrectfloatImBuf(ibuf);
                anImage->ok = IMA_OK_LOADED;
 
+               IMB_display_buffer_invalidate(ibuf);
+
+               BLI_unlock_thread(LOCK_DRAW_IMAGE);
        }
+
        if (m_doDepthBuffer) 
        {
                addzbuffloatImBuf(ibuf);
        }
        BLI_unlock_thread(LOCK_DRAW_IMAGE);
-       
-       
+
        /* now we combine the input with ibuf */
        this->m_outputBuffer = ibuf->rect_float;
        this->m_outputBufferDisplay = (unsigned char *)ibuf->rect;
+
+       /* needed for display buffer update
+        *
+        * no need to lock / reference the image buffer because it's seems
+        * to be the single place which changes buffers of viewer image
+        * which is this node
+        */
+       this->m_ibuf = ibuf;
+
        if (m_doDepthBuffer)
        {
                this->m_depthBuffer = ibuf->zbuf_float;
        }
-       
+
        BKE_image_release_ibuf(this->m_image, this->m_lock);
 }
 void ViewerBaseOperation:: updateImage(rcti *rect)
 {
+       IMB_partial_display_buffer_update(this->m_ibuf, this->m_outputBuffer, getWidth(), 0, 0,
+                                         rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+
        WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
 }