[librsvg: 10/12] Use 32 bit floating point for Pixel::unpremultiply()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 10/12] Use 32 bit floating point for Pixel::unpremultiply()
- Date: Tue, 13 Oct 2020 14:03:23 +0000 (UTC)
commit 184046914659b4b0b151d1ce49d620370a932eec
Author: Sven Neumann <sven svenfoo org>
Date: Tue Oct 13 13:18:41 2020 +0200
Use 32 bit floating point for Pixel::unpremultiply()
This is slightly faster, at least on my machine.
librsvg/pixbuf_utils.rs | 1 +
rsvg_internals/src/surface_utils/mod.rs | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/librsvg/pixbuf_utils.rs b/librsvg/pixbuf_utils.rs
index 53e1406b..ebb92734 100644
--- a/librsvg/pixbuf_utils.rs
+++ b/librsvg/pixbuf_utils.rs
@@ -51,6 +51,7 @@ pub fn pixbuf_from_surface(surface: &SharedImageSurface) -> Result<Pixbuf, Rende
for (src_row, dest_row) in surface.rows().zip(pixbuf_rows) {
let row: &mut [Pixel] = dest_row.as_rgba_mut();
+
for (src, dest) in src_row.iter().zip(row.iter_mut()) {
*dest = if src.a == 0 {
Pixel::default()
diff --git a/rsvg_internals/src/surface_utils/mod.rs b/rsvg_internals/src/surface_utils/mod.rs
index c4e2182b..7fb35984 100644
--- a/rsvg_internals/src/surface_utils/mod.rs
+++ b/rsvg_internals/src/surface_utils/mod.rs
@@ -87,8 +87,8 @@ impl PixelOps for Pixel {
if self.a == 0 {
self
} else {
- let alpha = f64::from(self.a) / 255.0;
- self.map_rgb(|x| ((f64::from(x) / alpha) + 0.5) as u8)
+ let alpha = f32::from(self.a) / 255.0;
+ self.map_rgb(|x| ((f32::from(x) / alpha) + 0.5) as u8)
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]