summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJosh Andler <scislac@gmail.com>2009-09-22 05:16:43 +0000
committerscislac <scislac@users.sourceforge.net>2009-09-22 05:16:43 +0000
commit6413ea1f0bc64210933ddc237aaea4c8ed10f859 (patch)
tree2c8ca9c99eedeb754cf629274c22bbfce556e796 /src
parentfix by Diederik for 422972 (diff)
downloadinkscape-6413ea1f0bc64210933ddc237aaea4c8ed10f859.tar.gz
inkscape-6413ea1f0bc64210933ddc237aaea4c8ed10f859.zip
Fix by Adib for 430804.
(bzr r8628)
Diffstat (limited to 'src')
-rw-r--r--src/display/nr-filter.cpp20
-rw-r--r--src/extension/internal/filter/filter.cpp30
2 files changed, 31 insertions, 19 deletions
diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp
index af432bdf3..3ca2b0dba 100644
--- a/src/display/nr-filter.cpp
+++ b/src/display/nr-filter.cpp
@@ -52,7 +52,7 @@
#if defined (SOLARIS) && (SOLARIS == 8)
#include "round.h"
using Inkscape::round;
-#endif
+#endif
namespace Inkscape {
namespace Filters {
@@ -92,9 +92,9 @@ Filter::Filter()
Filter::Filter(int n)
{
_primitive_count = 0;
- _primitive_table_size = n;
- _primitive = new FilterPrimitive*[n];
- for ( int i = 0 ; i < n ; i++ ) {
+ _primitive_table_size = (n > 0) ? n : 1; // we guarantee there is at least 1(one) filter slot
+ _primitive = new FilterPrimitive*[_primitive_table_size];
+ for ( int i = 0 ; i < _primitive_table_size ; i++ ) {
_primitive[i] = NULL;
}
_common_init();
@@ -159,7 +159,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb)
// It's no use to try and filter an empty object.
return 1;
}
-
+
FilterUnits units(_filter_units, _primitive_units);
units.set_ctm(trans);
units.set_item_bbox(item_bbox);
@@ -370,7 +370,11 @@ void Filter::_enlarge_primitive_table() {
for (int i = _primitive_count ; i < _primitive_table_size ; i++) {
new_tbl[i] = NULL;
}
- delete[] _primitive;
+ if(_primitive != NULL) {
+ delete[] _primitive;
+ } else {
+ g_warning("oh oh");
+ }
_primitive = new_tbl;
}
@@ -434,7 +438,7 @@ void Filter::clear_primitives()
}
void Filter::set_x(SVGLength const &length)
-{
+{
if (length._set)
_region_x = length;
}
@@ -449,7 +453,7 @@ void Filter::set_width(SVGLength const &length)
_region_width = length;
}
void Filter::set_height(SVGLength const &length)
-{
+{
if (length._set)
_region_height = length;
}
diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp
index 048207332..d98f8e9a2 100644
--- a/src/extension/internal/filter/filter.cpp
+++ b/src/extension/internal/filter/filter.cpp
@@ -70,7 +70,7 @@ Filter::get_filter (Inkscape::Extension::Extension * ext) {
return sp_repr_read_mem(filter, strlen(filter), NULL);
}
-void
+void
Filter::merge_filters (Inkscape::XML::Node * to, Inkscape::XML::Node * from, Inkscape::XML::Document * doc, gchar * srcGraphic, gchar * srcGraphicAlpha)
{
if (from == NULL) return;
@@ -99,7 +99,7 @@ Filter::merge_filters (Inkscape::XML::Node * to, Inkscape::XML::Node * from, Ink
from_child != NULL ; from_child = from_child->next()) {
Glib::ustring name = "svg:";
name += from_child->name();
-
+
Inkscape::XML::Node * to_child = doc->createElement(name.c_str());
to->appendChild(to_child);
merge_filters(to_child, from_child, doc, srcGraphic, srcGraphicAlpha);
@@ -149,7 +149,7 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d
Glib::ustring url = "url(#"; url += newfilterroot->attribute("id"); url += ")";
merge_filters(newfilterroot, filterdoc->root(), xmldoc);
-
+
Inkscape::GC::release(newfilterroot);
sp_repr_css_set_property(css, "filter", url.c_str());
@@ -170,21 +170,29 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d
}
g_free(lfilter);
+ // no filter
if (filternode == NULL) {
+ g_warning("no assoziating filter found!");
continue;
}
- filternode->lastChild()->setAttribute("result", FILTER_SRC_GRAPHIC);
+ if (filternode->lastChild() == NULL) {
+ // empty filter, we insert
+ merge_filters(filternode, filterdoc->root(), xmldoc);
+ } else {
+ // existing filter, we merge
+ filternode->lastChild()->setAttribute("result", FILTER_SRC_GRAPHIC);
+ Inkscape::XML::Node * alpha = xmldoc->createElement("svg:feColorMatrix");
+ alpha->setAttribute("result", FILTER_SRC_GRAPHIC_ALPHA);
+ alpha->setAttribute("in", FILTER_SRC_GRAPHIC); // not required, but we're being explicit
+ alpha->setAttribute("values", "0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0");
- Inkscape::XML::Node * alpha = xmldoc->createElement("svg:feColorMatrix");
- alpha->setAttribute("result", FILTER_SRC_GRAPHIC_ALPHA);
- alpha->setAttribute("in", FILTER_SRC_GRAPHIC); // not required, but we're being explicit
- alpha->setAttribute("values", "0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0");
- filternode->appendChild(alpha);
+ filternode->appendChild(alpha);
- merge_filters(filternode, filterdoc->root(), xmldoc, FILTER_SRC_GRAPHIC, FILTER_SRC_GRAPHIC_ALPHA);
+ merge_filters(filternode, filterdoc->root(), xmldoc, FILTER_SRC_GRAPHIC, FILTER_SRC_GRAPHIC_ALPHA);
- Inkscape::GC::release(alpha);
+ Inkscape::GC::release(alpha);
+ }
}
}