1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef SEEN_SP_FILTER_PRIMITIVE_H
3 #define SEEN_SP_FILTER_PRIMITIVE_H
4 
5 /** \file
6  * Document level base class for all SVG filter primitives.
7  */
8 /*
9  * Authors:
10  *   Hugo Rodrigues <haa.rodrigues@gmail.com>
11  *   Niko Kiirala <niko@kiirala.com>
12  *
13  * Copyright (C) 2006,2007 Authors
14  *
15  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
16  */
17 
18 #include "2geom/rect.h"
19 #include "../sp-object.h"
20 #include "../sp-dimensions.h"
21 
22 #define SP_FILTER_PRIMITIVE(obj) (dynamic_cast<SPFilterPrimitive*>((SPObject*)obj))
23 #define SP_IS_FILTER_PRIMITIVE(obj) (dynamic_cast<const SPFilterPrimitive*>((SPObject*)obj) != NULL)
24 
25 namespace Inkscape {
26 namespace Filters {
27 class Filter;
28 class FilterPrimitive;
29 } }
30 
31 class SPFilterPrimitive : public SPObject, public SPDimensions {
32 public:
33 	SPFilterPrimitive();
34 	~SPFilterPrimitive() override;
35 
36     int image_in, image_out;
37 
38 protected:
39 	void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
40 	void release() override;
41 
42 	void set(SPAttr key, char const* value) override;
43 
44 	void update(SPCtx* ctx, unsigned int flags) override;
45 
46 	Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags) override;
47 
48 public:
49 	virtual void build_renderer(Inkscape::Filters::Filter* filter) = 0;
50 
51         /* Calculate the filter's effect on the region */
52         virtual Geom::Rect calculate_region(Geom::Rect region);
53 
54         /* Return true if the object should be allowed to use this filter */
valid_for(SPObject const * obj)55         virtual bool valid_for(SPObject const *obj) const {
56             // This is used by feImage to stop infinate loops.
57             return true;
58         };
59 
60 	/* Common initialization for filter primitives */
61 	void renderer_common(Inkscape::Filters::FilterPrimitive *nr_prim);
62 
63 	int name_previous_out();
64 	int read_in(char const *name);
65 	int read_result(char const *name);
66 };
67 
68 #endif
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:fileencoding=utf-8:textwidth=99 :
79