paysages3d/src/render/software/RenderProgress.h

67 lines
1.1 KiB
C
Raw Normal View History

#ifndef RENDERPROGRESS_H
#define RENDERPROGRESS_H
#include "software_global.h"
#include <stack>
namespace paysages {
namespace software {
struct RenderSub {
double start;
double end;
int count;
double previous_step;
};
/**
* Utility to keep track of render progress.
*/
class SOFTWARESHARED_EXPORT RenderProgress {
public:
RenderProgress(int count = 1);
~RenderProgress();
inline double get() const {
return global;
}
2015-09-09 22:40:47 +00:00
void reset();
void add(int value = 1);
void enterSub(int count);
void exitSub();
2015-09-13 20:38:44 +00:00
void end();
/**
* Get the render duration in milliseconds.
*/
unsigned long getDuration() const;
/**
* Get the estimated remaining time in milliseconds.
*
* Returns 0 if unknown.
*/
2015-11-02 22:39:34 +00:00
unsigned long estimateRemainingTime();
private:
Mutex *lock;
2015-11-02 22:39:34 +00:00
double global;
double step;
2015-11-02 22:39:34 +00:00
2015-09-13 20:38:44 +00:00
unsigned long start_time;
unsigned long end_time;
2015-11-02 22:39:34 +00:00
unsigned long prev_est_spent;
double prev_est_done;
double prev_est_speed;
2015-12-10 23:36:50 +00:00
stack<RenderSub> subs;
};
}
}
#endif // RENDERPROGRESS_H