Cleanup: move BLI_timestr to BLI_timecode
This commit is contained in:
parent
56ca7f34dd
commit
8bef305b6d
|
@ -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) + " | ";
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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, "| ");
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue