Merged changes in the trunk up to revision 55357.
[blender.git] / source / blender / render / intern / source / render_result.c
index eb330177bacd4f43074912dc2c851651b05bcbb6..21e7b6986100826b7679b7c8a38ecfb725ee8124 100644 (file)
 
 #include "MEM_guardedalloc.h"
 
-#include "BKE_image.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_report.h"
-
+#include "BLI_utildefines.h"
 #include "BLI_fileops.h"
 #include "BLI_listbase.h"
 #include "BLI_path_util.h"
 #include "BLI_rect.h"
 #include "BLI_string.h"
 #include "BLI_threads.h"
-#include "BLI_utildefines.h"
+
+#include "BKE_image.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
 
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
@@ -57,7 +57,9 @@
 #include "render_result.h"
 #include "render_types.h"
 
-#include "FRS_freestyle_config.h"
+#ifdef WITH_FREESTYLE
+#  include "FRS_freestyle_config.h"
+#endif
 
 /********************************** Free *************************************/
 
@@ -436,7 +438,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
        rr->renrect.xmin = 0; rr->renrect.xmax = rectx - 2 * crop;
        /* crop is one or two extra pixels rendered for filtering, is used for merging and display too */
        rr->crop = crop;
-       
+
        /* tilerect is relative coordinates within render disprect. do not subtract crop yet */
        rr->tilerect.xmin = partrct->xmin - re->disprect.xmin;
        rr->tilerect.xmax = partrct->xmax - re->disprect.xmin;
@@ -566,7 +568,9 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
                rl->lay = (1 << 20) - 1;
                rl->layflag = 0x7FFF;    /* solid ztra halo strand */
                rl->passflag = SCE_PASS_COMBINED;
-               FRS_add_freestyle_config( srl );
+#ifdef WITH_FREESTYLE
+               FRS_init_freestyle_config(&srl->freestyleConfig);
+#endif
                
                re->r.actlay = 0;
        }
@@ -927,7 +931,7 @@ static void save_empty_result_tiles(Render *re)
                        IMB_exrtile_clear_channels(rl->exrhandle);
                
                        for (pa = re->parts.first; pa; pa = pa->next) {
-                               if (pa->ready == 0) {
+                               if (pa->status != PART_STATUS_READY) {
                                        int party = pa->disprect.ymin - re->disprect.ymin + pa->crop;
                                        int partx = pa->disprect.xmin - re->disprect.xmin + pa->crop;
                                        IMB_exrtile_write_channels(rl->exrhandle, partx, party, 0);
@@ -986,11 +990,9 @@ void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart)
 /* path to temporary exr file */
 void render_result_exr_file_path(Scene *scene, const char *layname, int sample, char *filepath)
 {
-       char di[FILE_MAX], name[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100], fi[FILE_MAXFILE];
-       
-       BLI_strncpy(di, G.main->name, FILE_MAX);
-       BLI_splitdirstring(di, fi);
+       char name[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100], fi[FILE_MAXFILE];
        
+       BLI_split_file_part(G.main->name, fi, sizeof(fi));
        if (sample == 0)
                BLI_snprintf(name, sizeof(name), "%s_%s_%s.exr", fi, scene->id.name + 2, layname);
        else
@@ -1080,8 +1082,7 @@ int render_result_exr_file_read_path(RenderResult *rr, RenderLayer *rl_single, c
 
 ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd)
 {
-       int flags = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) ? IB_cm_predivide : 0;
-       ImBuf *ibuf = IMB_allocImBuf(rr->rectx, rr->recty, rd->im_format.planes, flags);
+       ImBuf *ibuf = IMB_allocImBuf(rr->rectx, rr->recty, rd->im_format.planes, 0);
        
        /* if not exists, BKE_imbuf_write makes one */
        ibuf->rect = (unsigned int *)rr->rect32;
@@ -1098,6 +1099,10 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd)
                if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) {
                        IMB_float_from_rect(ibuf);
                }
+               else  {
+                       /* ensure no float buffer remained from previous frame */
+                       ibuf->rect_float = NULL;
+               }
        }
 
        /* color -> grayscale */
@@ -1151,17 +1156,15 @@ void render_result_rect_fill_zero(RenderResult *rr)
                rr->rect32 = MEM_callocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
 }
 
-void render_result_rect_get_pixels(RenderResult *rr, RenderData *rd, unsigned int *rect, int rectx, int recty,
+void render_result_rect_get_pixels(RenderResult *rr, unsigned int *rect, int rectx, int recty,
                                    const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 {
        if (rr->rect32) {
                memcpy(rect, rr->rect32, sizeof(int) * rr->rectx * rr->recty);
        }
        else if (rr->rectf) {
-               int predivide = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
-
                IMB_display_buffer_transform_apply((unsigned char *) rect, rr->rectf, rr->rectx, rr->recty, 4,
-                                                  view_settings, display_settings, predivide);
+                                                  view_settings, display_settings, TRUE);
        }
        else
                /* else fill with black */