1 #define __NR_FILTER_PRIMITIVE_CPP__
3 /*
4 * SVG filters rendering
5 *
6 * Author:
7 * Niko Kiirala <niko@kiirala.com>
8 *
9 * Copyright (C) 2006 Niko Kiirala
10 *
11 * Released under GNU GPL, read the file 'COPYING' for more information
12 */
14 #include "display/nr-filter-primitive.h"
15 #include "display/nr-filter-types.h"
16 #include "libnr/nr-pixblock.h"
17 #include "svg/svg-length.h"
19 namespace NR {
21 FilterPrimitive::FilterPrimitive()
22 {
23 _input = NR_FILTER_SLOT_NOT_SET;
24 _output = NR_FILTER_SLOT_NOT_SET;
26 // These defaults are according to SVG standard.
27 // NB: SVGLength.set takes prescaled percent values: 1 means 100%
28 _region_x.set(SVGLength::PERCENT, 0, 0);
29 _region_y.set(SVGLength::PERCENT, 0, 0);
30 _region_width.set(SVGLength::PERCENT, 1, 0);
31 _region_height.set(SVGLength::PERCENT, 1, 0);
32 }
34 FilterPrimitive::~FilterPrimitive()
35 {
36 // Nothing to do here
37 }
39 /** Wrapper function for rendering with C-style matrices. */
40 int FilterPrimitive::render(FilterSlot &slot, NRMatrix const *trans) {
41 if(trans) {
42 return this->render(slot, *trans);
43 } else {
44 Matrix tmp;
45 tmp.set_identity();
46 return this->render(slot, tmp);
47 }
48 }
50 void FilterPrimitive::area_enlarge(NRRectL &area, Matrix const &m)
51 {
52 // This doesn't need to do anything by default
53 }
55 void FilterPrimitive::set_input(int slot) {
56 set_input(0, slot);
57 }
59 void FilterPrimitive::set_input(int input, int slot) {
60 if (input == 0) _input = slot;
61 }
63 void FilterPrimitive::set_output(int slot) {
64 if (slot >= 0) _output = slot;
65 }
67 } /* namespace NR */
69 /*
70 Local Variables:
71 mode:c++
72 c-file-style:"stroustrup"
73 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
74 indent-tabs-mode:nil
75 fill-column:99
76 End:
77 */
78 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :