Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/scripts/startup/bl_ui/properties_output.py2
-rw-r--r--source/blender/blenkernel/intern/image.c71
-rw-r--r--source/blender/makesdna/DNA_scene_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_scene.c5
4 files changed, 79 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_output.py b/release/scripts/startup/bl_ui/properties_output.py
index 06119140245..d7b482c4dc5 100644
--- a/release/scripts/startup/bl_ui/properties_output.py
+++ b/release/scripts/startup/bl_ui/properties_output.py
@@ -205,6 +205,8 @@ class RENDER_PT_stamp(RenderOutputButtonsPanel, Panel):
col.prop(rd, "use_stamp_frame_range", text="Frame Range")
col = flow.column()
col.prop(rd, "use_stamp_memory", text="Memory")
+ col = flow.column()
+ col.prop(rd, "use_stamp_hostname", text="Hostname")
col = flow.column()
col.prop(rd, "use_stamp_camera", text="Camera")
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 67dca475650..3ba5f333b8d 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -35,6 +35,16 @@
#ifndef WIN32
# include <unistd.h>
#else
+# ifndef NOGDI
+# define NOGDI
+# endif
+# ifndef NOMINMAX
+# define NOMINMAX
+# endif
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include <Windows.h> /* for GetComputerName function */
# include <io.h>
#endif
@@ -1545,6 +1555,7 @@ typedef struct StampData {
char strip[STAMP_NAME_SIZE];
char rendertime[STAMP_NAME_SIZE];
char memory[STAMP_NAME_SIZE];
+ char hostname[512];
/* Custom fields are used to put extra meta information header from render
* engine to the result image.
@@ -1556,6 +1567,32 @@ typedef struct StampData {
#undef STAMP_NAME_SIZE
/**
+ * Obtain the hostname from the system.
+ *
+ * This simply determines the host's name, and doesn't do any DNS lookup of any
+ * IP address of the machine. As such, it's only usable for identification
+ * purposes, and not for reachability over a network.
+ *
+ * @param buffer Character buffer to write the hostname into.
+ * @param bufsize Size of the character buffer, including trailing '\0'.
+ */
+static void get_hostname(char *buffer, size_t bufsize)
+{
+#ifndef WIN32
+ if (gethostname(buffer, bufsize-1) < 0) {
+ strncpy(buffer, "-unknown-", bufsize);
+ }
+ /* When gethostname() truncates, it doesn't guarantee the trailing \0. */
+ buffer[bufsize - 1] = '\0';
+#else
+ DWORD bufsize_inout = bufsize;
+ if(!GetComputerName(buffer, &bufsize_inout)) {
+ strncpy(buffer, "-unknown-", bufsize);
+ }
+#endif
+}
+
+/**
* \param do_prefix: Include a label like "File ", "Date ", etc. in the stamp data strings.
* \param use_dynamic: Also include data that can change on a per-frame basis.
*/
@@ -1704,6 +1741,16 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
else {
stamp_data->frame_range[0] = '\0';
}
+
+ if (scene->r.stamp & R_STAMP_HOSTNAME) {
+ char hostname[500]; /* sizeof(stamp_data->hostname) minus some bytes for a label. */
+ get_hostname(hostname, sizeof(hostname));
+ SNPRINTF(stamp_data->hostname, do_prefix ? "Hostname %s" : "%s", hostname);
+ }
+ else {
+ stamp_data->hostname[0] = '\0';
+ }
+
}
/* Will always add prefix. */
@@ -1783,6 +1830,12 @@ static void stampdata_from_template(StampData *stamp_data,
else {
stamp_data->memory[0] = '\0';
}
+ if (scene->r.stamp & R_STAMP_HOSTNAME) {
+ SNPRINTF(stamp_data->hostname, "Hostname %s", stamp_data_template->hostname);
+ }
+ else {
+ stamp_data->hostname[0] = '\0';
+ }
}
void BKE_image_stamp_buf(
@@ -1910,7 +1963,22 @@ void BKE_image_stamp_buf(
y -= BUFF_MARGIN_Y * 2;
}
- /* Top left corner, below File, Date, Memory, Rendertime */
+ /* Top left corner, below File, Date, Rendertime, Memory */
+ if (TEXT_SIZE_CHECK(stamp_data.hostname, 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.hostname, BLF_DRAW_STR_DUMMY_MAX);
+
+ /* the extra pixel for background. */
+ y -= BUFF_MARGIN_Y * 2;
+ }
+
+ /* Top left corner, below File, Date, Memory, Rendertime, Hostname */
BLF_enable(mono, BLF_WORD_WRAP);
if (TEXT_SIZE_CHECK_WORD_WRAP(stamp_data.note, w, h)) {
y -= h;
@@ -2091,6 +2159,7 @@ void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCall
CALL(strip, "Strip");
CALL(rendertime, "RenderTime");
CALL(memory, "Memory");
+ CALL(hostname, "Hostname");
LISTBASE_FOREACH(StampDataCustomField *, custom_field, &stamp_data->custom_fields) {
if (noskip || custom_field->value[0]) {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index b191c4c5a7c..c1853ce1745 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1724,10 +1724,11 @@ enum {
#define R_STAMP_MEMORY 0x2000
#define R_STAMP_HIDE_LABELS 0x4000
#define R_STAMP_FRAME_RANGE 0x8000
+#define R_STAMP_HOSTNAME 0x10000
#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_MEMORY| \
- R_STAMP_HIDE_LABELS|R_STAMP_FRAME_RANGE)
+ R_STAMP_HIDE_LABELS|R_STAMP_FRAME_RANGE|R_STAMP_HOSTNAME)
/* RenderData.alphamode */
#define R_ADDSKY 0
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index fe4d69b910f..4372f167c28 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5189,6 +5189,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
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, "use_stamp_hostname", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_HOSTNAME);
+ RNA_def_property_ui_text(prop, "Stamp Hostname", "Include the hostnamename of the machine running Blender");
+ 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);