2015-08-23 18:22:37 +00:00
|
|
|
#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.
|
|
|
|
*/
|
2015-11-09 21:30:46 +00:00
|
|
|
class SOFTWARESHARED_EXPORT RenderProgress {
|
|
|
|
public:
|
|
|
|
RenderProgress(int count = 1);
|
2015-08-23 18:22:37 +00:00
|
|
|
~RenderProgress();
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
inline double get() const {
|
|
|
|
return global;
|
|
|
|
}
|
2015-08-23 18:22:37 +00:00
|
|
|
|
2015-09-09 22:40:47 +00:00
|
|
|
void reset();
|
2015-11-09 21:30:46 +00:00
|
|
|
void add(int value = 1);
|
2015-08-23 18:22:37 +00:00
|
|
|
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();
|
2015-08-23 18:22:37 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
private:
|
2015-08-23 18:22:37 +00:00
|
|
|
Mutex *lock;
|
2015-11-02 22:39:34 +00:00
|
|
|
|
2015-08-23 18:22:37 +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;
|
2015-08-23 18:22:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // RENDERPROGRESS_H
|