[Bf-blender-cvs] [8bef305] master: Cleanup: move BLI_timestr to BLI_timecode

Campbell Barton noreply at git.blender.org
Tue Jun 30 07:52:41 CEST 2015


Commit: 8bef305b6d6628d9d0cd9b8e8765108842fddc5b
Author: Campbell Barton
Date:   Tue Jun 30 14:47:31 2015 +1000
Branches: master
https://developer.blender.org/rB8bef305b6d6628d9d0cd9b8e8765108842fddc5b

Cleanup: move BLI_timestr to BLI_timecode

===================================================================

M	intern/cycles/blender/blender_session.cpp
M	intern/cycles/blender/blender_util.h
M	source/blender/blenkernel/intern/image.c
M	source/blender/blenlib/BLI_string.h
M	source/blender/blenlib/BLI_timecode.h
M	source/blender/blenlib/intern/string.c
M	source/blender/blenlib/intern/timecode.c
M	source/blender/editors/animation/anim_draw.c
M	source/blender/editors/interface/view2d.c
M	source/blender/editors/physics/dynamicpaint_ops.c
M	source/blender/editors/render/render_internal.c
M	source/blender/render/intern/source/pipeline.c

===================================================================

diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index b82289e..cdc4474 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -874,12 +874,12 @@ void BlenderSession::update_status_progress()
 			scene += ", " + b_rview_name;
 	}
 	else {
-		BLI_timestr(total_time, time_str, sizeof(time_str));
+		BLI_timecode_string_from_time_simple(time_str, sizeof(time_str), total_time);
 		timestatus = "Time:" + string(time_str) + " | ";
 	}
 
 	if(remaining_time > 0) {
-		BLI_timestr(remaining_time, time_str, sizeof(time_str));
+		BLI_timecode_string_from_time_simple(time_str, sizeof(time_str), remaining_time);
 		timestatus += "Remaining:" + string(time_str) + " | ";
 	}
 
diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h
index 78a0adb..165242d 100644
--- a/intern/cycles/blender/blender_util.h
+++ b/intern/cycles/blender/blender_util.h
@@ -28,7 +28,7 @@
  * todo: clean this up ... */
 
 extern "C" {
-void BLI_timestr(double _time, char *str, size_t maxlen);
+size_t BLI_timecode_string_from_time_simple(char *str, size_t maxlen, double time_seconds);
 void BKE_image_user_frame_calc(void *iuser, int cfra, int fieldnr);
 void BKE_image_user_file_path(void *iuser, void *ima, char *path);
 unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index d648db7..df4bd6f 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1839,7 +1839,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
 		RenderStats *stats = re ? RE_GetStats(re) : NULL;
 
 		if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) {
-			BLI_timestr(stats->lastframetime, text, sizeof(text));
+			BLI_timecode_string_from_time_simple(text, sizeof(text), stats->lastframetime);
 
 			BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s" : "%s", text);
 		}
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index c8491f4..1fea42e 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -78,7 +78,6 @@ int BLI_natstrcmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_N
 int BLI_strcmp_ignore_pad(const char *str1, const char *str2, const char pad) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 
 size_t BLI_strnlen(const char *str, const size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
-void BLI_timestr(double _time, char *str, size_t maxlen) ATTR_NONNULL();
 
 void BLI_ascii_strtolower(char *str, const size_t len) ATTR_NONNULL();
 void BLI_ascii_strtoupper(char *str, const size_t len) ATTR_NONNULL();
diff --git a/source/blender/blenlib/BLI_timecode.h b/source/blender/blenlib/BLI_timecode.h
index b6cd011..8f88b55 100644
--- a/source/blender/blenlib/BLI_timecode.h
+++ b/source/blender/blenlib/BLI_timecode.h
@@ -31,11 +31,19 @@
  *  \ingroup BLI
  */
 
+#include "BLI_compiler_attrs.h"
+
 size_t BLI_timecode_string_from_time(
         char *str, const size_t len, const int power, const float time_seconds,
-        const double scene_fps, const short timecode_style);
+        const double scene_fps, const short timecode_style)
+        ATTR_NONNULL();
 
 size_t BLI_timecode_string_from_time_simple(
-        char *str, const size_t len, const int power, const float time_seconds);
+        char *str, size_t maxlen, double time_seconds)
+        ATTR_NONNULL();
+
+size_t BLI_timecode_string_from_time_seconds(
+        char *str, const size_t len, const int power, const float time_seconds)
+        ATTR_NONNULL();
 
 #endif  /* __BLI_TIMECODE_H__ */
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 3177bc6..f846183 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -701,22 +701,6 @@ int BLI_strcmp_ignore_pad(const char *str1, const char *str2, const char pad)
 	}
 }
 
