Merging r49815 through r49833 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Sun, 12 Aug 2012 10:07:55 +0000 (10:07 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sun, 12 Aug 2012 10:07:55 +0000 (10:07 +0000)
1  2 
build_files/cmake/macros.cmake
build_files/scons/config/linux-config.py
build_files/scons/config/win32-vc-config.py
build_files/scons/config/win64-vc-config.py
build_files/scons/tools/Blender.py
build_files/scons/tools/btools.py
source/blender/editors/render/render_internal.c
source/blender/editors/space_image/image_ops.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_window.c

index 88dd64640b6346c35beab5ebe3e22488f54e24f5,62e1e83326c7f4c069f880795f3892b4a8f9d1a3..f14e92047329d7c8a3ab7f59d86f4ef5e9b1fb24
@@@ -212,9 -212,6 +212,9 @@@ macro(SETUP_LIBDIRS
        if(WITH_OPENIMAGEIO)
                link_directories(${OPENIMAGEIO_LIBPATH})
        endif()
 +      if(WITH_OPENCOLORIO)
 +              link_directories(${OPENCOLORIO_LIBPATH})
 +      endif()
        if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG)
                link_directories(${OPENJPEG_LIBPATH})
        endif()
@@@ -310,9 -307,6 +310,9 @@@ macro(setup_liblink
        if(WITH_OPENIMAGEIO)
                target_link_libraries(${target} ${OPENIMAGEIO_LIBRARIES})
        endif()
 +      if(WITH_OPENCOLORIO)
 +              target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
 +      endif()
        if(WITH_BOOST)
                target_link_libraries(${target} ${BOOST_LIBRARIES})
        endif()
@@@ -733,7 -727,6 +733,6 @@@ macro(set_lib_pat
  endmacro()
  
  
- # TODO, create a C binary and call it instead!, doing this in cmake its slow
  macro(data_to_c
        file_from file_to
        list_to_add)
        add_custom_command(
                OUTPUT ${file_to}
                COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path}
-               COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc
-                       ${file_from}
-                       ${file_to}
-               DEPENDS ${file_from})
+               COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc ${file_from} ${file_to}
+               DEPENDS ${file_from} datatoc)
        unset(_file_to_path)
  endmacro()
  
  # same as above but generates the var name and output automatic.
  macro(data_to_c_simple
        file_from
        list_to_add)
  
-       # only to avoid confusion
-       set(_file_to ${file_from}.c)
+       # remove ../'s
+       get_filename_component(_file_from ${CMAKE_CURRENT_SOURCE_DIR}/${file_from}   REALPATH)
+       get_filename_component(_file_to   ${CMAKE_CURRENT_BINARY_DIR}/${file_from}.c REALPATH)
  
-       list(APPEND ${list_to_add} ${CMAKE_CURRENT_BINARY_DIR}/${_file_to})
+       list(APPEND ${list_to_add} ${_file_to})
  
        get_filename_component(_file_to_path ${_file_to} PATH)
  
        add_custom_command(
-               OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file_to}
+               OUTPUT  ${_file_to}
                COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path}
-               COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc
-                       ${CMAKE_CURRENT_SOURCE_DIR}/${file_from}
-                       ${CMAKE_CURRENT_BINARY_DIR}/${_file_to}
-               DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file_from})
+               COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc ${_file_from} ${_file_to}
+               DEPENDS ${_file_from} datatoc)
  
-       unset(_var_name)
+       unset(_file_from)
        unset(_file_to)
        unset(_file_to_path)
  endmacro()
index a63000d7d7d3f041c33ea6cdb99243b2a8f92672,e97c3b8b9d7825cb41221c80537161fa56b077b7..5c16baa2ee8d87f6abb54682e5e653fd7eef4c2d
@@@ -105,6 -105,11 +105,11 @@@ BF_BULLET = '#extern/bullet2/src
  BF_BULLET_INC = '${BF_BULLET}'
  BF_BULLET_LIB = 'extern_bullet'
  
