[librsvg: 6/14] Return SharedImageSurface from extract_alpha()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 6/14] Return SharedImageSurface from extract_alpha()
- Date: Sun, 15 Jul 2018 17:55:51 +0000 (UTC)
commit f7775e109a9fe872b11c217c9077dd191412cfea
Author: Ivan Molodetskikh <yalterz gmail com>
Date: Sun Jul 15 13:29:20 2018 +0300
Return SharedImageSurface from extract_alpha()
rsvg_internals/src/filters/context.rs | 12 +++---------
rsvg_internals/src/surface_utils/shared_surface.rs | 4 ++--
2 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/rsvg_internals/src/filters/context.rs b/rsvg_internals/src/filters/context.rs
index 13e605c7..a41216fc 100644
--- a/rsvg_internals/src/filters/context.rs
+++ b/rsvg_internals/src/filters/context.rs
@@ -294,7 +294,7 @@ impl FilterContext {
/// Returns the surface containing the source graphic alpha.
#[inline]
- pub fn source_alpha(&self, bounds: IRect) -> Result<cairo::ImageSurface, FilterError> {
+ pub fn source_alpha(&self, bounds: IRect) -> Result<SharedImageSurface, FilterError> {
self.source_surface
.extract_alpha(bounds)
.map_err(FilterError::CairoError)
@@ -370,7 +370,7 @@ impl FilterContext {
&self,
draw_ctx: &DrawingCtx,
bounds: IRect,
- ) -> Result<cairo::ImageSurface, FilterError> {
+ ) -> Result<SharedImageSurface, FilterError> {
self.background_image(draw_ctx)?
.extract_alpha(bounds)
.map_err(FilterError::CairoError)
@@ -521,9 +521,6 @@ impl FilterContext {
Input::SourceGraphic => Ok(FilterInput::StandardInput(self.source_graphic().clone())),
Input::SourceAlpha => self
.source_alpha(self.effects_region().rect.unwrap().into())
- .and_then(|surface| {
- SharedImageSurface::new(surface).map_err(FilterError::CairoError)
- })
.map(FilterInput::StandardInput),
Input::BackgroundImage => self
.background_image(draw_ctx)
@@ -531,9 +528,6 @@ impl FilterContext {
.map(FilterInput::StandardInput),
Input::BackgroundAlpha => self
.background_alpha(draw_ctx, self.effects_region().rect.unwrap().into())
- .and_then(|surface| {
- SharedImageSurface::new(surface).map_err(FilterError::CairoError)
- })
.map(FilterInput::StandardInput),
Input::FillPaint => self
@@ -678,7 +672,7 @@ mod tests {
}
let surface = SharedImageSurface::new(surface).unwrap();
- let alpha = SharedImageSurface::new(surface.extract_alpha(BOUNDS).unwrap()).unwrap();
+ let alpha = surface.extract_alpha(BOUNDS).unwrap();
for (x, y, p, pa) in
Pixels::new(&surface, FULL_BOUNDS).map(|(x, y, p)| (x, y, p, alpha.get_pixel(x, y)))
diff --git a/rsvg_internals/src/surface_utils/shared_surface.rs
b/rsvg_internals/src/surface_utils/shared_surface.rs
index 1ec35cc9..f4ffd632 100644
--- a/rsvg_internals/src/surface_utils/shared_surface.rs
+++ b/rsvg_internals/src/surface_utils/shared_surface.rs
@@ -207,7 +207,7 @@ impl SharedImageSurface {
}
/// Returns a surface with black background and alpha channel matching this surface.
- pub fn extract_alpha(&self, bounds: IRect) -> Result<ImageSurface, cairo::Status> {
+ pub fn extract_alpha(&self, bounds: IRect) -> Result<SharedImageSurface, cairo::Status> {
let mut output_surface =
ImageSurface::create(cairo::Format::ARgb32, self.width, self.height)?;
@@ -226,7 +226,7 @@ impl SharedImageSurface {
}
}
- Ok(output_surface)
+ SharedImageSurface::new(output_surface)
}
/// Returns a surface with pre-multiplication of color values undone.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]