Skip to content

Commit

Permalink
fix: respect optimize_epd
Browse files Browse the repository at this point in the history
  • Loading branch information
Kneemund committed Dec 3, 2024
1 parent 708a51c commit 90b483e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crates/rnote-engine/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,8 @@ impl Engine {
/// Handle a requested animation frame.
///
/// Can request another frame using `ÈngineViewMut#animation.claim_frame()`.
pub fn handle_animation_frame(&mut self) {
pub fn handle_animation_frame(&mut self, optimize_epd: bool) {
self.penholder
.handle_animation_frame(&mut engine_view_mut!(self));
.handle_animation_frame(&mut engine_view_mut!(self), optimize_epd);
}
}
2 changes: 1 addition & 1 deletion crates/rnote-engine/src/pens/penbehaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub trait PenBehaviour: DrawableOnDoc {
/// Handle a requested animation frame.
///
/// Can request another frame using `ÈngineViewMut#animation.claim_frame()`.
fn handle_animation_frame(&mut self, _engine_view: &mut EngineViewMut) {}
fn handle_animation_frame(&mut self, _engine_view: &mut EngineViewMut, _optimize_epd: bool) {}

/// Fetch clipboard content from the pen.
///
Expand Down
5 changes: 3 additions & 2 deletions crates/rnote-engine/src/pens/penholder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,9 @@ impl PenHolder {
/// Handle a requested animation frame.
///
/// Can request another frame using `ÈngineViewMut#animation.claim_frame()`.
pub fn handle_animation_frame(&mut self, engine_view: &mut EngineViewMut) {
self.current_pen.handle_animation_frame(engine_view);
pub fn handle_animation_frame(&mut self, engine_view: &mut EngineViewMut, optimize_epd: bool) {
self.current_pen
.handle_animation_frame(engine_view, optimize_epd);
}

/// Handle a pressed shortcut key.
Expand Down
10 changes: 8 additions & 2 deletions crates/rnote-ui/src/canvas/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,14 @@ mod imp {
glib::ControlFlow::Break,
move |_widget, _frame_clock| {
if canvas.engine_mut().animation.process_frame() {
canvas.engine_mut().handle_animation_frame();
canvas.queue_draw();
let optimize_epd = canvas.engine_ref().optimize_epd();
canvas.engine_mut().handle_animation_frame(optimize_epd);

// if optimize_epd is enabled, we only redraw the canvas
// when no follow-up frame has been requested (i.e. the animation is done)
if !optimize_epd || !canvas.engine_ref().animation.frame_in_flight() {
canvas.queue_draw();
}
}

glib::ControlFlow::Continue
Expand Down

0 comments on commit 90b483e

Please sign in to comment.