[librsvg: 3/14] filters: port component transfer to ExclusiveImageSurface
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 3/14] filters: port component transfer to ExclusiveImageSurface
- Date: Wed, 15 Jan 2020 00:32:24 +0000 (UTC)
commit 599bfb945c13e78bd9da00119c589dfc5d8f3078
Author: Paolo Borelli <pborelli gnome org>
Date: Tue Jan 14 01:10:22 2020 +0100
filters: port component transfer to ExclusiveImageSurface
rsvg_internals/src/filters/component_transfer.rs | 39 ++++++++++--------------
1 file changed, 16 insertions(+), 23 deletions(-)
---
diff --git a/rsvg_internals/src/filters/component_transfer.rs
b/rsvg_internals/src/filters/component_transfer.rs
index 5024ccc2..f433fe93 100644
--- a/rsvg_internals/src/filters/component_transfer.rs
+++ b/rsvg_internals/src/filters/component_transfer.rs
@@ -9,9 +9,7 @@ use crate::node::{NodeResult, NodeTrait, NodeType, RsvgNode};
use crate::number_list::{NumberList, NumberListLength};
use crate::parsers::{Parse, ParseValue};
use crate::property_bag::PropertyBag;
-use crate::surface_utils::{
- iterators::Pixels, shared_surface::SharedImageSurface, ImageSurfaceDataExt, Pixel,
-};
+use crate::surface_utils::{iterators::Pixels, shared_surface::ExclusiveImageSurface, Pixel};
use crate::util::clamp;
use super::context::{FilterContext, FilterOutput, FilterResult};
@@ -279,10 +277,10 @@ impl FilterEffect for FeComponentTransfer {
.into_irect(draw_ctx);
// Create the output surface.
- let mut output_surface = cairo::ImageSurface::create(
- cairo::Format::ARgb32,
+ let mut surface = ExclusiveImageSurface::new(
ctx.source_graphic().width(),
ctx.source_graphic().height(),
+ input.surface().surface_type(),
)?;
// Get a node for every pixel component.
@@ -357,29 +355,24 @@ impl FilterEffect for FeComponentTransfer {
let compute_a = |alpha| compute_a(¶ms_a, alpha);
// Do the actual processing.
- let output_stride = output_surface.get_stride() as usize;
- {
- let mut output_data = output_surface.get_data().unwrap();
-
- for (x, y, pixel) in Pixels::within(input.surface(), bounds) {
- let alpha = f64::from(pixel.a) / 255f64;
- let new_alpha = compute_a(alpha);
-
- let output_pixel = Pixel {
- r: compute_r(pixel.r, alpha, new_alpha),
- g: compute_g(pixel.g, alpha, new_alpha),
- b: compute_b(pixel.b, alpha, new_alpha),
- a: ((new_alpha * 255f64) + 0.5) as u8,
- };
-
- output_data.set_pixel(output_stride, output_pixel, x, y);
- }
+ for (x, y, pixel) in Pixels::within(input.surface(), bounds) {
+ let alpha = f64::from(pixel.a) / 255f64;
+ let new_alpha = compute_a(alpha);
+
+ let output_pixel = Pixel {
+ r: compute_r(pixel.r, alpha, new_alpha),
+ g: compute_g(pixel.g, alpha, new_alpha),
+ b: compute_b(pixel.b, alpha, new_alpha),
+ a: ((new_alpha * 255f64) + 0.5) as u8,
+ };
+
+ surface.set_pixel(output_pixel, x, y);
}
Ok(FilterResult {
name: self.base.result.clone(),
output: FilterOutput {
- surface: SharedImageSurface::wrap(output_surface, input.surface().surface_type())?,
+ surface: surface.share()?,
bounds,
},
})
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]