1 #ifndef __NR_FILTER_PRIMITIVE_H__
2 #define __NR_FILTER_PRIMITIVE_H__
4 /*
5 * SVG filters rendering
6 *
7 * Author:
8 * Niko Kiirala <niko@kiirala.com>
9 *
10 * Copyright (C) 2006 Niko Kiirala
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #include "display/nr-filter-slot.h"
16 #include "libnr/nr-pixblock.h"
17 #include "libnr/nr-matrix.h"
18 #include "libnr/nr-rect-l.h"
19 #include "svg/svg-length.h"
21 namespace NR {
23 class FilterPrimitive {
24 public:
25 FilterPrimitive();
26 virtual ~FilterPrimitive();
28 int render(FilterSlot &slot, NRMatrix const *trans);
29 virtual int render(FilterSlot &slot, Matrix const &trans) = 0;
30 virtual void area_enlarge(NRRectL &area, Matrix const &m);
32 /**
33 * Sets the input slot number 'slot' to be used as input in rendering
34 * filter primitive 'primitive'
35 * For filter primitive types accepting more than one input, this sets the
36 * first input.
37 * If any of the required input slots is not set, the output of previous
38 * filter primitive is used, or SourceGraphic if this is the first
39 * primitive for this filter.
40 */
41 virtual void set_input(int slot);
43 /**
44 * Sets the input slot number 'slot' to be user as input number 'input' in
45 * rendering filter primitive 'primitive'
46 * First input for a filter primitive is number 0. For primitives with
47 * attributes 'in' and 'in2', these are numbered 0 and 1, respectively.
48 * If any of required input slots for a filter is not set, the output of
49 * previous filter primitive is used, or SourceGraphic if this is the first
50 * filter primitive for this filter.
51 */
52 virtual void set_input(int input, int slot);
54 /**
55 * Sets the slot number 'slot' to be used as output from filter primitive
56 * 'primitive'
57 * If output slot for a filter element is not set, one of the unused image
58 * slots is used.
59 * It is an error to specify a pre-defined slot as 'slot'. Such call does
60 * not have any effect to the state of filter or its primitives.
61 */
62 virtual void set_output(int slot);
64 void set_x(SVGLength &length);
65 void set_y(SVGLength &length);
66 void set_width(SVGLength &length);
67 void set_height(SVGLength &length);
69 /**
70 * Sets the filter primitive subregion. Passing an unset length
71 * (length._set == false) as any parameter results in that parameter
72 * not being changed.
73 * Filter primitive will not hold any references to the passed
74 * SVGLength object after function returns.
75 * If any of the parameters does not get set the default value, as
76 * defined in SVG standard, for that parameter is used instead.
77 */
78 void set_region(SVGLength &x, SVGLength &y,
79 SVGLength &width, SVGLength &height);
81 /**
82 * Resets the filter primitive subregion to its default value
83 */
84 void reset_region();
86 protected:
87 int _input;
88 int _output;
90 SVGLength _region_x;
91 SVGLength _region_y;
92 SVGLength _region_width;
93 SVGLength _region_height;
94 };
97 } /* namespace NR */
102 #endif /* __NR_FILTER_PRIMITIVE_H__ */
103 /*
104 Local Variables:
105 mode:c++
106 c-file-style:"stroustrup"
107 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
108 indent-tabs-mode:nil
109 fill-column:99
110 End:
111 */
112 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :