mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-05 10:59:47 -05:00
Add the ability to limit-rate the dashboard updating (#3527)
Co-authored-by: Emma Broman <emma.broman@liu.se>
This commit is contained in:
@@ -200,11 +200,10 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona
|
||||
_shouldClearCache = true;
|
||||
});
|
||||
addProperty(_clearCache);
|
||||
|
||||
_buffer.resize(128);
|
||||
_localBuffer.resize(128);
|
||||
}
|
||||
|
||||
void DashboardItemFramerate::render(glm::vec2& penPosition) {
|
||||
void DashboardItemFramerate::update() {
|
||||
ZoneScoped;
|
||||
|
||||
if (_shouldClearCache) {
|
||||
@@ -224,28 +223,21 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) {
|
||||
|
||||
const FrametimeType frametimeType = FrametimeType(_frametimeType.value());
|
||||
|
||||
std::fill(_buffer.begin(), _buffer.end(), char(0));
|
||||
std::fill(_localBuffer.begin(), _localBuffer.end(), char(0));
|
||||
char* end = format(
|
||||
_buffer,
|
||||
_localBuffer,
|
||||
frametimeType,
|
||||
_minDeltaTimeCache,
|
||||
_maxDeltaTimeCache
|
||||
);
|
||||
const std::string_view text = std::string_view(_buffer.data(), end - _buffer.data());
|
||||
|
||||
const int nLines = text.empty() ?
|
||||
0 :
|
||||
static_cast<int>((std::count(text.begin(), text.end(), '\n') + 1));
|
||||
|
||||
penPosition.y -= _font->height() * static_cast<float>(nLines);
|
||||
RenderFont(*_font, penPosition, text);
|
||||
_buffer = std::string(_localBuffer.data(), end - _localBuffer.data());
|
||||
}
|
||||
|
||||
glm::vec2 DashboardItemFramerate::size() const {
|
||||
ZoneScoped;
|
||||
|
||||
const FrametimeType t = FrametimeType(_frametimeType.value());
|
||||
char* end = format(_buffer, t, _minDeltaTimeCache, _maxDeltaTimeCache);
|
||||
char* end = format(_localBuffer, t, _minDeltaTimeCache, _maxDeltaTimeCache);
|
||||
const std::string_view res = std::string_view(_buffer.data(), end - _buffer.data());
|
||||
|
||||
if (res.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user