+ WITH_BF_ELTOPO = False
+ BF_LAPACK = '/usr'
+ BF_LAPACK_LIB = 'lapack3gf blas clapack'
+ BF_LAPACK_LIBPATH = '${BF_LAPACK}/lib'
  BF_FREETYPE = '/usr'
  BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2'
  BF_FREETYPE_LIB = 'freetype'
@@@ -210,16 -215,6 +215,16 @@@ BF_OIIO_INC = BF_OIIO + '/include
  BF_OIIO_LIB = 'OpenImageIO'
  BF_OIIO_LIBPATH = BF_OIIO + '/lib'
  
 +WITH_BF_OCIO = True
 +WITH_BF_STATICOCIO = False
 +BF_OCIO = LIBDIR + '/ocio'
 +if not os.path.exists(LCGDIR + '/ocio'):
 +    WITH_BF_OCIO = False
 +    BF_OCIO = '/usr'
 +BF_OCIO_INC = BF_OCIO + '/include'
 +BF_OCIO_LIB = 'OpenColorIO yaml-cpp tinyxml'
 +BF_OCIO_LIBPATH = BF_OCIO + '/lib'
 +
  WITH_BF_BOOST = True
  WITH_BF_STATICBOOST = False
  BF_BOOST = LIBDIR + '/boost'
index 1e1084a9d40d4170592740e775dfa34567d18dd7,452bbaaf54f9613e49c603f9616c291256b65b83..b77ff8e70e075def7a55cb746cebce91d182d5bb
@@@ -101,6 -101,11 +101,11 @@@ BF_BULLET = '#extern/bullet2/src
  BF_BULLET_INC = '${BF_BULLET}'
  BF_BULLET_LIB = 'extern_bullet'
  
+ WITH_BF_ELTOPO = False
+ BF_LAPACK = LIBDIR + '/lapack'
+ BF_LAPACK_LIB = 'libf2c clapack_nowrap BLAS_nowrap'
+ BF_LAPACK_LIBPATH = '${BF_LAPACK}/lib'
  BF_WINTAB = LIBDIR + '/wintab'
  BF_WINTAB_INC = '${BF_WINTAB}/INCLUDE'
  
@@@ -155,12 -160,6 +160,12 @@@ BF_OIIO = '${LIBDIR}/openimageio
  BF_OIIO_INC = '${BF_OIIO}/include'
  BF_OIIO_LIB = 'OpenImageIO'
  BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
 +
 +WITH_BF_OCIO = True
 +BF_OCIO = '${LIBDIR}/opencolorio'
 +BF_OCIO_INC = '${BF_OCIO}/include'
 +BF_OCIO_LIB = 'OpenColorIO'
 +BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
  
  WITH_BF_BOOST = True
  BF_BOOST = '${LIBDIR}/boost'
index 64c741e4bdf22f6b6c45ad4f12f718e69f330b29,b6a3c108cdb86736c8db4bf13a407d1d53735d12..4b719469c392a8e0e718807d38a4770df9bc65ed
@@@ -97,6 -97,11 +97,11 @@@ BF_BULLET = '#extern/bullet2/src
  BF_BULLET_INC = '${BF_BULLET}'
  BF_BULLET_LIB = 'extern_bullet'
  
+ WITH_BF_ELTOPO = False
+ BF_LAPACK = LIBDIR + '/lapack'
+ BF_LAPACK_LIB = 'libf2c clapack_nowrap BLAS_nowrap'
+ BF_LAPACK_LIBPATH = '${BF_LAPACK}/lib'
  BF_WINTAB = LIBDIR + '/wintab'
  BF_WINTAB_INC = '${BF_WINTAB}/INCLUDE'
  
@@@ -153,13 -158,6 +158,13 @@@ BF_OIIO_LIB = 'OpenImageIO
  BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
  BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
  
 +WITH_BF_OCIO = True
 +BF_OCIO = '${LIBDIR}/opencolorio'
 +BF_OCIO_INC = '${BF_OCIO}/include'
 +BF_OCIO_LIB = 'OpenColorIO'
 +BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
 +BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
 +
  WITH_BF_BOOST = True
  BF_BOOST = '${LIBDIR}/boost'
  BF_BOOST_INC = '${BF_BOOST}/include'
index 7b59466c4045ff332e61f95156f24c1612345ebd,56d13649cd1b075c4f375b6555f58d186054c8ef..40e9179f12b7cd669aa0926d32a17846a65471e5
@@@ -159,6 -159,10 +159,10 @@@ def setup_staticlibs(lenv)
          libincs += Split(lenv['BF_FFTW3_LIBPATH'])
          if lenv['WITH_BF_STATICFFTW3']:
              statlibs += Split(lenv['BF_FFTW3_LIB_STATIC'])
+     if lenv['WITH_BF_ELTOPO']:
+         libincs += Split(lenv['BF_LAPACK_LIBPATH'])
+         if lenv['WITH_BF_STATICLAPACK']:
+                   statlibs += Split(lenv['BF_LAPACK_LIB_STATIC'])        
      if lenv['WITH_BF_FFMPEG'] and lenv['WITH_BF_STATICFFMPEG']:
          statlibs += Split(lenv['BF_FFMPEG_LIB_STATIC'])
      if lenv['WITH_BF_INTERNATIONAL']:
          if lenv['WITH_BF_STATICOIIO']:
              statlibs += Split(lenv['BF_OIIO_LIB_STATIC'])
  
 +    if lenv['WITH_BF_OCIO']:
 +        libincs += Split(lenv['BF_OCIO_LIBPATH'])
 +        if lenv['WITH_BF_STATICOCIO']:
 +            statlibs += Split(lenv['BF_OCIO_LIB_STATIC'])
 +
      if lenv['WITH_BF_BOOST']:
          libincs += Split(lenv['BF_BOOST_LIBPATH'])
          if lenv['WITH_BF_STATICBOOST']:
@@@ -253,10 -252,6 +257,10 @@@ def setup_syslibs(lenv)
          if not lenv['WITH_BF_STATICOIIO']:
              syslibs += Split(lenv['BF_OIIO_LIB'])
  
 +    if lenv['WITH_BF_OCIO']:
 +        if not lenv['WITH_BF_STATICOCIO']:
 +            syslibs += Split(lenv['BF_OCIO_LIB'])
 +
      if lenv['WITH_BF_OPENEXR'] and not lenv['WITH_BF_STATICOPENEXR']:
          syslibs += Split(lenv['BF_OPENEXR_LIB'])
      if lenv['WITH_BF_TIFF'] and not lenv['WITH_BF_STATICTIFF']:
          syslibs += Split(lenv['BF_SNDFILE_LIB'])
      if lenv['WITH_BF_FFTW3'] and not lenv['WITH_BF_STATICFFTW3']:
          syslibs += Split(lenv['BF_FFTW3_LIB'])
+     if lenv['WITH_BF_ELTOPO']:
+         syslibs += Split(lenv['BF_LAPACK_LIB'])
      if lenv['WITH_BF_SDL']:
          syslibs += Split(lenv['BF_SDL_LIB'])
      if not lenv['WITH_BF_STATICOPENGL']:
