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--intern/cycles/blender/blender_session.cpp4
-rw-r--r--intern/cycles/blender/blender_util.h2
-rw-r--r--source/blender/blenkernel/intern/image.c2
-rw-r--r--source/blender/blenlib/BLI_string.h1
-rw-r--r--source/blender/blenlib/BLI_timecode.h12
-rw-r--r--source/blender/blenlib/intern/string.c16
-rw-r--r--source/blender/blenlib/intern/timecode.c30
-rw-r--r--source/blender/editors/animation/anim_draw.c2
-rw-r--r--source/blender/editors/interface/view2d.c2
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c7
-rw-r--r--source/blender/editors/render/render_internal.c8
-rw-r--r--source/blender/render/intern/source/pipeline.c7
12 files changed, 55 insertions, 38 deletions
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index b82289e007b..cdc44748923 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 78a0adbef00..165242d0dff 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 d648db77186..df4bd6ff3ab 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 c8491f4c8f1..1fea42ec922 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 b6cd0117bf5..8f88b555095 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 3177bc659b2..f846183b082 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 39ffbcd7ebe..4ae9249ec0d 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 d5945425576..498086047ad 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 4f4b5ab07ff..5f0c3ff6993 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 d864934171b..245d8790399 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 2ba1e615a9e..bf2fcb73249 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 0dcf78a1b0c..c939c697f1c 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 "BLI_rand.h"
@@ -172,7 +173,7 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
if (rs->curblur)
fprintf(stdout, IFACE_("Blur %d "), rs->curblur);
- 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);
fprintf(stdout, IFACE_("| Time:%s | "), info_time_str);
if (rs->infostr) {
@@ -3416,7 +3417,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
render_time = re->i.lastframetime;
re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime;
- BLI_timestr(re->i.lastframetime, name, sizeof(name));
+ BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime);
printf(" Time: %s", name);
/* Flush stdout to be sure python callbacks are printing stuff after blender. */
@@ -3424,7 +3425,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie
BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS);
- BLI_timestr(re->i.lastframetime - render_time, name, sizeof(name));
+ BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime - render_time);
printf(" (Saving: %s)\n", name);
fputc('\n', stdout);