Skip to content

Commit

Permalink
egui/eframe 0.29
Browse files Browse the repository at this point in the history
  • Loading branch information
ahirner committed Oct 15, 2023
1 parent 9551e05 commit 0959c72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion infur/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ thiserror.workspace = true
tracing.workspace = true
serde.workspace = true
once_cell = "1"
eframe = { version = "0.19", features = ["wgpu", "default_fonts"], default-features = false }
eframe = { version = "0.23", features = ["wgpu", "default_fonts"], default-features = false }
tracing-subscriber = { version = "0.3", features = ["ansi", "env-filter", "fmt"], default-features = false }
stable-eyre = "0.2"
image-ext = { path = "../image-ext" }
Expand Down
19 changes: 13 additions & 6 deletions infur/src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::app::{AppCmd, AppCmdError, AppInfo, AppProcError, GUIFrame};
use crate::predict_onnx::ModelCmd;
use crate::processing::VideoCmd;
use eframe::{
egui::{self, CentralPanel, RichText, SidePanel, Slider, TextureFilter, TextureHandle},
epaint::FontId,
egui::{self, CentralPanel, RichText, SidePanel, Slider, TextureHandle, TextureOptions},
epaint::{FontId, Vec2},
};

/// Result from processing a frame
Expand Down Expand Up @@ -169,12 +169,19 @@ impl eframe::App for InFur {
match self.frame_rx.recv_timeout(Duration::from_millis(30)) {
Ok(Ok(frame)) => {
let decoded_handle = frame.decoded_buffer.map(|decoded_img| {
ctx.load_texture("decoded_texture", decoded_img, TextureFilter::Linear)
ctx.load_texture("decoded_texture", decoded_img, TextureOptions::NEAREST)
});

let tex = TextureFrame {
id: frame.id,
handle: ctx.load_texture("main_texture", frame.buffer, TextureFilter::Linear),
handle: ctx.load_texture(
"main_texture",
frame.buffer,
TextureOptions {
magnification: egui::TextureFilter::Nearest,
minification: egui::TextureFilter::Linear,
},
),
decoded_handle,
};
new_frame = true;
Expand Down Expand Up @@ -321,11 +328,11 @@ impl eframe::App for InFur {
let [w, h] = tex_frame.handle.size();
let w_scale = max_width / w as f32;
let (w, h) = (w as f32 * w_scale, h as f32 * w_scale);
ui.image(&tex_frame.handle, [w, h]);
ui.add(egui::Image::new(&tex_frame.handle).fit_to_exact_size(Vec2::new(w, h)));
// prop decoded image underneath
// todo: blend somehow?
if let Some(ref handle) = tex_frame.decoded_handle {
ui.image(handle, [w, h]);
ui.add(egui::Image::new(handle).fit_to_exact_size(Vec2::new(w, h)));
};
});
};
Expand Down
2 changes: 1 addition & 1 deletion infur/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fn main() -> Result<()> {
let app_gui = gui::InFur::new(config, ctrl_tx_gui, frame_rx, ctrl_result_rx);
Box::new(app_gui)
}),
);
)?;

// ensure exit code
infur_thread.join().unwrap().unwrap();
Expand Down

0 comments on commit 0959c72

Please sign in to comment.