Keep the redraw invariant concise
This commit is contained in:
1 parent
6884160bfe
commit
072f1e31ad
1 file changed
+4
-11
@@ -52,7 +52,7 @@ impl UiRenderState {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
let root = root.into();
|
let root = root.into();
|
||||||
if self.needs_redraw_all(root) {
|
if self.needs_full_redraw(root) {
|
||||||
self.redraw_all(root, rsc);
|
self.redraw_all(root, rsc);
|
||||||
self.old_root = root.map(|r| r.id());
|
self.old_root = root.map(|r| r.id());
|
||||||
self.resized = false;
|
self.resized = false;
|
||||||
@@ -218,15 +218,8 @@ impl UiRenderState {
|
|||||||
root.into().map(|r| r.id()) != self.old_root
|
root.into().map(|r| r.id()) != self.old_root
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What `update` will redraw everything for. Named and shared with
|
// Scheduling and drawing must use the same full-redraw predicate.
|
||||||
/// `needs_redraw` rather than written out twice, because the two must
|
fn needs_full_redraw<'a>(&self, root: impl Into<Option<&'a StrongWidget>>) -> bool {
|
||||||
/// agree: `needs_redraw` is what asks for the frame that `update` would
|
|
||||||
/// draw, so a condition in one and not the other is a frame nobody
|
|
||||||
/// requests and a stale window. `resized` was missing from `needs_redraw`,
|
|
||||||
/// which is latent on Wayland only because winit asks for a redraw after a
|
|
||||||
/// resize by itself -- a resize changes neither the root nor any widget,
|
|
||||||
/// so nothing else here would have asked.
|
|
||||||
fn needs_redraw_all<'a>(&self, root: impl Into<Option<&'a StrongWidget>>) -> bool {
|
|
||||||
self.root_changed(root) || self.resized
|
self.root_changed(root) || self.resized
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +228,7 @@ impl UiRenderState {
|
|||||||
root: impl Into<Option<&'a StrongWidget>>,
|
root: impl Into<Option<&'a StrongWidget>>,
|
||||||
widgets: &Widgets,
|
widgets: &Widgets,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
self.needs_redraw_all(root) || widgets.has_updates()
|
self.needs_full_redraw(root) || widgets.has_updates()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn active_widgets(&self) -> usize {
|
pub fn active_widgets(&self) -> usize {
|
||||||
|
|||||||
Reference in new issue
Block a user