-void BLI_timestr(double _time, char *str, size_t maxlen)
-{
-	/* format 00:00:00.00 (hr:min:sec) string has to be 12 long */
-	int  hr = ( (int)  _time) / (60 * 60);
-	int min = (((int)  _time) / 60 ) % 60;
-	int sec = ( (int)  _time) % 60;
-	int hun = ( (int) (_time   * 100.0)) % 100;
-
-	if (hr) {
-		BLI_snprintf(str, maxlen, "%.2d:%.2d:%.2d.%.2d", hr, min, sec, hun);
-	}
-	else {
-		BLI_snprintf(str, maxlen, "%.2d:%.2d.%.2d", min, sec, hun);
-	}
-}
-
 /* determine the length of a fixed-size string */
 size_t BLI_strnlen(const char *s, const size_t maxlen)
 {
diff --git a/source/blender/blenlib/intern/timecode.c b/source/blender/blenlib/intern/timecode.c
index 39ffbcd..4ae9249 100644
--- a/source/blender/blenlib/intern/timecode.c
+++ b/source/blender/blenlib/intern/timecode.c
@@ -187,6 +187,34 @@ size_t BLI_timecode_string_from_time(
 	return rlen;
 }
 
+/**
+ * Generate time string and store in \a str
+ *
+ * \param str: destination string
+ * \param maxncpy: maximum number of characters to copy ``sizeof(str)``
+ * \param time_seconds: time total time in seconds
+ * \return length of \a str
+ */
+size_t BLI_timecode_string_from_time_simple(
+        char *str, const size_t maxncpy, const double time_seconds)
+{
+	size_t rlen;
+
+	/* format 00:00:00.00 (hr:min:sec) string has to be 12 long */
+	const int  hr = ( (int)  time_seconds) / (60 * 60);
+	const int min = (((int)  time_seconds) / 60 ) % 60;
+	const int sec = ( (int)  time_seconds) % 60;
+	const int hun = ( (int) (time_seconds   * 100.0)) % 100;
+
+	if (hr) {
+		rlen = BLI_snprintf(str, maxncpy, "%.2d:%.2d:%.2d.%.2d", hr, min, sec, hun);
+	}
+	else {
+		rlen = BLI_snprintf(str, maxncpy, "%.2d:%.2d.%.2d", min, sec, hun);
+	}
+
+	return rlen;
+}
 
 /**
  * Generate time string and store in \a str
@@ -200,7 +228,7 @@ size_t BLI_timecode_string_from_time(
  *
  * \note in some cases this is used to print non-seconds values.
  */
-size_t BLI_timecode_string_from_time_simple(
+size_t BLI_timecode_string_from_time_seconds(
         char *str, const size_t maxncpy, const int power, const float time_seconds)
 {
 	size_t rlen;
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index d594542..4980860 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -86,7 +86,7 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
 		BLI_timecode_string_from_time(&numstr[4], sizeof(numstr) - 4, 0, FRA2TIME(cfra), FPS, U.timecode_style);
 	}
 	else {
-		BLI_timecode_string_from_time_simple(&numstr[4], sizeof(numstr) - 4, 1, cfra);
+		BLI_timecode_string_from_time_seconds(&numstr[4], sizeof(numstr) - 4, 1, cfra);
 	}
 
 	slen = UI_fontstyle_string_width(fstyle, numstr) - 1;
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 4f4b5ab..5f0c3ff 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1663,7 +1663,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
 		BLI_timecode_string_from_time(timecode_str, sizeof(timecode_str), power, val, FPS, U.timecode_style);
 	}
 	else {
-		BLI_timecode_string_from_time_simple(timecode_str, sizeof(timecode_str), power, val);
+		BLI_timecode_string_from_time_seconds(timecode_str, sizeof(timecode_str), power, val);
 	}
 	
 	/* get length of string, and adjust printing location to fit it into the horizontal scrollbar */
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index d864934..245d879 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -396,13 +396,8 @@ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op)
 	/* Bake was successful:
 	 *  Report for ended bake and how long it took */
 	if (status) {
-		/* Format time string */
-		char time_str[30];
-		double time = PIL_check_seconds_timer() - timer;
-		BLI_timestr(time, time_str, sizeof(time_str));
-
 		/* Show bake info */
-		BKE_reportf(op->reports, RPT_INFO, "Bake complete! (%s)", time_str);
+		BKE_reportf(op->reports, RPT_INFO, "Bake complete! (%.2f)", PIL_check_seconds_timer() - timer);
 	}
 	else {
 		if (strlen(canvas->error)) { /* If an error occurred */
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 2ba1e61..bf2fcb7 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -33,7 +33,9 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
+#include "BLI_rect.h"
+#include "BLI_timecode.h"
 #include "BLI_math.h"
 #include "BLI_threads.h"
 #include "BLI_utildefines.h"
@@ -374,7 +376,7 @@ static void make_renderinfo_string(const RenderStats *rs,
 	spos += sprintf(spos, IFACE_("Frame:%d "), (scene->r.cfra));
 
 	/* previous and elapsed time */
-	BLI_timestr(rs->lastframetime, info_time_str, sizeof(info_time_str));
+	BLI_timecode_string_from_time_simple(info_time_str, sizeof(info_time_str), rs->lastframetime);
 
 	if (rs->infostr && rs->infostr[0]) {
 		if (rs->lastframetime != 0.0)
@@ -382,7 +384,7 @@ static void make_renderinfo_string(const RenderStats *rs,
 		else
 			spos += sprintf(spos, "| ");
 
-		BLI_timestr(PIL_check_seconds_timer() - rs->starttime, info_time_str, sizeof(info_time_str));
+		BLI_timecode_string_from_time_simple(info_time_str, sizeof(info_time_str), PIL_check_seconds_timer() - rs->starttime);
 	}
 	else
 		spos += sprintf(spos, "| ");
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 0dcf78a..c939c69 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -49,6 +49,7 @@
 #include "BLI_listbase.h"
 #include "BLI_string.h"
 #include "BLI_path_util.h"
+#include "BLI_timecode.h"
 #include "BLI_fileops.h"
 #include "BLI_threads.h"
 #include "

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list