@@@ -587,9 -584,6 +593,9 @@@ def AppIt(target=None, source=None, env
          commands.getoutput(cmd)
          cmd = 'cp -R %s/release/datafiles/fonts %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION)
          commands.getoutput(cmd)
 +        if env['WITH_BF_OCIO']:
 +            cmd = 'cp -R %s/release/datafiles/colormanagement %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION)
 +            commands.getoutput(cmd)
          cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/%s/'%(bldroot,installdir,binary,VERSION)
          commands.getoutput(cmd)
  
index 570048495a64d3d518e30e10954c77494d40e157,8f5bb1ffc57f6556e99fc2119c0985e11e7e3c01..dbec5b3ba6c5c039dc3c1357d610bab41ebc0e01
@@@ -120,7 -120,7 +120,7 @@@ def validate_arguments(args, bc)
              'WITH_BF_ICONV', 'BF_ICONV', 'BF_ICONV_INC', 'BF_ICONV_LIB', 'BF_ICONV_LIBPATH',
              'WITH_BF_GAMEENGINE',
              'WITH_BF_BULLET', 'BF_BULLET', 'BF_BULLET_INC', 'BF_BULLET_LIB',
-             'WITH_BF_ELTOPO',
+             'WITH_BF_ELTOPO', 'BF_LAPACK', 'BF_LAPACK_LIB', 'BF_LAPACK_LIBPATH', 'BF_LAPACK_LIB_STATIC',
              'BF_WINTAB', 'BF_WINTAB_INC',
              'BF_FREETYPE', 'BF_FREETYPE_INC', 'BF_FREETYPE_LIB', 'BF_FREETYPE_LIBPATH', 'BF_FREETYPE_LIB_STATIC', 'WITH_BF_FREETYPE_STATIC',
              'WITH_BF_QUICKTIME', 'BF_QUICKTIME', 'BF_QUICKTIME_INC', 'BF_QUICKTIME_LIB', 'BF_QUICKTIME_LIBPATH',
              'WITH_BF_3DMOUSE', 'WITH_BF_STATIC3DMOUSE', 'BF_3DMOUSE', 'BF_3DMOUSE_INC', 'BF_3DMOUSE_LIB', 'BF_3DMOUSE_LIBPATH', 'BF_3DMOUSE_LIB_STATIC',
              'WITH_BF_CYCLES', 'WITH_BF_CYCLES_CUDA_BINARIES', 'BF_CYCLES_CUDA_NVCC', 'BF_CYCLES_CUDA_NVCC', 'WITH_BF_CYCLES_CUDA_THREADED_COMPILE',
              'WITH_BF_OIIO', 'WITH_BF_STATICOIIO', 'BF_OIIO', 'BF_OIIO_INC', 'BF_OIIO_LIB', 'BF_OIIO_LIB_STATIC', 'BF_OIIO_LIBPATH',
 +            'WITH_BF_OCIO', 'WITH_BF_STATICOCIO', 'BF_OCIO', 'BF_OCIO_INC', 'BF_OCIO_LIB', 'BF_OCIO_LIB_STATIC', 'BF_OCIO_LIBPATH',
              'WITH_BF_BOOST', 'WITH_BF_STATICBOOST', 'BF_BOOST', 'BF_BOOST_INC', 'BF_BOOST_LIB', 'BF_BOOST_LIB_STATIC', 'BF_BOOST_LIBPATH',
              'WITH_BF_LIBMV'
              ]
@@@ -394,7 -393,13 +394,13 @@@ def read_opts(env, cfg, args)
          (BoolVariable('WITH_BF_GAMEENGINE', 'Build with gameengine' , False)),
  
          (BoolVariable('WITH_BF_BULLET', 'Use Bullet if true', True)),
+         
          (BoolVariable('WITH_BF_ELTOPO', 'Use Eltopo collision library if true', False)),
+         ('BF_LAPACK', 'LAPACK base path', ''),
+         ('BF_LAPACK_LIB', 'LAPACK library', ''),
+         ('BF_LAPACK_LIB_STATIC', 'LAPACK library', ''),
+         ('BF_LAPACK_LIBPATH', 'LAPACK library path', ''),
+         (BoolVariable('WITH_BF_STATICLAPACK', 'Staticly link to LAPACK', False)),
          
          ('BF_BULLET', 'Bullet base dir', ''),
          ('BF_BULLET_INC', 'Bullet include path', ''),
          ('BF_OIIO_LIBPATH', 'OIIO library path', ''),
          ('BF_OIIO_LIB_STATIC', 'OIIO static library', ''),
  
 +        (BoolVariable('WITH_BF_OCIO', 'Build with OpenColorIO', False)),
 +        (BoolVariable('WITH_BF_STATICOCIO', 'Staticly link to OpenColorIO', False)),
 +        ('BF_OCIO', 'OCIO root path', ''),
 +        ('BF_OCIO_INC', 'OCIO include path', ''),
 +        ('BF_OCIO_LIB', 'OCIO library', ''),
 +        ('BF_OCIO_LIBPATH', 'OCIO library path', ''),
 +        ('BF_OCIO_LIB_STATIC', 'OCIO static library', ''),
 +
          (BoolVariable('WITH_BF_BOOST', 'Build with Boost', False)),
          (BoolVariable('WITH_BF_STATICBOOST', 'Staticly link to boost', False)),
          ('BF_BOOST', 'Boost root path', ''),
index bc43dcbc1eed6985b56148b336f37f84c1a6f67a,ae1b82c6690aede336c8d221b46c73e75047335b..031ad017c79764fe79c0e05c387801c2c953064d
@@@ -61,7 -61,6 +61,7 @@@
  #include "ED_object.h"
  
  #include "RE_pipeline.h"
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf.h"
  #include "IMB_imbuf_types.h"
  
@@@ -151,9 -150,6 +151,9 @@@ void image_buffer_rect_update(Scene *sc
        IMB_buffer_byte_from_float(rectc, rectf,
                                   4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
                                   xmax, ymax, ibuf->x, rr->rectx);
 +
 +      IMB_partial_display_buffer_update(ibuf, rectf, rr->rectx, rxmin, rymin,
 +                                        rxmin, rymin, rxmin + xmax, rymin + ymax);
  }
  
  /* ****************************** render invoking ***************** */
@@@ -569,7 -565,7 +569,7 @@@ static int screen_render_invoke(bContex
        else name = "Render";
  
        steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag);
-       WM_jobs_customdata(steve, rj, render_freejob);
+       WM_jobs_customdata_set(steve, rj, render_freejob);
        WM_jobs_timer(steve, 0.2, NC_SCENE | ND_RENDER_RESULT, 0);
        WM_jobs_callbacks(steve, render_startjob, NULL, NULL, render_endjob);
  
index d85cc307c3ebf937765fc8a98bc75c3eba0e2afc,b2a9584b243a7d02dcc9b53027cc77e2f64c82b3..1d8f63ce385248cf2d223a14f39dcc4dd28dd385
@@@ -55,7 -55,6 +55,7 @@@
  #include "BKE_report.h"
  #include "BKE_screen.h"
  
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf.h"
  #include "IMB_imbuf_types.h"
  
@@@ -581,7 -580,7 +581,7 @@@ static int image_view_all_exec(bContex
        w = width * aspx;
        h = height * aspy;
        
-       /* check if the image will fit in the image with zoom==1 */
+       /* check if the image will fit in the image with (zoom == 1) */
        width = ar->winrct.xmax - ar->winrct.xmin + 1;
        height = ar->winrct.ymax - ar->winrct.ymin + 1;
  
@@@ -1115,14 -1114,12 +1115,14 @@@ static char imtype_best_depth(ImBuf *ib
        }
  }
  
 -static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene, const short guess_path)
 +static int save_image_options_init(bContext *C, SaveImageOptions *simopts, SpaceImage *sima, Scene *scene, const short guess_path)
  {
        void *lock;
        ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
  
        if (ibuf) {
 +              wmWindow *win = CTX_wm_window(C);
 +              const ColorManagedViewSettings *view_settings;
                Image *ima = sima->image;
                short is_depth_set = FALSE;
  
                        }
                        BLI_path_abs(simopts->filepath, G.main->name);
                }
 +
 +              /* color management */
 +              view_settings = IMB_view_settings_get_effective(win, &sima->view_settings);
 +
 +              BKE_color_managed_display_settings_copy(&simopts->im_format.display_settings, &win->display_settings);
 +              BKE_color_managed_view_settings_copy(&simopts->im_format.view_settings, view_settings);
        }
  
        ED_space_image_release_buffer(sima, lock);
