Skip to content

Commit

Permalink
Merge branch 'master' into fix_thumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
woelper authored Jan 30, 2025
2 parents 4964c5e + 8698de6 commit 1a67f51
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
28 changes: 20 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,27 +948,39 @@ fn drawe(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut O
debug!("Received image buffer: {:?}", img.dimensions(),);
state.image_geometry.dimensions = img.dimensions();

state
.current_texture
.set_image(&img, gfx, &state.persistent_settings);
if let Err(error) =
state
.current_texture
.set_image(&img, gfx, &state.persistent_settings)
{
state.send_message_warn(&format!("Error while displaying image: {error}"));
}
state.current_image = Some(img);
}
Frame::UpdateTexture => {
// Only update the texture.

// Prefer the edit result, if present
if state.edit_state.result_pixel_op != Default::default() {
state.current_texture.set_image(
if let Err(error) = state.current_texture.set_image(
&state.edit_state.result_pixel_op,
gfx,
&state.persistent_settings,
);
) {
state.send_message_warn(&format!("Error while displaying image: {error}"));
}
} else {
// update from image
if let Some(img) = &state.current_image {
state
.current_texture
.set_image(&img, gfx, &state.persistent_settings);
if let Err(error) =
state
.current_texture
.set_image(&img, gfx, &state.persistent_settings)
{
state.send_message_warn(&format!(
"Error while displaying image: {error}"
));
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/texture_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ impl TextureWrapperManager {
&& tex.height() as u32 == img.height()
&& img.color() == tex.image_format
{
debug!("Re-using texture as it is the same size and type.");
match tex.update_textures(gfx, img) {
Ok(_) => {}
Ok(_) => return Ok(()),
Err(error) => {
self.clear();
error!("{error}");
Expand Down
4 changes: 3 additions & 1 deletion src/ui/edit_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ pub fn edit_ui(app: &mut App, ctx: &Context, state: &mut OculanteState, gfx: &mu
if ui.add(egui::Button::new("Original").min_size(vec2(ui.available_width()/2., 0.))).clicked() {
if let Some(img) = &state.current_image {
state.image_geometry.dimensions = img.dimensions();
state.current_texture.set_image(img, gfx, &state.persistent_settings);
if let Err(error) = state.current_texture.set_image(img, gfx, &state.persistent_settings){
state.send_message_warn(&format!("Error while displaying image: {error}"));
}
}
}
if ui.add(egui::Button::new("Modified").min_size(vec2(ui.available_width(), 0.))).clicked() {
Expand Down

0 comments on commit 1a67f51

Please sign in to comment.