From c6c387ac9d151b60ab64ec3c9d647bf31576735e Mon Sep 17 00:00:00 2001 From: kiirala Date: Sat, 21 Jul 2007 07:00:28 +0000 Subject: [PATCH] Added a missing link in making the filterRes attribute work --- src/display/nr-filter.cpp | 27 +++++++++++++++++++++++---- src/display/nr-filter.h | 12 ++++++------ src/sp-filter.cpp | 36 +++++++++++++++++++++++------------- 3 files changed, 52 insertions(+), 23 deletions(-) diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 73a3df415..47b05d0b8 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -406,27 +406,46 @@ void Filter::clear_primitives() _primitive_count = 0; } -void Filter::set_x(SVGLength &length) +void Filter::set_x(SVGLength const &length) { if (length._set) _region_x = length; } -void Filter::set_y(SVGLength &length) +void Filter::set_y(SVGLength const &length) { if (length._set) _region_y = length; } -void Filter::set_width(SVGLength &length) +void Filter::set_width(SVGLength const &length) { if (length._set) _region_width = length; } -void Filter::set_height(SVGLength &length) +void Filter::set_height(SVGLength const &length) { if (length._set) _region_height = length; } +void Filter::set_resolution(double const pixels) { + if (pixels > 0) { + _x_pixels = pixels; + _y_pixels = pixels; + } +} + +void Filter::set_resolution(double const x_pixels, double const y_pixels) { + if (x_pixels >= 0 && y_pixels >= 0) { + _x_pixels = x_pixels; + _y_pixels = y_pixels; + } +} + +void Filter::reset_resolution() { + _x_pixels = -1; + _y_pixels = -1; +} + } /* namespace NR */ /* diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index baf23886e..835266e73 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -77,10 +77,10 @@ public: */ void set_output(int slot); - void set_x(SVGLength &lenght); - void set_y(SVGLength &length); - void set_width(SVGLength &length); - void set_height(SVGLength &length); + void set_x(SVGLength const &lenght); + void set_y(SVGLength const &length); + void set_width(SVGLength const &length); + void set_height(SVGLength const &length); /** * Sets the filter effects region. @@ -105,7 +105,7 @@ public: * resolution is determined automatically. If x_pixels is less than zero, * calling this function results in no changes to filter state. */ - void set_resolution(double x_pixels); + void set_resolution(double const x_pixels); /** * Sets the width and height of intermediate images in pixels. If not set, @@ -113,7 +113,7 @@ public: * less than zero, calling this function results in no changes to filter * state. */ - void set_resolution(double x_pixels, double y_pixels); + void set_resolution(double const x_pixels, double const y_pixels); /** * Resets the filter resolution to its default value, i.e. automatically diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index aae143e8d..e9c2af19d 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -207,24 +207,25 @@ sp_filter_set(SPObject *object, unsigned int key, gchar const *value) } object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_X: + case SP_ATTR_X: filter->x.readOrUnset(value); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_Y: - filter->y.readOrUnset(value); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + case SP_ATTR_Y: + filter->y.readOrUnset(value); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_WIDTH: - filter->width.readOrUnset(value); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + case SP_ATTR_WIDTH: + filter->width.readOrUnset(value); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_HEIGHT: - filter->height.readOrUnset(value); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + case SP_ATTR_HEIGHT: + filter->height.readOrUnset(value); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_FILTERRES: - filter->filterRes.set(value); + case SP_ATTR_FILTERRES: + filter->filterRes.set(value); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_XLINK_HREF: if (value) { @@ -412,6 +413,15 @@ void sp_filter_build_renderer(SPFilter *sp_filter, NR::Filter *nr_filter) nr_filter->set_width(sp_filter->width); nr_filter->set_height(sp_filter->height); + if (sp_filter->filterRes.getNumber() >= 0) { + if (sp_filter->filterRes.getOptNumber() >= 0) { + nr_filter->set_resolution(sp_filter->filterRes.getNumber(), + sp_filter->filterRes.getOptNumber()); + } else { + nr_filter->set_resolution(sp_filter->filterRes.getNumber()); + } + } + nr_filter->clear_primitives(); SPObject *primitive_obj = sp_filter->children; while (primitive_obj) { -- 2.30.2