@@@ -1205,38 -1196,6 +1205,38 @@@ static void save_image_options_to_op(Sa
        RNA_string_set(op->ptr, "filepath", simopts->filepath);
  }
  
 +static ImBuf *save_image_colormanaged_imbuf_acquire(ImBuf *ibuf, SaveImageOptions *simopts, void **cache_handle)
 +{
 +      ImageFormatData *imf = &simopts->im_format;
 +      ImBuf *colormanaged_ibuf;
 +      int do_colormanagement;
 +
 +      *cache_handle = NULL;
 +      do_colormanagement = !BKE_imtype_supports_float(imf->imtype);
 +
 +      if (do_colormanagement) {
 +              unsigned char *display_buffer =
 +                      IMB_display_buffer_acquire(ibuf, &imf->view_settings, &imf->display_settings, cache_handle);
 +
 +              if (*cache_handle) {
 +                      colormanaged_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0);
 +                      colormanaged_ibuf->rect = (unsigned int *) display_buffer;
 +              }
 +              else {
 +                      /* no cache handle means color management didn't run transformation
 +                       * or performed transformation to image's byte buffer which doesn't
 +                       * require allocating new image buffer
 +                       */
 +                      colormanaged_ibuf = ibuf;
 +              }
 +      }
 +      else {
 +              colormanaged_ibuf = ibuf;
 +      }
 +
 +      return colormanaged_ibuf;
 +}
 +
  /* assumes name is FILE_MAX */
  /* ima->name and ibuf->name should end up the same */
  static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath)
        ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
  
        if (ibuf) {
 +              void *cache_handle;
 +              ImBuf *colormanaged_ibuf;
                const char *relbase = ID_BLEND_PATH(CTX_data_main(C), &ima->id);
                const short relative = (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
                const short save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
                                ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? 32 : 24;
                        }
                }
 -              
 +
 +              colormanaged_ibuf = save_image_colormanaged_imbuf_acquire(ibuf, simopts, &cache_handle);
 +
                if (simopts->im_format.imtype == R_IMF_IMTYPE_MULTILAYER) {
                        Scene *scene = CTX_data_scene(C);
                        RenderResult *rr = BKE_image_acquire_renderresult(scene, ima);
                        BKE_image_release_renderresult(scene, ima);
                }
                else {
 -                      if (BKE_imbuf_write_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
 +                      if (BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
                                ok = TRUE;
                        }
                }
                WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image);
  
                WM_cursor_wait(0);
 +
 +              if (cache_handle) {
 +                      colormanaged_ibuf->rect = NULL;
 +                      IMB_freeImBuf(colormanaged_ibuf);
 +
 +                      IMB_display_buffer_release(cache_handle);
 +              }
        }
  
        ED_space_image_release_buffer(sima, lock);
