Color management: fix regression with updating image while painting
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 24 Aug 2012 11:02:01 +0000 (11:02 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 24 Aug 2012 11:02:01 +0000 (11:02 +0000)
It'll update image properly but it seems it behaves slower then in trunk,
would investigate further.

source/blender/imbuf/intern/colormanagement.c

index 1480fe2738c34388158bff73f15cb980b32a199d..39b2964ee8ccd23e8d466aec22ff465afd88fe19 100644 (file)
@@ -1164,9 +1164,12 @@ static void imbuf_verify_float(ImBuf *ibuf)
         */
        BLI_lock_thread(LOCK_COLORMANAGE);
 
-       if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID)))
+       if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID))) {
                IMB_rect_from_float(ibuf);
 
+               ibuf->userflags &= ~IB_RECT_INVALID;
+       }
+
        BLI_unlock_thread(LOCK_COLORMANAGE);
 }
 
@@ -1232,6 +1235,22 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
                ColormanageCacheViewSettings cache_view_settings;
                ColormanageCacheDisplaySettings cache_display_settings;
 
+               if (ibuf->userflags & IB_RECT_INVALID) {
+                       /* if byte buffer is marked as invalid, it means that float buffer was modified
+                        * and display buffer should be updated
+                        * mark all existing color managed display buffers as invalid, also free
+                        * legacy byte buffer to be sure all users would re-calculate display buffers
+                        * after removing RECT_INVALID flag
+                        */
+
+                       IMB_display_buffer_invalidate(ibuf);
+
+                       if (ibuf->rect)
+                               imb_freerectImBuf(ibuf);
+
+                       ibuf->userflags &= ~IB_RECT_INVALID;
+               }
+
                colormanage_view_settings_to_cache(&cache_view_settings, view_settings);
                colormanage_display_settings_to_cache(&cache_display_settings, display_settings);