Update reductions flag when alpha changed

This commit is contained in:
Kornel Lesiński 2018-11-13 20:44:47 +00:00
parent e0e90a7da7
commit 345232d30a
2 changed files with 6 additions and 2 deletions

View file

@ -768,7 +768,9 @@ fn perform_reductions(png: &mut PngData, opts: &Options, deadline: &Deadline) ->
return reduction_occurred; return reduction_occurred;
} }
png.try_alpha_reduction(&opts.alphas); if png.try_alpha_reduction(&opts.alphas) {
reduction_occurred = true;
}
reduction_occurred reduction_occurred
} }

View file

@ -587,7 +587,7 @@ impl PngData {
changed changed
} }
pub fn try_alpha_reduction(&mut self, alphas: &HashSet<AlphaOptim>) { pub fn try_alpha_reduction(&mut self, alphas: &HashSet<AlphaOptim>) -> bool {
assert!(!alphas.is_empty()); assert!(!alphas.is_empty());
let alphas = alphas.iter().collect::<Vec<_>>(); let alphas = alphas.iter().collect::<Vec<_>>();
let best_size = AtomicMin::new(None); let best_size = AtomicMin::new(None);
@ -623,7 +623,9 @@ impl PngData {
if let Some(best) = best { if let Some(best) = best {
self.raw_data = best.1.raw_data; self.raw_data = best.1.raw_data;
return true;
} }
false
} }
pub fn reduce_alpha_channel(&mut self, optim: AlphaOptim) -> bool { pub fn reduce_alpha_channel(&mut self, optim: AlphaOptim) -> bool {