Add Peak Memory as render stamp option
authorLukas Stockner <lukas.stockner@freenet.de>
Thu, 19 May 2016 19:39:22 +0000 (21:39 +0200)
committerLukas Stockner <lukas.stockner@freenet.de>
Thu, 19 May 2016 20:57:38 +0000 (22:57 +0200)
This commit adds Peak Memory to the stamp options, the value is the same one that is already shown in the image viewer.

Requested by @nutel.

Reviewers: campbellbarton

Subscribers: campbellbarton, nutel

Differential Revision: https://developer.blender.org/D1989

release/scripts/startup/bl_ui/properties_render.py
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/scene.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c

index 6c4904939bf802146e7762f113782af3e52f039d..13e7265319bb8141f748e9ec348668845799ff8d 100644 (file)
@@ -360,6 +360,7 @@ class RENDER_PT_stamp(RenderButtonsPanel, Panel):
         col.prop(rd, "use_stamp_render_time", text="RenderTime")
         col.prop(rd, "use_stamp_frame", text="Frame")
         col.prop(rd, "use_stamp_scene", text="Scene")
+        col.prop(rd, "use_stamp_memory", text="Memory")
 
         col = split.column()
         col.prop(rd, "use_stamp_camera", text="Camera")
index d4551fd0b2ccc1bf86bd99e4bb204938c3709596..1ae7ca189fb4c5f2629282b74be729efc08ff870 100644 (file)
@@ -1748,6 +1748,7 @@ typedef struct StampData {
        char scene[STAMP_NAME_SIZE];
        char strip[STAMP_NAME_SIZE];
        char rendertime[STAMP_NAME_SIZE];
+       char memory[STAMP_NAME_SIZE];
 } StampData;
 #undef STAMP_NAME_SIZE
 
@@ -1869,6 +1870,13 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
                else {
                        stamp_data->rendertime[0] = '\0';
                }
+
+               if (stats && (scene->r.stamp & R_STAMP_MEMORY)) {
+                       BLI_snprintf(stamp_data->memory, sizeof(stamp_data->memory), do_prefix ? "Peak Memory %.2fM" : "%.2fM", stats->mem_peak);
+               }
+               else {
+                       stamp_data->memory[0] = '\0';
+               }
        }
 }
 
@@ -1943,6 +1951,12 @@ static void stampdata_from_template(StampData *stamp_data,
        else {
                stamp_data->rendertime[0] = '\0';
        }
+       if (scene->r.stamp & R_STAMP_MEMORY) {
+               BLI_snprintf(stamp_data->memory, sizeof(stamp_data->memory), "Peak Memory %s", stamp_data_template->memory);
+       }
+       else {
+               stamp_data->memory[0] = '\0';
+       }
 }
 
 void BKE_image_stamp_buf(
@@ -2056,6 +2070,21 @@ void BKE_image_stamp_buf(
        }
 
        /* Top left corner, below File, Date, Rendertime */
+       if (TEXT_SIZE_CHECK(stamp_data.memory, w, h)) {
+               y -= h;
+
+               /* and space for background. */
+               buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
+                                 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y);
+
+               BLF_position(mono, x, y + y_ofs, 0.0);
+               BLF_draw_buffer(mono, stamp_data.memory, BLF_DRAW_STR_DUMMY_MAX);
+
+               /* the extra pixel for background. */
+               y -= BUFF_MARGIN_Y * 2;
+       }
+
+       /* Top left corner, below File, Date, Memory, Rendertime */
        BLF_enable(mono, BLF_WORD_WRAP);
        if (TEXT_SIZE_CHECK_WORD_WRAP(stamp_data.note, w, h)) {
                y -= h;
@@ -2219,6 +2248,7 @@ void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCall
        CALL(scene, "Scene");
        CALL(strip, "Strip");
        CALL(rendertime, "RenderTime");
+       CALL(memory, "Memory");
 
 #undef CALL
 }
index 27abbb627623204f366b2f2e8897efd6dc532ab6..d307ba1811b3649513af348c59f7445251a3a87e 100644 (file)
@@ -545,7 +545,7 @@ void BKE_scene_init(Scene *sce)
        sce->r.bake.im_format.compress = 15;
 
        sce->r.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION;
-       sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME;
+       sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME | R_STAMP_MEMORY;
        sce->r.stamp_font_id = 12;
        sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f;
        sce->r.fg_stamp[3] = 1.0f;
index 39508e17be51837899d7cd1ac61592107fc38c58..1bf044ffecb3ae672fec2be9042131a623df65ca 100644 (file)
@@ -1714,9 +1714,10 @@ typedef struct Scene {
 #define R_STAMP_RENDERTIME     0x0400
 #define R_STAMP_CAMERALENS     0x0800
 #define R_STAMP_STRIPMETA      0x1000
+#define R_STAMP_MEMORY         0x2000
 #define R_STAMP_ALL (R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE| \
                      R_STAMP_NOTE|R_STAMP_MARKER|R_STAMP_FILENAME|R_STAMP_SEQSTRIP|        \
-                     R_STAMP_RENDERTIME|R_STAMP_CAMERALENS)
+                     R_STAMP_RENDERTIME|R_STAMP_CAMERALENS|R_STAMP_MEMORY)
 
 /* alphamode */
 #define R_ADDSKY               0
index e89edaf74ad204a9e104199c9eabc766d5422fed..79b8ddec08ae65bcec6fbe1cebb93779ff49003b 100644 (file)
@@ -5968,6 +5968,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Strip Metadata", "Use metadata from the strips in the sequencer");
        RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
 
+       prop = RNA_def_property(srna, "use_stamp_memory", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_MEMORY);
+       RNA_def_property_ui_text(prop, "Stamp Peak Memory", "Include the peak memory usage in image metadata");
+       RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
        prop = RNA_def_property(srna, "stamp_font_size", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "stamp_font_id");
        RNA_def_property_range(prop, 8, 64);