stamp font size and added rendertime stamp option
authorCampbell Barton <ideasman42@gmail.com>
Thu, 15 Oct 2009 19:18:40 +0000 (19:18 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 15 Oct 2009 19:18:40 +0000 (19:18 +0000)
release/scripts/ui/buttons_render.py
source/blender/blenkernel/intern/image.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c

index 699fd8d73919f46c850c85e5b848a033ceac92b9..0826c766ce3659d921c74ccf352e34f3978dedc8 100644 (file)
@@ -422,6 +422,7 @@ class RENDER_PT_stamp(RenderButtonsPanel):
                col = split.column()
                col.itemR(rd, "stamp_time", text="Time")
                col.itemR(rd, "stamp_date", text="Date")
+               col.itemR(rd, "stamp_render_time", text="RenderTime")
                col.itemR(rd, "stamp_frame", text="Frame")
                col.itemR(rd, "stamp_scene", text="Scene")
                col.itemR(rd, "stamp_camera", text="Camera")
index 09d150341b2df51d24561c3b659dbf91af489d5a..efe53f6f8ef1f78a5821e329c450eaa869f70519 100644 (file)
@@ -964,6 +964,7 @@ typedef struct StampData {
        char    camera[64];
        char    scene[64];
        char    strip[64];
+       char    rendertime[64];
 } StampData;
 
 static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
@@ -1087,6 +1088,20 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
        } else {
                stamp_data->strip[0] = '\0';
        }
+
+       {
+               Render *re= RE_GetRender(scene->id.name);
+               RenderStats *stats= re ? RE_GetStats(re):NULL;
+
+               if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) {
+                       BLI_timestr(stats->lastframetime, text);
+
+                       if (do_prefix)          sprintf(stamp_data->rendertime, "RenderTime %s", text);
+                       else                            sprintf(stamp_data->rendertime, "%s", text);
+               } else {
+                       stamp_data->rendertime[0] = '\0';
+               }
+       }
 }
 
 // XXX - Bad level call.
@@ -1116,7 +1131,12 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
                return;
        
        stampdata(scene, &stamp_data, 1);
-       stamp_font_begin(12);
+
+       /* TODO, do_versions */
+       if(scene->r.stamp_font_id < 8)
+               scene->r.stamp_font_id= 12;
+
+       stamp_font_begin(scene->r.stamp_font_id);
 
        BLF_buffer(rectf, rect, width, height, channels);
        BLF_buffer_col(scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0);
@@ -1166,6 +1186,21 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
 
                BLF_position(x, y, 0.0);
                BLF_draw_buffer(stamp_data.date);
+
+               /* the extra pixel for background. */
+               y -= 4;
+       }
+
+       /* Top left corner, below File, Date or Note */
+       if (stamp_data.rendertime[0]) {
+               BLF_width_and_height(stamp_data.rendertime, &w, &h);
+               y -= h;
+
+               /* and space for background. */
+               buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3);
+
+               BLF_position(x, y, 0.0);
+               BLF_draw_buffer(stamp_data.rendertime);
        }
 
        x= 0;
index d2e88408f6b93a056111fce2c06449d069553c64..91f8e8d5c414d07d61dfd19f947366960965a329 100644 (file)
@@ -866,7 +866,8 @@ typedef struct Scene {
 #define R_STAMP_MARKER 0x0080
 #define R_STAMP_FILENAME       0x0100
 #define R_STAMP_SEQSTRIP       0x0200
-#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)
+#define R_STAMP_RENDERTIME     0x0400
+#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)
 
 /* alphamode */
 #define R_ADDSKY               0
index 59850216060c3ee0eab54c4fd8ff7657ce0b067d..b9fd2926ca3d7a94a7a37e38c3ed62294ce8922e 100644 (file)
@@ -1280,14 +1280,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
                {0, "THREADS_AUTO", 0, "Auto-detect", "Automatically determine the number of threads, based on CPUs"},
                {R_FIXED_THREADS, "THREADS_FIXED", 0, "Fixed", "Manually determine the number of threads"},
                {0, NULL, 0, NULL, NULL}};
-       
-       static EnumPropertyItem stamp_font_size_items[] = {
-               {1, "STAMP_FONT_TINY", 0, "Tiny", ""},
-               {2, "STAMP_FONT_SMALL", 0, "Small", ""},
-               {3, "STAMP_FONT_MEDIUM", 0, "Medium", ""},
-               {0, "STAMP_FONT_LARGE", 0, "Large", ""},
-               {4, "STAMP_FONT_EXTRALARGE", 0, "Extra Large", ""},
-               {0, NULL, 0, NULL, NULL}};
 
        static EnumPropertyItem image_type_items[] = {
                {0, "", 0, "Image", NULL},
@@ -2005,23 +1997,28 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_SEQSTRIP);
        RNA_def_property_ui_text(prop, "Stamp Sequence Strip", "Include the name of the foreground sequence strip in image metadata");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+
+       prop= RNA_def_property(srna, "stamp_render_time", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_RENDERTIME);
+       RNA_def_property_ui_text(prop, "Stamp Render Time", "Include the render time in the stamp image");
+       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
        prop= RNA_def_property(srna, "stamp_note_text", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "stamp_udata");
        RNA_def_property_ui_text(prop, "Stamp Note Text", "Custom text to appear in the stamp note");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
-       
+
        prop= RNA_def_property(srna, "render_stamp", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_DRAW);
        RNA_def_property_ui_text(prop, "Render Stamp", "Render the stamp info text in the rendered image");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
-       prop= RNA_def_property(srna, "stamp_font_size", PROP_ENUM, PROP_NONE);
-       RNA_def_property_enum_sdna(prop, NULL, "stamp_font_id");
-       RNA_def_property_enum_items(prop, stamp_font_size_items);
-       RNA_def_property_ui_text(prop, "Stamp Font Size", "Size of the font used when rendering stamp text");
+       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);
+       RNA_def_property_ui_text(prop, "Font Size", "Size of the font used when rendering stamp text");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
-       
+
        prop= RNA_def_property(srna, "stamp_foreground", PROP_FLOAT, PROP_COLOR);
        RNA_def_property_float_sdna(prop, NULL, "fg_stamp");
        RNA_def_property_array(prop, 4);