64625f4c22e3d153b9c5de2028a92d0bdfbda509
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 "libnr/nr-pixblock.h"
16 #include "libnr/nr-matrix.h"
17 #include "svg/svg-length.h"
19 namespace NR {
21 class FilterPrimitive {
22 public:
23 FilterPrimitive();
24 virtual ~FilterPrimitive();
26 int render(NRPixBlock **pb, NRMatrix const *trans);
27 virtual int render(NRPixBlock **pb, Matrix const &trans) = 0;
28 virtual int get_enlarge(Matrix const &m);
30 /**
31 * Sets the input slot number 'slot' to be used as input in rendering
32 * filter primitive 'primitive'
33 * For filter primitive types accepting more than one input, this sets the
34 * first input.
35 * If any of the required input slots is not set, the output of previous
36 * filter primitive is used, or SourceGraphic if this is the first
37 * primitive for this filter.
38 */
39 virtual void set_input(int slot);
41 /**
42 * Sets the input slot number 'slot' to be user as input number 'input' in
43 * rendering filter primitive 'primitive'
44 * First input for a filter primitive is number 0. For primitives with
45 * attributes 'in' and 'in2', these are numbered 0 and 1, respectively.
46 * If any of required input slots for a filter is not set, the output of
47 * previous filter primitive is used, or SourceGraphic if this is the first
48 * filter primitive for this filter.
49 */
50 virtual void set_input(int input, int slot);
52 /**
53 * Sets the slot number 'slot' to be used as output from filter primitive
54 * 'primitive'
55 * If output slot for a filter element is not set, one of the unused image
56 * slots is used.
57 * It is an error to specify a pre-defined slot as 'slot'. Such call does
58 * not have any effect to the state of filter or its primitives.
59 */
60 virtual void set_output(int slot);
62 void set_x(SVGLength &length);
63 void set_y(SVGLength &length);
64 void set_width(SVGLength &length);
65 void set_height(SVGLength &length);
67 /**
68 * Sets the filter primitive subregion. Passing an unset length
69 * (length._set == false) as any parameter results in that parameter
70 * not being changed.
71 * Filter primitive will not hold any references to the passed
72 * SVGLength object after function returns.
73 * If any of the parameters does not get set the default value, as
74 * defined in SVG standard, for that parameter is used instead.
75 */
76 void set_region(SVGLength &x, SVGLength &y,
77 SVGLength &width, SVGLength &height);
79 /**
80 * Resets the filter primitive subregion to its default value
81 */
82 void reset_region();
84 protected:
85 int _input;
86 int _output;
88 SVGLength _region_x;
89 SVGLength _region_y;
90 SVGLength _region_width;
91 SVGLength _region_height;
92 };
95 } /* namespace NR */
100 #endif /* __NR_FILTER_PRIMITIVE_H__ */
101 /*
102 Local Variables:
103 mode:c++
104 c-file-style:"stroustrup"
105 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
106 indent-tabs-mode:nil
107 fill-column:99
108 End:
109 */
110 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :