Always start off painting two frames to allow things to settle

This commit is contained in:
Emil Ernerfeldt 2020-12-06 13:11:15 +01:00
parent 428e2373e5
commit 5fcc64dc85
2 changed files with 8 additions and 2 deletions

View file

@ -76,7 +76,12 @@ impl Clone for Context {
impl Context {
pub fn new() -> Arc<Self> {
Arc::new(Self::default())
Arc::new(Self {
// Start with painting an extra frame to compensate for some widgets
// that take two frames before they "settle":
repaint_requests: AtomicU32::new(1),
..Self::default()
})
}
/// How much space is still available after panels has been added.

View file

@ -60,6 +60,7 @@ impl Default for FrameHistory {
}
impl FrameHistory {
// Called first
pub fn on_new_frame(&mut self, now: f64, previus_frame_time: Option<f32>) {
let previus_frame_time = previus_frame_time.unwrap_or_default();
if let Some(latest) = self.frame_times.latest_mut() {
@ -74,7 +75,7 @@ impl FrameHistory {
fn ui(&mut self, ui: &mut Ui) {
ui.label(format!(
"Total frames painted: {}",
"Total frames painted (including this one): {}",
self.frame_times.total_count()
));