Skip to content

Commit d166fcc

Browse files
committed
Fix paint code
1 parent cf37f15 commit d166fcc

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

masonry_core/src/passes/paint.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ fn paint_widget(
2929
let _span = enter_span_if(trace, state.reborrow());
3030

3131
let id = state.item.id;
32+
let is_stashed = state.item.is_stashed;
33+
34+
// Note: At this point we could short-circuit if is_stashed is true,
35+
// but we deliberately avoid doing that to avoid creating zombie flags.
36+
// (See WidgetState doc.)
3237

3338
// TODO - Handle damage regions
3439
// https://github.com/linebender/xilem/issues/789
@@ -39,7 +44,7 @@ fn paint_widget(
3944
widget_children: widget.children.reborrow_mut(),
4045
debug_paint,
4146
};
42-
if ctx.widget_state.request_paint && !ctx.widget_state.is_stashed {
47+
if ctx.widget_state.request_paint && !is_stashed {
4348
if trace {
4449
trace!("Painting widget '{}' {}", widget.item.short_type_name(), id);
4550
}
@@ -58,16 +63,17 @@ fn paint_widget(
5863
state.item.request_paint = false;
5964
state.item.needs_paint = false;
6065

61-
let clip = state.item.clip_path;
62-
let has_clip = clip.is_some();
63-
let transform = state.item.window_transform;
64-
let scene = scenes.get(&id).unwrap();
66+
let has_clip = state.item.clip_path.is_some();
67+
if !is_stashed {
68+
let transform = state.item.window_transform;
69+
let scene = scenes.get(&id).unwrap();
6570

66-
if let Some(clip) = clip {
67-
complete_scene.push_layer(Mix::Clip, 1., transform, &clip);
68-
}
71+
if let Some(clip) = state.item.clip_path {
72+
complete_scene.push_layer(Mix::Clip, 1., transform, &clip);
73+
}
6974

70-
complete_scene.append(scene, Some(transform));
75+
complete_scene.append(scene, Some(transform));
76+
}
7177

7278
let id = state.item.id;
7379
let bounding_rect = state.item.bounding_rect;
@@ -97,16 +103,18 @@ fn paint_widget(
97103
},
98104
);
99105

100-
// draw the global axis aligned bounding rect of the widget
101-
if debug_paint {
102-
const BORDER_WIDTH: f64 = 1.0;
103-
let color = get_debug_color(id.to_raw());
104-
let rect = bounding_rect.inset(BORDER_WIDTH / -2.0);
105-
stroke(complete_scene, &rect, color, BORDER_WIDTH);
106-
}
106+
if !is_stashed {
107+
// draw the global axis aligned bounding rect of the widget
108+
if debug_paint {
109+
const BORDER_WIDTH: f64 = 1.0;
110+
let color = get_debug_color(id.to_raw());
111+
let rect = bounding_rect.inset(BORDER_WIDTH / -2.0);
112+
stroke(complete_scene, &rect, color, BORDER_WIDTH);
113+
}
107114

108-
if has_clip {
109-
complete_scene.pop_layer();
115+
if has_clip {
116+
complete_scene.pop_layer();
117+
}
110118
}
111119
}
112120

0 commit comments

Comments
 (0)