[librsvg: 3/14] Return SharedImageSurface from scale{,_to}()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 3/14] Return SharedImageSurface from scale{,_to}()
- Date: Sun, 15 Jul 2018 17:55:36 +0000 (UTC)
commit e650025c9acba5636adc0c1eea7141c9e6aa48c4
Author: Ivan Molodetskikh <yalterz gmail com>
Date: Sun Jul 15 13:21:03 2018 +0300
Return SharedImageSurface from scale{,_to}()
rsvg_internals/src/filters/convolve_matrix.rs | 6 ++----
rsvg_internals/src/filters/light/diffuse_lighting.rs | 6 ++----
rsvg_internals/src/filters/light/specular_lighting.rs | 6 ++----
rsvg_internals/src/surface_utils/shared_surface.rs | 6 +++---
4 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/rsvg_internals/src/filters/convolve_matrix.rs b/rsvg_internals/src/filters/convolve_matrix.rs
index 37c85010..b63fafd6 100644
--- a/rsvg_internals/src/filters/convolve_matrix.rs
+++ b/rsvg_internals/src/filters/convolve_matrix.rs
@@ -242,8 +242,6 @@ impl Filter for ConvolveMatrix {
// Scale the input surface to match kernel_unit_length.
let (new_surface, new_bounds) = input_surface.scale(bounds, 1.0 / ox, 1.0 / oy)?;
- let new_surface = SharedImageSurface::new(new_surface)?;
-
input_surface = new_surface;
bounds = new_bounds;
}
@@ -328,13 +326,13 @@ impl Filter for ConvolveMatrix {
if let Some((ox, oy)) = scale {
// Scale the output surface back.
- output_surface = SharedImageSurface::new(output_surface.scale_to(
+ output_surface = output_surface.scale_to(
ctx.source_graphic().width(),
ctx.source_graphic().height(),
original_bounds,
ox,
oy,
- )?)?;
+ )?;
bounds = original_bounds;
}
diff --git a/rsvg_internals/src/filters/light/diffuse_lighting.rs
b/rsvg_internals/src/filters/light/diffuse_lighting.rs
index d6275f73..95a7076d 100644
--- a/rsvg_internals/src/filters/light/diffuse_lighting.rs
+++ b/rsvg_internals/src/filters/light/diffuse_lighting.rs
@@ -144,8 +144,6 @@ impl Filter for DiffuseLighting {
// Scale the input surface to match kernel_unit_length.
let (new_surface, new_bounds) = input_surface.scale(bounds, 1.0 / ox, 1.0 / oy)?;
- let new_surface = SharedImageSurface::new(new_surface)?;
-
input_surface = new_surface;
bounds = new_bounds;
}
@@ -190,13 +188,13 @@ impl Filter for DiffuseLighting {
if let Some((ox, oy)) = scale {
// Scale the output surface back.
- output_surface = SharedImageSurface::new(output_surface.scale_to(
+ output_surface = output_surface.scale_to(
ctx.source_graphic().width(),
ctx.source_graphic().height(),
original_bounds,
ox,
oy,
- )?)?;
+ )?;
bounds = original_bounds;
}
diff --git a/rsvg_internals/src/filters/light/specular_lighting.rs
b/rsvg_internals/src/filters/light/specular_lighting.rs
index f77396cf..c35ff9de 100644
--- a/rsvg_internals/src/filters/light/specular_lighting.rs
+++ b/rsvg_internals/src/filters/light/specular_lighting.rs
@@ -162,8 +162,6 @@ impl Filter for SpecularLighting {
// Scale the input surface to match kernel_unit_length.
let (new_surface, new_bounds) = input_surface.scale(bounds, 1.0 / ox, 1.0 / oy)?;
- let new_surface = SharedImageSurface::new(new_surface)?;
-
input_surface = new_surface;
bounds = new_bounds;
}
@@ -212,13 +210,13 @@ impl Filter for SpecularLighting {
if let Some((ox, oy)) = scale {
// Scale the output surface back.
- output_surface = SharedImageSurface::new(output_surface.scale_to(
+ output_surface = output_surface.scale_to(
ctx.source_graphic().width(),
ctx.source_graphic().height(),
original_bounds,
ox,
oy,
- )?)?;
+ )?;
bounds = original_bounds;
}
diff --git a/rsvg_internals/src/surface_utils/shared_surface.rs
b/rsvg_internals/src/surface_utils/shared_surface.rs
index 088c642d..297e18e6 100644
--- a/rsvg_internals/src/surface_utils/shared_surface.rs
+++ b/rsvg_internals/src/surface_utils/shared_surface.rs
@@ -167,7 +167,7 @@ impl SharedImageSurface {
bounds: IRect,
x: f64,
y: f64,
- ) -> Result<ImageSurface, cairo::Status> {
+ ) -> Result<SharedImageSurface, cairo::Status> {
let output_surface = ImageSurface::create(cairo::Format::ARgb32, width, height)?;
{
@@ -185,7 +185,7 @@ impl SharedImageSurface {
cr.paint();
}
- Ok(output_surface)
+ SharedImageSurface::new(output_surface)
}
/// Returns a scaled version of a surface and bounds.
@@ -195,7 +195,7 @@ impl SharedImageSurface {
bounds: IRect,
x: f64,
y: f64,
- ) -> Result<(ImageSurface, IRect), cairo::Status> {
+ ) -> Result<(SharedImageSurface, IRect), cairo::Status> {
let new_width = (f64::from(self.width) * x).ceil() as i32;
let new_height = (f64::from(self.height) * y).ceil() as i32;
let new_bounds = bounds.scale(x, y);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]