Revision: 49172
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49172
Author:   nazgul
Date:     2012-07-24 11:49:21 +0000 (Tue, 24 Jul 2012)
Log Message:
-----------
Color management: fix memory corruption when using border rendering

Image's get render result function used to modify ImBuf directly,
without making needed invalidates to color management cache when
it's needed.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c   
2012-07-24 10:28:29 UTC (rev 49171)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c   
2012-07-24 11:49:21 UTC (rev 49172)
@@ -2560,6 +2560,13 @@
                image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
        }
 
+       /* invalidate color managed buffers if render result changed */
+       BLI_lock_thread(LOCK_COLORMANAGE);
+       if (ibuf->x != rres.rectx || ibuf->y != rres.recty || ibuf->rect_float 
!= rectf) {
+               IMB_display_buffer_invalidate(ibuf);
+       }
+       BLI_unlock_thread(LOCK_COLORMANAGE);
+
        ibuf->x = rres.rectx;
        ibuf->y = rres.recty;
 

Modified: branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c
===================================================================
--- branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c      
2012-07-24 10:28:29 UTC (rev 49171)
+++ branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c      
2012-07-24 11:49:21 UTC (rev 49172)
@@ -316,6 +316,10 @@
        if (cache_ibuf) {
                ColormnaageCacheData *cache_data;
 
+               BLI_assert(cache_ibuf->x == ibuf->x &&
+                          cache_ibuf->y == ibuf->y &&
+                          cache_ibuf->channels == ibuf->channels);
+
                /* only buffers with different color space conversions are 
being stored
                 * in cache separately. buffer which were used only different 
exposure/gamma
                 * are re-suing the same cached buffer
@@ -1822,7 +1826,6 @@
 
        int *display_buffer_flags;
 
-       int buffer_width = ibuf->x;
        int channels = ibuf->channels;
        int predivide = ibuf->flags & IB_cm_predivide;
        int dither = ibuf->dither;
@@ -1859,12 +1862,19 @@
                                void *cache_handle;
                                int view_index = view + 1; /* views in 
configuration are 1-based */
                                float exposure, gamma;
+                               int buffer_width;
 
                                view_settings.view = view_index;
 
                                BLI_lock_thread(LOCK_COLORMANAGE);
                                display_buffer = 
colormanage_cache_get_cache_data(ibuf, &view_settings, &display_settings,
                                                                                
  &cache_handle, &exposure, &gamma);
+
+                               /* in some rare cases buffer's dimension could 
be changing directly from
+                                * different thread
+                                * this i.e. happens when image editor acquires 
render result
+                                */
+                               buffer_width = ibuf->x;
                                BLI_unlock_thread(LOCK_COLORMANAGE);
 
                                if (display_buffer) {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to