Color Management, Stage 2: Switch color pipeline to use OpenColorIO
[blender.git] / source / blender / imbuf / intern / allocimbuf.c
index 7724f444b2c01f3dc726236ae7a206dee2c0b8c7..690482741041f1d808d58fd76c60982a15e78d83 100644 (file)
@@ -41,6 +41,7 @@
 #include "IMB_allocimbuf.h"
 #include "IMB_filetype.h"
 #include "IMB_metadata.h"
+#include "IMB_colormanagement_intern.h"
 
 #include "imbuf.h"
 
@@ -162,8 +163,11 @@ void IMB_freeImBuf(ImBuf *ibuf)
                        IMB_freezbuffloatImBuf(ibuf);
                        freeencodedbufferImBuf(ibuf);
                        IMB_metadata_free(ibuf);
-                       if (ibuf->dds_data.data != NULL)
+                       colormanage_cache_free(ibuf);
+
+                       if (ibuf->dds_data.data != NULL) {
                                free(ibuf->dds_data.data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
+                       }
                        MEM_freeN(ibuf);
                }
        }
@@ -354,7 +358,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
                ibuf->ftype = TGA;
                ibuf->channels = 4;  /* float option, is set to other values when buffers get assigned */
                ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254; /* IMB_DPI_DEFAULT -> pixels-per-meter */
-               
+
                if (flags & IB_rect) {
                        if (imb_addrectImBuf(ibuf) == FALSE) {
                                IMB_freeImBuf(ibuf);
@@ -382,6 +386,9 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
                                return NULL;
                        }
                }
+
+               /* assign default spaces */
+               colormanage_imbuf_set_default_spaces(ibuf);
        }
        return (ibuf);
 }
@@ -442,8 +449,11 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1)
        /* for now don't duplicate metadata */
        tbuf.metadata = NULL;
 
+       tbuf.display_buffer_flags = NULL;
+       tbuf.colormanage_cache = NULL;
+
        *ibuf2 = tbuf;
-       
+
        return(ibuf2);
 }