Code

boiler plate code for feTile
authorjucablues <jucablues@users.sourceforge.net>
Fri, 3 Aug 2007 22:06:30 +0000 (22:06 +0000)
committerjucablues <jucablues@users.sourceforge.net>
Fri, 3 Aug 2007 22:06:30 +0000 (22:06 +0000)
src/display/Makefile_insert
src/display/nr-filter-tile.cpp [new file with mode: 0644]
src/display/nr-filter-tile.h [new file with mode: 0644]
src/display/nr-filter.cpp
src/sp-fetile.cpp
src/sp-fetile.h

index 1713dc75114dcf11071c82fa081a769c156272e7..ed9eae9befe7523a93d9e21ebae96770a2f2dd52 100644 (file)
@@ -93,6 +93,8 @@ display_libspdisplay_a_SOURCES = \
        display/nr-filter-slot.h        \
        display/nr-filter-specularlighting.cpp     \
        display/nr-filter-specularlighting.h       \
+       display/nr-filter-tile.cpp      \
+       display/nr-filter-tile.h        \
        display/nr-filter-turbulence.cpp      \
        display/nr-filter-turbulence.h        \
        display/nr-filter-pixops.h      \
diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp
new file mode 100644 (file)
index 0000000..69d5776
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * feTile filter primitive renderer
+ *
+ * Authors:
+ *   Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
+ *
+ * Copyright (C) 2007 authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "display/nr-filter-tile.h"
+namespace NR {
+
+FilterTile::FilterTile()
+{
+    g_warning("FilterTile::render not implemented.");
+}
+
+FilterPrimitive * FilterTile::create() {
+    return new FilterTile();
+}
+
+FilterTile::~FilterTile()
+{}
+
+int FilterTile::render(FilterSlot &slot, Matrix const &trans) {
+    NRPixBlock *in = slot.get(_input);
+    NRPixBlock *out = new NRPixBlock;
+
+    nr_pixblock_setup_fast(out, in->mode,
+                           in->area.x0, in->area.y0, in->area.x1, in->area.y1,
+                           true);
+
+    unsigned char *in_data = NR_PIXBLOCK_PX(in);
+    unsigned char *out_data = NR_PIXBLOCK_PX(out);
+
+//IMPLEMENT ME!
+    
+    out->empty = FALSE;
+    slot.set(_output, out);
+    return 0;
+}
+
+void FilterTile::area_enlarge(NRRectL &area, Matrix const &trans)
+{
+}
+
+} /* namespace NR */
+
+/*
+  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 :
diff --git a/src/display/nr-filter-tile.h b/src/display/nr-filter-tile.h
new file mode 100644 (file)
index 0000000..32aa7b0
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __NR_FILTER_TILE_H__
+#define __NR_FILTER_TILE_H__
+
+/*
+ * feTile filter primitive renderer
+ *
+ * Authors:
+ *   Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
+ *
+ * Copyright (C) 2007 authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "display/nr-filter-primitive.h"
+#include "display/nr-filter-slot.h"
+#include "libnr/nr-matrix.h"
+#include "libnr/nr-rect-l.h"
+
+namespace NR {
+
+class FilterTile : public FilterPrimitive {
+public:
+    FilterTile();
+    static FilterPrimitive *create();
+    virtual ~FilterTile();
+
+    virtual int render(FilterSlot &slot, Matrix const &trans);
+    virtual void area_enlarge(NRRectL &area, Matrix const &trans);
+};
+
+} /* namespace NR */
+
+#endif /* __NR_FILTER_TILE_H__ */
+/*
+  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 :
index 95867363b8956b90b46e175584e5681205dc1ecb..31c3478a2619ec937d5a9f7f07457c28b05d3cce 100644 (file)
@@ -31,6 +31,7 @@
 #include "display/nr-filter-merge.h"
 #include "display/nr-filter-offset.h"
 #include "display/nr-filter-specularlighting.h"
+#include "display/nr-filter-tile.h"
 #include "display/nr-filter-turbulence.h"
 
 #include "display/nr-arena-item.h"
@@ -331,7 +332,7 @@ void Filter::_create_constructor_table()
     _constructor[NR_FILTER_MORPHOLOGY] = NULL;
     _constructor[NR_FILTER_OFFSET] = &FilterOffset::create;
     _constructor[NR_FILTER_SPECULARLIGHTING] = &FilterSpecularLighting::create;
-    _constructor[NR_FILTER_TILE] = NULL;
+    _constructor[NR_FILTER_TILE] = &FilterTile::create;
     _constructor[NR_FILTER_TURBULENCE] = &FilterTurbulence::create;
     created = true;
 }
index 03967ce0510cbe1e77429f9b50759af2825be8f4..bb86a46278888b912c3c94d40d1b7d4e41a8f62a 100644 (file)
@@ -33,6 +33,7 @@ static void sp_feTile_release(SPObject *object);
 static void sp_feTile_set(SPObject *object, unsigned int key, gchar const *value);
 static void sp_feTile_update(SPObject *object, SPCtx *ctx, guint flags);
 static Inkscape::XML::Node *sp_feTile_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static void sp_feTile_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter);
 
 static SPFilterPrimitiveClass *feTile_parent_class;
 
@@ -61,6 +62,7 @@ static void
 sp_feTile_class_init(SPFeTileClass *klass)
 {
     SPObjectClass *sp_object_class = (SPObjectClass *)klass;
+    SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass;
 
     feTile_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass);
 
@@ -69,6 +71,7 @@ sp_feTile_class_init(SPFeTileClass *klass)
     sp_object_class->write = sp_feTile_write;
     sp_object_class->set = sp_feTile_set;
     sp_object_class->update = sp_feTile_update;
+    sp_primitive_class->build_renderer = sp_feTile_build_renderer;
 }
 
 static void
@@ -161,6 +164,19 @@ sp_feTile_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     return repr;
 }
 
+static void sp_feTile_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter) {
+    g_assert(primitive != NULL);
+    g_assert(filter != NULL);
+
+    SPFeTile *sp_tile = SP_FETILE(primitive);
+
+    int primitive_n = filter->add_primitive(NR::NR_FILTER_TILE);
+    NR::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
+    NR::FilterTile *nr_tile = dynamic_cast<NR::FilterTile*>(nr_primitive);
+    g_assert(nr_tile != NULL);
+
+    sp_filter_primitive_renderer_common(primitive, nr_primitive);
+}
 
 /*
   Local Variables:
index b6234c3f2832023c33997182467f86733370739b..efcccf11d4c029be37d83de4812058e09ff8f820 100644 (file)
@@ -16,6 +16,9 @@
 #include "sp-filter.h"
 #include "sp-fetile-fns.h"
 
+#include "display/nr-filter.h"
+#include "display/nr-filter-tile.h"
+
 /* FeTile base class */
 class SPFeTileClass;