Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-filter-primitive.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_SP_FILTER_PRIMITIVE_H
3#define SEEN_SP_FILTER_PRIMITIVE_H
4
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 <optional>
19#include <memory>
20#include <string>
21#include <2geom/rect.h>
22#include "colors/color.h"
23#include "colors/manager.h"
24#include "document.h"
25#include "object/sp-object.h"
28
29namespace Inkscape {
30class Drawing;
31class DrawingItem;
32namespace Filters {
33class Filter;
34class FilterPrimitive;
35} // namespace Filters
36} // namespace Inkscape
37
38class SlotResolver;
39
41 : public SPObject
42 , public SPDimensions
43{
44public:
47 int tag() const override { return tag_of<decltype(*this)>; }
48
49 int get_in() const { return in_slot; }
50 int get_out() const { return out_slot; }
51
54
55 virtual std::unique_ptr<Inkscape::Filters::FilterPrimitive> build_renderer(Inkscape::DrawingItem *item) const = 0;
56
57 /* Calculate the filter's effect on the region */
58 virtual Geom::Rect calculate_region(Geom::Rect const &region) const;
59
60 /* Return true if the object should be allowed to use this filter */
61 virtual bool valid_for(SPObject const *obj) const
62 {
63 // This is used by feImage to stop infinite loops.
64 return true;
65 };
66
68 virtual void resolve_slots(SlotResolver &);
69
70protected:
71 void build(SPDocument *doc, Inkscape::XML::Node *repr) override;
72 void release() override;
73 void set(SPAttr key, char const *value) override;
74 void update(SPCtx *ctx, unsigned flags) override;
76
77 // Common initialization for filter primitives.
79
80private:
81 std::optional<std::string> in_name, out_name;
84};
85
86#endif // SEEN_SP_FILTER_PRIMITIVE_H
87
88/*
89 Local Variables:
90 mode:c++
91 c-file-style:"stroustrup"
92 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
93 indent-tabs-mode:nil
94 fill-column:99
95 End:
96*/
97// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
Axis aligned, non-empty rectangle.
Definition rect.h:92
SVG drawing item for display.
Interface for refcounted XML nodes.
Definition node.h:80
SVGLength x
Typed SVG document implementation.
Definition document.h:101
void update(SPCtx *ctx, unsigned flags) override
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
virtual void hide(Inkscape::DrawingItem *item)
std::optional< std::string > out_name
std::optional< std::string > in_name
virtual void show(Inkscape::DrawingItem *item)
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned flags) override
virtual void resolve_slots(SlotResolver &)
virtual bool valid_for(SPObject const *obj) const
virtual std::unique_ptr< Inkscape::Filters::FilterPrimitive > build_renderer(Inkscape::DrawingItem *item) const =0
~SPFilterPrimitive() override
virtual Geom::Rect calculate_region(Geom::Rect const &region) const
void build_renderer_common(Inkscape::Filters::FilterPrimitive *primitive) const
int tag() const override
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
Inkscape::XML::Node * repr
Definition sp-object.h:193
SPItem * item
Helper class to stream background task notifications as a series of messages.
TODO: insert short description here.
static cairo_user_data_key_t key
Axis-aligned rectangle.
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94