summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3f54b6f)
raw | patch | inline | side by side (parent: 3f54b6f)
author | scislac <scislac@users.sourceforge.net> | |
Tue, 22 Sep 2009 05:16:43 +0000 (05:16 +0000) | ||
committer | scislac <scislac@users.sourceforge.net> | |
Tue, 22 Sep 2009 05:16:43 +0000 (05:16 +0000) |
src/display/nr-filter.cpp | patch | blob | history | |
src/extension/internal/filter/filter.cpp | patch | blob | history |
index af432bdf343b524ae46999f3c8cde196a0514798..3ca2b0dbaedd0ba2a13930359a9f341978784c7c 100644 (file)
#if defined (SOLARIS) && (SOLARIS == 8)
#include "round.h"
using Inkscape::round;
-#endif
+#endif
namespace Inkscape {
namespace Filters {
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();
// 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);
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;
}
}
void Filter::set_x(SVGLength const &length)
-{
+{
if (length._set)
_region_x = length;
}
_region_width = length;
}
void Filter::set_height(SVGLength const &length)
-{
+{
if (length._set)
_region_height = length;
}
index 048207332eb80789907023ac972bdd4113db8623..d98f8e9a200146eba303eeac2f863b467bc49221 100644 (file)
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;
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);
+ }
}
}