1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef SEEN_NR_FILTER_COLOR_MATRIX_H
3 #define SEEN_NR_FILTER_COLOR_MATRIX_H
4 
5 /*
6  * feColorMatrix filter primitive renderer
7  *
8  * Authors:
9  *   Felipe Corrêa da Silva Sanches <juca@members.fsf.org>
10  *
11  * Copyright (C) 2007 authors
12  *
13  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14  */
15 
16 #include <vector>
17 #include <2geom/forward.h>
18 #include "display/nr-filter-primitive.h"
19 
20 typedef unsigned int guint32;
21 typedef signed int gint32;
22 
23 namespace Inkscape {
24 namespace Filters {
25 
26 class FilterSlot;
27 
28 enum FilterColorMatrixType {
29     COLORMATRIX_MATRIX,
30     COLORMATRIX_SATURATE,
31     COLORMATRIX_HUEROTATE,
32     COLORMATRIX_LUMINANCETOALPHA,
33     COLORMATRIX_ENDTYPE
34 };
35 
36 class FilterColorMatrix : public FilterPrimitive {
37 public:
38     FilterColorMatrix();
39     static FilterPrimitive *create();
40     ~FilterColorMatrix() override;
41 
42     void render_cairo(FilterSlot &slot) override;
43     bool can_handle_affine(Geom::Affine const &) override;
44     double complexity(Geom::Affine const &ctm) override;
45 
46     virtual void set_type(FilterColorMatrixType type);
47     virtual void set_value(double value);
48     virtual void set_values(std::vector<double> const &values);
49 
name()50     Glib::ustring name() override { return Glib::ustring("Color Matrix"); }
51 
52 public:
53     struct ColorMatrixMatrix {
54         ColorMatrixMatrix(std::vector<double> const &values);
55         guint32 operator()(guint32 in);
56     private:
57         gint32 _v[20];
58     };
59 
60 private:
61     std::vector<double> values;
62     double value;
63     FilterColorMatrixType type;
64 };
65 
66 } /* namespace Filters */
67 } /* namespace Inkscape */
68 
69 #endif /* __NR_FILTER_COLOR_MATRIX_H__ */
70 /*
71   Local Variables:
72   mode:c++
73   c-file-style:"stroustrup"
74   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
75   indent-tabs-mode:nil
76   fill-column:99
77   End:
78 */
79 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
80