mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
3DFileViewer: Improve FPS display
We only showed frame times down to the millisecond. Our FPS counter was based off of that, allowing for a limited set of possible FPS values. Convert these calculations to floating point so we get more useful FPS and frame time values.
This commit is contained in:
parent
f151a0d720
commit
dcc7d7d566
1 changed files with 7 additions and 6 deletions
|
@ -128,7 +128,7 @@ void GLContextWidget::resize_event(GUI::ResizeEvent& event)
|
||||||
GUI::Frame::resize_event(event);
|
GUI::Frame::resize_event(event);
|
||||||
|
|
||||||
if (m_stats)
|
if (m_stats)
|
||||||
m_stats->set_x(width() - m_stats->width());
|
m_stats->set_x(width() - m_stats->width() - 6);
|
||||||
};
|
};
|
||||||
|
|
||||||
void GLContextWidget::mousemove_event(GUI::MouseEvent& event)
|
void GLContextWidget::mousemove_event(GUI::MouseEvent& event)
|
||||||
|
@ -182,9 +182,9 @@ void GLContextWidget::timer_event(Core::TimerEvent&)
|
||||||
m_context->present();
|
m_context->present();
|
||||||
|
|
||||||
if ((m_cycles % 30) == 0) {
|
if ((m_cycles % 30) == 0) {
|
||||||
int render_time = m_accumulated_time / 30;
|
auto render_time = m_accumulated_time / 30.0;
|
||||||
int frame_rate = render_time > 0 ? 1000 / render_time : 0;
|
auto frame_rate = render_time > 0 ? 1000 / render_time : 0;
|
||||||
m_stats->set_text(String::formatted("{} fps, {} ms", frame_rate, render_time));
|
m_stats->set_text(String::formatted("{:.0f} fps, {:.1f} ms", frame_rate, render_time));
|
||||||
m_accumulated_time = 0;
|
m_accumulated_time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,8 +307,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto& time = widget.add<GUI::Label>();
|
auto& time = widget.add<GUI::Label>();
|
||||||
time.set_visible(false);
|
time.set_visible(false);
|
||||||
time.set_foreground_role(ColorRole::HoverHighlight);
|
time.set_foreground_role(ColorRole::HoverHighlight);
|
||||||
time.set_relative_rect({ 0, 8, 86, 10 });
|
time.set_relative_rect({ 0, 8, 100, 10 });
|
||||||
time.set_x(widget.width() - time.width());
|
time.set_text_alignment(Gfx::TextAlignment::CenterRight);
|
||||||
|
time.set_x(widget.width() - time.width() - 6);
|
||||||
widget.set_stat_label(time);
|
widget.set_stat_label(time);
|
||||||
|
|
||||||
auto& file_menu = window->add_menu("&File");
|
auto& file_menu = window->add_menu("&File");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue