1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /** \file
3  * SVG <feTile> implementation.
4  *
5  */
6 /*
7  * Authors:
8  *   hugo Rodrigues <haa.rodrigues@gmail.com>
9  *
10  * Copyright (C) 2006 Hugo Rodrigues
11  *
12  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
13  */
14 
15 #include "tile.h"
16 
17 #include "attributes.h"
18 
19 #include "display/nr-filter.h"
20 #include "display/nr-filter-tile.h"
21 
22 #include "svg/svg.h"
23 
24 #include "xml/repr.h"
25 
SPFeTile()26 SPFeTile::SPFeTile() : SPFilterPrimitive() {
27 }
28 
29 SPFeTile::~SPFeTile() = default;
30 
31 /**
32  * Reads the Inkscape::XML::Node, and initializes SPFeTile variables.  For this to get called,
33  * our name must be associated with a repr via "sp_object_type_register".  Best done through
34  * sp-object-repr.cpp's repr_name_entries array.
35  */
build(SPDocument * document,Inkscape::XML::Node * repr)36 void SPFeTile::build(SPDocument *document, Inkscape::XML::Node *repr) {
37 	SPFilterPrimitive::build(document, repr);
38 }
39 
40 /**
41  * Drops any allocated memory.
42  */
release()43 void SPFeTile::release() {
44 	SPFilterPrimitive::release();
45 }
46 
47 /**
48  * Sets a specific value in the SPFeTile.
49  */
set(SPAttr key,gchar const * value)50 void SPFeTile::set(SPAttr key, gchar const *value) {
51     switch(key) {
52 	/*DEAL WITH SETTING ATTRIBUTES HERE*/
53         default:
54         	SPFilterPrimitive::set(key, value);
55             break;
56     }
57 }
58 
59 /**
60  * Receives update notifications.
61  */
update(SPCtx * ctx,guint flags)62 void SPFeTile::update(SPCtx *ctx, guint flags) {
63     if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
64                  SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
65 
66         /* do something to trigger redisplay, updates? */
67 
68     }
69 
70     SPFilterPrimitive::update(ctx, flags);
71 }
72 
73 /**
74  * Writes its settings to an incoming repr object, if any.
75  */
write(Inkscape::XML::Document * doc,Inkscape::XML::Node * repr,guint flags)76 Inkscape::XML::Node* SPFeTile::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
77     /* TODO: Don't just clone, but create a new repr node and write all
78      * relevant values into it */
79     if (!repr) {
80         repr = this->getRepr()->duplicate(doc);
81     }
82 
83     SPFilterPrimitive::write(doc, repr, flags);
84 
85     return repr;
86 }
87 
build_renderer(Inkscape::Filters::Filter * filter)88 void SPFeTile::build_renderer(Inkscape::Filters::Filter* filter) {
89     g_assert(filter != nullptr);
90 
91     int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_TILE);
92     Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
93     Inkscape::Filters::FilterTile *nr_tile = dynamic_cast<Inkscape::Filters::FilterTile*>(nr_primitive);
94     g_assert(nr_tile != nullptr);
95 
96     this->renderer_common(nr_primitive);
97 }
98 
99 /*
100   Local Variables:
101   mode:c++
102   c-file-style:"stroustrup"
103   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
104   indent-tabs-mode:nil
105   fill-column:99
106   End:
107 */
108 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
109