Code

Added virtual destructors for filter primitives. Corrected
[inkscape.git] / src / display / nr-filter-gaussian.h
1 #ifndef __NR_FILTER_GAUSSIAN_H__
2 #define __NR_FILTER_GAUSSIAN_H__
4 /*
5  * Gaussian blur renderer
6  *
7  * Author:
8  *   Niko Kiirala <niko@kiirala.com>
9  *
10  * Copyright (C) 2006 Niko Kiirala
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include "display/nr-filter-primitive.h"
16 #include "libnr/nr-pixblock.h"
17 #include "libnr/nr-matrix.h"
19 namespace NR {
21 class FilterGaussian : public FilterPrimitive {
22 public:
23     FilterGaussian();
24     static FilterPrimitive *create();
25     virtual ~FilterGaussian();
27     virtual int render(NRPixBlock **pb, Matrix const &trans);
28     virtual int get_enlarge(Matrix const &m);
30     /**
31      * Set the standard deviation value for gaussian blur. Deviation along
32      * both axis is set to the provided value.
33      * Negative value, NaN and infinity are considered an error and no
34      * changes to filter state are made. If not set, default value of zero
35      * is used, which means the filter results in transparent black image.
36      */
37     void set_deviation(double deviation);
38     /**
39      * Set the standard deviation value for gaussian blur. First parameter
40      * sets the deviation alogn x-axis, second along y-axis.
41      * Negative value, NaN and infinity are considered an error and no
42      * changes to filter state are made. If not set, default value of zero
43      * is used, which means the filter results in transparent black image.
44      */
45     void set_deviation(double x, double y);
47 private:
48     double _deviation_x;
49     double _deviation_y;
51     int _kernel_size(Matrix const &trans);
52     void _make_kernel(double *kernel, double deviation, double expansion);
53     int _effect_area_scr_x(Matrix const &trans);
54     int _effect_area_scr_y(Matrix const &trans);
55     int _effect_subsample_step(int scr_len_x);
56     int _effect_subsample_step_log2(int scr_len_x);
58     inline int _min(int const a, int const b)
59     {
60         return ((a < b) ? a : b);
61     }
62     inline int _max(int const a, int const b)
63     {
64         return ((a > b) ? a : b);
65     }
66 };
69 } /* namespace NR */
74 #endif /* __NR_FILTER_GAUSSIAN_H__ */
75 /*
76   Local Variables:
77   mode:c++
78   c-file-style:"stroustrup"
79   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
80   indent-tabs-mode:nil
81   fill-column:99
82   End:
83 */
84 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :