Code

disable motion hints again
[inkscape.git] / src / display / nr-filter-flood.cpp
1 /*
2  * feFlood filter primitive renderer
3  *
4  * Authors:
5  *   Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
6  *
7  * Copyright (C) 2007 authors
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #include "display/nr-filter-flood.h"
13 #include "display/nr-filter-utils.h"
15 namespace NR {
17 FilterFlood::FilterFlood()
18 {}
20 FilterPrimitive * FilterFlood::create() {
21     return new FilterFlood();
22 }
24 FilterFlood::~FilterFlood()
25 {}
27 int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) {
28     NRPixBlock *in = slot.get(_input);
29     if (!in) {
30         g_warning("Missing source image for feFlood (in=%d)", _input);
31         return 1;
32     }
34     int i;
35     int in_w = in->area.x1 - in->area.x0;
36     int in_h = in->area.y1 - in->area.y0;
37  
38     NRPixBlock *out = new NRPixBlock;
40     nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N,
41                            in->area.x0, in->area.y0, in->area.x1, in->area.y1,
42                            true);
44     unsigned char *out_data = NR_PIXBLOCK_PX(out);
46     unsigned char r,g,b,a;
47     r = CLAMP_D_TO_U8((color >> 24) % 256);
48     g = CLAMP_D_TO_U8((color >> 16) % 256);
49     b = CLAMP_D_TO_U8((color >>  8) % 256);
50     a = CLAMP_D_TO_U8(opacity*255);
52     for(i=0; i < 4*in_h*in_w; i+=4){
53             out_data[i]=r;
54             out_data[i+1]=g;
55             out_data[i+2]=b;
56             out_data[i+3]=a;
57     }
59     out->empty = FALSE;
60     slot.set(_output, out);
61     return 0;
62 }
64 void FilterFlood::set_color(guint32 c) {
65     color = c;
66 }
68 void FilterFlood::set_opacity(double o) {
69     opacity = o;
70 }
72 void FilterFlood::area_enlarge(NRRectL &/*area*/, Matrix const &/*trans*/)
73 {
74 }
76 } /* namespace NR */
78 /*
79   Local Variables:
80   mode:c++
81   c-file-style:"stroustrup"
82   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
83   indent-tabs-mode:nil
84   fill-column:99
85   End:
86 */
87 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :