From: buliabyak Date: Wed, 27 Jun 2007 06:34:35 +0000 (+0000) Subject: use an accessor method to get filter from style X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2a2558985bdd7d96bcecb578cb2b6a5f50addd0c;p=inkscape.git use an accessor method to get filter from style --- diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index c6344da5c..94221ba54 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1030,12 +1030,12 @@ objects_query_blend (GSList *objects, SPStyle *style_res) items++; //if object has a filter - if (style->filter.set && style->filter.href->getObject()) { + if (style->filter.set && style->getFilter()) { int blurcount = 0; int blendcount = 0; // determine whether filter is simple (blend and/or blur) or complex - for(SPObject *primitive_obj = style->filter.href->getObject()->children; + for(SPObject *primitive_obj = style->getFilter()->children; primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj); primitive_obj = primitive_obj->next) { SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj); @@ -1051,7 +1051,7 @@ objects_query_blend (GSList *objects, SPStyle *style_res) // simple filter if(blurcount == 1 || blendcount == 1) { - for(SPObject *primitive_obj = style->filter.href->getObject()->children; + for(SPObject *primitive_obj = style->getFilter()->children; primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj); primitive_obj = primitive_obj->next) { if(SP_IS_FEBLEND(primitive_obj)) { @@ -1118,9 +1118,9 @@ objects_query_blur (GSList *objects, SPStyle *style_res) items ++; //if object has a filter - if (style->filter.set && style->filter.href->getObject()) { + if (style->filter.set && style->getFilter()) { //cycle through filter primitives - SPObject *primitive_obj = style->filter.href->getObject()->children; + SPObject *primitive_obj = style->getFilter()->children; while (primitive_obj) { if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) { SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj); diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 3f08f42f4..912992a6e 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -196,12 +196,12 @@ void nr_arena_group_set_style (NRArenaGroup *group, SPStyle *style) group->style = style; //if group has a filter - if (style->filter.set && style->filter.href->getObject()) { + if (style->filter.set && style->getFilter()) { if (!group->filter) { - int primitives = sp_filter_primitive_count(style->filter.href->getObject()); + int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); group->filter = new NR::Filter(primitives); } - sp_filter_build_renderer(style->filter.href->getObject(), group->filter); + sp_filter_build_renderer(SP_FILTER(style->getFilter()), group->filter); } else { //no filter set for this group delete group->filter; diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 87cc94e1b..e388fca1d 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -369,12 +369,12 @@ void nr_arena_image_set_style (NRArenaImage *image, SPStyle *style) image->style = style; //if image has a filter - if (style->filter.set && style->filter.href->getObject()) { + if (style->filter.set && style->getFilter()) { if (!image->filter) { - int primitives = sp_filter_primitive_count(style->filter.href->getObject()); + int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); image->filter = new NR::Filter(primitives); } - sp_filter_build_renderer(style->filter.href->getObject(), image->filter); + sp_filter_build_renderer(SP_FILTER(style->getFilter()), image->filter); } else { //no filter set for this image delete image->filter; diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 0e7dd2798..a31363f9a 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -1360,12 +1360,12 @@ nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) shape->setMitreLimit(style->stroke_miterlimit.value); //if shape has a filter - if (style->filter.set && style->filter.href->getObject()) { + if (style->filter.set && style->getFilter()) { if (!shape->filter) { - int primitives = sp_filter_primitive_count(style->filter.href->getObject()); + int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); shape->filter = new NR::Filter(primitives); } - sp_filter_build_renderer(style->filter.href->getObject(), shape->filter); + sp_filter_build_renderer(SP_FILTER(style->getFilter()), shape->filter); } else { //no filter set for this shape delete shape->filter; diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 5515d0a04..e59036362 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -41,7 +41,7 @@ count_filter_hrefs(SPObject *o, SPFilter *filter) SPStyle *style = SP_OBJECT_STYLE(o); if (style && style->filter.set - && style->filter.href->getObject() == filter) + && style->getFilter() == filter) { i ++; } @@ -305,13 +305,13 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, //return new_filter_gaussian_blur_from_item(document, item, radius); } - SPFilter *filter = SP_FILTER(item->style->filter.href->getObject()); + SPFilter *filter = SP_FILTER(item->style->getFilter()); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); // If there are more users for this filter, duplicate it if (SP_OBJECT_HREFCOUNT(filter) > count_filter_hrefs(item, filter)) { Inkscape::XML::Node *repr; - repr = SP_OBJECT_REPR(item->style->filter.href->getObject())->duplicate(xml_doc); + repr = SP_OBJECT_REPR(item->style->getFilter())->duplicate(xml_doc); SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); SP_OBJECT_REPR(defs)->appendChild(repr); @@ -338,7 +338,7 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, } // Set the filter effects area - Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->filter.href->getObject()); + Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->getFilter()); set_filter_area(repr, radius, expansion, i2d.expansionX(), i2d.expansionY(), width, height); @@ -391,9 +391,9 @@ void remove_filter (SPObject *item, bool recursive) * be handled gracefully */ void remove_filter_gaussian_blur (SPObject *item) { - if (item->style && item->style->filter.set && item->style->filter.href->getObject()) { + if (item->style && item->style->filter.set && item->style->getFilter()) { // Search for the first blur primitive and remove it. (if found) - Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->filter.href->getObject()); + Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->getFilter()); Inkscape::XML::Node *primitive = repr->firstChild(); while (primitive) { if (strcmp("svg:feGaussianBlur", primitive->name()) == 0) { diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 27c04f1dd..ce66243cc 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -953,8 +953,8 @@ void sp_copy_stuff_used_by_item (GSList **defs_clip, SPItem *item, const GSList } } - if (style->filter.href->getObject()) { - SPObject *filter = style->filter.href->getObject(); + if (style->getFilter()) { + SPObject *filter = style->getFilter(); if (SP_IS_FILTER(filter)) { sp_copy_single (defs_clip, filter, xml_doc); } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 7c1a46447..8b101896f 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1201,7 +1201,7 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix cons !preserve && // user did not chose to preserve all transforms !item->clip_ref->getObject() && // the object does not have a clippath !item->mask_ref->getObject() && // the object does not have a mask - !(!transform.is_translation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.href->getObject()) + !(!transform.is_translation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform(item, transform); diff --git a/src/style.cpp b/src/style.cpp index 46b544382..699d95054 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -397,7 +397,7 @@ static void sp_style_filter_ref_modified(SPObject *obj, guint flags, SPStyle *style) { SPFilter *filter=static_cast(obj); - if (style->filter.href->getObject() == filter) + if (style->getFilter() == filter) { if (style->object) { style->object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); diff --git a/src/style.h b/src/style.h index df2ba127f..0aec2151d 100644 --- a/src/style.h +++ b/src/style.h @@ -17,6 +17,7 @@ #include "forward.h" #include "sp-marker-loc.h" #include "sp-filter.h" +#include "sp-filter-reference.h" #include @@ -169,8 +170,6 @@ struct SPIPaint { } value; }; -struct SPFilterReference; - /// Filter type internal to SPStyle struct SPIFilter { unsigned set : 1; @@ -360,6 +359,8 @@ struct SPStyle { sigc::connection stroke_release_connection; sigc::connection stroke_modified_connection; + + SPObject *getFilter() {if (filter.href) return filter.href->getObject(); else return NULL;} }; SPStyle *sp_style_new(SPDocument *document);