Code

added some more boilerplate code on feTurbulence.
[inkscape.git] / src / display / nr-arena-group.cpp
index 0678eb37ecf3672668d353faae60e50ca56f1725..912992a6e38bc88633a32e13d13d5f4b9138b7d0 100644 (file)
 #include "display/nr-filter-types.h"
 #include "style.h"
 #include "sp-filter.h"
+#include "sp-filter-reference.h"
 #include "sp-gaussian-blur.h"
+#include "sp-feblend.h"
+#include "display/nr-filter-blend.h"
 
 static void nr_arena_group_class_init (NRArenaGroupClass *klass);
 static void nr_arena_group_init (NRArenaGroup *group);
@@ -185,53 +188,30 @@ nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int
 
 void nr_arena_group_set_style (NRArenaGroup *group, SPStyle *style)
 {
-  g_return_if_fail(group != NULL);
-  g_return_if_fail(NR_IS_ARENA_GROUP(group));
-
-  if (style) sp_style_ref(style);
-  if (group->style) sp_style_unref(group->style);
-  group->style = style;
-
-  //if there is a filter set for this group
-  if (style && style->filter.set && style->filter.filter) {
-  
-        group->filter = new NR::Filter();
-        group->filter->set_x(style->filter.filter->x);
-        group->filter->set_y(style->filter.filter->y);
-        group->filter->set_width(style->filter.filter->width);
-        group->filter->set_height(style->filter.filter->height);
-        
-        //go through all SP filter primitives
-        for(int i=0; i<style->filter.filter->_primitive_count; i++)
-        {
-            SPFilterPrimitive *primitive = style->filter.filter->_primitives[i];
-            //if primitive is gaussianblur
-            if(SP_IS_GAUSSIANBLUR(primitive))
-            {
-                NR::FilterGaussian * gaussian = (NR::FilterGaussian *) group->filter->add_primitive(NR::NR_FILTER_GAUSSIANBLUR);
-                SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive);
-                float num = spblur->stdDeviation.getNumber();
-                if( num>=0.0 )
-                {
-                    float optnum = spblur->stdDeviation.getOptNumber();
-                    if( optnum>=0.0 )
-                        gaussian->set_deviation((double) num, (double) optnum);
-                    else
-                        gaussian->set_deviation((double) num);
-                }
-            }
+    g_return_if_fail(group != NULL);
+    g_return_if_fail(NR_IS_ARENA_GROUP(group));
+
+    if (style) sp_style_ref(style);
+    if (group->style) sp_style_unref(group->style);
+    group->style = style;
+
+    //if group has a filter
+    if (style->filter.set && style->getFilter()) {
+        if (!group->filter) {
+            int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter()));
+            group->filter = new NR::Filter(primitives);
         }
-    }
-    else
-    {
+        sp_filter_build_renderer(SP_FILTER(style->getFilter()), group->filter);
+    } else {
         //no filter set for this group
+        delete group->filter;
         group->filter = NULL;
     }
-
-  if (style && style->enable_background.set
-      && style->enable_background.value == SP_CSS_BACKGROUND_NEW) {
-    group->background_new = true;
-  }
+  
+    if (style && style->enable_background.set
+        && style->enable_background.value == SP_CSS_BACKGROUND_NEW) {
+        group->background_new = true;
+    }
 }
 
 static unsigned int
@@ -306,4 +286,13 @@ void nr_arena_group_set_child_transform(NRArenaGroup *group, NRMatrix const *t)
        }
 }
 
-
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :