Skip to content

Commit bec6c62

Browse files
committed
masonry_android: Don't do an AnimFrame event in response to surface changes, but do handle signals
1 parent 7d4e3ab commit bec6c62

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

masonry/src/lib.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -241,26 +241,6 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
241241
fn redraw(&mut self, ctx: &mut CallbackCtx) {
242242
let _span = info_span!("redraw");
243243

244-
let now = Instant::now();
245-
// TODO: this calculation uses wall-clock time of the paint call, which
246-
// potentially has jitter.
247-
//
248-
// See https://github.com/linebender/druid/issues/85 for discussion.
249-
let last = self.state.last_anim.take();
250-
let elapsed = last.map(|t| now.duration_since(t)).unwrap_or_default();
251-
self.state
252-
.render_root
253-
.handle_window_event(WindowEvent::AnimFrame(elapsed));
254-
255-
// Make sure we handle any signals emitted in response to the
256-
// `AnimFrame` event before we redraw.
257-
self.handle_signals(ctx);
258-
259-
// If this animation will continue, store the time.
260-
// If a new animation starts, then it will have zero reported elapsed time.
261-
let animation_continues = self.state.render_root.needs_anim();
262-
self.state.last_anim = animation_continues.then_some(now);
263-
264244
let (scene, tree_update) = self.state.render_root.redraw();
265245

266246
if let Some(events) = self
@@ -469,6 +449,7 @@ impl<Driver: AppDriver> ViewPeer for MasonryViewPeer<Driver> {
469449
self.state
470450
.render_root
471451
.handle_window_event(WindowEvent::Resize(size));
452+
self.handle_signals(ctx);
472453

473454
let window = holder.surface(&mut ctx.env).to_native_window(&mut ctx.env);
474455
// Drop the old surface, if any, that owned the native window
@@ -518,6 +499,28 @@ impl<Driver: AppDriver> ViewPeer for MasonryViewPeer<Driver> {
518499
}
519500

520501
fn do_frame(&mut self, ctx: &mut CallbackCtx, _frame_time_nanos: jlong) {
502+
let _span = info_span!("do_frame");
503+
504+
let now = Instant::now();
505+
// TODO: this calculation uses wall-clock time of the paint call, which
506+
// potentially has jitter.
507+
//
508+
// See https://github.com/linebender/druid/issues/85 for discussion.
509+
let last = self.state.last_anim.take();
510+
let elapsed = last.map(|t| now.duration_since(t)).unwrap_or_default();
511+
self.state
512+
.render_root
513+
.handle_window_event(WindowEvent::AnimFrame(elapsed));
514+
515+
// Make sure we handle any signals emitted in response to the
516+
// `AnimFrame` event before we redraw.
517+
self.handle_signals(ctx);
518+
519+
// If this animation will continue, store the time.
520+
// If a new animation starts, then it will have zero reported elapsed time.
521+
let animation_continues = self.state.render_root.needs_anim();
522+
self.state.last_anim = animation_continues.then_some(now);
523+
521524
self.redraw(ctx);
522525
}
523526

0 commit comments

Comments
 (0)