@@@ -1368,7 -1316,7 +1368,7 @@@ static int image_save_as_exec(bContext 
  
        /* just in case to initialize values,
         * these should be set on invoke or by the caller. */
 -      save_image_options_init(&simopts, sima, CTX_data_scene(C), 0);
 +      save_image_options_init(C, &simopts, sima, CTX_data_scene(C), 0);
  
        save_image_options_from_op(&simopts, op);
  
@@@ -1397,7 -1345,7 +1397,7 @@@ static int image_save_as_invoke(bContex
  
        save_image_options_defaults(&simopts);
  
 -      if (save_image_options_init(&simopts, sima, scene, TRUE) == 0)
 +      if (save_image_options_init(C, &simopts, sima, scene, TRUE) == 0)
                return OPERATOR_CANCELLED;
        save_image_options_to_op(&simopts, op);
  
@@@ -1483,7 -1431,7 +1483,7 @@@ static int image_save_exec(bContext *C
        Scene *scene = CTX_data_scene(C);
        SaveImageOptions simopts;
  
 -      if (save_image_options_init(&simopts, sima, scene, FALSE) == 0)
 +      if (save_image_options_init(C, &simopts, sima, scene, FALSE) == 0)
                return OPERATOR_CANCELLED;
        save_image_options_from_op(&simopts, op);
  
@@@ -2304,7 -2252,7 +2304,7 @@@ static int image_record_composite_apply
        Scene *scene = CTX_data_scene(C);
        ImBuf *ibuf;
        
-       WM_timecursor(CTX_wm_window(C), scene->r.cfra);
+       WM_cursor_time(CTX_wm_window(C), scene->r.cfra);
  
        // XXX scene->nodetree->test_break= blender_test_break;
        // XXX scene->nodetree->test_break= NULL;
index dc897820399f89eaa64f6c4e44d4249667e48a6d,ac9b44fddb0a1f6d30477ce7c8da33969f6263b0..0742a52727e9b2db9eef40d4f45bcb06d3cc06af
@@@ -67,6 -67,7 +67,6 @@@
  #include "BKE_tracking.h" /* free tracking clipboard */
  
  #include "BLI_listbase.h"
 -#include "BLI_math_color.h"
  #include "BLI_string.h"
  #include "BLI_utildefines.h"
  
  #include "BKE_depsgraph.h"
  #include "BKE_sound.h"
  
 +#include "IMB_colormanagement.h"
 +
  static void wm_init_reports(bContext *C)
  {
        BKE_reports_init(CTX_wm_reports(C), RPT_STORE);
@@@ -149,11 -148,11 +149,11 @@@ void WM_init(bContext *C, int argc, con
        BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
        BLF_lang_init();
  
 -      /* initialize color stuff */
 -      BLI_init_srgb_conversion();
 +      /* initialize color management stuff */
 +      IMB_colormanagement_init();
  
        /* get the default database, plus a wm */
-       WM_read_homefile(C, NULL, G.factory_startup);
+       WM_homefile_read(C, NULL, G.factory_startup);
  
        BLF_lang_set(NULL);
  
         * initializing space types and other internal data.
         *
         * However cant redo this at the moment. Solution is to load python
-        * before WM_read_homefile() or make py-drivers check if python is running.
+        * before WM_homefile_read() or make py-drivers check if python is running.
         * Will try fix when the crash can be repeated. - campbell. */
  
  #ifdef WITH_PYTHON
@@@ -372,7 -371,6 +372,7 @@@ void WM_exit_ext(bContext *C, const sho
  
        sound_exit();
  
 +      IMB_colormanagement_exit();
  
        /* first wrap up running stuff, we assume only the active WM is running */
        /* modal handlers are on window level freed, others too? */
index 1dad92d68932f948cdff663b9276cd3b5962150a,c2aa99352e953220da33d1a63093fdea0d29b41c..1f1698e8e5aa061554eab158da16691b9e70f960
@@@ -49,7 -49,6 +49,7 @@@
  #include "BLF_translation.h"
  
  #include "BKE_blender.h"
 +#include "BKE_colortools.h"
  #include "BKE_context.h"
  #include "BKE_library.h"
  #include "BKE_global.h"
@@@ -244,9 -243,7 +244,9 @@@ wmWindow *wm_window_copy(bContext *C, w
  
        win->drawmethod = -1;
        win->drawdata = NULL;
 -      
 +
 +      BKE_color_managed_display_settings_copy(&win->display_settings, &winorig->display_settings);
 +
        return win;
  }
  
@@@ -1205,7 -1202,7 +1205,7 @@@ void wm_get_cursor_position(wmWindow *w
  
  
  /* called whem no ghost system was initialized */
- void WM_setprefsize(int stax, int stay, int sizx, int sizy)
+ void WM_init_state_size_set(int stax, int stay, int sizx, int sizy)
  {
        wm_init_state.start_x = stax; /* left hand pos */
        wm_init_state.start_y = stay; /* bottom pos */
  }
  
  /* for borderless and border windows set from command-line */
- void WM_setinitialstate_fullscreen(void)
+ void WM_init_state_fullscreen_set(void)
  {
        wm_init_state.windowstate = GHOST_kWindowStateFullScreen;
        wm_init_state.override_flag |= WIN_OVERRIDE_WINSTATE;
  }
  
- void WM_setinitialstate_normal(void)
+ void WM_init_state_normal_set(void)
  {
        wm_init_state.windowstate = GHOST_kWindowStateNormal;
        wm_init_state.override_flag |= WIN_OVERRIDE_WINSTATE;