[librsvg: 9/14] Optimize unpremultiply() for alpha_only



commit 6c64b0c278e3fa8be891c9a48ff49affe4b9677d
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Sun Jul 15 14:08:01 2018 +0300

    Optimize unpremultiply() for alpha_only

 rsvg_internals/src/surface_utils/shared_surface.rs | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/rsvg_internals/src/surface_utils/shared_surface.rs 
b/rsvg_internals/src/surface_utils/shared_surface.rs
index eaa1c7cf..870f8196 100644
--- a/rsvg_internals/src/surface_utils/shared_surface.rs
+++ b/rsvg_internals/src/surface_utils/shared_surface.rs
@@ -267,6 +267,11 @@ impl SharedImageSurface {
     /// HACK: this is storing unpremultiplied pixels in an ARGB32 image surface (which is supposed
     /// to be premultiplied pixels).
     pub fn unpremultiply(&self, bounds: IRect) -> Result<SharedImageSurface, cairo::Status> {
+        // Unpremultiplication doesn't affect the alpha channel.
+        if self.alpha_only {
+            return Ok(self.clone());
+        }
+
         let mut output_surface =
             ImageSurface::create(cairo::Format::ARgb32, self.width, self.height)?;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]