feImage: Pass the bounding boxes to render_external_image()

Don't compute them inside there.
parent 85ffed8b
......@@ -14,7 +14,6 @@ use property_bag::PropertyBag;
use rect::IRect;
use surface_utils::shared_surface::{SharedImageSurface, SurfaceType};
use super::bounds::BoundsBuilder;
use super::context::{FilterContext, FilterOutput, FilterResult};
use super::{Filter, FilterError, Primitive};
......@@ -104,8 +103,9 @@ impl Image {
fn render_external_image(
&self,
ctx: &FilterContext,
draw_ctx: &mut DrawingCtx,
bounds_builder: BoundsBuilder<'_>,
draw_ctx: &DrawingCtx,
bounds: &IRect,
unclipped_bounds: &IRect,
href: &Href,
) -> Result<ImageSurface, FilterError> {
let surface = if let Href::PlainUrl(ref url) = *href {
......@@ -124,15 +124,14 @@ impl Image {
)?;
// TODO: this goes through a f64->i32->f64 conversion.
let render_bounds = bounds_builder.into_irect_without_clipping(draw_ctx);
let aspect = self.aspect.get();
let (x, y, w, h) = aspect.compute(
f64::from(surface.width()),
f64::from(surface.height()),
f64::from(render_bounds.x0),
f64::from(render_bounds.y0),
f64::from(render_bounds.x1 - render_bounds.x0),
f64::from(render_bounds.y1 - render_bounds.y0),
f64::from(unclipped_bounds.x0),
f64::from(unclipped_bounds.y0),
f64::from(unclipped_bounds.x1 - unclipped_bounds.x0),
f64::from(unclipped_bounds.y1 - unclipped_bounds.y0),
);
if w.approx_eq_cairo(&0.0) || h.approx_eq_cairo(&0.0) {
......@@ -151,7 +150,6 @@ impl Image {
matrix.invert();
ptn.set_matrix(matrix);
let bounds = bounds_builder.into_irect(draw_ctx);
let cr = cairo::Context::new(&output_surface);
cr.rectangle(
f64::from(bounds.x0),
......@@ -208,7 +206,8 @@ impl Filter for Image {
if let Some(href) = href_opt {
let output_surface = match *href {
Href::PlainUrl(_) => {
self.render_external_image(ctx, draw_ctx, bounds_builder, href)?
let unclipped_bounds = bounds_builder.into_irect_without_clipping(draw_ctx);
self.render_external_image(ctx, draw_ctx, &bounds, &unclipped_bounds, href)?
}
Href::WithFragment(ref frag) => self.render_node(ctx, draw_ctx, bounds, frag)?,
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment